main() –>
SurfaceFlinger::instantiate(); –>
defaultServiceManager()→addService(String16(“SurfaceFlinger”), new SurfaceFlinger());
start system_server when system boot in init.rc
main() –> system_init(); –>
SurfaceFlinger::instantiate();
surface flinger extend a threads (framework/base/libs/utils/threads.cpp ) –SurfaceFlinger.cpp
start SurfaceFlinger::readyToRun in Thread::_threadLoop(); –SurfaceFlinger.cpp
DisplayHardware* const hw = new DisplayHardware(this, dpy); –SurfaceFlinger.cpp
DisplayHardware::init() –DisplayHardware.cpp
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY) (implement in ligagl.so or libhgl.so)
mDisplaySurface = new EGLDisplaySurface();
surface = eglCreateWindowSurface(display, config, mDisplaySurface.get(), NULL);
context = eglCreateContext(display, config, NULL, NULL); ( Create our OpenGL ES context in libagl.so or libhgl.so)
open copybit & overlay modules:
mBlitEngine = NULL;
if (hw_get_module(COPYBIT_HARDWARE_MODULE_ID, &module) == 0)
{
copybit_open(module, &mBlitEngine);
}
mOverlayEngine = NULL;
if (hw_get_module(OVERLAY_HARDWARE_MODULE_ID, &module) == 0)
{
overlay_control_open(module, &mOverlayEngine);
}
framework/base/opengl/libs/egl.cpp (libGLESv1_CM.so)
eglGetDisplay() in egl.cpp, dynamically load all our EGL implementations( agl/hgl ) for that display and call into the real eglGetGisplay()
provide base egl APIs wappers in egl.cpp and implementaton in libagl.so or libhgl.so
Can combine 2D and 3D surfaces and surfaces from multiple applications
Surfaces passed as buffers via Binder IPC calls
Can use OpenGL ES and 2D hardware accelerator for its compositions
Double-buffering using page-flip