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

Commit 91865b34 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Cache color corrected variant of every image buffer shader" into sc-dev am: 7d2d7839

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/14327946

Change-Id: I274e86dc5eee5eb002452d4044748db633dcfb3d
parents 4c3b4880 7d2d7839
Loading
Loading
Loading
Loading
+20 −18
Original line number Diff line number Diff line
@@ -42,10 +42,8 @@ const auto kScaleYOnly = mat4(1.f, 0.f, 0.f, 0.f,
                              0.f,   0.f, 1.f, 0.f,
                              0.f,   0.f, 0.f, 1.f);
// clang-format on
// When choosing dataspaces below, whether the match the destination or not determined whether
// a color correction effect is added to the shader. There may be other additional shader details
// for particular color spaces.
// TODO(b/184842383) figure out which color related shaders are necessary
// When setting layer.sourceDataspace, whether it matches the destination or not determines whether
// a color correction effect is added to the shader.
constexpr auto kDestDataSpace = ui::Dataspace::SRGB;
constexpr auto kOtherDataSpace = ui::Dataspace::DISPLAY_P3;
} // namespace
@@ -120,13 +118,16 @@ static void drawImageLayers(SkiaRenderEngine* renderengine, const DisplaySetting

    // Test both drawRect and drawRRect
    auto layers = std::vector<const LayerSettings*>{&layer};
    for (auto dataspace : {kDestDataSpace, kOtherDataSpace}) {
        layer.sourceDataspace = dataspace;
        for (bool identity : {true, false}) {
            layer.geometry.positionTransform = identity ? mat4() : kScaleAndTranslate;
            // Corner radii less than 0.5 creates a special shader. This likely occurs in real usage
            // due to animating corner radius.
            // For the non-idenity matrix, only the large corner radius will create a new shader.
            for (float roundedCornersRadius : identity ? threeCornerRadii : oneCornerRadius) {
            // roundedCornersCrop is always set, but it is this radius that triggers the behavior
                // roundedCornersCrop is always set, but it is this radius that triggers the
                // behavior
                layer.geometry.roundedCornersRadius = roundedCornersRadius;
                for (bool isOpaque : {true, false}) {
                    layer.source.buffer.isOpaque = isOpaque;
@@ -139,6 +140,7 @@ static void drawImageLayers(SkiaRenderEngine* renderengine, const DisplaySetting
            }
        }
    }
}

static void drawSolidLayers(SkiaRenderEngine* renderengine, const DisplaySettings& display,
                            const std::shared_ptr<ExternalTexture>& dstTexture) {