SurfaceFlinger: Optimize region calculation for invisible layers.
This CL causes the computeVisibleRegions codepath to escape earlier
for a given layer when it is found that it's visible region is empty.
All the juggling in the later part of the function can end up being
quite expensive even when it's no-op. It seems this is largely due
to allocation of storage space for temporary Region variables. In particular
I found that without this CL Walleye was uncapable of staying in 60fps mode
when there were 100 fully occluded layers and 1 visible layer. With this CL
we're able to stay in 60FPS. We are running in to this issue in some practical
cases where we can have a few dozen parent layers with no buffer adding a lot
of time to computeVisibleRegion. Since they have no mActiveBuffer they will
bail early from isVisible and benefit from this change.
Test: Manual. Existing tests pass.
Change-Id: I7dd39f8641649a3cc38b4ed017ffe9b6eefcf224
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
// ----------------------------------------------------------------------------