surfaceflinger: RenderIntent::COLORIMETRIC is no longer mandatory

RenderIntent::COLORIMETRIC is mandatory only for SDR color modes.
For HDR color modes, RenderIntent::TONE_MAP_COLORIMETRIC is
mandatory.

Bug: 80030364
Test: HDR videos
Change-Id: I70d96ac66d069218d789dded330169284a61bde1
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index f5fa478..a120738 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1932,27 +1932,27 @@
     Dataspace hdrDataSpace;
     Dataspace bestDataSpace = getBestDataspace(displayDevice, &hdrDataSpace);
 
+    // respect hdrDataSpace only when there is modern HDR support
+    const bool isHdr = hdrDataSpace != Dataspace::UNKNOWN &&
+        displayDevice->hasModernHdrSupport(hdrDataSpace);
+    if (isHdr) {
+        bestDataSpace = hdrDataSpace;
+    }
+
     RenderIntent intent;
     switch (mDisplayColorSetting) {
         case DisplayColorSetting::MANAGED:
         case DisplayColorSetting::UNMANAGED:
-            intent = RenderIntent::COLORIMETRIC;
+            intent = isHdr ? RenderIntent::TONE_MAP_COLORIMETRIC : RenderIntent::COLORIMETRIC;
             break;
         case DisplayColorSetting::ENHANCED:
-            intent = RenderIntent::ENHANCE;
+            intent = isHdr ? RenderIntent::TONE_MAP_ENHANCE : RenderIntent::ENHANCE;
             break;
         default: // vendor display color setting
             intent = static_cast<RenderIntent>(mDisplayColorSetting);
             break;
     }
 
-    // respect hdrDataSpace only when there is modern HDR support
-    if (hdrDataSpace != Dataspace::UNKNOWN && displayDevice->hasModernHdrSupport(hdrDataSpace)) {
-        bestDataSpace = hdrDataSpace;
-        intent = mDisplayColorSetting == DisplayColorSetting::ENHANCED ?
-            RenderIntent::TONE_MAP_ENHANCE : RenderIntent::TONE_MAP_COLORIMETRIC;
-    }
-
     displayDevice->getBestColorMode(bestDataSpace, intent, outDataSpace, outMode, outRenderIntent);
 }