From 439b60968f1fe544b79a5c5ba4657fca9e82b54a Mon Sep 17 00:00:00 2001 From: Alec Mouri Date: Wed, 14 Sep 2022 22:24:17 +0000 Subject: Remove coordinate swapping in region sampling Captured screens for region sampling were originally rendered upside-down, which required swapping coordinates to sample from the correct area in the output buffer. Since then, several fixes to the screenshot path have landed, which treat screen orientation consistently, so the captured images are no longer upside-down. But, the coordinate swapping was never removed. Remove it now, as sampling during landscape is now broken. Bug: 133849373 Bug: 241967077 Test: Split screen in landscape with settings app in dark mode, calculator in light mode, and trigger back gestures Change-Id: I52c65032d33d01a4407dc1b30215e7edac6eb1ea --- services/surfaceflinger/RegionSamplingThread.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'services/surfaceflinger/RegionSamplingThread.cpp') diff --git a/services/surfaceflinger/RegionSamplingThread.cpp b/services/surfaceflinger/RegionSamplingThread.cpp index 570525598e..8dd3b0f59d 100644 --- a/services/surfaceflinger/RegionSamplingThread.cpp +++ b/services/surfaceflinger/RegionSamplingThread.cpp @@ -203,25 +203,14 @@ float sampleArea(const uint32_t* data, int32_t width, int32_t height, int32_t st return 0.0f; } - // (b/133849373) ROT_90 screencap images produced upside down - auto area = sample_area; - if (orientation & ui::Transform::ROT_90) { - area.top = height - area.top; - area.bottom = height - area.bottom; - std::swap(area.top, area.bottom); - - area.left = width - area.left; - area.right = width - area.right; - std::swap(area.left, area.right); - } - - const uint32_t pixelCount = (area.bottom - area.top) * (area.right - area.left); + const uint32_t pixelCount = + (sample_area.bottom - sample_area.top) * (sample_area.right - sample_area.left); uint32_t accumulatedLuma = 0; // Calculates luma with approximation of Rec. 709 primaries - for (int32_t row = area.top; row < area.bottom; ++row) { + for (int32_t row = sample_area.top; row < sample_area.bottom; ++row) { const uint32_t* rowBase = data + row * stride; - for (int32_t column = area.left; column < area.right; ++column) { + for (int32_t column = sample_area.left; column < sample_area.right; ++column) { uint32_t pixel = rowBase[column]; const uint32_t r = pixel & 0xFF; const uint32_t g = (pixel >> 8) & 0xFF; -- cgit v1.2.3-59-g8ed1b