Fix virtual display nesting
This fixes the cycling rendering loop caused by nesting virtual
displays by preventing them from recomposing if their contents
haven't changed.
(cherry-pick from master I600365c0fd5d3ad93e04295d26cf9de177ffc79b)
Bug: 12101046
Change-Id: I6182993d53537781aedb522f97a50f06eed8b80f
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 86be6c3..1a9a694 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -881,7 +881,9 @@
void SurfaceFlinger::setUpHWComposer() {
for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) {
- mDisplays[dpy]->beginFrame();
+ bool mustRecompose =
+ !(mDisplays[dpy]->getDirtyRegion(false).isEmpty());
+ mDisplays[dpy]->beginFrame(mustRecompose);
}
HWComposer& hwc(getHwComposer());
@@ -1499,6 +1501,15 @@
void SurfaceFlinger::doDisplayComposition(const sp<const DisplayDevice>& hw,
const Region& inDirtyRegion)
{
+ // We only need to actually compose the display if:
+ // 1) It is being handled by hardware composer, which may need this to
+ // keep its virtual display state machine in sync, or
+ // 2) There is work to be done (the dirty region isn't empty)
+ bool isHwcDisplay = hw->getHwcDisplayId() >= 0;
+ if (!isHwcDisplay && inDirtyRegion.isEmpty()) {
+ return;
+ }
+
Region dirtyRegion(inDirtyRegion);
// compute the invalid region