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

Commit fb1bc8bc authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "SkCanvas is no longer refcnted, use SkClipOps"

parents cbe1a792 d43eaa90
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -121,13 +121,13 @@ public:
            const SkPaint*) {
            const SkPaint*) {
        ADD_FAILURE() << "onDrawBitmapLattice not expected in this test";
        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";
        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";
        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";
        ADD_FAILURE() << "onClipRegion not expected in this test";
    }
    }
    void onDiscard() {
    void onDiscard() {
+10 −11
Original line number Original line Diff line number Diff line
@@ -206,7 +206,6 @@ public:
        , mCanvas(canvas) {
        , mCanvas(canvas) {
    }
    }
    SkCanvas* onNewCanvas() override {
    SkCanvas* onNewCanvas() override {
        mCanvas->ref();
        return mCanvas;
        return mCanvas;
    }
    }
    sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override {
    sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override {
@@ -216,7 +215,7 @@ public:
        return sk_sp<SkImage>();
        return sk_sp<SkImage>();
    }
    }
    void onCopyOnWrite(ContentChangeMode) override {}
    void onCopyOnWrite(ContentChangeMode) override {}
    T* mCanvas;
    T* mCanvas;  // bare pointer, not owned/ref'd
};
};
}
}


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


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


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


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


}
}