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
This commit is contained in:
robertphillips 2016-07-11 10:43:58 -07:00 committed by Commit bot
parent 00dd4538a5
commit 8e375309ca

View File

@ -567,9 +567,10 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext,
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 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext,
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 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext,
passes[1] = &gEOColorPass;
}
}
drawFace[0] = drawFace[1] = GrPipelineBuilder::kBoth_DrawFace;
break;
case SkPath::kInverseWinding_FillType:
@ -610,17 +609,15 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext,
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 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext,
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 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext,
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);
}
drawContext->drawBatch(pipelineBuilder, clip, batch);
} else {
@ -676,12 +669,7 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext,
}
GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint));
pipelineBuilder.setDrawFace(drawFace[p]);
if (passes[p]) {
pipelineBuilder.setUserStencil(passes[p]);
} else {
pipelineBuilder.setUserStencil(userStencilSettings);
}
if (passCount > 1) {
pipelineBuilder.setDisableColorXPFactory();
}