From 4d143eed994778d37eb09bb5d452c26f12bca6e1 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 23 Feb 2012 20:05:39 -0800 Subject: [PATCH 1/2] fix an issue in SF where we could miss some updates Change-Id: I7d350bc05d1596655baddff3deaebaba58c9bcc0 --- services/surfaceflinger/Layer.cpp | 51 ++++++++++------------ services/surfaceflinger/Layer.h | 2 +- services/surfaceflinger/SurfaceFlinger.cpp | 4 ++ 3 files changed, 27 insertions(+), 30 deletions(-) diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 3e6b87252..4ee695398 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -42,7 +42,6 @@ #define DEBUG_RESIZE 0 - namespace android { // --------------------------------------------------------------------------- @@ -55,7 +54,7 @@ Layer::Layer(SurfaceFlinger* flinger, mCurrentTransform(0), mCurrentScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE), mCurrentOpacity(true), - mRefreshPending(0), + mRefreshPending(false), mFrameLatencyNeeded(false), mFrameLatencyOffset(0), mFormat(PIXEL_FORMAT_NONE), @@ -408,15 +407,9 @@ bool Layer::isCropped() const { // pageflip handling... // ---------------------------------------------------------------------------- -bool Layer::onPreComposition() -{ - // if there was more than one pending update, request a refresh - if (mRefreshPending >= 2) { - mRefreshPending = 0; - return true; - } - mRefreshPending = 0; - return false; +bool Layer::onPreComposition() { + mRefreshPending = false; + return mQueuedFrames > 0; } void Layer::lockPageFlip(bool& recomputeVisibleRegions) @@ -428,9 +421,11 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions) // because we cannot call updateTeximage() without a corresponding // compositionComplete() call. // we'll trigger an update in onPreComposition(). - if (mRefreshPending++) { + if (mRefreshPending) { + mPostedDirtyRegion.clear(); return; } + mRefreshPending = true; // Capture the old state of the layer for comparisons later const bool oldOpacity = isOpaque(); @@ -541,25 +536,23 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions) void Layer::unlockPageFlip( const Transform& planeTransform, Region& outDirtyRegion) { - if (mRefreshPending >= 2) { - return; - } - - Region dirtyRegion(mPostedDirtyRegion); - if (!dirtyRegion.isEmpty()) { + Region postedRegion(mPostedDirtyRegion); + if (!postedRegion.isEmpty()) { mPostedDirtyRegion.clear(); - // The dirty region is given in the layer's coordinate space - // transform the dirty region by the surface's transformation - // and the global transformation. - const Layer::State& s(drawingState()); - const Transform tr(planeTransform * s.transform); - dirtyRegion = tr.transform(dirtyRegion); + if (!visibleRegionScreen.isEmpty()) { + // The dirty region is given in the layer's coordinate space + // transform the dirty region by the surface's transformation + // and the global transformation. + const Layer::State& s(drawingState()); + const Transform tr(planeTransform * s.transform); + postedRegion = tr.transform(postedRegion); - // At this point, the dirty region is in screen space. - // Make sure it's constrained by the visible region (which - // is in screen space as well). - dirtyRegion.andSelf(visibleRegionScreen); - outDirtyRegion.orSelf(dirtyRegion); + // At this point, the dirty region is in screen space. + // Make sure it's constrained by the visible region (which + // is in screen space as well). + postedRegion.andSelf(visibleRegionScreen); + outDirtyRegion.orSelf(postedRegion); + } } } diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index bf30608c9..39bbb2b1d 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -116,7 +116,7 @@ private: uint32_t mCurrentTransform; uint32_t mCurrentScalingMode; bool mCurrentOpacity; - size_t mRefreshPending; + bool mRefreshPending; bool mFrameLatencyNeeded; int mFrameLatencyOffset; diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 9e3f54839..68521138f 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1776,6 +1776,10 @@ status_t SurfaceFlinger::onTransact( setTransactionFlags(eTransactionNeeded|eTraversalNeeded); return NO_ERROR; } + case 1006:{ // send empty update + signalRefresh(); + return NO_ERROR; + } case 1008: // toggle use of hw composer n = data.readInt32(); mDebugDisableHWC = n ? 1 : 0; From fbc7922ec87298601ba6a3be1bd9f83ffaf9a233 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 23 Feb 2012 21:20:01 -0800 Subject: [PATCH 2/2] workaround for an issue where the screen would flicker sometimes bug: 6020860 Change-Id: I97807db66b66c5f4dcbed0df79d5d257cfc7c0bd --- services/surfaceflinger/SurfaceFlinger.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 68521138f..9d821dc47 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1000,6 +1000,12 @@ void SurfaceFlinger::composeSurfaces(const Region& dirty) drawWormhole(); } + // FIXME: workaroud for b/6020860 + glEnable(GL_SCISSOR_TEST); + glScissor(0,0,0,0); + glClear(GL_COLOR_BUFFER_BIT); + // end-workaround + /* * and then, render the layers targeted at the framebuffer */