Simplify MSAA path renderer
This simplification is based on the observations that:
there were never more than 2 passes
the only time passes[] was null was the single-pass, !stencilOnly case
only kBoth_DrawFace was was ever used
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2135053002
Review-Url: https://codereview.chromium.org/2135053002
diff --git a/src/gpu/batches/GrMSAAPathRenderer.cpp b/src/gpu/batches/GrMSAAPathRenderer.cpp
index d38d886..39b924c 100644
--- a/src/gpu/batches/GrMSAAPathRenderer.cpp
+++ b/src/gpu/batches/GrMSAAPathRenderer.cpp
@@ -567,9 +567,10 @@
SkPath path;
shape.asPath(&path);
+ static const int kMaxNumPasses = 2;
+
int passCount = 0;
- const GrUserStencilSettings* passes[3];
- GrPipelineBuilder::DrawFace drawFace[3];
+ const GrUserStencilSettings* passes[kMaxNumPasses];
bool reverse = false;
bool lastPassIsBounds;
@@ -578,9 +579,8 @@
if (stencilOnly) {
passes[0] = &gDirectToStencil;
} else {
- passes[0] = nullptr;
+ passes[0] = userStencilSettings;
}
- drawFace[0] = GrPipelineBuilder::kBoth_DrawFace;
lastPassIsBounds = false;
} else {
switch (path.getFillType()) {
@@ -601,7 +601,6 @@
passes[1] = &gEOColorPass;
}
}
- drawFace[0] = drawFace[1] = GrPipelineBuilder::kBoth_DrawFace;
break;
case SkPath::kInverseWinding_FillType:
@@ -610,17 +609,15 @@
case SkPath::kWinding_FillType:
passes[0] = &gWindStencilSeparateWithWrap;
passCount = 2;
- drawFace[0] = GrPipelineBuilder::kBoth_DrawFace;
if (stencilOnly) {
lastPassIsBounds = false;
- --passCount;
+ passCount = 1;
} else {
lastPassIsBounds = true;
- drawFace[passCount-1] = GrPipelineBuilder::kBoth_DrawFace;
if (reverse) {
- passes[passCount-1] = &gInvWindColorPass;
+ passes[1] = &gInvWindColorPass;
} else {
- passes[passCount-1] = &gWindColorPass;
+ passes[1] = &gWindColorPass;
}
}
break;
@@ -633,6 +630,8 @@
SkRect devBounds;
GetPathDevBounds(path, drawContext->width(), drawContext->height(), viewMatrix, &devBounds);
+ SkASSERT(passCount <= kMaxNumPasses);
+
for (int p = 0; p < passCount; ++p) {
if (lastPassIsBounds && (p == passCount-1)) {
SkRect bounds;
@@ -658,14 +657,8 @@
GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewM, bounds, nullptr,
&localMatrix));
- SkASSERT(GrPipelineBuilder::kBoth_DrawFace == drawFace[p]);
GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint));
- pipelineBuilder.setDrawFace(drawFace[p]);
- if (passes[p]) {
- pipelineBuilder.setUserStencil(passes[p]);
- } else {
- pipelineBuilder.setUserStencil(userStencilSettings);
- }
+ pipelineBuilder.setUserStencil(passes[p]);
drawContext->drawBatch(pipelineBuilder, clip, batch);
} else {
@@ -676,12 +669,7 @@
}
GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint));
- pipelineBuilder.setDrawFace(drawFace[p]);
- if (passes[p]) {
- pipelineBuilder.setUserStencil(passes[p]);
- } else {
- pipelineBuilder.setUserStencil(userStencilSettings);
- }
+ pipelineBuilder.setUserStencil(passes[p]);
if (passCount > 1) {
pipelineBuilder.setDisableColorXPFactory();
}