[SurfaceFlinger] Add BT2100_PQ and BT2100_HLG color mode.
When hardware composer has native HDR10/HLG support, SurfaceFlinger will always
pass the layer to hardware composer. When hardware composer doesn't have native
HDR10/HLG support, but has BT2100_PQ or BT2100_HLG color mode with render
intent, SurfaceFlinger will always set the color mode to BT2100_PQ and
BT2100_HLG respectively, and set the render intent to TONE_MAP_ENHANCE if
supported, or TONE_MAP_COLORIMETRIC. Otherwise, SurfaceFlinger will set the
color mode to Display P3 and simulate PQ/HLG in RenderEngine.
Since SurfaceFlinger now can simulate HLG support in Display P3 mode, when apps
query HDR capability from platform, we also return HLG support.
BUG: 73825729
Test: build, flash
Change-Id: I53696360f2b3d986aa9191ff42866e275ba4fd0b
Merged-In: I53696360f2b3d986aa9191ff42866e275ba4fd0b
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index 00f8cc9..2b1e577 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -80,6 +80,7 @@
bool hasWideColorGamut,
const HdrCapabilities& hdrCapabilities,
const int32_t supportedPerFrameMetadata,
+ const std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>>& hdrAndRenderIntents,
int initialPowerMode)
: lastCompositionHadVisibleLayers(false),
mFlinger(flinger),
@@ -105,7 +106,11 @@
mHasHdr10(false),
mHasHLG(false),
mHasDolbyVision(false),
- mSupportedPerFrameMetadata(supportedPerFrameMetadata)
+ mSupportedPerFrameMetadata(supportedPerFrameMetadata),
+ mHasBT2100PQColorimetric(false),
+ mHasBT2100PQEnhance(false),
+ mHasBT2100HLGColorimetric(false),
+ mHasBT2100HLGEnhance(false)
{
// clang-format on
std::vector<Hdr> types = hdrCapabilities.getSupportedHdrTypes();
@@ -145,6 +150,18 @@
}
mHdrCapabilities = HdrCapabilities(types, maxLuminance, maxAverageLuminance, minLuminance);
+ auto iter = hdrAndRenderIntents.find(ColorMode::BT2100_PQ);
+ if (iter != hdrAndRenderIntents.end()) {
+ hasToneMapping(iter->second,
+ &mHasBT2100PQColorimetric, &mHasBT2100PQEnhance);
+ }
+
+ iter = hdrAndRenderIntents.find(ColorMode::BT2100_HLG);
+ if (iter != hdrAndRenderIntents.end()) {
+ hasToneMapping(iter->second,
+ &mHasBT2100HLGColorimetric, &mHasBT2100HLGEnhance);
+ }
+
// initialize the display orientation transform.
setProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
}
@@ -529,6 +546,22 @@
result.append(surfaceDump);
}
+void DisplayDevice::hasToneMapping(const std::vector<RenderIntent>& renderIntents,
+ bool* outColorimetric, bool *outEnhance) {
+ for (auto intent : renderIntents) {
+ switch (intent) {
+ case RenderIntent::TONE_MAP_COLORIMETRIC:
+ *outColorimetric = true;
+ break;
+ case RenderIntent::TONE_MAP_ENHANCE:
+ *outEnhance = true;
+ break;
+ default:
+ break;
+ }
+ }
+}
+
std::atomic<int32_t> DisplayDeviceState::nextDisplayId(1);
DisplayDeviceState::DisplayDeviceState(DisplayDevice::DisplayType type, bool isSecure)