aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/GrCCPRTest.cpp
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2018-06-24 13:08:57 -0600
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-25 01:47:14 +0000
commita2b5b6467f347962e0d6942da0dff9148fbb3375 (patch)
treebca84406c7de1810fa2ce099fbf118e44df8c1e9 /tests/GrCCPRTest.cpp
parentebf160f308b698c075c9c1cf8d65d40cb2486238 (diff)
ccpr: Enable ccpr by default
Now that the path cache is implemented, we can use ccpr everywhere. Modifies ccpr to not cache unless the "fAllowPathMaskCaching" context option is enabled. Adds a small condition to skip complicated paths with more vertices than pixels, simply so we don't regress a couple testcases. Updates skpbench to do three draws before starting the timer, in order to prime the cache. Bug: skia: Change-Id: Ic3a0a2bdad8a22ff6431e77fa4da2b54d6bb9aba Reviewed-on: https://skia-review.googlesource.com/137207 Commit-Queue: Chris Dalton <csmartdalton@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tests/GrCCPRTest.cpp')
-rw-r--r--tests/GrCCPRTest.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/tests/GrCCPRTest.cpp b/tests/GrCCPRTest.cpp
index 2cc456946c..9ac425c987 100644
--- a/tests/GrCCPRTest.cpp
+++ b/tests/GrCCPRTest.cpp
@@ -53,11 +53,6 @@ private:
const SkPath fPath;
};
-enum class MarkVolatile : bool {
- kNo = false,
- kYes = true
-};
-
class CCPRPathDrawer {
public:
CCPRPathDrawer(GrContext* ctx, skiatest::Reporter* reporter)
@@ -82,8 +77,7 @@ public:
void clear() const { fRTC->clear(nullptr, 0, GrRenderTargetContext::CanClearFullscreen::kYes); }
void abandonGrContext() { fCtx = nullptr; fCCPR = nullptr; fRTC = nullptr; }
- void drawPath(SkPath path, const SkMatrix& matrix = SkMatrix::I(),
- MarkVolatile markVolatile = MarkVolatile::kYes) const {
+ void drawPath(const SkPath& path, const SkMatrix& matrix = SkMatrix::I()) const {
SkASSERT(this->valid());
GrPaint paint;
@@ -92,13 +86,11 @@ public:
GrNoClip noClip;
SkIRect clipBounds = SkIRect::MakeWH(kCanvasSize, kCanvasSize);
- if (MarkVolatile::kYes == markVolatile) {
- path.setIsVolatile(true);
- }
GrShape shape(path);
- fCCPR->drawPath({fCtx, std::move(paint), &GrUserStencilSettings::kUnused, fRTC.get(),
- &noClip, &clipBounds, &matrix, &shape, GrAAType::kCoverage, false});
+ fCCPR->testingOnly_drawPathDirectly({
+ fCtx, std::move(paint), &GrUserStencilSettings::kUnused, fRTC.get(), &noClip,
+ &clipBounds, &matrix, &shape, GrAAType::kCoverage, false});
}
void clipFullscreenRect(SkPath clipPath, GrColor4f color = GrColor4f(0, 1, 0, 1)) {
@@ -137,12 +129,13 @@ public:
mockOptions.fGeometryShaderSupport = true;
mockOptions.fIntegerSupport = true;
mockOptions.fFlatInterpolationSupport = true;
- this->customizeMockOptions(&mockOptions);
GrContextOptions ctxOptions;
ctxOptions.fAllowPathMaskCaching = false;
ctxOptions.fGpuPathRenderers = GpuPathRenderers::kCoverageCounting;
+ this->customizeOptions(&mockOptions, &ctxOptions);
+
fMockContext = GrContext::MakeMock(&mockOptions, ctxOptions);
if (!fMockContext) {
ERRORF(reporter, "could not create mock context");
@@ -166,7 +159,7 @@ public:
virtual ~CCPRTest() {}
protected:
- virtual void customizeMockOptions(GrMockOptions*) {}
+ virtual void customizeOptions(GrMockOptions*, GrContextOptions*) {}
virtual void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr) = 0;
sk_sp<GrContext> fMockContext;
@@ -213,8 +206,8 @@ class GrCCPRTest_cleanup : public CCPRTest {
DEF_CCPR_TEST(GrCCPRTest_cleanup)
class GrCCPRTest_cleanupWithTexAllocFail : public GrCCPRTest_cleanup {
- void customizeMockOptions(GrMockOptions* options) override {
- options->fFailTextureAllocations = true;
+ void customizeOptions(GrMockOptions* mockOptions, GrContextOptions*) override {
+ mockOptions->fFailTextureAllocations = true;
}
};
DEF_CCPR_TEST(GrCCPRTest_cleanupWithTexAllocFail)
@@ -281,6 +274,10 @@ DEF_CCPR_TEST(GrCCPRTest_parseEmptyPath)
// transformation matrices. We then vary the matrices independently by whole and partial pixels,
// and verify the caching behaved as expected.
class GrCCPRTest_cache : public CCPRTest {
+ void customizeOptions(GrMockOptions*, GrContextOptions* ctxOptions) override {
+ ctxOptions->fAllowPathMaskCaching = true;
+ }
+
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr) override {
static constexpr int kPathSize = 20;
SkRandom rand;
@@ -312,7 +309,7 @@ class GrCCPRTest_cache : public CCPRTest {
REPORTER_ASSERT(reporter, !stashedAtlasKey->isValid());
for (size_t i = 0; i < SK_ARRAY_COUNT(paths); ++i) {
- ccpr.drawPath(paths[i], matrices[i % 2], MarkVolatile::kNo);
+ ccpr.drawPath(paths[i], matrices[i % 2]);
}
ccpr.flush();