Index: src/gpu/GrDrawTarget.cpp |
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp |
index 0f180dc861b92ced07c2ddc9548564894f7642b0..7166fc7160008159ab4bcc7208fcb6ae8d93f64f 100644 |
--- a/src/gpu/GrDrawTarget.cpp |
+++ b/src/gpu/GrDrawTarget.cpp |
@@ -16,6 +16,7 @@ |
#include "GrRenderTarget.h" |
#include "GrResourceProvider.h" |
#include "GrRenderTargetPriv.h" |
+#include "GrStencilAttachment.h" |
#include "GrSurfacePriv.h" |
#include "GrTexture.h" |
#include "gl/GrGLRenderTarget.h" |
@@ -235,17 +236,16 @@ void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, |
GrDrawBatch* batch, |
const SkIRect* scissorRect) { |
// Setup clip |
- GrPipelineBuilder::AutoRestoreStencil ars; |
GrAppliedClip clip; |
if (scissorRect) { |
SkASSERT(GrClip::kWideOpen_ClipType == pipelineBuilder.clip().clipType()); |
- if (!fClipMaskManager->setupScissorClip(pipelineBuilder, &ars, *scissorRect, |
+ if (!fClipMaskManager->setupScissorClip(pipelineBuilder, *scissorRect, |
&batch->bounds(), &clip)) { |
return; |
} |
} else { |
- if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &batch->bounds(), &clip)) { |
+ if (!fClipMaskManager->setupClipping(pipelineBuilder, &batch->bounds(), &clip)) { |
return; |
} |
} |
@@ -257,7 +257,8 @@ void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, |
} |
GrPipeline::CreateArgs args; |
- if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip.scissorState(), batch)) { |
+ if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip.scissorState(), |
+ clip.hasStencilClip(), batch)) { |
return; |
} |
@@ -269,34 +270,36 @@ void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, |
this->recordBatch(batch); |
} |
-void GrDrawTarget::getPathStencilSettingsForFilltype(GrPathRendering::FillType fill, |
- const GrStencilAttachment* sb, |
- GrStencilSettings* outStencilSettings) { |
- static constexpr GrStencilSettings kWindingStencilSettings( |
- kIncClamp_StencilOp, |
- kIncClamp_StencilOp, |
- kAlwaysIfInClip_StencilFunc, |
- 0xFFFF, 0xFFFF, 0xFFFF |
+inline static const GrUserStencilSettings& get_path_stencil_settings_for_fill( |
+ GrPathRendering::FillType fill) { |
+ static constexpr GrUserStencilSettings kWindingStencilSettings( |
+ GrUserStencilSettings::StaticInit< |
+ 0xffff, |
+ GrUserStencilTest::kAlwaysIfInClip, |
+ 0xffff, |
+ GrUserStencilOp::kIncMaybeClamp, // TODO: Use wrap ops for NVPR. |
+ GrUserStencilOp::kIncMaybeClamp, |
+ 0xffff>() |
); |
- static constexpr GrStencilSettings kEvenODdStencilSettings( |
- kInvert_StencilOp, |
- kInvert_StencilOp, |
- kAlwaysIfInClip_StencilFunc, |
- 0xFFFF, 0xFFFF, 0xFFFF |
+ static constexpr GrUserStencilSettings kEvenOddStencilSettings( |
+ GrUserStencilSettings::StaticInit< |
+ 0xffff, |
+ GrUserStencilTest::kAlwaysIfInClip, |
+ 0xffff, |
+ GrUserStencilOp::kInvert, |
+ GrUserStencilOp::kInvert, |
+ 0xffff>() |
); |
switch (fill) { |
default: |
SkFAIL("Unexpected path fill."); |
case GrPathRendering::kWinding_FillType: |
- *outStencilSettings = kWindingStencilSettings; |
- break; |
+ return kWindingStencilSettings; |
case GrPathRendering::kEvenOdd_FillType: |
- *outStencilSettings = kEvenODdStencilSettings; |
- break; |
+ return kEvenOddStencilSettings; |
} |
- fClipMaskManager->adjustPathStencilParams(sb, outStencilSettings); |
} |
void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder, |
@@ -308,9 +311,8 @@ void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder, |
SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); |
// Setup clip |
- GrPipelineBuilder::AutoRestoreStencil ars; |
GrAppliedClip clip; |
- if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, nullptr, &clip)) { |
+ if (!fClipMaskManager->setupClipping(pipelineBuilder, nullptr, &clip)) { |
return; |
} |
@@ -320,15 +322,15 @@ void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder, |
arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor()); |
} |
- // set stencil settings for path |
- GrStencilSettings stencilSettings; |
GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
- GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt); |
- this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); |
+ GrStencilAttachment* stencilAttachment = fResourceProvider->attachStencilAttachment(rt); |
GrBatch* batch = GrStencilPathBatch::Create(viewMatrix, |
pipelineBuilder.isHWAntialias(), |
- stencilSettings, clip.scissorState(), |
+ get_path_stencil_settings_for_fill(fill), |
+ clip.hasStencilClip(), |
+ stencilAttachment->bits(), |
+ clip.scissorState(), |
pipelineBuilder.getRenderTarget(), |
path); |
this->recordBatch(batch); |
@@ -343,9 +345,8 @@ void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, |
// batches. |
SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); |
- GrPipelineBuilder::AutoRestoreStencil ars; |
GrAppliedClip clip; |
- if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &batch->bounds(), &clip)) { |
+ if (!fClipMaskManager->setupClipping(pipelineBuilder, &batch->bounds(), &clip)) { |
return; |
} |
@@ -356,14 +357,16 @@ void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, |
} |
// Ensure the render target has a stencil buffer and get the stencil settings. |
- GrStencilSettings stencilSettings; |
GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt); |
- this->getPathStencilSettingsForFilltype(batch->fillType(), sb, &stencilSettings); |
- batch->setStencilSettings(stencilSettings); |
+ // TODO: Move this step into GrDrawPathPath::onPrepare(). |
+ batch->setStencilSettings(get_path_stencil_settings_for_fill(batch->fillType()), |
+ clip.hasStencilClip(), |
+ sb->bits()); |
GrPipeline::CreateArgs args; |
- if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip.scissorState(), batch)) { |
+ if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip.scissorState(), |
+ clip.hasStencilClip(), batch)) { |
return; |
} |
@@ -547,11 +550,20 @@ void GrDrawTarget::forwardCombine() { |
bool GrDrawTarget::installPipelineInDrawBatch(const GrPipelineBuilder* pipelineBuilder, |
const GrScissorState* scissor, |
+ bool hasStencilClip, |
GrDrawBatch* batch) { |
GrPipeline::CreateArgs args; |
args.fPipelineBuilder = pipelineBuilder; |
args.fCaps = this->caps(); |
args.fScissor = scissor; |
+ if (pipelineBuilder->hasUserStencilSettings() || hasStencilClip) { |
+ GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); |
+ GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt); |
+ args.fNumStencilBits = sb->bits(); |
+ } else { |
+ args.fNumStencilBits = 0; |
+ } |
+ args.fHasStencilClip = hasStencilClip; |
batch->getPipelineOptimizations(&args.fOpts); |
GrScissorState finalScissor; |
if (args.fOpts.fOverrides.fUsePLSDstRead) { |