Merge "SurfaceFlinger: Optimize region calculation for invisible layers."
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 63f6781..33f0796 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -871,6 +871,12 @@
this->visibleNonTransparentRegion = setVisibleNonTransparentRegion;
}
+void Layer::clearVisibilityRegions() {
+ visibleRegion.clear();
+ visibleNonTransparentRegion.clear();
+ coveredRegion.clear();
+}
+
// ----------------------------------------------------------------------------
// transaction
// ----------------------------------------------------------------------------
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index e44ccf8..c63399e 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -435,6 +435,11 @@
void setVisibleNonTransparentRegion(const Region& visibleNonTransparentRegion);
/*
+ * Clear the visible, covered, and non-transparent regions.
+ */
+ void clearVisibilityRegions();
+
+ /*
* latchBuffer - called each time the screen is redrawn and returns whether
* the visible regions need to be recomputed (this is a fairly heavy
* operation, so this should be set only if needed). Typically this is used
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index f21a691..b03519e 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2534,6 +2534,11 @@
}
}
+ if (visibleRegion.isEmpty()) {
+ layer->clearVisibilityRegions();
+ return;
+ }
+
// Clip the covered region to the visible region
coveredRegion = aboveCoveredLayers.intersect(visibleRegion);