SurfaceFlinger Input: Correct screen magnification.
We need to pass the computed scaling factors through SurfaceFlinger
as well as appropriately scaling the touchable region. We also need
to be careful as to which axes we scale. In the past screen magnification
has not lead to scaling of the TOUCH_MAJOR/MINOR axes, whereas whole-screen
display compatibility scaling has. We preserve this behavior by differentiating
between the global scale and a scale on any particular window. The window scale
works like the global scale used to and the global scale is only used for additional
scaling of the MAJOR/MINOR axes.
Bug: 80101428
Bug: 113136004
Bug: 111440400
Change-Id: I97d809826f86b452f28443cb1046e8bfef1bbf9d
diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp
index fe4ae6c..8150931 100644
--- a/libs/ui/Region.cpp
+++ b/libs/ui/Region.cpp
@@ -325,6 +325,20 @@
return *this;
}
+Region& Region::scaleSelf(int sx, int 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++;
+ count--;
+ }
+ return *this;
+}
+
// ----------------------------------------------------------------------------
const Region Region::merge(const Rect& rhs) const {
diff --git a/libs/ui/Transform.cpp b/libs/ui/Transform.cpp
index 8e949ec..25128ef 100644
--- a/libs/ui/Transform.cpp
+++ b/libs/ui/Transform.cpp
@@ -95,6 +95,14 @@
return mMatrix[2][1];
}
+float Transform::sx() const {
+ return mMatrix[0][0];
+}
+
+float Transform::sy() const {
+ return mMatrix[1][1];
+}
+
void Transform::reset() {
mType = IDENTITY;
for(size_t i = 0; i < 3; i++) {
diff --git a/libs/ui/include/ui/Region.h b/libs/ui/include/ui/Region.h
index 68b60fc..c5e31c5 100644
--- a/libs/ui/include/ui/Region.h
+++ b/libs/ui/include/ui/Region.h
@@ -89,11 +89,13 @@
// these translate rhs first
Region& translateSelf(int dx, int dy);
+ Region& scaleSelf(int sx, int 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);
Region& subtractSelf(const Region& rhs, int dx, int dy);
+
// these translate rhs first
const Region translate(int dx, int dy) const WARN_UNUSED;
const Region merge(const Region& rhs, int dx, int dy) const WARN_UNUSED;
diff --git a/libs/ui/include/ui/Transform.h b/libs/ui/include/ui/Transform.h
index 42dca75..900a5c4 100644
--- a/libs/ui/include/ui/Transform.h
+++ b/libs/ui/include/ui/Transform.h
@@ -65,6 +65,8 @@
const vec3& operator [] (size_t i) const; // returns column i
float tx() const;
float ty() const;
+ float sx() const;
+ float sy() const;
// modify the transform
void reset();