SF: Switch computeBounds to return FloatRect

Switches Layer::computeBounds to return a FloatRect instead of a Rect.

During the computation of the bounds, we apply the layer transformation
to its nominal dimensions, clip it against its bounds (which are either
its parents bounds or the screen bounds), and apply the inverse of the
layer transformation.

Previously, the intermediate position (after transformation/clip, but
before inverse transformation) was stored as Rect, which is to say that
it was truncated to integer coordinates. After applying the inverse
transformation, this loss of precision can cause glitches where a layer
that should be clipped against, e.g., the side of the screen no longer
creates a watertight seal against that side.

In order to fix this, we now store the intermediate value as a FloatRect
and propagate float precision back through computeBounds. The callers of
computeBounds tend to then immediately apply the transform again, at
which point it is safe to round back to integer.

Bug: 64070729
Bug: 66431327
Bug: 69935057
Test: Modified android.view.cts.SurfaceViewSyncTest#
      testSurfaceViewBigScale no longer produces bogus display frames
Change-Id: If5987ca4ad76657f9670a5f59258f896180352e2
diff --git a/services/surfaceflinger/Transform.cpp b/services/surfaceflinger/Transform.cpp
index 37925a1..e05ed53 100644
--- a/services/surfaceflinger/Transform.cpp
+++ b/services/surfaceflinger/Transform.cpp
@@ -224,6 +224,27 @@
     return r;
 }
 
+FloatRect Transform::transform(const FloatRect& bounds) const
+{
+    vec2 lt(bounds.left, bounds.top);
+    vec2 rt(bounds.right, bounds.top);
+    vec2 lb(bounds.left, bounds.bottom);
+    vec2 rb(bounds.right, bounds.bottom);
+
+    lt = transform(lt);
+    rt = transform(rt);
+    lb = transform(lb);
+    rb = transform(rb);
+
+    FloatRect r;
+    r.left = min(lt[0], rt[0], lb[0], rb[0]);
+    r.top = min(lt[1], rt[1], lb[1], rb[1]);
+    r.right = max(lt[0], rt[0], lb[0], rb[0]);
+    r.bottom = max(lt[1], rt[1], lb[1], rb[1]);
+
+    return r;
+}
+
 Region Transform::transform(const Region& reg) const
 {
     Region out;