1:layer的创建过程:在WMS中的relayoutWindow()函数中
在winAnimator.createSurfaceLocked()中,会创建一个surfaceControl:
mSurfaceControl = new SurfaceControl( //这里new出一个SurfaceControl的对象
mSession.mSurfaceSession,
attrs.getTitle().toString(),
width, height, format, flags);
2:在SurfaceControl
的构造函数中:
public SurfaceControl(SurfaceSession session,
String name, int w, int h, int format, int flags)
throws OutOfResourcesException {
创建本地的SurfaceControl 对象
mNativeObject =
nativeCreate(session, name, w, h, format, flags);
}
3:在native层:
static jlong nativeCreate(JNIEnv* env, jclass clazz) {
//创建了本地的SurfaceComposerClient的对象,
SurfaceComposerClient* client =
new SurfaceComposerClient();
client->incStrong((void*)nativeCreate);
return reinterpret_cast<jlong>(client);
}
4:和bootanimo中创建SurfaceComposerClient的流程一致,最后调用到SF中去创建layer。