aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2017-12-05 10:05:21 -0700
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-05 18:06:18 +0000
commita32a3c32c32e02baecffb537f6f26c0a67a1c130 (patch)
tree049aceb1e15505619f39caf74f305d0d50db98dc /tests
parentf32b27d2e4872966a360fb296acccae3e186a4a5 (diff)
Add analytic clip FPs that read from the CCPR atlas
Bug: skia:7190 Change-Id: Ie31d368f52910e6917efdeb1b024370b06fc11ee Reviewed-on: https://skia-review.googlesource.com/77160 Commit-Queue: Chris Dalton <csmartdalton@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/GrCCPRTest.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/GrCCPRTest.cpp b/tests/GrCCPRTest.cpp
index 32d4f6aa45..33246bfc88 100644
--- a/tests/GrCCPRTest.cpp
+++ b/tests/GrCCPRTest.cpp
@@ -28,6 +28,30 @@
static constexpr int kCanvasSize = 100;
+class CCPRClip : public GrClip {
+public:
+ CCPRClip(GrCoverageCountingPathRenderer* ccpr, const SkPath& path) : fCCPR(ccpr), fPath(path) {}
+
+private:
+ bool apply(GrContext*, GrRenderTargetContext* rtc, bool, bool, GrAppliedClip* out,
+ SkRect* bounds) const override {
+ out->addCoverageFP(fCCPR->makeClipProcessor(rtc->priv().testingOnly_getOpListID(), fPath,
+ SkIRect::MakeWH(rtc->width(), rtc->height()),
+ rtc->width(), rtc->height()));
+ return true;
+ }
+ bool quickContains(const SkRect&) const final { return false; }
+ bool isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA*) const final { return false; }
+ void getConservativeBounds(int width, int height, SkIRect* rect, bool* iior) const final {
+ rect->set(0, 0, width, height);
+ if (iior) {
+ *iior = false;
+ }
+ }
+ GrCoverageCountingPathRenderer* const fCCPR;
+ const SkPath fPath;
+};
+
class CCPRPathDrawer {
public:
CCPRPathDrawer(GrContext* ctx, skiatest::Reporter* reporter)
@@ -66,6 +90,16 @@ public:
&noClip, &clipBounds, &matrix, &shape, GrAAType::kCoverage, false});
}
+ void clipFullscreenRect(SkPath clipPath, GrColor4f color = GrColor4f(0, 1, 0, 1)) {
+ SkASSERT(this->valid());
+
+ GrPaint paint;
+ paint.setColor4f(color);
+
+ fRTC->drawRect(CCPRClip(fCCPR, clipPath), std::move(paint), GrAA::kYes, SkMatrix::I(),
+ SkRect::MakeIWH(kCanvasSize, kCanvasSize));
+ }
+
void flush() const {
SkASSERT(this->valid());
fCtx->flush();
@@ -137,6 +171,7 @@ class GrCCPRTest_cleanup : public CCPRTest {
// Ensure paths get unreffed.
for (int i = 0; i < 10; ++i) {
ccpr.drawPath(fPath);
+ ccpr.clipFullscreenRect(fPath);
}
REPORTER_ASSERT(reporter, !SkPathPriv::TestingOnly_unique(fPath));
ccpr.flush();
@@ -145,6 +180,7 @@ class GrCCPRTest_cleanup : public CCPRTest {
// Ensure paths get unreffed when we delete the context without flushing.
for (int i = 0; i < 10; ++i) {
ccpr.drawPath(fPath);
+ ccpr.clipFullscreenRect(fPath);
}
ccpr.abandonGrContext();
REPORTER_ASSERT(reporter, !SkPathPriv::TestingOnly_unique(fPath));
@@ -196,6 +232,18 @@ class GrCCPRTest_parseEmptyPath : public CCPRTest {
// This is the test. It will exercise various internal asserts and verify we do not crash.
ccpr.flush();
+
+ // Now try again with clips.
+ ccpr.clipFullscreenRect(largeOutsidePath);
+ ccpr.clipFullscreenRect(emptyPath);
+ ccpr.flush();
+
+ // ... and both.
+ ccpr.drawPath(largeOutsidePath);
+ ccpr.clipFullscreenRect(largeOutsidePath);
+ ccpr.drawPath(emptyPath);
+ ccpr.clipFullscreenRect(emptyPath);
+ ccpr.flush();
}
};
DEF_CCPR_TEST(GrCCPRTest_parseEmptyPath)