Don't overdim SDR content in an HLG screenshot.

Aligning HLG and PQ to 1.0 == 203 nits made SDR assets in screenshots
too dim, since both the colorspace and the color transform applied
dimming. Removing dimming application from the color transform is a
larger change, so just compensate when configuring the screenshot in
SurfaceFlinger instead.

Bug: 280347733
Test: HwAccelerationTest
Test: Navigate in and out of recents
Change-Id: Idfdb74c0c3b977717b870b2bb9a469be37d27dc9
diff --git a/services/surfaceflinger/ScreenCaptureOutput.cpp b/services/surfaceflinger/ScreenCaptureOutput.cpp
index b70b53d..09dac23 100644
--- a/services/surfaceflinger/ScreenCaptureOutput.cpp
+++ b/services/surfaceflinger/ScreenCaptureOutput.cpp
@@ -94,6 +94,16 @@
         }
     }
 
+    if (outputDataspace == ui::Dataspace::BT2020_HLG) {
+        for (auto& layer : clientCompositionLayers) {
+            auto transfer = layer.sourceDataspace & ui::Dataspace::TRANSFER_MASK;
+            if (transfer != static_cast<int32_t>(ui::Dataspace::TRANSFER_HLG) &&
+                transfer != static_cast<int32_t>(ui::Dataspace::TRANSFER_ST2084)) {
+                layer.whitePointNits *= (1000.0f / 203.0f);
+            }
+        }
+    }
+
     Rect sourceCrop = mRenderArea.getSourceCrop();
     compositionengine::LayerFE::LayerSettings fillLayer;
     fillLayer.source.buffer.buffer = nullptr;