From 6e220a6ce6971555b883f4852c6e5d4c7a617815 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Thu, 13 Sep 2012 19:22:41 -0700 Subject: [PATCH] Fix display projections when translated. There are two different translations to apply in the logical orientation, one before scaling and one after. So translate, scale, translate then rotate. Bug: 7139798 Change-Id: I0726991cadb62988390e77503dbbaed54f07bfe3 --- services/surfaceflinger/DisplayDevice.cpp | 15 +++++++-------- services/surfaceflinger/SurfaceFlinger.cpp | 8 ++++++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp index 6a9cb3e03..2c06a0b55 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 T, R, S; + Transform TL, TP, R, S; if (DisplayDevice::orientationToTransfrom( mOrientation, w, h, &R) == NO_ERROR) { dirtyRegion.set(bounds()); @@ -350,13 +350,12 @@ void DisplayDevice::updateGeometryTransform() { 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; - T.set(tx, ty); + TL.set(-src_x, -src_y); + TP.set(dst_x, dst_y); - // 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; + // The viewport and frame are both in the logical orientation. + // Apply the logical translation, scale to physical size, apply the + // physical translation and finally rotate to the physical orientation. + mGlobalTransform = R * TP * S * TL; } } diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 6542acd29..da15248c4 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1976,7 +1976,8 @@ void SurfaceFlinger::dumpAllLocked( snprintf(buffer, SIZE, "+ DisplayDevice[%u]\n" " type=%x, layerStack=%u, (%4dx%4d), orient=%2d (type=%08x), " - "flips=%u, secure=%d, numLayers=%u, v:[%d,%d,%d,%d], f:[%d,%d,%d,%d]\n", + "flips=%u, secure=%d, numLayers=%u, v:[%d,%d,%d,%d], f:[%d,%d,%d,%d], " + "transform:[[%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f]]\n", dpy, hw->getDisplayType(), hw->getLayerStack(), hw->getWidth(), hw->getHeight(), @@ -1985,7 +1986,10 @@ void SurfaceFlinger::dumpAllLocked( hw->getSecureLayerVisible(), hw->getVisibleLayersSortedByZ().size(), hw->getViewport().left, hw->getViewport().top, hw->getViewport().right, hw->getViewport().bottom, - hw->getFrame().left, hw->getFrame().top, hw->getFrame().right, hw->getFrame().bottom); + hw->getFrame().left, hw->getFrame().top, hw->getFrame().right, hw->getFrame().bottom, + hw->getTransform()[0][0], hw->getTransform()[1][0], hw->getTransform()[2][0], + hw->getTransform()[0][1], hw->getTransform()[1][1], hw->getTransform()[2][1], + hw->getTransform()[0][2], hw->getTransform()[1][2], hw->getTransform()[2][2]); result.append(buffer); }