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/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp
index 440f1e2..52fbd44 100644
--- a/services/surfaceflinger/BufferLayer.cpp
+++ b/services/surfaceflinger/BufferLayer.cpp
@@ -667,6 +667,36 @@
     }
 }
 
+Rect BufferLayer::getBufferSize(const State& s) const {
+    // If we have a sideband stream, or we are scaling the buffer then return the layer size since
+    // we cannot determine the buffer size.
+    if ((s.sidebandStream != nullptr) ||
+        (getEffectiveScalingMode() != NATIVE_WINDOW_SCALING_MODE_FREEZE)) {
+        return Rect(getActiveWidth(s), getActiveHeight(s));
+    }
+
+    if (mActiveBuffer == nullptr) {
+        return Rect::INVALID_RECT;
+    }
+
+    uint32_t bufWidth = mActiveBuffer->getWidth();
+    uint32_t bufHeight = mActiveBuffer->getHeight();
+
+    // Undo any transformations on the buffer and return the result.
+    if (mCurrentTransform & ui::Transform::ROT_90) {
+        std::swap(bufWidth, bufHeight);
+    }
+
+    if (getTransformToDisplayInverse()) {
+        uint32_t invTransform = DisplayDevice::getPrimaryDisplayOrientationTransform();
+        if (invTransform & ui::Transform::ROT_90) {
+            std::swap(bufWidth, bufHeight);
+        }
+    }
+
+    return Rect(bufWidth, bufHeight);
+}
+
 } // namespace android
 
 #if defined(__gl_h_)