diff options
author | 2017-12-05 10:05:21 -0700 | |
---|---|---|
committer | 2017-12-05 18:06:18 +0000 | |
commit | a32a3c32c32e02baecffb537f6f26c0a67a1c130 (patch) | |
tree | 049aceb1e15505619f39caf74f305d0d50db98dc /src/gpu/GrClipStackClip.cpp | |
parent | f32b27d2e4872966a360fb296acccae3e186a4a5 (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 'src/gpu/GrClipStackClip.cpp')
-rw-r--r-- | src/gpu/GrClipStackClip.cpp | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp index bd6ed9afed..0f647e07b4 100644 --- a/src/gpu/GrClipStackClip.cpp +++ b/src/gpu/GrClipStackClip.cpp @@ -11,9 +11,9 @@ #include "GrContextPriv.h" #include "GrDeferredProxyUploader.h" #include "GrDrawingManager.h" -#include "GrRenderTargetContextPriv.h" #include "GrFixedClip.h" #include "GrGpuResourcePriv.h" +#include "GrRenderTargetContextPriv.h" #include "GrResourceProvider.h" #include "GrStencilAttachment.h" #include "GrSWMaskHelper.h" @@ -190,6 +190,8 @@ bool GrClipStackClip::apply(GrContext* context, GrRenderTargetContext* renderTar return true; } + const auto* caps = context->caps()->shaderCaps(); + int maxWindowRectangles = renderTargetContext->priv().maxWindowRectangles(); int maxAnalyticFPs = context->caps()->maxClipAnalyticFPs(); if (GrFSAAType::kNone != renderTargetContext->fsaaType()) { // With mixed samples (non-msaa color buffer), any coverage info is lost from color once it @@ -200,10 +202,13 @@ bool GrClipStackClip::apply(GrContext* context, GrRenderTargetContext* renderTar } SkASSERT(!context->caps()->avoidStencilBuffers()); // We disable MSAA when avoiding stencil. } + auto* ccpr = context->contextPriv().drawingManager()->getCoverageCountingPathRenderer(); - const auto* caps = context->caps()->shaderCaps(); - GrReducedClip reducedClip(*fStack, devBounds, caps, - renderTargetContext->priv().maxWindowRectangles(), maxAnalyticFPs); + GrReducedClip reducedClip(*fStack, devBounds, caps, maxWindowRectangles, maxAnalyticFPs, ccpr); + if (InitialState::kAllOut == reducedClip.initialState() && + reducedClip.maskElements().isEmpty()) { + return false; + } if (reducedClip.hasScissor() && !GrClip::IsInsideClip(reducedClip.scissor(), devBounds)) { out->hardClip().addScissor(reducedClip.scissor(), bounds); @@ -214,14 +219,27 @@ bool GrClipStackClip::apply(GrContext* context, GrRenderTargetContext* renderTar GrWindowRectsState::Mode::kExclusive); } - if (std::unique_ptr<GrFragmentProcessor> clipFPs = reducedClip.detachAnalyticFPs()) { - out->addCoverageFP(std::move(clipFPs)); + if (!reducedClip.maskElements().isEmpty()) { + if (!this->applyClipMask(context, renderTargetContext, reducedClip, hasUserStencilSettings, + out)) { + return false; + } } - if (reducedClip.maskElements().isEmpty()) { - return InitialState::kAllIn == reducedClip.initialState(); + // The opList ID must not be looked up until AFTER producing the clip mask (if any). That step + // can cause a flush or otherwise change which opList our draw is going into. + uint32_t opListID = renderTargetContext->getOpList()->uniqueID(); + int rtWidth = renderTargetContext->width(), rtHeight = renderTargetContext->height(); + if (auto clipFPs = reducedClip.finishAndDetachAnalyticFPs(opListID, rtWidth, rtHeight)) { + out->addCoverageFP(std::move(clipFPs)); } + return true; +} + +bool GrClipStackClip::applyClipMask(GrContext* context, GrRenderTargetContext* renderTargetContext, + const GrReducedClip& reducedClip, bool hasUserStencilSettings, + GrAppliedClip* out) const { #ifdef SK_DEBUG SkASSERT(reducedClip.hasScissor()); SkIRect rtIBounds = SkIRect::MakeWH(renderTargetContext->width(), |