From 6360ec42d414b1351ecb6c5fc4b8afa30d8f4ebf Mon Sep 17 00:00:00 2001 From: Jesse Hall Date: Wed, 12 Sep 2012 13:49:10 -0700 Subject: [PATCH] Fix display projection transforms Bug: 7139798 Change-Id: I61aafe99180d85563c6880d16bc367fce80e6022 --- services/surfaceflinger/DisplayDevice.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp index 01ae1c2d3..6a9cb3e03 100644 --- a/services/surfaceflinger/DisplayDevice.cpp +++ b/services/surfaceflinger/DisplayDevice.cpp @@ -309,7 +309,7 @@ void DisplayDevice::setProjection(int orientation, void DisplayDevice::updateGeometryTransform() { int w = mDisplayWidth; int h = mDisplayHeight; - Transform R, S; + Transform T, R, S; if (DisplayDevice::orientationToTransfrom( mOrientation, w, h, &R) == NO_ERROR) { dirtyRegion.set(bounds()); @@ -340,20 +340,23 @@ void DisplayDevice::updateGeometryTransform() { float src_height = viewport.height(); float dst_width = frame.width(); float dst_height = frame.height(); - if (src_width != src_height || dst_width != dst_height) { + if (src_width != dst_width || src_height != dst_height) { float sx = dst_width / src_width; float sy = dst_height / src_height; S.set(sx, 0, 0, sy); } + float src_x = viewport.left; float src_y = viewport.top; float dst_x = frame.left; float dst_y = frame.top; float tx = dst_x - src_x; float ty = dst_y - src_y; - S.set(tx, ty); + T.set(tx, ty); - // rotate first, followed by scaling - mGlobalTransform = S * R; + // The viewport and frame are both in the logical orientation, so the + // translation is also in that space. So translation must be applied + // before rotating from logical to physical orientation. + mGlobalTransform = S * R * T; } }