Fix seaming issue in BitmapRegionDecoder for gainmaps

Rounding discrepancies in the image codec infrastructure was allowing
gainmaps to be decoded with a 1px border on the edge, which introduces
visible seams when zooming into large images.

Fix this by adjusting how computing the desired gainmap subregion size,
by pretending we downsample first, then compute the subregion size based
on that.

Add a long paragraph explaining why we have to do this with an example,
because it's not entirely intuitive.

Also adjust how we poke at the gainmap resampling flag, since some CTS
tests run before RenderThread starts up and intializes the properties.

Bug: 371123308
Flag: com.android.graphics.hwui.flags.resample_gainmap_regions
Test: Decoding in Photos and Files
Test: GainmapTest
Change-Id: Id608c5838f7890d0304b040e13d7281aa879a75c
diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp
index ae46a99..064cac2 100644
--- a/libs/hwui/Properties.cpp
+++ b/libs/hwui/Properties.cpp
@@ -113,7 +113,6 @@
 bool Properties::clipSurfaceViews = false;
 bool Properties::hdr10bitPlus = false;
 bool Properties::skipTelemetry = false;
-bool Properties::resampleGainmapRegions = false;
 bool Properties::queryGlobalPriority = false;
 
 int Properties::timeoutMultiplier = 1;
@@ -190,8 +189,6 @@
     clipSurfaceViews =
             base::GetBoolProperty("debug.hwui.clip_surfaceviews", hwui_flags::clip_surfaceviews());
     hdr10bitPlus = hwui_flags::hdr_10bit_plus();
-    resampleGainmapRegions = base::GetBoolProperty("debug.hwui.resample_gainmap_regions",
-                                                   hwui_flags::resample_gainmap_regions());
     queryGlobalPriority = hwui_flags::query_global_priority();
 
     timeoutMultiplier = android::base::GetIntProperty("ro.hw_timeout_multiplier", 1);
@@ -288,5 +285,11 @@
     return base::GetBoolProperty(PROPERTY_INITIALIZE_GL_ALWAYS, hwui_flags::initialize_gl_always());
 }
 
+bool Properties::resampleGainmapRegions() {
+    static bool sResampleGainmapRegions = base::GetBoolProperty(
+            "debug.hwui.resample_gainmap_regions", hwui_flags::resample_gainmap_regions());
+    return sResampleGainmapRegions;
+}
+
 }  // namespace uirenderer
 }  // namespace android