summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alec Mouri <alecmouri@google.com> 2022-04-11 20:02:17 +0000
committer Alec Mouri <alecmouri@google.com> 2022-04-14 22:59:27 +0000
commitfcedb9ca3fa14607451ca24f32539a36f2261912 (patch)
tree8b09a3c0a491b2f53d8826a9380ef3383cd2a6c2
parent168f6ccfce328a1224297ba5b7af2779fcee0d9a (diff)
Support RenderIntents in libtonemap.
Add RenderIntent as a supported uniform which is needed as some devices may perform contrast enhancements intended for SDR content which must be compensated for pre-blend for HDR content. Bug: 227779465 Test: builds Change-Id: Id74277e727d73cb9e371c37a83bef805e66271f4
-rw-r--r--libs/renderengine/include/renderengine/DisplaySettings.h5
-rw-r--r--libs/renderengine/skia/SkiaGLRenderEngine.cpp2
-rw-r--r--libs/renderengine/skia/filters/LinearEffect.cpp14
-rw-r--r--libs/renderengine/skia/filters/LinearEffect.h13
-rw-r--r--libs/shaders/Android.bp1
-rw-r--r--libs/shaders/include/shaders/shaders.h11
-rw-r--r--libs/shaders/shaders.cpp13
-rw-r--r--libs/tonemap/Android.bp1
-rw-r--r--libs/tonemap/include/tonemap/tonemap.h14
-rw-r--r--libs/tonemap/tests/Android.bp1
-rw-r--r--services/surfaceflinger/CompositionEngine/src/Output.cpp3
-rw-r--r--services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp103
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp5
13 files changed, 136 insertions, 50 deletions
diff --git a/libs/renderengine/include/renderengine/DisplaySettings.h b/libs/renderengine/include/renderengine/DisplaySettings.h
index bf506448f6..a5e0879ce5 100644
--- a/libs/renderengine/include/renderengine/DisplaySettings.h
+++ b/libs/renderengine/include/renderengine/DisplaySettings.h
@@ -17,6 +17,7 @@
#pragma once
#include <aidl/android/hardware/graphics/composer3/DimmingStage.h>
+#include <aidl/android/hardware/graphics/composer3/RenderIntent.h>
#include <iosfwd>
#include <math/mat4.h>
@@ -73,6 +74,10 @@ struct DisplaySettings {
// Configures when dimming should be applied for each layer.
aidl::android::hardware::graphics::composer3::DimmingStage dimmingStage =
aidl::android::hardware::graphics::composer3::DimmingStage::NONE;
+
+ // Configures the rendering intent of the output display. This is used for tonemapping.
+ aidl::android::hardware::graphics::composer3::RenderIntent renderIntent =
+ aidl::android::hardware::graphics::composer3::RenderIntent::TONE_MAP_COLORIMETRIC;
};
static inline bool operator==(const DisplaySettings& lhs, const DisplaySettings& rhs) {
diff --git a/libs/renderengine/skia/SkiaGLRenderEngine.cpp b/libs/renderengine/skia/SkiaGLRenderEngine.cpp
index a77a798d0b..76ae2fc38c 100644
--- a/libs/renderengine/skia/SkiaGLRenderEngine.cpp
+++ b/libs/renderengine/skia/SkiaGLRenderEngine.cpp
@@ -662,7 +662,7 @@ sk_sp<SkShader> SkiaGLRenderEngine::createRuntimeEffectShader(
parameters.display.maxLuminance,
parameters.display.currentLuminanceNits,
parameters.layer.source.buffer.maxLuminanceNits,
- hardwareBuffer);
+ hardwareBuffer, parameters.display.renderIntent);
}
return parameters.shader;
}
diff --git a/libs/renderengine/skia/filters/LinearEffect.cpp b/libs/renderengine/skia/filters/LinearEffect.cpp
index d479606f2b..f7dcd3a6e1 100644
--- a/libs/renderengine/skia/filters/LinearEffect.cpp
+++ b/libs/renderengine/skia/filters/LinearEffect.cpp
@@ -40,12 +40,11 @@ sk_sp<SkRuntimeEffect> buildRuntimeEffect(const shaders::LinearEffect& linearEff
return shader;
}
-sk_sp<SkShader> createLinearEffectShader(sk_sp<SkShader> shader,
- const shaders::LinearEffect& linearEffect,
- sk_sp<SkRuntimeEffect> runtimeEffect,
- const mat4& colorTransform, float maxDisplayLuminance,
- float currentDisplayLuminanceNits, float maxLuminance,
- AHardwareBuffer* buffer) {
+sk_sp<SkShader> createLinearEffectShader(
+ sk_sp<SkShader> shader, const shaders::LinearEffect& linearEffect,
+ sk_sp<SkRuntimeEffect> runtimeEffect, const mat4& colorTransform, float maxDisplayLuminance,
+ float currentDisplayLuminanceNits, float maxLuminance, AHardwareBuffer* buffer,
+ aidl::android::hardware::graphics::composer3::RenderIntent renderIntent) {
ATRACE_CALL();
SkRuntimeShaderBuilder effectBuilder(runtimeEffect);
@@ -53,7 +52,8 @@ sk_sp<SkShader> createLinearEffectShader(sk_sp<SkShader> shader,
const auto uniforms =
shaders::buildLinearEffectUniforms(linearEffect, colorTransform, maxDisplayLuminance,
- currentDisplayLuminanceNits, maxLuminance, buffer);
+ currentDisplayLuminanceNits, maxLuminance, buffer,
+ renderIntent);
for (const auto& uniform : uniforms) {
effectBuilder.uniform(uniform.name.c_str()).set(uniform.value.data(), uniform.value.size());
diff --git a/libs/renderengine/skia/filters/LinearEffect.h b/libs/renderengine/skia/filters/LinearEffect.h
index 26bae3b5f0..3c66c513d9 100644
--- a/libs/renderengine/skia/filters/LinearEffect.h
+++ b/libs/renderengine/skia/filters/LinearEffect.h
@@ -42,12 +42,13 @@ sk_sp<SkRuntimeEffect> buildRuntimeEffect(const shaders::LinearEffect& linearEff
// or as the max light level from the CTA 861.3 standard.
// * An AHardwareBuffer for implementations that support gralloc4 metadata for
// communicating any HDR metadata.
-sk_sp<SkShader> createLinearEffectShader(sk_sp<SkShader> inputShader,
- const shaders::LinearEffect& linearEffect,
- sk_sp<SkRuntimeEffect> runtimeEffect,
- const mat4& colorTransform, float maxDisplayLuminance,
- float currentDisplayLuminanceNits, float maxLuminance,
- AHardwareBuffer* buffer);
+// * A RenderIntent that communicates the downstream renderintent for a physical display, for image
+// quality compensation.
+sk_sp<SkShader> createLinearEffectShader(
+ sk_sp<SkShader> inputShader, const shaders::LinearEffect& linearEffect,
+ sk_sp<SkRuntimeEffect> runtimeEffect, const mat4& colorTransform, float maxDisplayLuminance,
+ float currentDisplayLuminanceNits, float maxLuminance, AHardwareBuffer* buffer,
+ aidl::android::hardware::graphics::composer3::RenderIntent renderIntent);
} // namespace skia
} // namespace renderengine
} // namespace android
diff --git a/libs/shaders/Android.bp b/libs/shaders/Android.bp
index 2f8bf49c8a..6b936de0ec 100644
--- a/libs/shaders/Android.bp
+++ b/libs/shaders/Android.bp
@@ -29,6 +29,7 @@ cc_library_static {
shared_libs: [
"android.hardware.graphics.common-V3-ndk",
+ "android.hardware.graphics.composer3-V1-ndk",
"android.hardware.graphics.common@1.2",
"libnativewindow",
],
diff --git a/libs/shaders/include/shaders/shaders.h b/libs/shaders/include/shaders/shaders.h
index 4ec7594901..2a4a370078 100644
--- a/libs/shaders/include/shaders/shaders.h
+++ b/libs/shaders/include/shaders/shaders.h
@@ -97,11 +97,10 @@ struct LinearEffectHasher {
std::string buildLinearEffectSkSL(const LinearEffect& linearEffect);
// Generates a list of uniforms to set on the LinearEffect shader above.
-std::vector<tonemap::ShaderUniform> buildLinearEffectUniforms(const LinearEffect& linearEffect,
- const mat4& colorTransform,
- float maxDisplayLuminance,
- float currentDisplayLuminanceNits,
- float maxLuminance,
- AHardwareBuffer* buffer = nullptr);
+std::vector<tonemap::ShaderUniform> buildLinearEffectUniforms(
+ const LinearEffect& linearEffect, const mat4& colorTransform, float maxDisplayLuminance,
+ float currentDisplayLuminanceNits, float maxLuminance, AHardwareBuffer* buffer = nullptr,
+ aidl::android::hardware::graphics::composer3::RenderIntent renderIntent =
+ aidl::android::hardware::graphics::composer3::RenderIntent::TONE_MAP_COLORIMETRIC);
} // namespace android::shaders
diff --git a/libs/shaders/shaders.cpp b/libs/shaders/shaders.cpp
index 5935589fdf..f0d45c2123 100644
--- a/libs/shaders/shaders.cpp
+++ b/libs/shaders/shaders.cpp
@@ -464,12 +464,10 @@ std::string buildLinearEffectSkSL(const LinearEffect& linearEffect) {
}
// Generates a list of uniforms to set on the LinearEffect shader above.
-std::vector<tonemap::ShaderUniform> buildLinearEffectUniforms(const LinearEffect& linearEffect,
- const mat4& colorTransform,
- float maxDisplayLuminance,
- float currentDisplayLuminanceNits,
- float maxLuminance,
- AHardwareBuffer* buffer) {
+std::vector<tonemap::ShaderUniform> buildLinearEffectUniforms(
+ const LinearEffect& linearEffect, const mat4& colorTransform, float maxDisplayLuminance,
+ float currentDisplayLuminanceNits, float maxLuminance, AHardwareBuffer* buffer,
+ aidl::android::hardware::graphics::composer3::RenderIntent renderIntent) {
std::vector<tonemap::ShaderUniform> uniforms;
if (linearEffect.inputDataspace == linearEffect.outputDataspace) {
uniforms.push_back({.name = "in_rgbToXyz", .value = buildUniformValue<mat4>(mat4())});
@@ -495,7 +493,8 @@ std::vector<tonemap::ShaderUniform> buildLinearEffectUniforms(const LinearEffect
.currentDisplayLuminance = currentDisplayLuminanceNits > 0
? currentDisplayLuminanceNits
: maxDisplayLuminance,
- .buffer = buffer};
+ .buffer = buffer,
+ .renderIntent = renderIntent};
for (const auto uniform : tonemap::getToneMapper()->generateShaderSkSLUniforms(metadata)) {
uniforms.push_back(uniform);
diff --git a/libs/tonemap/Android.bp b/libs/tonemap/Android.bp
index dc55586a1d..37c98240c5 100644
--- a/libs/tonemap/Android.bp
+++ b/libs/tonemap/Android.bp
@@ -29,6 +29,7 @@ cc_library_static {
shared_libs: [
"android.hardware.graphics.common-V3-ndk",
+ "android.hardware.graphics.composer3-V1-ndk",
"liblog",
"libnativewindow",
],
diff --git a/libs/tonemap/include/tonemap/tonemap.h b/libs/tonemap/include/tonemap/tonemap.h
index c51016db56..852fc87c57 100644
--- a/libs/tonemap/include/tonemap/tonemap.h
+++ b/libs/tonemap/include/tonemap/tonemap.h
@@ -17,6 +17,7 @@
#pragma once
#include <aidl/android/hardware/graphics/common/Dataspace.h>
+#include <aidl/android/hardware/graphics/composer3/RenderIntent.h>
#include <android/hardware_buffer.h>
#include <math/vec3.h>
@@ -41,7 +42,7 @@ struct ShaderUniform {
// Describes metadata which may be used for constructing the shader uniforms.
// This metadata should not be used for manipulating the source code of the shader program directly,
-// as otherwise caching by other system of these shaders may break.
+// as otherwise caching by other parts of the system using these shaders may break.
struct Metadata {
// The maximum luminance of the display in nits
float displayMaxLuminance = 0.0;
@@ -61,6 +62,17 @@ struct Metadata {
// texture that does not have associated metadata. As such, implementations
// must support nullptr.
AHardwareBuffer* buffer = nullptr;
+
+ // RenderIntent of the destination display.
+ // Non-colorimetric render-intents may be defined in order to take advantage of the full display
+ // gamut. Various contrast-enhancement mechanisms may be employed on SDR content as a result,
+ // which means that HDR content may need to be compensated in order to achieve correct blending
+ // behavior. This default is effectively optional - the display render intent may not be
+ // available to clients such as HWUI which are display-agnostic. For those clients, tone-map
+ // colorimetric may be assumed so that the luminance range may be converted to the correct range
+ // based on the output dataspace.
+ aidl::android::hardware::graphics::composer3::RenderIntent renderIntent =
+ aidl::android::hardware::graphics::composer3::RenderIntent::TONE_MAP_COLORIMETRIC;
};
// Utility class containing pre-processed conversions for a particular color
diff --git a/libs/tonemap/tests/Android.bp b/libs/tonemap/tests/Android.bp
index 26a1d79058..58851b41be 100644
--- a/libs/tonemap/tests/Android.bp
+++ b/libs/tonemap/tests/Android.bp
@@ -32,6 +32,7 @@ cc_test {
],
shared_libs: [
"android.hardware.graphics.common-V3-ndk",
+ "android.hardware.graphics.composer3-V1-ndk",
"libnativewindow",
],
static_libs: [
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index e99b70ff1e..004e0717d2 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -1177,6 +1177,9 @@ std::optional<base::unique_fd> Output::composeSurfaces(
clientCompositionDisplay.targetLuminanceNits =
outputState.clientTargetBrightness * outputState.displayBrightnessNits;
clientCompositionDisplay.dimmingStage = outputState.clientTargetDimmingStage;
+ clientCompositionDisplay.renderIntent =
+ static_cast<aidl::android::hardware::graphics::composer3::RenderIntent>(
+ outputState.renderIntent);
// Compute the global color transform matrix.
clientCompositionDisplay.colorTransform = outputState.colorTransformMatrix;
diff --git a/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp b/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp
index 31a89af013..42c8b37710 100644
--- a/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp
@@ -3711,6 +3711,16 @@ struct OutputComposeSurfacesTest_UsesExpectedDisplaySettings : public OutputComp
auto withDimmingStage(
aidl::android::hardware::graphics::composer3::DimmingStage dimmingStage) {
getInstance()->mOutput.mState.clientTargetDimmingStage = dimmingStage;
+ return nextState<OutputWithRenderIntent>();
+ }
+ };
+
+ struct OutputWithRenderIntent
+ : public CallOrderStateMachineHelper<TestType, OutputWithRenderIntent> {
+ auto withRenderIntent(
+ aidl::android::hardware::graphics::composer3::RenderIntent renderIntent) {
+ getInstance()->mOutput.mState.renderIntent =
+ static_cast<ui::RenderIntent>(renderIntent);
return nextState<SkipColorTransformState>();
}
};
@@ -3744,6 +3754,8 @@ TEST_F(OutputComposeSurfacesTest_UsesExpectedDisplaySettings, forHdrMixedComposi
.andIfUsesHdr(true)
.withDisplayBrightnessNits(kUnknownLuminance)
.withDimmingStage(aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR)
+ .withRenderIntent(
+ aidl::android::hardware::graphics::composer3::RenderIntent::COLORIMETRIC)
.andIfSkipColorTransform(false)
.thenExpectDisplaySettingsUsed(
{.physicalDisplay = kDefaultOutputDestinationClip,
@@ -3756,7 +3768,9 @@ TEST_F(OutputComposeSurfacesTest_UsesExpectedDisplaySettings, forHdrMixedComposi
.orientation = kDefaultOutputOrientationFlags,
.targetLuminanceNits = kClientTargetLuminanceNits,
.dimmingStage =
- aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR})
+ aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR,
+ .renderIntent = aidl::android::hardware::graphics::composer3::RenderIntent::
+ COLORIMETRIC})
.execute()
.expectAFenceWasReturned();
}
@@ -3767,7 +3781,8 @@ TEST_F(OutputComposeSurfacesTest_UsesExpectedDisplaySettings,
.andIfUsesHdr(true)
.withDisplayBrightnessNits(kDisplayLuminance)
.withDimmingStage(aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR)
-
+ .withRenderIntent(
+ aidl::android::hardware::graphics::composer3::RenderIntent::COLORIMETRIC)
.andIfSkipColorTransform(false)
.thenExpectDisplaySettingsUsed(
{.physicalDisplay = kDefaultOutputDestinationClip,
@@ -3780,7 +3795,9 @@ TEST_F(OutputComposeSurfacesTest_UsesExpectedDisplaySettings,
.orientation = kDefaultOutputOrientationFlags,
.targetLuminanceNits = kClientTargetLuminanceNits,
.dimmingStage =
- aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR})
+ aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR,
+ .renderIntent = aidl::android::hardware::graphics::composer3::RenderIntent::
+ COLORIMETRIC})
.execute()
.expectAFenceWasReturned();
}
@@ -3792,19 +3809,49 @@ TEST_F(OutputComposeSurfacesTest_UsesExpectedDisplaySettings,
.withDisplayBrightnessNits(kUnknownLuminance)
.withDimmingStage(
aidl::android::hardware::graphics::composer3::DimmingStage::GAMMA_OETF)
+ .withRenderIntent(
+ aidl::android::hardware::graphics::composer3::RenderIntent::COLORIMETRIC)
+ .andIfSkipColorTransform(false)
+ .thenExpectDisplaySettingsUsed(
+ {.physicalDisplay = kDefaultOutputDestinationClip,
+ .clip = kDefaultOutputViewport,
+ .maxLuminance = kDefaultMaxLuminance,
+ .currentLuminanceNits = kDefaultMaxLuminance,
+ .outputDataspace = kDefaultOutputDataspace,
+ .colorTransform = kDefaultColorTransformMat,
+ .deviceHandlesColorTransform = true,
+ .orientation = kDefaultOutputOrientationFlags,
+ .targetLuminanceNits = kClientTargetLuminanceNits,
+ .dimmingStage =
+ aidl::android::hardware::graphics::composer3::DimmingStage::GAMMA_OETF,
+ .renderIntent = aidl::android::hardware::graphics::composer3::RenderIntent::
+ COLORIMETRIC})
+ .execute()
+ .expectAFenceWasReturned();
+}
+TEST_F(OutputComposeSurfacesTest_UsesExpectedDisplaySettings,
+ forHdrMixedCompositionWithRenderIntent) {
+ verify().ifMixedCompositionIs(true)
+ .andIfUsesHdr(true)
+ .withDisplayBrightnessNits(kUnknownLuminance)
+ .withDimmingStage(aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR)
+ .withRenderIntent(aidl::android::hardware::graphics::composer3::RenderIntent::ENHANCE)
.andIfSkipColorTransform(false)
- .thenExpectDisplaySettingsUsed({.physicalDisplay = kDefaultOutputDestinationClip,
- .clip = kDefaultOutputViewport,
- .maxLuminance = kDefaultMaxLuminance,
- .currentLuminanceNits = kDefaultMaxLuminance,
- .outputDataspace = kDefaultOutputDataspace,
- .colorTransform = kDefaultColorTransformMat,
- .deviceHandlesColorTransform = true,
- .orientation = kDefaultOutputOrientationFlags,
- .targetLuminanceNits = kClientTargetLuminanceNits,
- .dimmingStage = aidl::android::hardware::graphics::
- composer3::DimmingStage::GAMMA_OETF})
+ .thenExpectDisplaySettingsUsed(
+ {.physicalDisplay = kDefaultOutputDestinationClip,
+ .clip = kDefaultOutputViewport,
+ .maxLuminance = kDefaultMaxLuminance,
+ .currentLuminanceNits = kDefaultMaxLuminance,
+ .outputDataspace = kDefaultOutputDataspace,
+ .colorTransform = kDefaultColorTransformMat,
+ .deviceHandlesColorTransform = true,
+ .orientation = kDefaultOutputOrientationFlags,
+ .targetLuminanceNits = kClientTargetLuminanceNits,
+ .dimmingStage =
+ aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR,
+ .renderIntent =
+ aidl::android::hardware::graphics::composer3::RenderIntent::ENHANCE})
.execute()
.expectAFenceWasReturned();
}
@@ -3814,7 +3861,8 @@ TEST_F(OutputComposeSurfacesTest_UsesExpectedDisplaySettings, forNonHdrMixedComp
.andIfUsesHdr(false)
.withDisplayBrightnessNits(kUnknownLuminance)
.withDimmingStage(aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR)
-
+ .withRenderIntent(
+ aidl::android::hardware::graphics::composer3::RenderIntent::COLORIMETRIC)
.andIfSkipColorTransform(false)
.thenExpectDisplaySettingsUsed(
{.physicalDisplay = kDefaultOutputDestinationClip,
@@ -3827,7 +3875,9 @@ TEST_F(OutputComposeSurfacesTest_UsesExpectedDisplaySettings, forNonHdrMixedComp
.orientation = kDefaultOutputOrientationFlags,
.targetLuminanceNits = kClientTargetLuminanceNits,
.dimmingStage =
- aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR})
+ aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR,
+ .renderIntent = aidl::android::hardware::graphics::composer3::RenderIntent::
+ COLORIMETRIC})
.execute()
.expectAFenceWasReturned();
}
@@ -3837,7 +3887,8 @@ TEST_F(OutputComposeSurfacesTest_UsesExpectedDisplaySettings, forHdrOnlyClientCo
.andIfUsesHdr(true)
.withDisplayBrightnessNits(kUnknownLuminance)
.withDimmingStage(aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR)
-
+ .withRenderIntent(
+ aidl::android::hardware::graphics::composer3::RenderIntent::COLORIMETRIC)
.andIfSkipColorTransform(false)
.thenExpectDisplaySettingsUsed(
{.physicalDisplay = kDefaultOutputDestinationClip,
@@ -3850,7 +3901,9 @@ TEST_F(OutputComposeSurfacesTest_UsesExpectedDisplaySettings, forHdrOnlyClientCo
.orientation = kDefaultOutputOrientationFlags,
.targetLuminanceNits = kClientTargetLuminanceNits,
.dimmingStage =
- aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR})
+ aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR,
+ .renderIntent = aidl::android::hardware::graphics::composer3::RenderIntent::
+ COLORIMETRIC})
.execute()
.expectAFenceWasReturned();
}
@@ -3860,7 +3913,8 @@ TEST_F(OutputComposeSurfacesTest_UsesExpectedDisplaySettings, forNonHdrOnlyClien
.andIfUsesHdr(false)
.withDisplayBrightnessNits(kUnknownLuminance)
.withDimmingStage(aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR)
-
+ .withRenderIntent(
+ aidl::android::hardware::graphics::composer3::RenderIntent::COLORIMETRIC)
.andIfSkipColorTransform(false)
.thenExpectDisplaySettingsUsed(
{.physicalDisplay = kDefaultOutputDestinationClip,
@@ -3873,7 +3927,9 @@ TEST_F(OutputComposeSurfacesTest_UsesExpectedDisplaySettings, forNonHdrOnlyClien
.orientation = kDefaultOutputOrientationFlags,
.targetLuminanceNits = kClientTargetLuminanceNits,
.dimmingStage =
- aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR})
+ aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR,
+ .renderIntent = aidl::android::hardware::graphics::composer3::RenderIntent::
+ COLORIMETRIC})
.execute()
.expectAFenceWasReturned();
}
@@ -3884,7 +3940,8 @@ TEST_F(OutputComposeSurfacesTest_UsesExpectedDisplaySettings,
.andIfUsesHdr(true)
.withDisplayBrightnessNits(kUnknownLuminance)
.withDimmingStage(aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR)
-
+ .withRenderIntent(
+ aidl::android::hardware::graphics::composer3::RenderIntent::COLORIMETRIC)
.andIfSkipColorTransform(true)
.thenExpectDisplaySettingsUsed(
{.physicalDisplay = kDefaultOutputDestinationClip,
@@ -3897,7 +3954,9 @@ TEST_F(OutputComposeSurfacesTest_UsesExpectedDisplaySettings,
.orientation = kDefaultOutputOrientationFlags,
.targetLuminanceNits = kClientTargetLuminanceNits,
.dimmingStage =
- aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR})
+ aidl::android::hardware::graphics::composer3::DimmingStage::LINEAR,
+ .renderIntent = aidl::android::hardware::graphics::composer3::RenderIntent::
+ COLORIMETRIC})
.execute()
.expectAFenceWasReturned();
}
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 115dc6435b..498f37ce4c 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -146,6 +146,7 @@
#include <aidl/android/hardware/graphics/common/DisplayDecorationSupport.h>
#include <aidl/android/hardware/graphics/composer3/DisplayCapability.h>
+#include <aidl/android/hardware/graphics/composer3/RenderIntent.h>
#undef NO_THREAD_SAFETY_ANALYSIS
#define NO_THREAD_SAFETY_ANALYSIS \
@@ -6668,6 +6669,7 @@ std::shared_future<renderengine::RenderEngineResult> SurfaceFlinger::renderScree
captureResults.buffer = buffer->getBuffer();
auto dataspace = renderArea.getReqDataSpace();
auto parent = renderArea.getParentLayer();
+ auto renderIntent = RenderIntent::TONE_MAP_COLORIMETRIC;
if ((dataspace == ui::Dataspace::UNKNOWN) && (parent != nullptr)) {
Mutex::Autolock lock(mStateLock);
auto display = findDisplay([layerStack = parent->getLayerStack()](const auto& display) {
@@ -6680,6 +6682,7 @@ std::shared_future<renderengine::RenderEngineResult> SurfaceFlinger::renderScree
const ui::ColorMode colorMode = display->getCompositionDisplay()->getState().colorMode;
dataspace = pickDataspaceFromColorMode(colorMode);
+ renderIntent = display->getCompositionDisplay()->getState().renderIntent;
}
captureResults.capturedDataspace = dataspace;
@@ -6701,6 +6704,8 @@ std::shared_future<renderengine::RenderEngineResult> SurfaceFlinger::renderScree
clientCompositionDisplay.outputDataspace = dataspace;
clientCompositionDisplay.maxLuminance = DisplayDevice::sDefaultMaxLumiance;
+ clientCompositionDisplay.renderIntent =
+ static_cast<aidl::android::hardware::graphics::composer3::RenderIntent>(renderIntent);
const float colorSaturation = grayscale ? 0 : 1;
clientCompositionDisplay.colorTransform = calculateColorMatrix(colorSaturation);