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

Commit d43eaa90 authored by Mike Reed's avatar Mike Reed
Browse files

SkCanvas is no longer refcnted, use SkClipOps

Change-Id: I57469f56187f1ca8624e7a63968124ee925b4c04
parent 6ae13327
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -121,13 +121,13 @@ public:
            const SkPaint*) {
        ADD_FAILURE() << "onDrawBitmapLattice not expected in this test";
    }
    void onClipRRect(const SkRRect& rrect, ClipOp, ClipEdgeStyle) {
    void onClipRRect(const SkRRect& rrect, SkClipOp, ClipEdgeStyle) {
        ADD_FAILURE() << "onClipRRect not expected in this test";
    }
    void onClipPath(const SkPath& path, ClipOp, ClipEdgeStyle) {
    void onClipPath(const SkPath& path, SkClipOp, ClipEdgeStyle) {
        ADD_FAILURE() << "onClipPath not expected in this test";
    }
    void onClipRegion(const SkRegion& deviceRgn, ClipOp) {
    void onClipRegion(const SkRegion& deviceRgn, SkClipOp) {
        ADD_FAILURE() << "onClipRegion not expected in this test";
    }
    void onDiscard() {
+10 −11
Original line number Diff line number Diff line
@@ -206,7 +206,6 @@ public:
        , mCanvas(canvas) {
    }
    SkCanvas* onNewCanvas() override {
        mCanvas->ref();
        return mCanvas;
    }
    sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override {
@@ -216,7 +215,7 @@ public:
        return sk_sp<SkImage>();
    }
    void onCopyOnWrite(ContentChangeMode) override {}
    T* mCanvas;
    T* mCanvas;  // bare pointer, not owned/ref'd
};
}

@@ -281,10 +280,10 @@ RENDERTHREAD_TEST(SkiaPipeline, deferRenderNodeScene) {
    LayerUpdateQueue layerUpdateQueue;
    SkRect dirty = SkRect::MakeWH(800, 600);
    auto pipeline = std::make_unique<SkiaOpenGLPipeline>(renderThread);
    sk_sp<DeferTestCanvas> canvas(new DeferTestCanvas());
    sk_sp<SkSurface> surface(new DeferLayer<DeferTestCanvas>(canvas.get()));
    DeferTestCanvas canvas;
    sk_sp<SkSurface> surface(new DeferLayer<DeferTestCanvas>(&canvas));
    pipeline->renderFrame(layerUpdateQueue, dirty, nodes, true, contentDrawBounds, surface);
    EXPECT_EQ(4, canvas->mDrawCounter);
    EXPECT_EQ(4, canvas.mDrawCounter);
}

RENDERTHREAD_TEST(SkiaPipeline, clipped) {
@@ -312,11 +311,11 @@ RENDERTHREAD_TEST(SkiaPipeline, clipped) {
    LayerUpdateQueue layerUpdateQueue;
    SkRect dirty = SkRect::MakeLTRB(10, 20, 30, 40);
    auto pipeline = std::make_unique<SkiaOpenGLPipeline>(renderThread);
    sk_sp<ClippedTestCanvas> canvas(new ClippedTestCanvas());
    sk_sp<SkSurface> surface(new DeferLayer<ClippedTestCanvas>(canvas.get()));
    ClippedTestCanvas canvas;
    sk_sp<SkSurface> surface(new DeferLayer<ClippedTestCanvas>(&canvas));
    pipeline->renderFrame(layerUpdateQueue, dirty, nodes, true,
            SkRect::MakeWH(CANVAS_WIDTH, CANVAS_HEIGHT), surface);
    EXPECT_EQ(1, canvas->mDrawCounter);
    EXPECT_EQ(1, canvas.mDrawCounter);
}

RENDERTHREAD_TEST(SkiaPipeline, clip_replace) {
@@ -347,9 +346,9 @@ RENDERTHREAD_TEST(SkiaPipeline, clip_replace) {
    LayerUpdateQueue layerUpdateQueue;
    SkRect dirty = SkRect::MakeLTRB(10, 10, 40, 40);
    auto pipeline = std::make_unique<SkiaOpenGLPipeline>(renderThread);
    sk_sp<ClipReplaceTestCanvas> canvas(new ClipReplaceTestCanvas());
    sk_sp<SkSurface> surface(new DeferLayer<ClipReplaceTestCanvas>(canvas.get()));
    ClipReplaceTestCanvas canvas;
    sk_sp<SkSurface> surface(new DeferLayer<ClipReplaceTestCanvas>(&canvas));
    pipeline->renderFrame(layerUpdateQueue, dirty, nodes, true,
            SkRect::MakeWH(CANVAS_WIDTH, CANVAS_HEIGHT), surface);
    EXPECT_EQ(1, canvas->mDrawCounter);
    EXPECT_EQ(1, canvas.mDrawCounter);
}
+5 −5
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ static void testProperty(std::function<void(RenderProperties&)> propSetupCallbac
            EXPECT_EQ(mDrawCounter++, 0);
            mCallback(*this);
        }
        void onClipRRect(const SkRRect& rrect, ClipOp op, ClipEdgeStyle style) {
        void onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle style) {
            SkCanvas::onClipRRect(rrect, op, style);
        }
        std::function<void(const SkCanvas&)> mCallback;
@@ -65,10 +65,10 @@ static void testProperty(std::function<void(RenderProperties&)> propSetupCallbac
        canvas.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, paint);
    });

    sk_sp<PropertyTestCanvas> canvas(new PropertyTestCanvas(opValidateCallback));
    RenderNodeDrawable drawable(node.get(), canvas.get(), true);
    canvas->drawDrawable(&drawable);
    EXPECT_EQ(1, canvas->mDrawCounter);
    PropertyTestCanvas canvas(opValidateCallback);
    RenderNodeDrawable drawable(node.get(), &canvas, true);
    canvas.drawDrawable(&drawable);
    EXPECT_EQ(1, canvas.mDrawCounter);
}

}