summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Peiyong Lin <lpy@google.com> 2019-03-15 18:40:15 -0700
committer Peiyong Lin <lpy@google.com> 2019-03-15 18:42:29 -0700
commit34ea5b964a3ef0f4503bb213117da6f6f1588ce1 (patch)
tree7dbc164e895c2f62ddc9e1b9ec9c6fd5d2d808e4
parent178e86bb5218595d9fe20d7aa94a89df5b62028d (diff)
Avoid setting color space agnostic when in HDR mode.
HDR is assumed to have high brightness, and thus the white means 10000 nits when in HDR 10. Making layers color space agnostic could probably results in wrong visual perception. BUG: 126616348 Test: Build, flash and boot. Verify with Youtube HDR. Change-Id: Icf6ae321cf53f31426362df2a972a0b396501f9f
-rw-r--r--services/surfaceflinger/BufferLayer.cpp4
-rw-r--r--services/surfaceflinger/ColorLayer.cpp4
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp26
3 files changed, 31 insertions, 3 deletions
diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp
index 4751e5f122..1b2b180c52 100644
--- a/services/surfaceflinger/BufferLayer.cpp
+++ b/services/surfaceflinger/BufferLayer.cpp
@@ -304,7 +304,9 @@ void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice,
setCompositionType(displayDevice, Hwc2::IComposerClient::Composition::DEVICE);
}
- ui::Dataspace dataspace = isColorSpaceAgnostic() ? targetDataspace : mCurrentDataSpace;
+ ui::Dataspace dataspace = isColorSpaceAgnostic() && targetDataspace != ui::Dataspace::UNKNOWN
+ ? targetDataspace
+ : mCurrentDataSpace;
error = hwcLayer->setDataspace(dataspace);
if (error != HWC2::Error::None) {
ALOGE("[%s] Failed to set dataspace %d: %s (%d)", mName.string(), dataspace,
diff --git a/services/surfaceflinger/ColorLayer.cpp b/services/surfaceflinger/ColorLayer.cpp
index 3364399b35..fcc2d97ca3 100644
--- a/services/surfaceflinger/ColorLayer.cpp
+++ b/services/surfaceflinger/ColorLayer.cpp
@@ -114,7 +114,9 @@ void ColorLayer::setPerFrameData(const sp<const DisplayDevice>& display,
setCompositionType(display, Hwc2::IComposerClient::Composition::SOLID_COLOR);
- const ui::Dataspace dataspace = isColorSpaceAgnostic() ? targetDataspace : mCurrentDataSpace;
+ const ui::Dataspace dataspace =
+ isColorSpaceAgnostic() && targetDataspace != ui::Dataspace::UNKNOWN ? targetDataspace
+ : mCurrentDataSpace;
error = hwcLayer->setDataspace(dataspace);
if (error != HWC2::Error::None) {
ALOGE("[%s] Failed to set dataspace %d: %s (%d)", mName.string(), dataspace,
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 83e53fa869..3f620796e4 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -157,6 +157,28 @@ bool isWideColorMode(const ColorMode colorMode) {
return false;
}
+bool isHdrColorMode(const ColorMode colorMode) {
+ switch (colorMode) {
+ case ColorMode::BT2100_PQ:
+ case ColorMode::BT2100_HLG:
+ return true;
+ case ColorMode::DISPLAY_P3:
+ case ColorMode::ADOBE_RGB:
+ case ColorMode::DCI_P3:
+ case ColorMode::BT2020:
+ case ColorMode::DISPLAY_BT2020:
+ case ColorMode::NATIVE:
+ case ColorMode::STANDARD_BT601_625:
+ case ColorMode::STANDARD_BT601_625_UNADJUSTED:
+ case ColorMode::STANDARD_BT601_525:
+ case ColorMode::STANDARD_BT601_525_UNADJUSTED:
+ case ColorMode::STANDARD_BT709:
+ case ColorMode::SRGB:
+ return false;
+ }
+ return false;
+}
+
ui::Transform::orientation_flags fromSurfaceComposerRotation(ISurfaceComposer::Rotation rotation) {
switch (rotation) {
case ISurfaceComposer::eRotateNone:
@@ -1836,7 +1858,9 @@ void SurfaceFlinger::calculateWorkingSet() {
const auto& displayState = display->getState();
layer->setPerFrameData(displayDevice, displayState.transform, displayState.viewport,
- displayDevice->getSupportedPerFrameMetadata(), targetDataspace);
+ displayDevice->getSupportedPerFrameMetadata(),
+ isHdrColorMode(displayState.colorMode) ? Dataspace::UNKNOWN
+ : targetDataspace);
}
}