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

Commit 091303fd authored by Derek Sollenberger's avatar Derek Sollenberger Committed by Automerger Merge Worker
Browse files

Merge "Avoid blur behind for layers that are fully opaque." into sc-dev am:...

Merge "Avoid blur behind for layers that are fully opaque." into sc-dev am: 9d799fbb am: ea2da71c am: 1fcb724c

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

Change-Id: I45be3c3e990e7c57e0c8a5cd29d09d0ec5384b93
parents df50ce20 1fcb724c
Loading
Loading
Loading
Loading
+22 −9
Original line number Diff line number Diff line
@@ -725,6 +725,14 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display,
        return BAD_VALUE;
    }

    // setup color filter if necessary
    sk_sp<SkColorFilter> displayColorTransform;
    if (display.colorTransform != mat4()) {
        displayColorTransform = SkColorFilters::Matrix(toSkColorMatrix(display.colorTransform));
    }
    const bool ctModifiesAlpha =
            displayColorTransform && !displayColorTransform->isAlphaUnchanged();

    // Find if any layers have requested blur, we'll use that info to decide when to render to an
    // offscreen buffer and when to render to the native buffer.
    sk_sp<SkSurface> activeSurface(dstSurface);
@@ -734,6 +742,10 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display,
    if (mBlurFilter) {
        bool requiresCompositionLayer = false;
        for (const auto& layer : layers) {
            // if the layer doesn't have blur or it is not visible then continue
            if (!layerHasBlur(layer, ctModifiesAlpha)) {
                continue;
            }
            if (layer->backgroundBlurRadius > 0 &&
                layer->backgroundBlurRadius < BlurFilter::kMaxCrossFadeRadius) {
                requiresCompositionLayer = true;
@@ -779,12 +791,6 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display,
        canvas->drawRegion(clearRegion, paint);
    }

    // setup color filter if necessary
    sk_sp<SkColorFilter> displayColorTransform;
    if (display.colorTransform != mat4()) {
        displayColorTransform = SkColorFilters::Matrix(toSkColorMatrix(display.colorTransform));
    }

    for (const auto& layer : layers) {
        ATRACE_NAME("DrawLayer");

@@ -850,7 +856,7 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display,
        const auto [bounds, roundRectClip] =
                getBoundsAndClip(layer->geometry.boundaries, layer->geometry.roundedCornersCrop,
                                 layer->geometry.roundedCornersRadius);
        if (mBlurFilter && layerHasBlur(layer)) {
        if (mBlurFilter && layerHasBlur(layer, ctModifiesAlpha)) {
            std::unordered_map<uint32_t, sk_sp<SkImage>> cachedBlurs;

            // if multiple layers have blur, then we need to take a snapshot now because
@@ -1188,8 +1194,15 @@ inline std::pair<SkRRect, SkRRect> SkiaGLRenderEngine::getBoundsAndClip(const Fl
    return {SkRRect::MakeRect(bounds), clip};
}

inline bool SkiaGLRenderEngine::layerHasBlur(const LayerSettings* layer) {
    return layer->backgroundBlurRadius > 0 || layer->blurRegions.size();
inline bool SkiaGLRenderEngine::layerHasBlur(const LayerSettings* layer,
                                             bool colorTransformModifiesAlpha) {
    if (layer->backgroundBlurRadius > 0 || layer->blurRegions.size()) {
        // return false if the content is opaque and would therefore occlude the blur
        const bool opaqueContent = !layer->source.buffer.buffer || layer->source.buffer.isOpaque;
        const bool opaqueAlpha = layer->alpha == 1.0f && !colorTransformModifiesAlpha;
        return layer->skipContentDraw || !(opaqueContent && opaqueAlpha);
    }
    return false;
}

inline SkColor SkiaGLRenderEngine::getSkColor(const vec4& color) {
+1 −1
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ private:
    inline SkRect getSkRect(const Rect& layer);
    inline std::pair<SkRRect, SkRRect> getBoundsAndClip(const FloatRect& bounds,
                                                        const FloatRect& crop, float cornerRadius);
    inline bool layerHasBlur(const LayerSettings* layer);
    inline bool layerHasBlur(const LayerSettings* layer, bool colorTransformModifiesAlpha);
    inline SkColor getSkColor(const vec4& color);
    inline SkM44 getSkM44(const mat4& matrix);
    inline SkPoint3 getSkPoint3(const vec3& vector);