Remove the concept of target dataspace
This is only needed for configuring colorspace agnostic dataspaces, but
no device does that. For colorspace agnostic layers, it's sufficient to
just use the colormode dataspace, with the possible exception of HDR
where we can preserve some bespoke logic, so we can just get rid of
target dataspaces and any associated plumbing.
Bug: 292162273
Test: builds
Test: libsurfaceflinger_unittest
Test: libcompositionengine_test
Change-Id: I319bb354e80e3ad1eaaacd896b897e6696f96588
diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
index 0ac0ecb..b492b6a 100644
--- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
@@ -315,9 +315,10 @@
// Determine the output dependent dataspace for this layer. If it is
// colorspace agnostic, it just uses the dataspace chosen for the output to
// avoid the need for color conversion.
- state.dataspace = layerFEState->isColorspaceAgnostic &&
- outputState.targetDataspace != ui::Dataspace::UNKNOWN
- ? outputState.targetDataspace
+ // For now, also respect the colorspace agnostic flag if we're drawing to HDR, to avoid drastic
+ // luminance shift. TODO(b/292162273): we should check if that's true though.
+ state.dataspace = layerFEState->isColorspaceAgnostic && !isHdrDataspace(outputState.dataspace)
+ ? outputState.dataspace
: layerFEState->dataspace;
// Override the dataspace transfer from 170M to sRGB if the device configuration requests this.