Fix empty region if the scale is smaller than 1

It may be used by Layer of SurfaceFlinger to calculate
touchable region. It should be able to scale a window
to a smaller size.

Bug: 111440400
Test: manual - An input-associated surface with a scaling
      matrix that has dsdx, dsdy < 1. Use "dumpsys input"
      to observe its touchable region.

Change-Id: I495bd16acec77f913fd39dcac90404eddc71cabb
diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp
index 8150931..618c7d6 100644
--- a/libs/ui/Region.cpp
+++ b/libs/ui/Region.cpp
@@ -325,14 +325,14 @@
     return *this;
 }
 
-Region& Region::scaleSelf(int sx, int sy) {
+Region& Region::scaleSelf(float sx, float sy) {
     size_t count = mStorage.size();
     Rect* rects = mStorage.editArray();
     while (count) {
-        rects->left *= sx;
-        rects->right *= sx;
-        rects->top *= sy;
-        rects->bottom *= sy;
+        rects->left = static_cast<int32_t>(rects->left * sx + 0.5f);
+        rects->right = static_cast<int32_t>(rects->right * sx + 0.5f);
+        rects->top = static_cast<int32_t>(rects->top * sy + 0.5f);
+        rects->bottom = static_cast<int32_t>(rects->bottom * sy + 0.5f);
         rects++;
         count--;
     }
diff --git a/libs/ui/include/ui/Region.h b/libs/ui/include/ui/Region.h
index c5e31c5..0a09960 100644
--- a/libs/ui/include/ui/Region.h
+++ b/libs/ui/include/ui/Region.h
@@ -89,7 +89,7 @@
 
             // these translate rhs first
             Region&     translateSelf(int dx, int dy);
-            Region&     scaleSelf(int sx, int sy);
+            Region&     scaleSelf(float sx, float sy);
             Region&     orSelf(const Region& rhs, int dx, int dy);
             Region&     xorSelf(const Region& rhs, int dx, int dy);
             Region&     andSelf(const Region& rhs, int dx, int dy);