以BootAnimation为例说明下surface与layer的关系:
在BootAnimation中
1:在BootAnimation的构造函数中
BootAnimation::BootAnimation(int animType) : Thread(false), mZip(NULL)
{
mAnimationType = animType;
mSession = new SurfaceComposerClient(); //创建SurfaceComposerClient
}
2:在BootAnimation的readyToRun()函数中:
// create the native surface 创建layer的地方
sp control = session()->createSurface(String8(“BootAnimation”),
dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565);
3:在createSurface中,注意gbp,这就是surface的producter
sp SurfaceComposerClient::createSurface(
const String8& name,
uint32_t w,
uint32_t h,
PixelFormat format,
uint32_t flags)
{
sp sur;
if (mStatus == NO_ERROR) {
sp handle;
sp gbp;
//最终会在surfaceflinger中创建layer,这个gdb会在layer的onFirstRef里面创建出来
status_t err = mClient->createSurface(name, w, h, format, flags,
&handle, &gbp);
ALOGE_IF(err, “SurfaceComposerClient::createSurface error
surfaceflinger中surface与layer的关系
最新推荐文章于 2025-06-18 14:45:36 发布