@@ -404,7 +404,9 @@ bool Layer::isCropped() const {
404404void Layer::lockPageFlip (bool & recomputeVisibleRegions)
405405{
406406 if (mQueuedFrames > 0 ) {
407+ // Capture the old state of the layer for comparisons later
407408 const bool oldOpacity = isOpaque ();
409+ sp<GraphicBuffer> oldActiveBuffer = mActiveBuffer ;
408410
409411 // signal another event if we have more frames pending
410412 if (android_atomic_dec (&mQueuedFrames ) > 1 ) {
@@ -417,7 +419,8 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
417419 return ;
418420 }
419421
420- sp<GraphicBuffer> newFrontBuffer (mSurfaceTexture ->getCurrentBuffer ());
422+ // update the active buffer
423+ mActiveBuffer = mSurfaceTexture ->getCurrentBuffer ();
421424
422425 const Rect crop (mSurfaceTexture ->getCurrentCrop ());
423426 const uint32_t transform (mSurfaceTexture ->getCurrentTransform ());
@@ -439,16 +442,16 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
439442 mFlinger ->invalidateHwcGeometry ();
440443 }
441444
442- uint32_t bufWidth = newFrontBuffer ->getWidth ();
443- uint32_t bufHeight = newFrontBuffer ->getHeight ();
444- if (mActiveBuffer != NULL ) {
445- if (bufWidth != uint32_t (mActiveBuffer ->width ) ||
446- bufHeight != uint32_t (mActiveBuffer ->height )) {
445+ uint32_t bufWidth = mActiveBuffer ->getWidth ();
446+ uint32_t bufHeight = mActiveBuffer ->getHeight ();
447+ if (oldActiveBuffer != NULL ) {
448+ if (bufWidth != uint32_t (oldActiveBuffer ->width ) ||
449+ bufHeight != uint32_t (oldActiveBuffer ->height )) {
447450 mFlinger ->invalidateHwcGeometry ();
448451 }
449452 }
450453
451- mCurrentOpacity = getOpacityForFormat (newFrontBuffer ->format );
454+ mCurrentOpacity = getOpacityForFormat (mActiveBuffer ->format );
452455 if (oldOpacity != isOpaque ()) {
453456 recomputeVisibleRegions = true ;
454457 }
@@ -462,9 +465,6 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
462465 // FIXME: mPostedDirtyRegion = dirty & bounds
463466 mPostedDirtyRegion .set (front.w , front.h );
464467
465- // update active buffer
466- mActiveBuffer = newFrontBuffer;
467-
468468 if ((front.w != front.requested_w ) ||
469469 (front.h != front.requested_h ))
470470 {
0 commit comments