summaryrefslogtreecommitdiffstats
path: root/services/surfaceflinger
diff options
context:
space:
mode:
authorMichael Lentine <mlentine@google.com>2014-11-25 18:44:51 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-11-25 18:44:51 +0000
commit1e6116621bc2f7aedfd52a5f1327b530328435b0 (patch)
tree9f4c056cde623097ed70a14446be6fb9c942bf19 /services/surfaceflinger
parentbbe43a4cdd0ea9a06d09e451dc256b7de59b5817 (diff)
parentb947f29a6af1622cda16d0b7112595082750dd07 (diff)
downloadframeworks_native-1e6116621bc2f7aedfd52a5f1327b530328435b0.zip
frameworks_native-1e6116621bc2f7aedfd52a5f1327b530328435b0.tar.gz
frameworks_native-1e6116621bc2f7aedfd52a5f1327b530328435b0.tar.bz2
am b947f29a: Merge "Add clamp to Layer and update Transform inverse." into lmp-mr1-dev
* commit 'b947f29a6af1622cda16d0b7112595082750dd07': Add clamp to Layer and update Transform inverse.
Diffstat (limited to 'services/surfaceflinger')
-rw-r--r--services/surfaceflinger/Layer.cpp15
-rw-r--r--services/surfaceflinger/Transform.cpp31
2 files changed, 29 insertions, 17 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 009baea..9da1efd 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -331,8 +331,12 @@ FloatRect Layer::computeCrop(const sp<const DisplayDevice>& hw) const {
activeCrop.intersect(hw->getViewport(), &activeCrop);
activeCrop = s.transform.inverse().transform(activeCrop);
- // paranoia: make sure the window-crop is constrained in the
- // window's bounds
+ // This needs to be here as transform.transform(Rect) computes the
+ // transformed rect and then takes the bounding box of the result before
+ // returning. This means
+ // transform.inverse().transform(transform.transform(Rect)) != Rect
+ // in which case we need to make sure the final rect is clipped to the
+ // display bounds.
activeCrop.intersect(Rect(s.active.w, s.active.h), &activeCrop);
// subtract the transparent region and snap to the bounds
@@ -431,6 +435,13 @@ void Layer::setGeometry(
activeCrop = s.transform.transform(activeCrop);
activeCrop.intersect(hw->getViewport(), &activeCrop);
activeCrop = s.transform.inverse().transform(activeCrop);
+ // This needs to be here as transform.transform(Rect) computes the
+ // transformed rect and then takes the bounding box of the result before
+ // returning. This means
+ // transform.inverse().transform(transform.transform(Rect)) != Rect
+ // in which case we need to make sure the final rect is clipped to the
+ // display bounds.
+ activeCrop.intersect(Rect(s.active.w, s.active.h), &activeCrop);
// mark regions outside the crop as transparent
activeTransparentRegion.orSelf(Rect(0, 0, s.active.w, activeCrop.top));
activeTransparentRegion.orSelf(Rect(0, activeCrop.bottom,
diff --git a/services/surfaceflinger/Transform.cpp b/services/surfaceflinger/Transform.cpp
index 3456abf..35e7e7d 100644
--- a/services/surfaceflinger/Transform.cpp
+++ b/services/surfaceflinger/Transform.cpp
@@ -301,16 +301,16 @@ Transform Transform::inverse() const {
// (T*M)^-1 = M^-1 * T^-1
Transform result;
if (mType <= TRANSLATE) {
- // 1 0 x
- // 0 1 y
- // 0 0 1
+ // 1 0 0
+ // 0 1 0
+ // x y 1
result = *this;
result.mMatrix[2][0] = -result.mMatrix[2][0];
result.mMatrix[2][1] = -result.mMatrix[2][1];
} else {
- // a c x
- // b d y
- // 0 0 1
+ // a c 0
+ // b d 0
+ // x y 1
const mat33& M(mMatrix);
const float a = M[0][0];
const float b = M[1][0];
@@ -319,16 +319,17 @@ Transform Transform::inverse() const {
const float x = M[2][0];
const float y = M[2][1];
- Transform R, T;
const float idet = 1.0 / (a*d - b*c);
- R.mMatrix[0][0] = d*idet; R.mMatrix[0][1] = -c*idet;
- R.mMatrix[1][0] = -b*idet; R.mMatrix[1][1] = a*idet;
- R.mType = mType &= ~TRANSLATE;
-
- T.mMatrix[2][0] = -x;
- T.mMatrix[2][1] = -y;
- T.mType = TRANSLATE;
- result = R * T;
+ result.mMatrix[0][0] = d*idet;
+ result.mMatrix[0][1] = -c*idet;
+ result.mMatrix[1][0] = -b*idet;
+ result.mMatrix[1][1] = a*idet;
+ result.mType = mType;
+
+ vec2 T(-x, -y);
+ T = result.transform(T);
+ result.mMatrix[2][0] = T[0];
+ result.mMatrix[2][1] = T[1];
}
return result;
}