summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/renderengine/gl/GLESRenderEngine.cpp3
-rw-r--r--libs/renderengine/gl/Program.cpp8
-rw-r--r--libs/renderengine/gl/Program.h4
-rw-r--r--libs/renderengine/gl/ProgramCache.cpp9
-rw-r--r--libs/renderengine/include/renderengine/LayerSettings.h2
-rw-r--r--libs/renderengine/include/renderengine/private/Description.h2
-rw-r--r--services/surfaceflinger/BufferLayer.cpp11
7 files changed, 34 insertions, 5 deletions
diff --git a/libs/renderengine/gl/GLESRenderEngine.cpp b/libs/renderengine/gl/GLESRenderEngine.cpp
index 15d025b6f7..394d05a876 100644
--- a/libs/renderengine/gl/GLESRenderEngine.cpp
+++ b/libs/renderengine/gl/GLESRenderEngine.cpp
@@ -983,6 +983,8 @@ status_t GLESRenderEngine::drawLayers(const DisplaySettings& display,
Mesh mesh(Mesh::TRIANGLE_FAN, 4, 2, 2);
for (auto layer : layers) {
+ mState.maxMasteringLuminance = layer.source.buffer.maxMasteringLuminance;
+ mState.maxContentLuminance = layer.source.buffer.maxContentLuminance;
mState.projectionMatrix = projectionMatrix * layer.geometry.positionTransform;
const FloatRect bounds = layer.geometry.boundaries;
@@ -998,7 +1000,6 @@ status_t GLESRenderEngine::drawLayers(const DisplaySettings& display,
bool usePremultipliedAlpha = true;
bool disableTexture = true;
bool isOpaque = false;
-
if (layer.source.buffer.buffer != nullptr) {
disableTexture = false;
isOpaque = layer.source.buffer.isOpaque;
diff --git a/libs/renderengine/gl/Program.cpp b/libs/renderengine/gl/Program.cpp
index fe9d909923..4eb5eb6a25 100644
--- a/libs/renderengine/gl/Program.cpp
+++ b/libs/renderengine/gl/Program.cpp
@@ -65,6 +65,8 @@ Program::Program(const ProgramCache::Key& /*needs*/, const char* vertex, const c
mSamplerLoc = glGetUniformLocation(programId, "sampler");
mColorLoc = glGetUniformLocation(programId, "color");
mDisplayMaxLuminanceLoc = glGetUniformLocation(programId, "displayMaxLuminance");
+ mMaxMasteringLuminanceLoc = glGetUniformLocation(programId, "maxMasteringLuminance");
+ mMaxContentLuminanceLoc = glGetUniformLocation(programId, "maxContentLuminance");
mInputTransformMatrixLoc = glGetUniformLocation(programId, "inputTransformMatrix");
mOutputTransformMatrixLoc = glGetUniformLocation(programId, "outputTransformMatrix");
mCornerRadiusLoc = glGetUniformLocation(programId, "cornerRadius");
@@ -138,6 +140,12 @@ void Program::setUniforms(const Description& desc) {
if (mDisplayMaxLuminanceLoc >= 0) {
glUniform1f(mDisplayMaxLuminanceLoc, desc.displayMaxLuminance);
}
+ if (mMaxMasteringLuminanceLoc >= 0) {
+ glUniform1f(mMaxMasteringLuminanceLoc, desc.maxMasteringLuminance);
+ }
+ if (mMaxContentLuminanceLoc >= 0) {
+ glUniform1f(mMaxContentLuminanceLoc, desc.maxContentLuminance);
+ }
if (mCornerRadiusLoc >= 0) {
glUniform1f(mCornerRadiusLoc, desc.cornerRadius);
}
diff --git a/libs/renderengine/gl/Program.h b/libs/renderengine/gl/Program.h
index bc9cf08b8b..c9beb6844f 100644
--- a/libs/renderengine/gl/Program.h
+++ b/libs/renderengine/gl/Program.h
@@ -90,6 +90,10 @@ private:
/* location of display luminance uniform */
GLint mDisplayMaxLuminanceLoc;
+ /* location of max mastering luminance uniform */
+ GLint mMaxMasteringLuminanceLoc;
+ /* location of max content luminance uniform */
+ GLint mMaxContentLuminanceLoc;
/* location of transform matrix */
GLint mInputTransformMatrixLoc;
diff --git a/libs/renderengine/gl/ProgramCache.cpp b/libs/renderengine/gl/ProgramCache.cpp
index 494623e67e..e2757e181b 100644
--- a/libs/renderengine/gl/ProgramCache.cpp
+++ b/libs/renderengine/gl/ProgramCache.cpp
@@ -339,9 +339,9 @@ void ProgramCache::generateToneMappingProcess(Formatter& fs, const Key& needs) {
default:
fs << R"__SHADER__(
highp vec3 ToneMap(highp vec3 color) {
- const float maxMasteringLumi = 1000.0;
- const float maxContentLumi = 1000.0;
- const float maxInLumi = min(maxMasteringLumi, maxContentLumi);
+ float maxMasteringLumi = maxMasteringLuminance;
+ float maxContentLumi = maxContentLuminance;
+ float maxInLumi = min(maxMasteringLumi, maxContentLumi);
float maxOutLumi = displayMaxLuminance;
float nits = color.y;
@@ -633,9 +633,10 @@ String8 ProgramCache::generateFragmentShader(const Key& needs) {
}
if (needs.hasTransformMatrix() || (needs.getInputTF() != needs.getOutputTF())) {
- // Currently, display maximum luminance is needed when doing tone mapping.
if (needs.needsToneMapping()) {
fs << "uniform float displayMaxLuminance;";
+ fs << "uniform float maxMasteringLuminance;";
+ fs << "uniform float maxContentLuminance;";
}
if (needs.hasInputTransformMatrix()) {
diff --git a/libs/renderengine/include/renderengine/LayerSettings.h b/libs/renderengine/include/renderengine/LayerSettings.h
index b8bf8019de..f76966bf12 100644
--- a/libs/renderengine/include/renderengine/LayerSettings.h
+++ b/libs/renderengine/include/renderengine/LayerSettings.h
@@ -60,6 +60,8 @@ struct Buffer {
// HDR color-space setting for Y410.
bool isY410BT2020 = false;
+ float maxMasteringLuminance = 0.0;
+ float maxContentLuminance = 0.0;
};
// Metadata describing the layer geometry.
diff --git a/libs/renderengine/include/renderengine/private/Description.h b/libs/renderengine/include/renderengine/private/Description.h
index bd2055f4e5..bad64c2f13 100644
--- a/libs/renderengine/include/renderengine/private/Description.h
+++ b/libs/renderengine/include/renderengine/private/Description.h
@@ -71,6 +71,8 @@ struct Description {
TransferFunction outputTransferFunction = TransferFunction::LINEAR;
float displayMaxLuminance;
+ float maxMasteringLuminance;
+ float maxContentLuminance;
// projection matrix
mat4 projectionMatrix;
diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp
index 94c4a81df2..054acc5069 100644
--- a/services/surfaceflinger/BufferLayer.cpp
+++ b/services/surfaceflinger/BufferLayer.cpp
@@ -56,6 +56,9 @@
namespace android {
+static constexpr float defaultMaxMasteringLuminance = 1000.0;
+static constexpr float defaultMaxContentLuminance = 1000.0;
+
BufferLayer::BufferLayer(const LayerCreationArgs& args)
: Layer(args),
mTextureName(args.textureName),
@@ -184,6 +187,14 @@ std::optional<renderengine::LayerSettings> BufferLayer::prepareClientComposition
layer.source.buffer.textureName = mTextureName;
layer.source.buffer.usePremultipliedAlpha = getPremultipledAlpha();
layer.source.buffer.isY410BT2020 = isHdrY410();
+ bool hasSmpte2086 = mBufferInfo.mHdrMetadata.validTypes & HdrMetadata::SMPTE2086;
+ bool hasCta861_3 = mBufferInfo.mHdrMetadata.validTypes & HdrMetadata::CTA861_3;
+ layer.source.buffer.maxMasteringLuminance = hasSmpte2086
+ ? mBufferInfo.mHdrMetadata.smpte2086.maxLuminance
+ : defaultMaxMasteringLuminance;
+ layer.source.buffer.maxContentLuminance = hasCta861_3
+ ? mBufferInfo.mHdrMetadata.cta8613.maxContentLightLevel
+ : defaultMaxContentLuminance;
// TODO: we could be more subtle with isFixedSize()
const bool useFiltering = targetSettings.needsFiltering || mNeedsFiltering || isFixedSize();