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

Commit d8169eac authored by Nathaniel Nifong's avatar Nathaniel Nifong Committed by Android (Google) Code Review
Browse files

Merge "Cull unnecessary shadow drawLayer calls."

parents 9378e224 49a59586
Loading
Loading
Loading
Loading
+21 −18
Original line number Diff line number Diff line
@@ -97,26 +97,28 @@ static void drawShadowLayers(SkiaRenderEngine* renderengine, const DisplaySettin

    base::unique_fd drawFence;
    auto layers = std::vector<const LayerSettings*>{&layer, &caster};
    // When sourceDataspace matches dest, the general shadow fragment shader doesn't
    // have color correction added.
    // independently, when it is not srgb, the *vertex* shader has color correction added.
    // This may be a bug, but the shader still needs to be cached as it is triggered
    // during youtube pip.
    for (auto dataspace : {kDestDataSpace, kOtherDataSpace}) {
        layer.sourceDataspace = dataspace;
        // The 2nd matrix, which has different scales for x and y, will
        // generate the slower (more general case) shadow shader
        for (auto transform : {mat4(), kScaleAndTranslate, kFlip}) {
    // Four combinations of settings are used (two transforms here, and drawShadowLayers is
    // called with two different destination data spaces) They're all rounded rect.
    // Three of these are cache misses that generate new shaders.
    // The first combination generates a short and simple shadow shader.
    // The second combination, flip transform, generates two shaders. The first appears to involve
    //   gaussian_fp. The second is a long and general purpose shadow shader with a device space
    //   transformation stage.
    // The third combination is a cache hit, nothing new.
    // The fourth combination, flip transform with a non-SRGB destination dataspace, is new.
    //   It is unique in that nearly everything is done in the vertex shader, and that vertex shader
    //   requires color correction. This is triggered differently from every other instance of color
    //   correction. All other instances are triggered when src and dst dataspaces differ, while
    //   this one is triggered by the destination being non-srgb. Apparently since the third
    //   combination is a cache hit, this color correction is only added when the vertex shader is
    //   doing something non-trivial.
    for (auto transform : {mat4(), kFlip}) {
        layer.geometry.positionTransform = transform;
        caster.geometry.positionTransform = transform;
            for (bool translucent : {false, true}){
                layer.shadow.casterIsTranslucent = translucent;
        renderengine->drawLayers(display, layers, dstTexture, kUseFrameBufferCache,
                                base::unique_fd(), &drawFence);
    }
}
    }
}

static void drawImageLayers(SkiaRenderEngine* renderengine, const DisplaySettings& display,
                            const std::shared_ptr<ExternalTexture>& dstTexture,
@@ -388,6 +390,7 @@ void Cache::primeShaderCache(SkiaRenderEngine* renderengine) {
                                                          ExternalTexture::Usage::WRITEABLE);
        drawHolePunchLayer(renderengine, display, dstTexture);
        drawSolidLayers(renderengine, display, dstTexture);

        drawShadowLayers(renderengine, display, srcTexture);
        drawShadowLayers(renderengine, p3Display, srcTexture);