[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.h b/services/surfaceflinger/DisplayDevice.h
index 1df8c49..d051e33 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -20,6 +20,7 @@
#include "Transform.h"
#include <stdlib.h>
+#include <unordered_map>
#include <math/mat4.h>
@@ -90,6 +91,7 @@
bool hasWideColorGamut,
const HdrCapabilities& hdrCapabilities,
const int32_t supportedPerFrameMetadata,
+ const std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>>& hdrAndRenderIntents,
int initialPowerMode);
// clang-format on
@@ -142,6 +144,7 @@
status_t beginFrame(bool mustRecompose) const;
status_t prepareFrame(HWComposer& hwc);
bool hasWideColorGamut() const { return mHasWideColorGamut; }
+ // Whether h/w composer has native support for specific HDR type.
bool hasHDR10Support() const { return mHasHdr10; }
bool hasHLGSupport() const { return mHasHLG; }
bool hasDolbyVisionSupport() const { return mHasDolbyVision; }
@@ -153,6 +156,14 @@
// respectively if hardware composer doesn't return meaningful values.
const HdrCapabilities& getHdrCapabilities() const { return mHdrCapabilities; }
+ // Whether h/w composer has BT2100_PQ color mode.
+ bool hasBT2100PQColorimetricSupport() const { return mHasBT2100PQColorimetric; }
+ bool hasBT2100PQEnhanceSupport() const { return mHasBT2100PQEnhance; }
+
+ // Whether h/w composer has BT2100_HLG color mode.
+ bool hasBT2100HLGColorimetricSupport() const { return mHasBT2100HLGColorimetric; }
+ bool hasBT2100HLGEnhanceSupport() const { return mHasBT2100HLGEnhance; }
+
void swapBuffers(HWComposer& hwc) const;
// called after h/w composer has completed its set() call
@@ -203,6 +214,9 @@
void dump(String8& result) const;
private:
+ void hasToneMapping(const std::vector<ui::RenderIntent>& renderIntents,
+ bool* outColorimetric, bool *outEnhance);
+
/*
* Constants, set during initialization
*/
@@ -274,6 +288,12 @@
bool mHasDolbyVision;
HdrCapabilities mHdrCapabilities;
const int32_t mSupportedPerFrameMetadata;
+ // Whether h/w composer has BT2100_PQ and BT2100_HLG color mode with
+ // colorimetrical tone mapping or enhanced tone mapping.
+ bool mHasBT2100PQColorimetric;
+ bool mHasBT2100PQEnhance;
+ bool mHasBT2100HLGColorimetric;
+ bool mHasBT2100HLGEnhance;
};
struct DisplayDeviceState {