summaryrefslogtreecommitdiff
path: root/libs/hwui/Properties.h
diff options
context:
space:
mode:
author Alec Mouri <alecmouri@google.com> 2024-07-26 13:41:04 +0000
committer Alec Mouri <alecmouri@google.com> 2024-08-08 15:47:47 +0000
commit7dcb7d2d82cc18266aeed8d92c7c35ec8a32f821 (patch)
treeb221aaf5d9875e3e754d8ff7f70fc9fb2e684e79 /libs/hwui/Properties.h
parent06d5b870dbed121847cc1832b1ece17ebccbfb56 (diff)
Resample gainmaps during region decoding.
Implicitly, region decoding is a cropping operation, which previously was introducing quality issues when decoding a gainmapped image. For instance: (a) Consider a 48x48 image with a 12x12 gainmap. (b) Consider decoding a 10x10 region of the image. The decoder must choose to either decode a 2x2 or 3x3 region of the gainmap, which does not match the 4x scale ratio of the source, so either we decode too much or too little of the image (c) When displaying the image, we bilinearly scale both the image and the gainmap to the destination, then apply the gainmap. But, because of (b), the gainmap is misaligned with the base image, introducing haloing artifacts. To fix this, we change (b) by always decoding a slightly larger region (in the examplar case, either a decode a 3x3 or 4x4 region), but retain information about the "logical" region we intended. Then, we resample from the "logical" region up to the decoded bounds. In the above example, this means that we decode a 3x3 or 4x4 bitmap, that holds the logical 2.5x2.5 region of the gainmap, ensuring that (0, 0) in the resulting bitmap maps to (0, 0) in the bitmap for the decoded region from the base image, so that the gainmap content lines up with the base image after the gainmap is upsampled during rendering. We do the actual resampling inside of the recycling allocator, since we sometimes perform a bitmap copy there anyways, so we can resample during the copy. Hide this behind a flag, since I broke decoding in about 5 different ways before settling on this. Bug: 352847821 Flag: com.android.graphics.hwui.flags.resample_gainmap_regions Test: Decoding works in Photos, Files, and modified SilkFX Change-Id: Ic21d44011858619273b11c20ee746614a1749a73
Diffstat (limited to 'libs/hwui/Properties.h')
-rw-r--r--libs/hwui/Properties.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h
index e2646422030e..73e80ce4afd0 100644
--- a/libs/hwui/Properties.h
+++ b/libs/hwui/Properties.h
@@ -342,6 +342,7 @@ public:
static bool clipSurfaceViews;
static bool hdr10bitPlus;
+ static bool resampleGainmapRegions;
static int timeoutMultiplier;