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

Commit 707d6084 authored by Cairn Overturf's avatar Cairn Overturf Committed by Android (Google) Code Review
Browse files

Merge "Optimize shadows on mali, this results in more than a 2x speedup on...

Merge "Optimize shadows on mali, this results in more than a 2x speedup on mali for large windows" into main
parents cff3c078 a49125f4
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -314,6 +314,11 @@ SkiaRenderEngine::Contexts SkiaGLRenderEngine::createContexts() {
    return contexts;
}

bool SkiaGLRenderEngine::supportsForwardPixelKill() const {
    // ARM gpu support this since 2013
    constexpr std::string kArm = "ARM";
    return GLExtensions::getInstance().getVendor() == kArm;
}
bool SkiaGLRenderEngine::supportsProtectedContentImpl() const {
    return mProtectedEGLContext != EGL_NO_CONTEXT;
}
+1 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ protected:
    // Implementations of abstract SkiaRenderEngine functions specific to
    // rendering backend
    virtual SkiaRenderEngine::Contexts createContexts();
    bool supportsForwardPixelKill() const override;
    bool supportsProtectedContentImpl() const override;
    bool useProtectedContextImpl(GrProtected isProtected) override;
    void waitFence(SkiaGpuContext* context, base::borrowed_fd fenceFd) override;
+30 −1
Original line number Diff line number Diff line
@@ -958,6 +958,7 @@ void SkiaRenderEngine::drawLayersInternal(
        }

        {
            SFTRACE_NAME("OutsetRendering");
            SkRRect otherCrop;
            otherCrop.setRectXY(getSkRect(layer.geometry.otherCrop),
                                layer.geometry.otherRoundedCornersRadius.x,
@@ -1009,6 +1010,9 @@ void SkiaRenderEngine::drawLayersInternal(
            // Similar to shadows, do the rendering before the clip is applied because even when the
            // layer is occluded it should have an outline.
            if (layer.borderSettings.strokeWidth > 0) {
                SFTRACE_NAME("LayerBorder");
                LOG_ALWAYS_FATAL_IF(layer.disableBlending,
                                    "Cannot disableBlending with an outline");
                SkRRect outlineRect = preferredOriginalBounds;
                outlineRect.outset(layer.borderSettings.strokeWidth,
                                   layer.borderSettings.strokeWidth);
@@ -1021,6 +1025,9 @@ void SkiaRenderEngine::drawLayersInternal(
            }

            if (!layer.boxShadowSettings.boxShadows.empty()) {
                SFTRACE_NAME("BoxShadows");
                LOG_ALWAYS_FATAL_IF(layer.disableBlending,
                                    "Cannot disableBlending with a box shadow");
                for (const gui::BoxShadowSettings::BoxShadowParams& box :
                     layer.boxShadowSettings.boxShadows) {
                    SkRRect boxRect = preferredOriginalBounds;
@@ -1028,11 +1035,33 @@ void SkiaRenderEngine::drawLayersInternal(
                    boxRect.offset(box.offsetX, box.offsetY);
                    float sigma = convertBlurUserRadiusToSigma(box.blurRadius);
                    SkPaint blur;
                    blur.setAntiAlias(true);
                    blur.setColor(box.color);
                    blur.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, sigma, false));
                    canvas->drawRRect(boxRect, blur);
                }

                const bool opaqueContent =
                        (!layer.source.buffer.buffer || layer.source.buffer.isOpaque) &&
                        layer.alpha == 1.0f;
                if (opaqueContent && supportsForwardPixelKill()) {
                    SFTRACE_NAME("FPKOptimization");
                    // This optimization is just for Ganesh and can be removed once graphite is
                    // enabled.
                    SkRRect p = preferredOriginalBounds;
                    // Assume corners are circles.
                    SkScalar maxRadius = std::max({p.radii(SkRRect::kUpperLeft_Corner).fX,
                                                   p.radii(SkRRect::kUpperRight_Corner).fX,
                                                   p.radii(SkRRect::kLowerRight_Corner).fX,
                                                   p.radii(SkRRect::kLowerLeft_Corner).fX});
                    SkRect killRect = p.rect();
                    killRect.inset(maxRadius, maxRadius);
                    SkPaint paint;
                    // Draw opaque rect to force FPK on mali results in 2x speedup.
                    paint.setAntiAlias(false);
                    paint.setColor(0);
                    paint.setBlendMode(SkBlendMode::kSrc);
                    canvas->drawRect(killRect, paint);
                }
            }
        }

+1 −0
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ protected:
    using Contexts = std::pair<unique_ptr<SkiaGpuContext>, unique_ptr<SkiaGpuContext>>;
    virtual Contexts createContexts() = 0;
    virtual bool supportsProtectedContentImpl() const = 0;
    virtual bool supportsForwardPixelKill() const { return false; }
    virtual bool useProtectedContextImpl(GrProtected isProtected) = 0;
    virtual void waitFence(SkiaGpuContext* context, base::borrowed_fd fenceFd) = 0;
    virtual base::unique_fd flushAndSubmit(SkiaGpuContext* context,