diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index e21dd3623..e7125232d 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -281,6 +281,11 @@ public: */ Rect getContentCrop() const; + /* + * Returns if a frame is queued. + */ + bool hasQueuedFrame() const { return mQueuedFrames > 0; } + // ----------------------------------------------------------------------- void clearWithOpenGL(const sp& hw, const Region& clip) const; diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 4b4b12732..bbe2aa1a2 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1636,9 +1636,24 @@ void SurfaceFlinger::handlePageFlip() bool visibleRegions = false; const LayerVector& layers(mDrawingState.layersSortedByZ); - const size_t count = layers.size(); - for (size_t i=0 ; i layersWithQueuedFrames; + for (size_t i = 0, count = layers.size(); i& layer(layers[i]); + if (layer->hasQueuedFrame()) + layersWithQueuedFrames.push_back(layer.get()); + } + for (size_t i = 0, count = layersWithQueuedFrames.size() ; ilatchBuffer(visibleRegions)); const Layer::State& s(layer->getDrawingState()); invalidateLayerStack(s.layerStack, dirty);