diff options
author | Chris Dalton <csmartdalton@google.com> | 2017-10-17 10:40:01 -0600 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-10-17 18:48:42 +0000 |
commit | a2ac30da36c80f616c909c671a240f2d468db124 (patch) | |
tree | 0f6190b0f04c83e2c2b0c24b850b9e9ebcb83e54 | |
parent | 2fb81c04d74973181208f4f33eb6be4d4bae0321 (diff) |
Enable CCPR for volatile paths
Enables for volatile paths and when path mask caching is disabled.
Bug: skia:
Change-Id: I644b17f2a4f77a4ddf85265f520599499c0800cf
Reviewed-on: https://skia-review.googlesource.com/60481
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
-rw-r--r-- | bench/PathTextBench.cpp | 8 | ||||
-rw-r--r-- | include/private/GrTypesPriv.h | 4 | ||||
-rw-r--r-- | src/gpu/GrPathRendererChain.cpp | 4 | ||||
-rw-r--r-- | src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp | 10 | ||||
-rw-r--r-- | src/gpu/ccpr/GrCoverageCountingPathRenderer.h | 8 | ||||
-rw-r--r-- | tests/GrCCPRTest.cpp | 2 |
6 files changed, 24 insertions, 12 deletions
diff --git a/bench/PathTextBench.cpp b/bench/PathTextBench.cpp index 6ee8f8879c..6551fa5f27 100644 --- a/bench/PathTextBench.cpp +++ b/bench/PathTextBench.cpp @@ -27,11 +27,12 @@ static_assert(52 == kNumGlyphs, "expected 52 glyphs"); */ class PathTextBench : public Benchmark { public: + PathTextBench(bool cached) : fCached(cached) {} bool isVisual() override { return true; } private: const char* onGetName() override { - return "path_text"; + return fCached ? "path_text" : "path_text_uncached"; } SkIPoint onGetSize() override { return SkIPoint::Make(kScreenWidth, kScreenHeight); } @@ -42,6 +43,7 @@ private: for (int i = 0; i < kNumGlyphs; ++i) { SkGlyphID id = cache->unicharToGlyph(kGlyphs[i]); cache->getScalerContext()->getPath(SkPackedGlyphID(id), &fGlyphs[i]); + fGlyphs[i].setIsVolatile(!fCached); } SkRandom rand; @@ -76,6 +78,7 @@ private: } } + const bool fCached; SkPath fGlyphs[kNumGlyphs]; SkPaint fPaints[kNumDraws]; SkMatrix fXforms[kNumDraws]; @@ -83,4 +86,5 @@ private: typedef Benchmark INHERITED; }; -DEF_BENCH(return new PathTextBench;) +DEF_BENCH(return new PathTextBench(false);) +DEF_BENCH(return new PathTextBench(true);) diff --git a/include/private/GrTypesPriv.h b/include/private/GrTypesPriv.h index bb3fe503c9..2b014114f1 100644 --- a/include/private/GrTypesPriv.h +++ b/include/private/GrTypesPriv.h @@ -757,9 +757,7 @@ enum class GpuPathRenderers { kTessellating = 1 << 7, kAll = (kTessellating | (kTessellating - 1)), - - // Temporarily disabling CCPR by default until it has had a time to soak. - kDefault = kAll & ~kCoverageCounting, + kDefault = kAll }; /** diff --git a/src/gpu/GrPathRendererChain.cpp b/src/gpu/GrPathRendererChain.cpp index b982a32e94..3bb744afab 100644 --- a/src/gpu/GrPathRendererChain.cpp +++ b/src/gpu/GrPathRendererChain.cpp @@ -51,7 +51,9 @@ GrPathRendererChain::GrPathRendererChain(GrContext* context, const Options& opti fChain.push_back(sk_make_sp<GrAAHairLinePathRenderer>()); if (options.fGpuPathRenderers & GpuPathRenderers::kCoverageCounting) { - if (auto ccpr = GrCoverageCountingPathRenderer::CreateIfSupported(*context->caps())) { + bool drawCachablePaths = !options.fAllowPathMaskCaching; + if (auto ccpr = GrCoverageCountingPathRenderer::CreateIfSupported(*context->caps(), + drawCachablePaths)) { context->contextPriv().addOnFlushCallbackObject(ccpr.get()); fChain.push_back(std::move(ccpr)); } diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp index 877c8727b0..86a436568f 100644 --- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp +++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp @@ -37,13 +37,17 @@ bool GrCoverageCountingPathRenderer::IsSupported(const GrCaps& caps) { } sk_sp<GrCoverageCountingPathRenderer> -GrCoverageCountingPathRenderer::CreateIfSupported(const GrCaps& caps) { - return sk_sp<GrCoverageCountingPathRenderer>(IsSupported(caps) ? - new GrCoverageCountingPathRenderer : nullptr); +GrCoverageCountingPathRenderer::CreateIfSupported(const GrCaps& caps, bool drawCachablePaths) { + auto ccpr = IsSupported(caps) ? new GrCoverageCountingPathRenderer(drawCachablePaths) : nullptr; + return sk_sp<GrCoverageCountingPathRenderer>(ccpr); } GrPathRenderer::CanDrawPath GrCoverageCountingPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { + if (args.fShape->hasUnstyledKey() && !fDrawCachablePaths) { + return CanDrawPath::kNo; + } + if (!args.fShape->style().isSimpleFill() || args.fShape->inverseFilled() || args.fViewMatrix->hasPerspective() || diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.h b/src/gpu/ccpr/GrCoverageCountingPathRenderer.h index 6025581da8..035898dc27 100644 --- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.h +++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.h @@ -32,7 +32,8 @@ class GrCoverageCountingPathRenderer public: static bool IsSupported(const GrCaps&); - static sk_sp<GrCoverageCountingPathRenderer> CreateIfSupported(const GrCaps&); + static sk_sp<GrCoverageCountingPathRenderer> CreateIfSupported(const GrCaps&, + bool drawCachablePaths); // GrPathRenderer overrides. StencilSupport onGetStencilSupport(const GrShape&) const override { @@ -121,7 +122,8 @@ public: }; private: - GrCoverageCountingPathRenderer() = default; + GrCoverageCountingPathRenderer(bool drawCachablePaths) + : fDrawCachablePaths(drawCachablePaths) {} void setupPerFlushResources(GrOnFlushResourceProvider*, const uint32_t* opListIDs, int numOpListIDs, SkTArray<sk_sp<GrRenderTargetContext>>* results); @@ -143,6 +145,8 @@ private: GrSTAllocator<4, GrCCPRAtlas> fPerFlushAtlases; bool fPerFlushResourcesAreValid; SkDEBUGCODE(bool fFlushing = false;) + + const bool fDrawCachablePaths; }; #endif diff --git a/tests/GrCCPRTest.cpp b/tests/GrCCPRTest.cpp index d8be726d6e..d685b1094b 100644 --- a/tests/GrCCPRTest.cpp +++ b/tests/GrCCPRTest.cpp @@ -29,7 +29,7 @@ class CCPRPathDrawer { public: CCPRPathDrawer(GrContext* ctx) : fCtx(ctx) - , fCCPR(GrCoverageCountingPathRenderer::CreateIfSupported(*fCtx->caps())) + , fCCPR(GrCoverageCountingPathRenderer::CreateIfSupported(*fCtx->caps(), true)) , fRTC(fCtx->makeDeferredRenderTargetContext(SkBackingFit::kExact, kCanvasSize, kCanvasSize, kRGBA_8888_GrPixelConfig, nullptr)) { |