From 351a513b12622781de9580b3c96fd0a8578b563b Mon Sep 17 00:00:00 2001 From: Jamie Gennis Date: Wed, 14 Sep 2011 18:23:37 -0700 Subject: [PATCH] (DO NOT MERGE) SurfaceFlinger: fix isOpaque check in lockPageFlip This change fixes an issue where Layer::isOpaque was being called in lockPageFlip to get the opaqueness for the new buffer before mActiveBuffer was updated. Bug: 5321313 Change-Id: Ibb5d7d3f4e9a2b1448e117a484a0d9f9ca5fc9de --- services/surfaceflinger/Layer.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index edbc7b023..f85ce7fd0 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -404,7 +404,9 @@ bool Layer::isCropped() const { void Layer::lockPageFlip(bool& recomputeVisibleRegions) { if (mQueuedFrames > 0) { + // Capture the old state of the layer for comparisons later const bool oldOpacity = isOpaque(); + sp oldActiveBuffer = mActiveBuffer; // signal another event if we have more frames pending if (android_atomic_dec(&mQueuedFrames) > 1) { @@ -417,7 +419,8 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions) return; } - sp newFrontBuffer(mSurfaceTexture->getCurrentBuffer()); + // update the active buffer + mActiveBuffer = mSurfaceTexture->getCurrentBuffer(); const Rect crop(mSurfaceTexture->getCurrentCrop()); const uint32_t transform(mSurfaceTexture->getCurrentTransform()); @@ -439,16 +442,16 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions) mFlinger->invalidateHwcGeometry(); } - uint32_t bufWidth = newFrontBuffer->getWidth(); - uint32_t bufHeight = newFrontBuffer->getHeight(); - if (mActiveBuffer != NULL) { - if (bufWidth != uint32_t(mActiveBuffer->width) || - bufHeight != uint32_t(mActiveBuffer->height)) { + uint32_t bufWidth = mActiveBuffer->getWidth(); + uint32_t bufHeight = mActiveBuffer->getHeight(); + if (oldActiveBuffer != NULL) { + if (bufWidth != uint32_t(oldActiveBuffer->width) || + bufHeight != uint32_t(oldActiveBuffer->height)) { mFlinger->invalidateHwcGeometry(); } } - mCurrentOpacity = getOpacityForFormat(newFrontBuffer->format); + mCurrentOpacity = getOpacityForFormat(mActiveBuffer->format); if (oldOpacity != isOpaque()) { recomputeVisibleRegions = true; } @@ -462,9 +465,6 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions) // FIXME: mPostedDirtyRegion = dirty & bounds mPostedDirtyRegion.set(front.w, front.h); - // update active buffer - mActiveBuffer = newFrontBuffer; - if ((front.w != front.requested_w) || (front.h != front.requested_h)) {