surfaceflinger: allow unknown render intents
Allow render intents that are unknown to SurfaceFlinger.
Bug: 79843697
Bug: 75981986
Test: manual
Change-Id: Ia81436747b1d2fe9f44e749b93a9c1a5a7f1f6cb
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index ccd2aba..bacee20 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -708,8 +708,18 @@
return;
}
+ // collect all known SDR render intents
+ std::unordered_set<RenderIntent> sdrRenderIntents(sSdrRenderIntents.begin(),
+ sSdrRenderIntents.end());
+ auto iter = hwcColorModes.find(ColorMode::SRGB);
+ if (iter != hwcColorModes.end()) {
+ for (auto intent : iter->second) {
+ sdrRenderIntents.insert(intent);
+ }
+ }
+
// add known SDR combinations
- for (auto intent : sSdrRenderIntents) {
+ for (auto intent : sdrRenderIntents) {
for (auto mode : sSdrColorModes) {
addColorMode(hwcColorModes, mode, intent);
}
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index fe9a1d0..4c695c4 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -158,29 +158,18 @@
return std::string(value) == "true";
}
-DisplayColorSetting toDisplayColorSetting(int value) {
- switch(value) {
- case 0:
- return DisplayColorSetting::MANAGED;
- case 1:
- return DisplayColorSetting::UNMANAGED;
- case 2:
- return DisplayColorSetting::ENHANCED;
- default:
- return DisplayColorSetting::MANAGED;
- }
-}
-
std::string decodeDisplayColorSetting(DisplayColorSetting displayColorSetting) {
switch(displayColorSetting) {
case DisplayColorSetting::MANAGED:
- return std::string("Natural Mode");
+ return std::string("Managed");
case DisplayColorSetting::UNMANAGED:
- return std::string("Saturated Mode");
+ return std::string("Unmanaged");
case DisplayColorSetting::ENHANCED:
- return std::string("Auto Color Mode");
+ return std::string("Enhanced");
+ default:
+ return std::string("Unknown ") +
+ std::to_string(static_cast<int>(displayColorSetting));
}
- return std::string("Unknown Display Color Setting");
}
NativeWindowSurface::~NativeWindowSurface() = default;
@@ -738,9 +727,7 @@
ALOGV("Saturation is set to %.2f", mGlobalSaturationFactor);
property_get("persist.sys.sf.native_mode", value, "0");
- mDisplayColorSetting = toDisplayColorSetting(atoi(value));
- ALOGV("Display Color Setting is set to %s.",
- decodeDisplayColorSetting(mDisplayColorSetting).c_str());
+ mDisplayColorSetting = static_cast<DisplayColorSetting>(atoi(value));
}
void SurfaceFlinger::startBootAnim() {
@@ -1918,8 +1905,19 @@
Dataspace hdrDataSpace;
Dataspace bestDataSpace = getBestDataspace(displayDevice, &hdrDataSpace);
- RenderIntent intent = mDisplayColorSetting == DisplayColorSetting::ENHANCED ?
- RenderIntent::ENHANCE : RenderIntent::COLORIMETRIC;
+ RenderIntent intent;
+ switch (mDisplayColorSetting) {
+ case DisplayColorSetting::MANAGED:
+ case DisplayColorSetting::UNMANAGED:
+ intent = RenderIntent::COLORIMETRIC;
+ break;
+ case DisplayColorSetting::ENHANCED:
+ intent = 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)) {
@@ -2303,10 +2301,6 @@
nativeWindowSurface->preallocateBuffers();
}
- if (hw->isPrimary() && hw->hasRenderIntent(RenderIntent::ENHANCE)) {
- mBuiltinDisplaySupportsEnhance = true;
- }
-
ColorMode defaultColorMode = ColorMode::NATIVE;
Dataspace defaultDataSpace = Dataspace::UNKNOWN;
if (hasWideColorGamut) {
@@ -2899,7 +2893,7 @@
}
needsLegacyColorMatrix =
- (displayDevice->getActiveRenderIntent() == RenderIntent::ENHANCE &&
+ (displayDevice->getActiveRenderIntent() >= RenderIntent::ENHANCE &&
outputDataspace != Dataspace::UNKNOWN &&
outputDataspace != Dataspace::SRGB);
@@ -4073,7 +4067,8 @@
void SurfaceFlinger::dumpWideColorInfo(String8& result) const {
result.appendFormat("hasWideColorDisplay: %d\n", hasWideColorDisplay);
- result.appendFormat("DisplayColorSetting: %d\n", mDisplayColorSetting);
+ result.appendFormat("DisplayColorSetting: %s\n",
+ decodeDisplayColorSetting(mDisplayColorSetting).c_str());
// TODO: print out if wide-color mode is active or not
@@ -4601,15 +4596,7 @@
return NO_ERROR;
}
case 1023: { // Set native mode
- int32_t value = data.readInt32();
- if (value > 2) {
- return BAD_VALUE;
- }
- if (value == 2 && !mBuiltinDisplaySupportsEnhance) {
- return BAD_VALUE;
- }
-
- mDisplayColorSetting = toDisplayColorSetting(value);
+ mDisplayColorSetting = static_cast<DisplayColorSetting>(data.readInt32());
invalidateHwcGeometry();
repaintEverything();
return NO_ERROR;
@@ -4638,20 +4625,27 @@
}
// Is a DisplayColorSetting supported?
case 1027: {
- int32_t value = data.readInt32();
- switch (value) {
- case 0:
- reply->writeBool(hasWideColorDisplay);
- return NO_ERROR;
- case 1:
- reply->writeBool(true);
- return NO_ERROR;
- case 2:
- reply->writeBool(mBuiltinDisplaySupportsEnhance);
- return NO_ERROR;
- default:
- return BAD_VALUE;
+ sp<const DisplayDevice> hw(getDefaultDisplayDevice());
+ if (!hw) {
+ return NAME_NOT_FOUND;
}
+
+ DisplayColorSetting setting = static_cast<DisplayColorSetting>(data.readInt32());
+ switch (setting) {
+ case DisplayColorSetting::MANAGED:
+ reply->writeBool(hasWideColorDisplay);
+ break;
+ case DisplayColorSetting::UNMANAGED:
+ reply->writeBool(true);
+ break;
+ case DisplayColorSetting::ENHANCED:
+ reply->writeBool(hw->hasRenderIntent(RenderIntent::ENHANCE));
+ break;
+ default: // vendor display color setting
+ reply->writeBool(hw->hasRenderIntent(static_cast<RenderIntent>(setting)));
+ break;
+ }
+ return NO_ERROR;
}
}
}
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index f889beb..fcfc54f 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -878,7 +878,6 @@
DisplayColorSetting mDisplayColorSetting = DisplayColorSetting::MANAGED;
// Applied on sRGB layers when the render intent is non-colorimetric.
mat4 mLegacySrgbSaturationMatrix;
- bool mBuiltinDisplaySupportsEnhance = false;
using CreateBufferQueueFunction =
std::function<void(sp<IGraphicBufferProducer>* /* outProducer */,