The beginning of the graphics system

An overview of

Android graphics system can be said to be one of the most important systems in Android, it contains Android system display, refresh and other mechanisms, through the Android hardware layer, native layer, as well as the application layer. When we explore the Android refresh mechanism, lag reason, display principle and so on, the graphics system is necessary to understand.

If you want to learn such a system, it is impossible to achieve it overnight, so this article will also serve as the outline and directory of graphic system source research. Of course, although it is an outline and table of contents, it actually changes as I write, because many ideas will change as I learn more and more.

1.1 Learning Methods

Android graphics system is a very complex system, in the exploration of Android graphics system, often encounter some mechanisms (or knowledge points), if you do not understand these mechanisms, you will understand some code in the system. But if you study these mechanisms in depth, it is easy to fall into the vast ocean of source code, lost in the original goal.

For these reasons, I decided to follow these steps when reading the source code

  1. First set the goal of each step you want to learn, and clarify the main process of the graphics system according to the goal.
  2. Understand the main goal-setting process and some details. But for the parts of it that involve other more complex mechanics, assume you already know.
  3. For different mechanism points, study separately to understand how these mechanisms work.
  4. Consolidate previous learning by bringing already familiar mechanics into the system’s workflow.

In view of the above learning steps, for the study of the system source code, it is impossible to just go over, more often will be the first to learn A point and ignore B point, after learning A point to learn B point, finally after learning B point to take B into A to learn again, this will be the process of the above spiral.

The second directory

2.1 Working principle of SurfaceFlinger

SurfaceFlinger startup process: SurfaceFlinger is a very important service in The Android system. The Android system will start it when starting the system service. So we need to understand how SurfaceFlinger is started, i.e. its startup process

How SurfaceFlinger works: After SurfaceFlinger starts, it starts its worker thread. We need to understand how SurfaceFlinger works, how it works and how it works.

2.2 Mechanism interpretation in SurfaceFlinger

Vsync is one of the most important refresh mechanisms in the Android system. It is generated by the hardware and passed to the software. So how is it created, how is it delivered. What are the hardware and software involved?

The refresh of Android system involves multiple processes, and even involves CPU and GPU. So how is the image data saved? The image data is much larger than ordinary data, and how is it transmitted?

When multiple processes use the image data at the same time, how do they synchronize?

On Android, a Fence synchronization mechanism is used to synchronize data. \

Decoding the GraphicBuffer: Images are stored in the GraphicBuffer.

To be continued…