SF: Add support for boundless layers 1/2
Size is currently used to bound a layer and its child layers. There are scenarios where we do not
want to restrict a layer or its children to any specific size. For example
1. Have a color layer fill the bounds of its parent.
2. Have a layer apply a transform (ROTATION) to all child layers without cropping them.
Currently this is achieved by providing a large enough size so that the layer or its children do
not get cropped incorrectly.
This change modifies computeBounds and computeScreenBounds to ignore a layer's size. We calculate
the bounds by using the layer's buffer size and/or crop. Then we pass the bounds to the parent
layer to crop to its bounds. If the layer has no bounds, we pass the child bounds forward. If
we are also at the bottom of the hierarchy, such as a boundless color layer, then our bounds are
set to the parent bounds.
In WM, we set the layer's crop property in places where we relied on layer size.
Bug: 114413815
Test: go/wm-smoke
Test: mmma frameworks/native/services/surfaceflinger/tests/ && \
mmma frameworks/native/libs/gui/tests/ && adb sync data && \
adb shell /data/nativetest64/libgui_test/libgui_test && \
adb shell /data/nativetest64/libsurfaceflinger_unittest/libsurfaceflinger_unittest && \
adb shell /data/nativetest64/SurfaceFlinger_test/SurfaceFlinger_test && \
adb shell /data/nativetest64/SurfaceParcelable_test/SurfaceParcelable_test && \
echo "ALL TESTS PASSED"
Change-Id: I962c0c7639f6c863fc16b8acd16f077f040f8de4
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 5d05f05..21729ad 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -575,7 +575,7 @@
ssize_t removeChild(const sp<Layer>& layer);
sp<Layer> getParent() const { return mCurrentParent.promote(); }
bool hasParent() const { return getParent() != nullptr; }
- Rect computeScreenBounds(bool reduceTransparentRegion = true) const;
+ Rect computeScreenBounds() const;
bool setChildLayer(const sp<Layer>& childLayer, int32_t z);
bool setChildRelativeLayer(const sp<Layer>& childLayer,
const sp<IBinder>& relativeToHandle, int32_t relativeZ);
@@ -785,6 +785,27 @@
const LayerVector::Visitor& visitor);
LayerVector makeChildrenTraversalList(LayerVector::StateSet stateSet,
const std::vector<Layer*>& layersInTree);
+
+ /**
+ * Retuns the child bounds in layer space cropped to its bounds as well all its parent bounds.
+ * The cropped bounds must be transformed back from parent layer space to child layer space by
+ * applying the inverse of the child's transformation.
+ */
+ FloatRect cropChildBounds(const FloatRect& childBounds) const;
+
+ /**
+ * Returns the cropped buffer size or the layer crop if the layer has no buffer. Return
+ * INVALID_RECT if the layer has no buffer and no crop.
+ * A layer with an invalid buffer size and no crop is considered to be boundless. The layer
+ * bounds are constrained by its parent bounds.
+ */
+ Rect getCroppedBufferSize(const Layer::State& s) const;
+
+ /**
+ * Returns active buffer size in the correct orientation. Buffer size is determined by undoing
+ * any buffer transformations. If the layer has no buffer then return INVALID_RECT.
+ */
+ virtual Rect getBufferSize(const Layer::State&) const { return Rect::INVALID_RECT; }
};
// ---------------------------------------------------------------------------