Sample from texel centers in downchunk shaders
Previously we weren't sampling from texel centers, which caused
incorrect pixels to be sampled when using nearest neighbor sampling.
Bug: 329464641
Flag: com.android.graphics.surfaceflinger.flags.local_tonemap_screenshots
Test: librenderengine_test
Test: Screenshots of UltraHDR and HDR video
Change-Id: Id1e3ea070368aecb18e5bd1ae7093537c76f6ddf
diff --git a/libs/renderengine/skia/filters/MouriMap.cpp b/libs/renderengine/skia/filters/MouriMap.cpp
index cc25fcc..b458939 100644
--- a/libs/renderengine/skia/filters/MouriMap.cpp
+++ b/libs/renderengine/skia/filters/MouriMap.cpp
@@ -35,7 +35,7 @@
float maximum = 0.0;
for (int y = 0; y < 16; y++) {
for (int x = 0; x < 16; x++) {
- float3 linear = toLinearSrgb(bitmap.eval(xy * 16 + vec2(x, y)).rgb) * hdrSdrRatio;
+ float3 linear = toLinearSrgb(bitmap.eval((xy - 0.5) * 16 + 0.5 + vec2(x, y)).rgb) * hdrSdrRatio;
float maxRGB = max(linear.r, max(linear.g, linear.b));
maximum = max(maximum, log2(max(maxRGB, 1.0)));
}
@@ -49,7 +49,7 @@
float maximum = 0.0;
for (int y = 0; y < 8; y++) {
for (int x = 0; x < 8; x++) {
- maximum = max(maximum, bitmap.eval(xy * 8 + vec2(x, y)).r);
+ maximum = max(maximum, bitmap.eval((xy - 0.5) * 8 + 0.5 + vec2(x, y)).r);
}
}
return float4(float3(maximum), 1.0);