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

Commit b026f353 authored by John Reck's avatar John Reck
Browse files

Use SkSurfaceProps forcedither

Use new shiny API to forceably dither instead of
an SkPaintFilterCanvas

Fixes: 276779571
Test: SilkFX gradients
Change-Id: Ia2f5323ed796e6f5f3cd4f44cb6334d04d3399a4
parent 70719574
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -104,7 +104,8 @@ IRenderPipeline::DrawResult SkiaOpenGLPipeline::draw(

    GrBackendRenderTarget backendRT(frame.width(), frame.height(), 0, STENCIL_BUFFER_SIZE, fboInfo);

    SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
    SkSurfaceProps props(mColorMode == ColorMode::Default ? 0 : SkSurfaceProps::kAlwaysDither_Flag,
                         kUnknown_SkPixelGeometry);

    SkASSERT(mRenderThread.getGrContext() != nullptr);
    sk_sp<SkSurface> surface;
+0 −24
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@
#include <SkMultiPictureDocument.h>
#include <SkOverdrawCanvas.h>
#include <SkOverdrawColorFilter.h>
#include <SkPaintFilterCanvas.h>
#include <SkPicture.h>
#include <SkPictureRecorder.h>
#include <SkRect.h>
@@ -450,23 +449,6 @@ void SkiaPipeline::endCapture(SkSurface* surface) {
    }
}

class ForceDitherCanvas : public SkPaintFilterCanvas {
public:
    ForceDitherCanvas(SkCanvas* canvas) : SkPaintFilterCanvas(canvas) {}

protected:
    bool onFilter(SkPaint& paint) const override {
        paint.setDither(true);
        return true;
    }

    void onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) override {
        // We unroll the drawable using "this" canvas, so that draw calls contained inside will
        // get dithering applied
        drawable->draw(this, matrix);
    }
};

void SkiaPipeline::renderFrame(const LayerUpdateQueue& layers, const SkRect& clip,
                               const std::vector<sp<RenderNode>>& nodes, bool opaque,
                               const Rect& contentDrawBounds, sk_sp<SkSurface> surface,
@@ -521,12 +503,6 @@ void SkiaPipeline::renderFrameImpl(const SkRect& clip,
        canvas->clear(SK_ColorTRANSPARENT);
    }

    std::optional<ForceDitherCanvas> forceDitherCanvas;
    if (shouldForceDither()) {
        forceDitherCanvas.emplace(canvas);
        canvas = &forceDitherCanvas.value();
    }

    if (1 == nodes.size()) {
        if (!nodes[0]->nothingToDraw()) {
            RenderNodeDrawable root(nodes[0].get(), canvas);
+0 −2
Original line number Diff line number Diff line
@@ -98,8 +98,6 @@ protected:

    bool isCapturingSkp() const { return mCaptureMode != CaptureMode::None; }

    virtual bool shouldForceDither() const { return mColorMode != ColorMode::Default; }

private:
    void renderFrameImpl(const SkRect& clip,
                         const std::vector<sp<RenderNode>>& nodes, bool opaque,
+0 −5
Original line number Diff line number Diff line
@@ -203,11 +203,6 @@ sk_sp<Bitmap> SkiaVulkanPipeline::allocateHardwareBitmap(renderthread::RenderThr
    return nullptr;
}

bool SkiaVulkanPipeline::shouldForceDither() const {
    if (mVkSurface && mVkSurface->isBeyond8Bit()) return false;
    return SkiaPipeline::shouldForceDither();
}

void SkiaVulkanPipeline::onContextDestroyed() {
    if (mVkSurface) {
        vulkanManager().destroySurface(mVkSurface);
+0 −2
Original line number Diff line number Diff line
@@ -63,8 +63,6 @@ public:
protected:
    void onContextDestroyed() override;

    bool shouldForceDither() const override;

private:
    renderthread::VulkanManager& vulkanManager();
    renderthread::VulkanSurface* mVkSurface = nullptr;
Loading