summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChia-I Wu <olv@google.com>2018-05-21 15:19:35 -0700
committerChia-I Wu <olv@google.com>2018-05-23 15:02:34 -0700
commit0d711268fe57b73a38ec3590b6e67f03ff789fa1 (patch)
tree10deb6952a505bc058b221835eb0d302251cb315
parentbbb44464990d0becd1c5eef77f85da82b8008534 (diff)
downloadnative-0d711268fe57b73a38ec3590b6e67f03ff789fa1.tar.gz
surfaceflinger: allow unknown render intents
Allow render intents that are unknown to SurfaceFlinger. Bug: 79843697 Bug: 75981986 Test: manual Change-Id: Ia81436747b1d2fe9f44e749b93a9c1a5a7f1f6cb
-rw-r--r--services/surfaceflinger/DisplayDevice.cpp12
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp90
-rw-r--r--services/surfaceflinger/SurfaceFlinger.h1
3 files changed, 53 insertions, 50 deletions
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index ccd2aba728..bacee209f5 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -708,8 +708,18 @@ void DisplayDevice::populateColorModes(
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 fe9a1d0ac1..4c695c4407 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -158,29 +158,18 @@ bool useTrebleTestingOverride() {
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 @@ void SurfaceFlinger::readPersistentProperties() {
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 @@ void SurfaceFlinger::pickColorMode(const sp<DisplayDevice>& displayDevice,
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 @@ sp<DisplayDevice> SurfaceFlinger::setupNewDisplayDeviceInternal(
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 @@ bool SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& displayDev
}
needsLegacyColorMatrix =
- (displayDevice->getActiveRenderIntent() == RenderIntent::ENHANCE &&
+ (displayDevice->getActiveRenderIntent() >= RenderIntent::ENHANCE &&
outputDataspace != Dataspace::UNKNOWN &&
outputDataspace != Dataspace::SRGB);
@@ -4073,7 +4067,8 @@ void SurfaceFlinger::dumpBufferingStats(String8& result) const {
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 @@ status_t SurfaceFlinger::onTransact(
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 @@ status_t SurfaceFlinger::onTransact(
}
// Is a DisplayColorSetting supported?
case 1027: {
- int32_t value = data.readInt32();
- switch (value) {
- case 0:
+ 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);
- return NO_ERROR;
- case 1:
+ break;
+ case DisplayColorSetting::UNMANAGED:
reply->writeBool(true);
- return NO_ERROR;
- case 2:
- reply->writeBool(mBuiltinDisplaySupportsEnhance);
- return NO_ERROR;
- default:
- return BAD_VALUE;
+ 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 f889beba8f..fcfc54f153 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -878,7 +878,6 @@ private:
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 */,