Loading libs/renderengine/skia/SkiaGLRenderEngine.cpp +12 −3 Original line number Diff line number Diff line Loading @@ -416,6 +416,11 @@ static bool needsToneMapping(ui::Dataspace sourceDataspace, ui::Dataspace destin sourceTransfer != destTransfer; } static bool needsLinearEffect(const mat4& colorTransform, ui::Dataspace sourceDataspace, ui::Dataspace destinationDataspace) { return colorTransform != mat4() || needsToneMapping(sourceDataspace, destinationDataspace); } void SkiaGLRenderEngine::unbindExternalTextureBuffer(uint64_t bufferId) { std::lock_guard<std::mutex> lock(mRenderingMutex); mTextureCache.erase(bufferId); Loading Loading @@ -559,10 +564,12 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display, false)); mTextureCache.insert({buffer->getId(), imageTextureRef}); } sk_sp<SkImage> image = imageTextureRef->getTexture() ->makeImage(mUseColorManagement ? (needsToneMapping(layer->sourceDataspace, ? (needsLinearEffect(layer->colorTransform, layer->sourceDataspace, display.outputDataspace) // If we need to map to linear space, // then mark the source image with the Loading Loading @@ -633,7 +640,8 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display, } if (mUseColorManagement && needsToneMapping(layer->sourceDataspace, display.outputDataspace)) { needsLinearEffect(layer->colorTransform, layer->sourceDataspace, display.outputDataspace)) { LinearEffect effect = LinearEffect{.inputDataspace = layer->sourceDataspace, .outputDataspace = display.outputDataspace, .undoPremultipliedAlpha = !item.isOpaque && Loading @@ -649,6 +657,7 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display, } paint.setShader(createLinearEffectShader(shader, effect, runtimeEffect, layer->colorTransform, display.maxLuminance, layer->source.buffer.maxMasteringLuminance, layer->source.buffer.maxContentLuminance)); Loading libs/renderengine/skia/filters/LinearEffect.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -447,8 +447,8 @@ sk_sp<SkRuntimeEffect> buildRuntimeEffect(const LinearEffect& linearEffect) { sk_sp<SkShader> createLinearEffectShader(sk_sp<SkShader> shader, const LinearEffect& linearEffect, sk_sp<SkRuntimeEffect> runtimeEffect, float maxDisplayLuminance, float maxMasteringLuminance, float maxContentLuminance) { const mat4& colorTransform, float maxDisplayLuminance, float maxMasteringLuminance, float maxContentLuminance) { ATRACE_CALL(); SkRuntimeShaderBuilder effectBuilder(runtimeEffect); Loading @@ -458,7 +458,7 @@ sk_sp<SkShader> createLinearEffectShader(sk_sp<SkShader> shader, const LinearEff ColorSpace outputColorSpace = toColorSpace(linearEffect.outputDataspace); effectBuilder.uniform("in_rgbToXyz") = mat4(inputColorSpace.getRGBtoXYZ()); effectBuilder.uniform("in_xyzToRgb") = mat4(outputColorSpace.getXYZtoRGB()); effectBuilder.uniform("in_xyzToRgb") = colorTransform * mat4(outputColorSpace.getXYZtoRGB()); effectBuilder.uniform("in_displayMaxLuminance") = maxDisplayLuminance; effectBuilder.uniform("in_inputMaxLuminance") = std::min(maxMasteringLuminance, maxContentLuminance); Loading libs/renderengine/skia/filters/LinearEffect.h +8 −5 Original line number Diff line number Diff line Loading @@ -16,9 +16,10 @@ #pragma once #include <math/mat4.h> #include <optional> #include "SkColorMatrix.h" #include "SkRuntimeEffect.h" #include "SkShader.h" #include "ui/GraphicTypes.h" Loading Loading @@ -84,8 +85,10 @@ struct LinearEffectHasher { sk_sp<SkRuntimeEffect> buildRuntimeEffect(const LinearEffect& linearEffect); // Generates a shader resulting from applying the a linear effect created from // LinearEffectARgs::buildEffect to an inputShader. We also provide additional HDR metadata upon // creating the shader: // LinearEffectArgs::buildEffect to an inputShader. // Optionally, a color transform may also be provided, which combines with the // matrix transforming from linear XYZ to linear RGB immediately before OETF. // We also provide additional HDR metadata upon creating the shader: // * The max display luminance is the max luminance of the physical display in nits // * The max mastering luminance is provided as the max luminance from the SMPTE 2086 // standard. Loading @@ -94,8 +97,8 @@ sk_sp<SkRuntimeEffect> buildRuntimeEffect(const LinearEffect& linearEffect); sk_sp<SkShader> createLinearEffectShader(sk_sp<SkShader> inputShader, const LinearEffect& linearEffect, sk_sp<SkRuntimeEffect> runtimeEffect, float maxDisplayLuminance, float maxMasteringLuminance, float maxContentLuminance); const mat4& colorTransform, float maxDisplayLuminance, float maxMasteringLuminance, float maxContentLuminance); } // namespace skia } // namespace renderengine } // namespace android Loading
libs/renderengine/skia/SkiaGLRenderEngine.cpp +12 −3 Original line number Diff line number Diff line Loading @@ -416,6 +416,11 @@ static bool needsToneMapping(ui::Dataspace sourceDataspace, ui::Dataspace destin sourceTransfer != destTransfer; } static bool needsLinearEffect(const mat4& colorTransform, ui::Dataspace sourceDataspace, ui::Dataspace destinationDataspace) { return colorTransform != mat4() || needsToneMapping(sourceDataspace, destinationDataspace); } void SkiaGLRenderEngine::unbindExternalTextureBuffer(uint64_t bufferId) { std::lock_guard<std::mutex> lock(mRenderingMutex); mTextureCache.erase(bufferId); Loading Loading @@ -559,10 +564,12 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display, false)); mTextureCache.insert({buffer->getId(), imageTextureRef}); } sk_sp<SkImage> image = imageTextureRef->getTexture() ->makeImage(mUseColorManagement ? (needsToneMapping(layer->sourceDataspace, ? (needsLinearEffect(layer->colorTransform, layer->sourceDataspace, display.outputDataspace) // If we need to map to linear space, // then mark the source image with the Loading Loading @@ -633,7 +640,8 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display, } if (mUseColorManagement && needsToneMapping(layer->sourceDataspace, display.outputDataspace)) { needsLinearEffect(layer->colorTransform, layer->sourceDataspace, display.outputDataspace)) { LinearEffect effect = LinearEffect{.inputDataspace = layer->sourceDataspace, .outputDataspace = display.outputDataspace, .undoPremultipliedAlpha = !item.isOpaque && Loading @@ -649,6 +657,7 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display, } paint.setShader(createLinearEffectShader(shader, effect, runtimeEffect, layer->colorTransform, display.maxLuminance, layer->source.buffer.maxMasteringLuminance, layer->source.buffer.maxContentLuminance)); Loading
libs/renderengine/skia/filters/LinearEffect.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -447,8 +447,8 @@ sk_sp<SkRuntimeEffect> buildRuntimeEffect(const LinearEffect& linearEffect) { sk_sp<SkShader> createLinearEffectShader(sk_sp<SkShader> shader, const LinearEffect& linearEffect, sk_sp<SkRuntimeEffect> runtimeEffect, float maxDisplayLuminance, float maxMasteringLuminance, float maxContentLuminance) { const mat4& colorTransform, float maxDisplayLuminance, float maxMasteringLuminance, float maxContentLuminance) { ATRACE_CALL(); SkRuntimeShaderBuilder effectBuilder(runtimeEffect); Loading @@ -458,7 +458,7 @@ sk_sp<SkShader> createLinearEffectShader(sk_sp<SkShader> shader, const LinearEff ColorSpace outputColorSpace = toColorSpace(linearEffect.outputDataspace); effectBuilder.uniform("in_rgbToXyz") = mat4(inputColorSpace.getRGBtoXYZ()); effectBuilder.uniform("in_xyzToRgb") = mat4(outputColorSpace.getXYZtoRGB()); effectBuilder.uniform("in_xyzToRgb") = colorTransform * mat4(outputColorSpace.getXYZtoRGB()); effectBuilder.uniform("in_displayMaxLuminance") = maxDisplayLuminance; effectBuilder.uniform("in_inputMaxLuminance") = std::min(maxMasteringLuminance, maxContentLuminance); Loading
libs/renderengine/skia/filters/LinearEffect.h +8 −5 Original line number Diff line number Diff line Loading @@ -16,9 +16,10 @@ #pragma once #include <math/mat4.h> #include <optional> #include "SkColorMatrix.h" #include "SkRuntimeEffect.h" #include "SkShader.h" #include "ui/GraphicTypes.h" Loading Loading @@ -84,8 +85,10 @@ struct LinearEffectHasher { sk_sp<SkRuntimeEffect> buildRuntimeEffect(const LinearEffect& linearEffect); // Generates a shader resulting from applying the a linear effect created from // LinearEffectARgs::buildEffect to an inputShader. We also provide additional HDR metadata upon // creating the shader: // LinearEffectArgs::buildEffect to an inputShader. // Optionally, a color transform may also be provided, which combines with the // matrix transforming from linear XYZ to linear RGB immediately before OETF. // We also provide additional HDR metadata upon creating the shader: // * The max display luminance is the max luminance of the physical display in nits // * The max mastering luminance is provided as the max luminance from the SMPTE 2086 // standard. Loading @@ -94,8 +97,8 @@ sk_sp<SkRuntimeEffect> buildRuntimeEffect(const LinearEffect& linearEffect); sk_sp<SkShader> createLinearEffectShader(sk_sp<SkShader> inputShader, const LinearEffect& linearEffect, sk_sp<SkRuntimeEffect> runtimeEffect, float maxDisplayLuminance, float maxMasteringLuminance, float maxContentLuminance); const mat4& colorTransform, float maxDisplayLuminance, float maxMasteringLuminance, float maxContentLuminance); } // namespace skia } // namespace renderengine } // namespace android