diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 058ba45a4..6542acd29 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -753,27 +753,29 @@ void SurfaceFlinger::rebuildLayerStacks() { ATRACE_CALL(); mVisibleRegionsDirty = false; invalidateHwcGeometry(); + const LayerVector& currentLayers(mDrawingState.layersSortedByZ); for (size_t dpy=0 ; dpy > layersSortedByZ; const sp& hw(mDisplays[dpy]); const Transform& tr(hw->getTransform()); const Rect bounds(hw->getBounds()); + if (hw->canDraw()) { + SurfaceFlinger::computeVisibleRegions(currentLayers, + hw->getLayerStack(), dirtyRegion, opaqueRegion); - Region opaqueRegion; - Region dirtyRegion; - computeVisibleRegions(currentLayers, - hw->getLayerStack(), dirtyRegion, opaqueRegion); - - Vector< sp > layersSortedByZ; - const size_t count = currentLayers.size(); - for (size_t i=0 ; i& layer(currentLayers[i]); - const Layer::State& s(layer->drawingState()); - if (s.layerStack == hw->getLayerStack()) { - Region visibleRegion(tr.transform(layer->visibleRegion)); - visibleRegion.andSelf(bounds); - if (!visibleRegion.isEmpty()) { - layersSortedByZ.add(layer); + const size_t count = currentLayers.size(); + for (size_t i=0 ; i& layer(currentLayers[i]); + const Layer::State& s(layer->drawingState()); + if (s.layerStack == hw->getLayerStack()) { + Region visibleRegion(tr.transform(layer->visibleRegion)); + visibleRegion.andSelf(bounds); + if (!visibleRegion.isEmpty()) { + layersSortedByZ.add(layer); + } } } } @@ -1776,6 +1778,7 @@ void SurfaceFlinger::onScreenReleased() { mEventThread->onScreenReleased(); hw->releaseScreen(); getHwComposer().release(); + mVisibleRegionsDirty = true; // from this point on, SF will stop drawing } } diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index ea03e2dcb..ffe68c6d3 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -351,8 +351,8 @@ private: * Compositing */ void invalidateHwcGeometry(); - void computeVisibleRegions(const LayerVector& currentLayers, - uint32_t layerStack, + static void computeVisibleRegions( + const LayerVector& currentLayers, uint32_t layerStack, Region& dirtyRegion, Region& opaqueRegion); void preComposition();