4242
4343#define DEBUG_RESIZE 0
4444
45-
4645namespace android {
4746
4847// ---------------------------------------------------------------------------
@@ -55,7 +54,7 @@ Layer::Layer(SurfaceFlinger* flinger,
5554 mCurrentTransform(0 ),
5655 mCurrentScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
5756 mCurrentOpacity(true ),
58- mRefreshPending(0 ),
57+ mRefreshPending(false ),
5958 mFrameLatencyNeeded(false ),
6059 mFrameLatencyOffset(0 ),
6160 mFormat(PIXEL_FORMAT_NONE),
@@ -408,15 +407,9 @@ bool Layer::isCropped() const {
408407// pageflip handling...
409408// ----------------------------------------------------------------------------
410409
411- bool Layer::onPreComposition ()
412- {
413- // if there was more than one pending update, request a refresh
414- if (mRefreshPending >= 2 ) {
415- mRefreshPending = 0 ;
416- return true ;
417- }
418- mRefreshPending = 0 ;
419- return false ;
410+ bool Layer::onPreComposition () {
411+ mRefreshPending = false ;
412+ return mQueuedFrames > 0 ;
420413}
421414
422415void Layer::lockPageFlip (bool & recomputeVisibleRegions)
@@ -428,9 +421,11 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
428421 // because we cannot call updateTeximage() without a corresponding
429422 // compositionComplete() call.
430423 // we'll trigger an update in onPreComposition().
431- if (mRefreshPending ++) {
424+ if (mRefreshPending ) {
425+ mPostedDirtyRegion .clear ();
432426 return ;
433427 }
428+ mRefreshPending = true ;
434429
435430 // Capture the old state of the layer for comparisons later
436431 const bool oldOpacity = isOpaque ();
@@ -541,25 +536,23 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
541536void Layer::unlockPageFlip (
542537 const Transform& planeTransform, Region& outDirtyRegion)
543538{
544- if (mRefreshPending >= 2 ) {
545- return ;
546- }
547-
548- Region dirtyRegion (mPostedDirtyRegion );
549- if (!dirtyRegion.isEmpty ()) {
539+ Region postedRegion (mPostedDirtyRegion );
540+ if (!postedRegion.isEmpty ()) {
550541 mPostedDirtyRegion .clear ();
551- // The dirty region is given in the layer's coordinate space
552- // transform the dirty region by the surface's transformation
553- // and the global transformation.
554- const Layer::State& s (drawingState ());
555- const Transform tr (planeTransform * s.transform );
556- dirtyRegion = tr.transform (dirtyRegion);
557-
558- // At this point, the dirty region is in screen space.
559- // Make sure it's constrained by the visible region (which
560- // is in screen space as well).
561- dirtyRegion.andSelf (visibleRegionScreen);
562- outDirtyRegion.orSelf (dirtyRegion);
542+ if (!visibleRegionScreen.isEmpty ()) {
543+ // The dirty region is given in the layer's coordinate space
544+ // transform the dirty region by the surface's transformation
545+ // and the global transformation.
546+ const Layer::State& s (drawingState ());
547+ const Transform tr (planeTransform * s.transform );
548+ postedRegion = tr.transform (postedRegion);
549+
550+ // At this point, the dirty region is in screen space.
551+ // Make sure it's constrained by the visible region (which
552+ // is in screen space as well).
553+ postedRegion.andSelf (visibleRegionScreen);
554+ outDirtyRegion.orSelf (postedRegion);
555+ }
563556 }
564557}
565558
0 commit comments