80,351
社区成员
发帖
与我相关
我的任务
分享
void SurfaceFlinger::postFramebuffer()
{
ATRACE_CALL();
const nsecs_t now = systemTime();
mDebugInSwapBuffers = now;
HWComposer& hwc(getHwComposer());
if (hwc.initCheck() == NO_ERROR) {
if (!hwc.supportsFramebufferTarget()) {
// EGL spec says:
// "surface must be bound to the calling thread's current context,
// for the current rendering API."
getDefaultDisplayDevice()->makeCurrent(mEGLDisplay, mEGLContext);
}
hwc.commit();
}
// make the default display current because the VirtualDisplayDevice code cannot
// deal with dequeueBuffer() being called outside of the composition loop; however
// the code below can call glFlush() which is allowed (and does in some case) call
// dequeueBuffer().
getDefaultDisplayDevice()->makeCurrent(mEGLDisplay, mEGLContext);
for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) {
sp<const DisplayDevice> hw(mDisplays[dpy]);
#ifdef MTK_AOSP_ENHANCEMENT
if (!hw->mustRecompose()) continue;
#endif
const Vector< sp<Layer> >& currentLayers(hw->getVisibleLayersSortedByZ());
hw->onSwapBuffersCompleted(hwc);
const size_t count = currentLayers.size();
int32_t id = hw->getHwcDisplayId();
if (id >=0 && hwc.initCheck() == NO_ERROR) {
HWComposer::LayerListIterator cur = hwc.begin(id);
const HWComposer::LayerListIterator end = hwc.end(id);
// 只有三帧
ALOGI(" tyty-layout count = %8d",count);
//注释会出现黑屏
//一半的数据没丢进去也没有设置NULL,间歇性黑屏?好像是系统挂了
//cant connect activity manager
/*
for (size_t i = 0; cur != end && i < count; ++i, ++cur) {
if(i < count/2)
{
currentLayers[i]->onLayerDisplayed(hw, &*cur);
}
else{
currentLayers[i]->onLayerDisplayed(hw, NULL);
}
}*/
for (size_t i = 0; cur != end && i < count; ++i, ++cur)
{
currentLayers[i]->onLayerDisplayed(hw, &*cur);
}
} else {
for (size_t i = 0; i < count; i++) {
currentLayers[i]->onLayerDisplayed(hw, NULL);
}
}
}
mLastSwapBufferTime = systemTime() - now;
mDebugInSwapBuffers = 0;
uint32_t flipCount = getDefaultDisplayDevice()->getPageFlipCount();
if (flipCount % LOG_FRAME_STATS_PERIOD == 0) {
logFrameStats();
}
}
virtual void onDisplayed() {
hwc_region_t& visibleRegion = getLayer()->visibleRegionScreen;
//把 bufferfromdata 修改
SharedBuffer const* sb = SharedBuffer::bufferFromData(visibleRegion.rects);
if (sb) {
sb->release();
// not technically needed but safer
visibleRegion.numRects = 0;
visibleRegion.rects = NULL;
}
getLayer()->acquireFenceFd = -1;
}