SF: Apply translations to transparent region

Correctly applies translation-only transforms to the transparent
region so that it aligns with the layer bounds in screen space.

Bug: 28220791
Change-Id: If9137b873f4b89890127671d8c45745e079f1cbc
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index a69b11b..91815f3 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1719,17 +1719,13 @@
                 // Remove the transparent area from the visible region
                 if (translucent) {
                     const Transform tr(s.active.transform);
-                    if (tr.transformed()) {
-                        if (tr.preserveRects()) {
-                            // transform the transparent region
-                            transparentRegion = tr.transform(s.activeTransparentRegion);
-                        } else {
-                            // transformation too complex, can't do the
-                            // transparent region optimization.
-                            transparentRegion.clear();
-                        }
+                    if (tr.preserveRects()) {
+                        // transform the transparent region
+                        transparentRegion = tr.transform(s.activeTransparentRegion);
                     } else {
-                        transparentRegion = s.activeTransparentRegion;
+                        // transformation too complex, can't do the
+                        // transparent region optimization.
+                        transparentRegion.clear();
                     }
                 }
 
diff --git a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
index 00700ab..de46dfa 100644
--- a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
+++ b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
@@ -1747,17 +1747,13 @@
                 // Remove the transparent area from the visible region
                 if (translucent) {
                     const Transform tr(s.active.transform);
-                    if (tr.transformed()) {
-                        if (tr.preserveRects()) {
-                            // transform the transparent region
-                            transparentRegion = tr.transform(s.activeTransparentRegion);
-                        } else {
-                            // transformation too complex, can't do the
-                            // transparent region optimization.
-                            transparentRegion.clear();
-                        }
+                    if (tr.preserveRects()) {
+                        // transform the transparent region
+                        transparentRegion = tr.transform(s.activeTransparentRegion);
                     } else {
-                        transparentRegion = s.activeTransparentRegion;
+                        // transformation too complex, can't do the
+                        // transparent region optimization.
+                        transparentRegion.clear();
                     }
                 }
 
diff --git a/services/surfaceflinger/Transform.cpp b/services/surfaceflinger/Transform.cpp
index 35e7e7d..c2be91d 100644
--- a/services/surfaceflinger/Transform.cpp
+++ b/services/surfaceflinger/Transform.cpp
@@ -87,10 +87,6 @@
     return mMatrix[i];
 }
 
-bool Transform::transformed() const {
-    return type() > TRANSLATE;
-}
-
 float Transform::tx() const {
     return mMatrix[2][0];
 }
@@ -224,7 +220,7 @@
 Region Transform::transform(const Region& reg) const
 {
     Region out;
-    if (CC_UNLIKELY(transformed())) {
+    if (CC_UNLIKELY(type() > TRANSLATE)) {
         if (CC_LIKELY(preserveRects())) {
             Region::const_iterator it = reg.begin();
             Region::const_iterator const end = reg.end();
diff --git a/services/surfaceflinger/Transform.h b/services/surfaceflinger/Transform.h
index 9efeb9e..90855da 100644
--- a/services/surfaceflinger/Transform.h
+++ b/services/surfaceflinger/Transform.h
@@ -60,7 +60,6 @@
             };
 
             // query the transform
-            bool        transformed() const;
             bool        preserveRects() const;
             uint32_t    getType() const;
             uint32_t    getOrientation() const;