This section describes the architecture of the user space Display Section, which has no direct connection with the kernel, mainly the section below JNI to Hal.
1. Surface Manager (surface flinger) Introduction
Surface manager is a module in libraries under the framework in the user space. As follows:
When the system executes multiple applications at the same time, surface manager is responsible for managing the interaction between the display and access operations, and also for merging 2D and 3D drawings.
Surface manager can prepare a surface (which can be regarded as a layer) and transmit the FD of the surface (a piece of memory) to an app so that the app can paint on it. Typical applications are as follows:
2. Surface manager Architecture Analysis
The image system in Android adopts the client/server architecture as follows:
Client: Application-related parts. The code is divided into two parts: one is the supplied APIs provided by Java, and the other is the underlying implementation written by C ++.
Server: surfaceflinger, responsible for merging and sending it to the buffer for display. It is mainly written by C ++ code.
The client and server communicate with each other through the binder IPC. The overall structure is as follows:
As shown in, the client part of the surface is actually a bridge for various applications to perform drawing operations. This bridge leads to surfaceflinger on the server through the binder, and surfaceflinger is responsible for synthesizing various surfaces, then, the buffer is transmitted to the framebuffer end for underlying display. Each surface corresponds to two buffers, one front buffer and one back buffer. when the data is updated, the data is updated on the back buffer. When the data needs to be displayed, the back buffer and the front buffer are exchanged.
In the next section, we will focus on surfaceflinger.