summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Lentine <mlentine@google.com>2014-08-18 16:35:43 -0700
committerMichael Lentine <mlentine@google.com>2014-08-18 16:35:43 -0700
commitf75514079434cefcdb746e8b083708d6de5f86ff (patch)
tree68c3b195665c56a53da09ce0f91c082b1b52ec05
parent45e2fc22261cb8ecac4901b4425bcb7352c71174 (diff)
downloadframeworks_native-f75514079434cefcdb746e8b083708d6de5f86ff.zip
frameworks_native-f75514079434cefcdb746e8b083708d6de5f86ff.tar.gz
frameworks_native-f75514079434cefcdb746e8b083708d6de5f86ff.tar.bz2
Incorporate TransformToDisplayInverse into the crop calculation.
Change-Id: Ia9757b3a43d3b8f99df9fef2ed4d11c43b5abdd2
-rw-r--r--services/surfaceflinger/Layer.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 716d24e..cf49798 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -323,6 +323,20 @@ FloatRect Layer::computeCrop(const sp<const DisplayDevice>& hw) const {
// which means using the inverse of the current transform set on the
// SurfaceFlingerConsumer.
uint32_t invTransform = mCurrentTransform;
+ if (mSurfaceFlingerConsumer->getTransformToDisplayInverse()) {
+ /*
+ * the code below applies the display's inverse transform to the buffer
+ */
+ uint32_t invTransformOrient = hw->getOrientationTransform();
+ // calculate the inverse transform
+ if (invTransformOrient & NATIVE_WINDOW_TRANSFORM_ROT_90) {
+ invTransformOrient ^= NATIVE_WINDOW_TRANSFORM_FLIP_V |
+ NATIVE_WINDOW_TRANSFORM_FLIP_H;
+ }
+ // and apply to the current transform
+ invTransform = (Transform(invTransform) * Transform(invTransformOrient)).getOrientation();
+ }
+
int winWidth = s.active.w;
int winHeight = s.active.h;
if (invTransform & NATIVE_WINDOW_TRANSFORM_ROT_90) {
@@ -332,16 +346,16 @@ FloatRect Layer::computeCrop(const sp<const DisplayDevice>& hw) const {
winHeight = s.active.w;
}
const Rect winCrop = activeCrop.transform(
- invTransform, winWidth, winHeight);
+ invTransform, s.active.w, s.active.h);
// below, crop is intersected with winCrop expressed in crop's coordinate space
float xScale = crop.getWidth() / float(winWidth);
float yScale = crop.getHeight() / float(winHeight);
- float insetL = winCrop.left * xScale;
- float insetT = winCrop.top * yScale;
- float insetR = (s.active.w - winCrop.right ) * xScale;
- float insetB = (s.active.h - winCrop.bottom) * yScale;
+ float insetL = winCrop.left * xScale;
+ float insetT = winCrop.top * yScale;
+ float insetR = (winWidth - winCrop.right ) * xScale;
+ float insetB = (winHeight - winCrop.bottom) * yScale;
crop.left += insetL;
crop.top += insetT;