SF: Handle buffer scale transforms when calculating layer geometry

In addition to layer transforms, buffer scale transform applied to a layer should be applied to all
its children. This is to ensure WM can treat child surfaces as pixels in the parent surface.

Current bounds calculations is based on the cropped parent bounds in parent layer space and its
effective transform. This breaks because if the parent buffer has a scale transform, the parent
bounds passed on to the child already has the buffer scale transform applied to it.

To fix this, we undo the scale transform on the cropped parent bounds before passing it on to its
children for cropping.

Fixes: 127368943
Test: atest SurfaceFlinger_test
Test: go/wm-smoke
Change-Id: I17966d08b98fbfbf44538cab0a95c9e78b23e11e
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 7f802e9..f333d0a 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -359,9 +359,15 @@
     // Compute bounds for the layer and cache the results.
     void computeBounds(FloatRect parentBounds, ui::Transform parentTransform);
 
+    // Returns the buffer scale transform if a scaling mode is set.
+    ui::Transform getBufferScaleTransform() const;
+
     // Get effective layer transform, taking into account all its parent transform with any
     // scaling if the parent scaling more is not NATIVE_WINDOW_SCALING_MODE_FREEZE.
-    ui::Transform getTransformWithScale() const;
+    ui::Transform getTransformWithScale(const ui::Transform& bufferScaleTransform) const;
+
+    // Returns the bounds of the layer without any buffer scaling.
+    FloatRect getBoundsPreScaling(const ui::Transform& bufferScaleTransform) const;
 
     int32_t getSequence() const { return sequence; }