From 0e65e6c283c96d514c5ecefbb46a976939cfa64a Mon Sep 17 00:00:00 2001 From: Dan Stoza Date: Tue, 26 May 2015 13:22:27 -0700 Subject: [PATCH] libgui: Fix surface damage on rotated buffers Flips the width and height when the buffer comes in with a 90 degree rotation so that performing the Y-flip from GL works correctly. Bug: 20761426 Change-Id: I41c9edc8549c6cbdb534277b996ff20c59034582 --- libs/gui/Surface.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp index 35aa7c76b..04ac0f438 100644 --- a/libs/gui/Surface.cpp +++ b/libs/gui/Surface.cpp @@ -335,10 +335,14 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) { // the origin being in the bottom-left corner. Here we flip to the // convention that the rest of the system uses (top-left corner) by // subtracting all top/bottom coordinates from the buffer height. + int height = buffer->height; + if ((mTransform ^ mStickyTransform) & NATIVE_WINDOW_TRANSFORM_ROT_90) { + height = buffer->width; + } Region flippedRegion; for (auto rect : mDirtyRegion) { - auto top = buffer->height - rect.bottom; - auto bottom = buffer->height - rect.top; + auto top = height - rect.bottom; + auto bottom = height - rect.top; Rect flippedRect{rect.left, top, rect.right, bottom}; flippedRegion.orSelf(flippedRect); }