SF Bounds caching 2/3: Compute and cache layer bounds during invalidate stage
- Compute and cache:
- effective transform - transform applied to source bounds to get the screen bounds,
taking into account parent scaling and parent transforms.
- source bounds - bounds of the layer before any transformation is applied and before
it has been cropped by its parents.
- bounds - bounds of the layer cropped to its own crop as well as its parents bounds.
- screen bounds - bounds in screen space calculated by transforming the layer bounds.
- Rename existing computeBounds and computeScreenBounds to make switch easier in
future patch.
- Update cached bounds when reparenting layers for screenshots.
Note: this change doesn't use the cached values.
Test: go/wm-smoke
Test: atest -a libinput_tests inputflinger_tests SurfaceFlinger_test libsurfaceflinger_unittest SurfaceParcelable_test libgui_test
Change-Id: I5d6ec6fd4acb0f955de27b713691ed99b029dcc2
diff --git a/services/surfaceflinger/BufferStateLayer.cpp b/services/surfaceflinger/BufferStateLayer.cpp
index b95cd2e..45e3b6a 100644
--- a/services/surfaceflinger/BufferStateLayer.cpp
+++ b/services/surfaceflinger/BufferStateLayer.cpp
@@ -313,7 +313,7 @@
// if the display frame is not defined, use the parent bounds as the buffer size.
const auto& p = mDrawingParent.promote();
if (p != nullptr) {
- Rect parentBounds = Rect(p->computeBounds(Region()));
+ Rect parentBounds = Rect(p->getBounds(Region()));
if (!parentBounds.isEmpty()) {
return parentBounds;
}
@@ -325,6 +325,18 @@
}
return Rect::INVALID_RECT;
}
+
+FloatRect BufferStateLayer::computeSourceBounds(const FloatRect& parentBounds) const {
+ const State& s(getDrawingState());
+ // for buffer state layers we use the display frame size as the buffer size.
+ if (getActiveWidth(s) < UINT32_MAX && getActiveHeight(s) < UINT32_MAX) {
+ return FloatRect(0, 0, getActiveWidth(s), getActiveHeight(s));
+ }
+
+ // if the display frame is not defined, use the parent bounds as the buffer size.
+ return parentBounds;
+}
+
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------