As I know so far, surfaceflinger providers surfaces to APP to render to and then composite all the surfaces to the final screen. (If any mistake, please point out Thx).
First question: Is the surface created by surfaceflinger is global available that can be used by all processes. (is the memory of the surface is in GPU memory?)
While as I googled it not possible to share openGL context between processes(here I mean the APP process and the surfaceflinger process). I'm not sure if so as to the GPU memory used by the surface?
If the answer to my first question is yes, than is there any openGL resource sharing to the surfaceflinger when an APP render to the surface? And how these shard things including the memory of the surface worked?
There is a difference between an Android Surface
and an EGL Surface
. They are closely related but are not the same thing.
EGL surfaces, created by methods like eglCreateWindowSurface()
, can be associated with an EGL context and used as targets for rendering. They cannot be shared between processes.
Android Surfaces are just wrappers for BufferQueue objects, which provide a way to move graphics buffers around the system. The buffer into which an app is rendering can be passed between the app and SurfaceFlinger, but none of the EGL state is passed along. All SurfaceFlinger gets is the finished product.
The system is described in some detail in the graphics architecture document.