Separate user and raw stencil settings
Adds a new GrUserStencilSettings class that describes in abstract terms
how a draw will use the stencil (e.g. kAlwaysIfInClip, kSetClipBit,
etc.). GrPipelineBuilder now only defines the GrUserStencilSettings.
When the GrPipeline is finalized, the user stencil settings are then
translated into concrete GrStencilSettings.
At this point, GrClipMaskManager only needs to tell the GrAppliedClip
whether or not there is a stencil clip. It does not need to modify
stencil settings and GrPipelineBuilder does not need
AutoRestoreStencil.
This is one step of the stencil overhaul. In the future it will also
allow us to clean up the special case handling for nvpr and the
stateful fClipMode member of GrClipMaskManager.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1962243002
Committed: https://skia.googlesource.com/skia/+/12dbb3947e1aaf205b4fcf13b40e54e50650eb37
Review-Url: https://codereview.chromium.org/1962243002
diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp
index 8d384ef..761a876 100644
--- a/src/gpu/GrPipeline.cpp
+++ b/src/gpu/GrPipeline.cpp
@@ -20,9 +20,35 @@
GrXPOverridesForBatch* overrides) {
const GrPipelineBuilder& builder = *args.fPipelineBuilder;
+ GrPipeline* pipeline = new (memory) GrPipeline;
+ pipeline->fRenderTarget.reset(builder.fRenderTarget.get());
+ SkASSERT(pipeline->fRenderTarget);
+ pipeline->fScissorState = *args.fScissor;
+ if (builder.hasUserStencilSettings() || args.fHasStencilClip) {
+ SkASSERT(args.fNumStencilBits);
+ pipeline->fStencilSettings.reset(*builder.getUserStencil(), args.fHasStencilClip,
+ args.fNumStencilBits);
+ SkASSERT(!pipeline->fStencilSettings.usesWrapOp() || args.fCaps->stencilWrapOpsSupport());
+ }
+ pipeline->fDrawFace = builder.getDrawFace();
+
+ pipeline->fFlags = 0;
+ if (builder.isHWAntialias()) {
+ pipeline->fFlags |= kHWAA_Flag;
+ }
+ if (builder.snapVerticesToPixelCenters()) {
+ pipeline->fFlags |= kSnapVertices_Flag;
+ }
+ if (builder.getDisableOutputConversionToSRGB()) {
+ pipeline->fFlags |= kDisableOutputConversionToSRGB_Flag;
+ }
+ if (builder.getAllowSRGBInputs()) {
+ pipeline->fFlags |= kAllowSRGBInputs_Flag;
+ }
+
// Create XferProcessor from DS's XPFactory
bool hasMixedSamples = builder.getRenderTarget()->hasMixedSamples() &&
- (builder.isHWAntialias() || !builder.getStencil().isDisabled());
+ (builder.isHWAntialias() || !pipeline->fStencilSettings.isDisabled());
const GrXPFactory* xpFactory = builder.getXPFactory();
SkAutoTUnref<GrXferProcessor> xferProcessor;
if (xpFactory) {
@@ -31,6 +57,7 @@
&args.fDstTexture,
*args.fCaps));
if (!xferProcessor) {
+ pipeline->~GrPipeline();
return nullptr;
}
} else {
@@ -51,7 +78,7 @@
const GrXferProcessor* xpForOpts = xferProcessor ? xferProcessor.get() :
&GrPorterDuffXPFactory::SimpleSrcOverXP();
optFlags = xpForOpts->getOptimizations(args.fOpts,
- builder.getStencil().doesWrite(),
+ pipeline->fStencilSettings.doesWrite(),
&overrideColor,
*args.fCaps);
@@ -59,6 +86,7 @@
// so we must check the draw type. In cases where we will skip drawing we simply return a
// null GrPipeline.
if (GrXferProcessor::kSkipDraw_OptFlag & optFlags) {
+ pipeline->~GrPipeline();
return nullptr;
}
@@ -67,29 +95,8 @@
overrideColor = GrColor_ILLEGAL;
}
- GrPipeline* pipeline = new (memory) GrPipeline;
pipeline->fXferProcessor.reset(xferProcessor);
- pipeline->fRenderTarget.reset(builder.fRenderTarget.get());
- SkASSERT(pipeline->fRenderTarget);
- pipeline->fScissorState = *args.fScissor;
- pipeline->fStencilSettings = builder.getStencil();
- pipeline->fDrawFace = builder.getDrawFace();
-
- pipeline->fFlags = 0;
- if (builder.isHWAntialias()) {
- pipeline->fFlags |= kHWAA_Flag;
- }
- if (builder.snapVerticesToPixelCenters()) {
- pipeline->fFlags |= kSnapVertices_Flag;
- }
- if (builder.getDisableOutputConversionToSRGB()) {
- pipeline->fFlags |= kDisableOutputConversionToSRGB_Flag;
- }
- if (builder.getAllowSRGBInputs()) {
- pipeline->fFlags |= kAllowSRGBInputs_Flag;
- }
-
int firstColorProcessorIdx = args.fOpts.fColorPOI.firstEffectiveProcessorIndex();
// TODO: Once we can handle single or four channel input into coverage GrFragmentProcessors