资源描述:
《Android6.0 显示系统(六) 图像的输出过程》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Android6.0显示系统(六)图像的输出过程主要就是分析这个函数,我们先看看它的代码:[cpp]viewplaincopy在CODE上查看代码片派生到我的代码片voidSurfaceFlinger::handleMessageRefresh(){ATRACE_CALL();staticnsecs_tpreviousExpectedPresent=0;nsecs_texpectedPresent=mPrimaryDispSync.computeNextRefresh(0);staticboolpreviousFrameMissed=false;boolframeMissed=(ex
2、pectedPresent==previousExpectedPresent);if(frameMissed!=previousFrameMissed){ATRACE_INT("FrameMissed",static_cast(frameMissed));}previousFrameMissed=frameMissed;if(CC_UNLIKELY(mDropMissedFrames&&frameMissed)){//Latchbuffers,butdon'tsendanythingtoHWC,thensignalanother//wakeupforthenextvsync
3、preComposition();repaintEverything();}else{preComposition();rebuildLayerStacks();setUpHWComposer();doDebugFlashRegions();doComposition();postComposition();}previousExpectedPresent=mPrimaryDispSync.computeNextRefresh(0);}我们主要看下下面几个函数。[cpp]viewplaincopy在CODE上查看代码片派生到我的代码片preComposition();rebuildL
4、ayerStacks();setUpHWComposer();doDebugFlashRegions();doComposition();postComposition();一、preComposition函数我们先来看第一个函数preComposition[cpp]viewplaincopy在CODE上查看代码片派生到我的代码片voidSurfaceFlinger::preComposition(){boolneedExtraInvalidate=false;constLayerVector&layers(mDrawingState.layersSortedByZ);constsi
5、ze_tcount=layers.size();for(size_ti=0;ionPreComposition()){needExtraInvalidate=true;}}if(needExtraInvalidate){signalLayerUpdate();}}上面函数先是调用了mDrawingState的layersSortedByZ来得到上次绘图的Layer层列表。并不是所有的Layer都会参与屏幕图像的绘制,因此SurfaceFlinger用state对象来记录参与绘制的Layer对象。记得在之前的博客,我们分析过creat
6、eLayer函数来创建Layer,创建之后会调用addClientLayer函数。[cpp]viewplaincopy在CODE上查看代码片派生到我的代码片status_tSurfaceFlinger::createLayer(constString8&name,constsp&client,uint32_tw,uint32_th,PixelFormatformat,uint32_tflags,sp*handle,sp*gbp){//ALOGD("createLayerfor(%dx%d),name=%
7、s",w,h,name.string());if(int32_t(w
8、h)<0){ALOGE("createLayer()failed,worhisnegative(w=%d,h=%d)",int(w),int(h));returnBAD_VALUE;}status_tresult=NO_ERROR;splayer;switch(flags&ISurfaceComposerClient::eFXSurfaceMask){caseISurfac