Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a3c5456 authored by Alec Mouri's avatar Alec Mouri
Browse files

Add AHardwareBuffer as a tone-mapping input.

This is to allow for partners to take gralloc4 metadata into account for
their tone-mapping operation.

Bug: 212641375
Test: builds
Change-Id: Id20291fc1a1a0350a7fff0a8e703f242c68d2b28
parent 63d679d2
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -654,10 +654,14 @@ sk_sp<SkShader> SkiaGLRenderEngine::createRuntimeEffectShader(
        colorTransform *=
                mat4::scale(vec4(parameters.layerDimmingRatio, parameters.layerDimmingRatio,
                                 parameters.layerDimmingRatio, 1.f));
        const auto targetBuffer = parameters.layer.source.buffer.buffer;
        const auto graphicBuffer = targetBuffer ? targetBuffer->getBuffer() : nullptr;
        const auto hardwareBuffer = graphicBuffer ? graphicBuffer->toAHardwareBuffer() : nullptr;
        return createLinearEffectShader(parameters.shader, effect, runtimeEffect, colorTransform,
                                        parameters.display.maxLuminance,
                                        parameters.display.currentLuminanceNits,
                                        parameters.layer.source.buffer.maxLuminanceNits);
                                        parameters.layer.source.buffer.maxLuminanceNits,
                                        hardwareBuffer);
    }
    return parameters.shader;
}
+4 −3
Original line number Diff line number Diff line
@@ -44,7 +44,8 @@ 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) {
                                         float currentDisplayLuminanceNits, float maxLuminance,
                                         AHardwareBuffer* buffer) {
    ATRACE_CALL();
    SkRuntimeShaderBuilder effectBuilder(runtimeEffect);

@@ -52,7 +53,7 @@ sk_sp<SkShader> createLinearEffectShader(sk_sp<SkShader> shader,

    const auto uniforms =
            shaders::buildLinearEffectUniforms(linearEffect, colorTransform, maxDisplayLuminance,
                                               currentDisplayLuminanceNits, maxLuminance);
                                               currentDisplayLuminanceNits, maxLuminance, buffer);

    for (const auto& uniform : uniforms) {
        effectBuilder.uniform(uniform.name.c_str()).set(uniform.value.data(), uniform.value.size());
+4 −1
Original line number Diff line number Diff line
@@ -40,11 +40,14 @@ sk_sp<SkRuntimeEffect> buildRuntimeEffect(const shaders::LinearEffect& linearEff
// * The current luminance of the physical display in nits
// * The max luminance is provided as the max luminance for the buffer, either from the SMPTE 2086
// 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);
                                         float currentDisplayLuminanceNits, float maxLuminance,
                                         AHardwareBuffer* buffer);
} // namespace skia
} // namespace renderengine
} // namespace android
+2 −0
Original line number Diff line number Diff line
@@ -30,9 +30,11 @@ cc_library_static {
    shared_libs: [
        "android.hardware.graphics.common-V3-ndk",
        "android.hardware.graphics.common@1.2",
        "libnativewindow",
    ],

    static_libs: [
        "libarect",
        "libmath",
        "libtonemap",
        "libui-types",
+2 −1
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ std::vector<tonemap::ShaderUniform> buildLinearEffectUniforms(const LinearEffect
                                                              const mat4& colorTransform,
                                                              float maxDisplayLuminance,
                                                              float currentDisplayLuminanceNits,
                                                              float maxLuminance);
                                                              float maxLuminance,
                                                              AHardwareBuffer* buffer = nullptr);

} // namespace android::shaders
Loading