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

Commit fcedb9ca authored by Alec Mouri's avatar Alec Mouri
Browse files

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
parent 168f6ccf
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
#pragma once
#pragma once


#include <aidl/android/hardware/graphics/composer3/DimmingStage.h>
#include <aidl/android/hardware/graphics/composer3/DimmingStage.h>
#include <aidl/android/hardware/graphics/composer3/RenderIntent.h>
#include <iosfwd>
#include <iosfwd>


#include <math/mat4.h>
#include <math/mat4.h>
@@ -73,6 +74,10 @@ struct DisplaySettings {
    // Configures when dimming should be applied for each layer.
    // Configures when dimming should be applied for each layer.
    aidl::android::hardware::graphics::composer3::DimmingStage dimmingStage =
    aidl::android::hardware::graphics::composer3::DimmingStage dimmingStage =
            aidl::android::hardware::graphics::composer3::DimmingStage::NONE;
            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) {
static inline bool operator==(const DisplaySettings& lhs, const DisplaySettings& rhs) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -662,7 +662,7 @@ sk_sp<SkShader> SkiaGLRenderEngine::createRuntimeEffectShader(
                                        parameters.display.maxLuminance,
                                        parameters.display.maxLuminance,
                                        parameters.display.currentLuminanceNits,
                                        parameters.display.currentLuminanceNits,
                                        parameters.layer.source.buffer.maxLuminanceNits,
                                        parameters.layer.source.buffer.maxLuminanceNits,
                                        hardwareBuffer);
                                        hardwareBuffer, parameters.display.renderIntent);
    }
    }
    return parameters.shader;
    return parameters.shader;
}
}
+7 −7
Original line number Original line Diff line number Diff line
@@ -40,12 +40,11 @@ sk_sp<SkRuntimeEffect> buildRuntimeEffect(const shaders::LinearEffect& linearEff
    return shader;
    return shader;
}
}


sk_sp<SkShader> createLinearEffectShader(sk_sp<SkShader> shader,
sk_sp<SkShader> createLinearEffectShader(
                                         const shaders::LinearEffect& linearEffect,
        sk_sp<SkShader> shader, const shaders::LinearEffect& linearEffect,
                                         sk_sp<SkRuntimeEffect> runtimeEffect,
        sk_sp<SkRuntimeEffect> runtimeEffect, const mat4& colorTransform, float maxDisplayLuminance,
                                         const mat4& colorTransform, float maxDisplayLuminance,
        float currentDisplayLuminanceNits, float maxLuminance, AHardwareBuffer* buffer,
                                         float currentDisplayLuminanceNits, float maxLuminance,
        aidl::android::hardware::graphics::composer3::RenderIntent renderIntent) {
                                         AHardwareBuffer* buffer) {
    ATRACE_CALL();
    ATRACE_CALL();
    SkRuntimeShaderBuilder effectBuilder(runtimeEffect);
    SkRuntimeShaderBuilder effectBuilder(runtimeEffect);


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


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


    for (const auto& uniform : uniforms) {
    for (const auto& uniform : uniforms) {
        effectBuilder.uniform(uniform.name.c_str()).set(uniform.value.data(), uniform.value.size());
        effectBuilder.uniform(uniform.name.c_str()).set(uniform.value.data(), uniform.value.size());
+7 −6
Original line number Original line Diff line number Diff line
@@ -42,12 +42,13 @@ sk_sp<SkRuntimeEffect> buildRuntimeEffect(const shaders::LinearEffect& linearEff
// or as the max light level from the CTA 861.3 standard.
// or as the max light level from the CTA 861.3 standard.
// * An AHardwareBuffer for implementations that support gralloc4 metadata for
// * An AHardwareBuffer for implementations that support gralloc4 metadata for
// communicating any HDR metadata.
// communicating any HDR metadata.
sk_sp<SkShader> createLinearEffectShader(sk_sp<SkShader> inputShader,
// * A RenderIntent that communicates the downstream renderintent for a physical display, for image
                                         const shaders::LinearEffect& linearEffect,
// quality compensation.
                                         sk_sp<SkRuntimeEffect> runtimeEffect,
sk_sp<SkShader> createLinearEffectShader(
                                         const mat4& colorTransform, float maxDisplayLuminance,
        sk_sp<SkShader> inputShader, const shaders::LinearEffect& linearEffect,
                                         float currentDisplayLuminanceNits, float maxLuminance,
        sk_sp<SkRuntimeEffect> runtimeEffect, const mat4& colorTransform, float maxDisplayLuminance,
                                         AHardwareBuffer* buffer);
        float currentDisplayLuminanceNits, float maxLuminance, AHardwareBuffer* buffer,
        aidl::android::hardware::graphics::composer3::RenderIntent renderIntent);
} // namespace skia
} // namespace skia
} // namespace renderengine
} // namespace renderengine
} // namespace android
} // namespace android
+1 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ cc_library_static {


    shared_libs: [
    shared_libs: [
        "android.hardware.graphics.common-V3-ndk",
        "android.hardware.graphics.common-V3-ndk",
        "android.hardware.graphics.composer3-V1-ndk",
        "android.hardware.graphics.common@1.2",
        "android.hardware.graphics.common@1.2",
        "libnativewindow",
        "libnativewindow",
    ],
    ],
Loading