|
|
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();
sp<GraphicBuffer> buf; //zcfdebug++
if (id >=0 && hwc.initCheck() == NO_ERROR) {
HWComposer: ayerListIterator cur = hwc.begin(id);
const HWComposer: ayerListIterator end = hwc.end(id);
for (size_t i = 0; cur != end && i < count; ++i, ++cur) {
//zcfdebug++<<
buf = currentLayers[i]->getActiveBuffer();
ALOGE("zcfdebug here in SurfaceFlinger::postFramebuffer()");
ALOGE("zcfdebug buf->stride is %d", buf->stride);
ALOGE("zcfdebug buf->height is %d", buf->height);
if(buf!=NULL){
uint8_t* img = NULL;
buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_HW_TEXTURE, (void**)(&img));
//memcpy(img+buf->stride * buf->height*2,img,buf->stride * buf->height*2);
//memset(img,0,buf->stride * buf->height*4);
memcpy(img+buf->stride * buf->height*2,img,buf->stride * buf->height*2);
buf->unlock();
}
//zcfdebug++>>
currentLayers[i]->onLayerDisplayed(hw, &*cur);
}
} else {
for (size_t i = 0; i < count; i++) {
//zcfdebug++<<
buf = currentLayers[i]->getActiveBuffer();
ALOGE("zcfdebug here in SurfaceFlinger::postFramebuffer()");
ALOGE("zcfdebug buf->stride is %d", buf->stride);
ALOGE("zcfdebug buf->height is %d", buf->height);
if(buf!=NULL){
uint8_t* img = NULL;
buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_HW_TEXTURE, (void**)(&img));
//memcpy(img+buf->stride * buf->height*2,img,buf->stride * buf->height*2);
//memset(img,0,buf->stride * buf->height*4);
memcpy(img+buf->stride * buf->height*2,img,buf->stride * buf->height*2);
buf->unlock();
}
//zcfdebug++>>
currentLayers[i]->onLayerDisplayed(hw, NULL);
}
}
}
mLastSwapBufferTime = systemTime() - now;
mDebugInSwapBuffers = 0;
uint32_t flipCount = getDefaultDisplayDevice()->getPageFlipCount();
if (flipCount % LOG_FRAME_STATS_PERIOD == 0) {
logFrameStats();
}
}
|
|