Revert of Retract PipelineBuilder some more (patchset #9 id:160001 of https://codereview.chromium.org/2092893003/ )

Reason for revert:
skbug.com/5559

Original issue's description:
> Retract PipelineBuilder some more
>
> The main part of this CL is widening SkDrawContext::drawBatch's API to accept the userStencilSettings & drawFace
>
> There is some ancillary spookiness related to expanding the should_apply_coverage_aa & mustUseHWAA methods to encompass mixedSamples
>
> Calved off:
> https://codereview.chromium.org/2165283002/ (Remove DrawFace enum from GrPipelineBuilder)
> https://codereview.chromium.org/2167183002/ (Minor change to Ganesh path renderers)
>
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2092893003
>
> Committed: https://skia.googlesource.com/skia/+/2895eeb11a9f0d9c0018d49dd4bc45f6c6fc062c

TBR=robertphillips@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review-Url: https://codereview.chromium.org/2175573004
This commit is contained in:
bsalomon 2016-07-22 07:10:19 -07:00 committed by Commit bot
parent 396fcdba14
commit bb24383abb
16 changed files with 109 additions and 58 deletions

View File

@ -44,7 +44,6 @@ struct SkRect;
class SkRRect;
struct SkRSXform;
class SkTextBlob;
struct GrUserStencilSettings;
/*
* A helper object to orchestrate draws
@ -261,8 +260,7 @@ public:
bool hasMixedSamples() const { return fRenderTarget->hasMixedSamples(); }
bool mustUseHWAA(const GrPaint& paint) const {
return paint.isAntiAlias() &&
(fRenderTarget->isUnifiedMultisampled() || fRenderTarget->hasMixedSamples());
return paint.isAntiAlias() && fRenderTarget->isUnifiedMultisampled();
}
const GrSurfaceDesc& desc() const { return fRenderTarget->desc(); }
@ -348,8 +346,7 @@ private:
// This entry point allows the GrTextContext-derived classes to add their batches to
// the drawTarget.
void drawBatch(const GrPaint&, const GrClip&, const GrUserStencilSettings&, GrDrawBatch* batch,
GrDrawFace = GrDrawFace::kBoth);
void drawBatch(const GrPipelineBuilder& pipelineBuilder, const GrClip&, GrDrawBatch* batch);
GrDrawTarget* getDrawTarget();

View File

@ -299,9 +299,9 @@ static bool should_apply_coverage_aa(const GrPaint& paint, GrRenderTarget* rt,
return false;
} else {
if (useHWAA) {
*useHWAA = rt->isUnifiedMultisampled() || rt->hasMixedSamples();
*useHWAA = rt->isUnifiedMultisampled();
}
return !rt->isUnifiedMultisampled() && !rt->hasMixedSamples();
return !rt->isUnifiedMultisampled();
}
}
@ -623,8 +623,8 @@ void GrDrawContext::fillRectToRect(const GrClip& clip,
batch.reset(ir->recordRect(croppedRect, viewMatrix, paint.getColor(), croppedLocalRect,
paint.isAntiAlias(), fInstancedPipelineInfo, &useHWAA));
if (batch) {
SkASSERT(useHWAA == this->mustUseHWAA(paint));
this->drawBatch(paint, clip, GrUserStencilSettings::kUnused, batch);
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
return;
}
}
@ -634,13 +634,15 @@ void GrDrawContext::fillRectToRect(const GrClip& clip,
batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), viewMatrix,
croppedRect, croppedLocalRect));
if (batch) {
SkASSERT(useHWAA == this->mustUseHWAA(paint));
this->drawBatch(paint, clip, GrUserStencilSettings::kUnused, batch);
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
this->drawBatch(pipelineBuilder, clip, batch);
return;
}
} else {
this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, &croppedLocalRect,
nullptr, nullptr);
}
}
void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip,
@ -1240,19 +1242,12 @@ void GrDrawContext::internalDrawPath(const GrClip& clip,
pr->drawPath(args);
}
void GrDrawContext::drawBatch(const GrPaint& paint,
const GrClip& clip,
const GrUserStencilSettings& userStencilSettings,
GrDrawBatch* batch,
GrDrawFace drawFace) {
void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const GrClip& clip,
GrDrawBatch* batch) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch");
GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint));
pipelineBuilder.setUserStencil(&userStencilSettings);
pipelineBuilder.setDrawFace(drawFace);
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
}

View File

@ -11,6 +11,7 @@
#include "GrContext.h"
#include "batches/GrDrawBatch.h"
#include "GrDrawContext.h"
#include "GrPipelineBuilder.h"
#include "GrShape.h"
#include "SkDistanceFieldGen.h"
@ -180,17 +181,18 @@ void GrSWMaskHelper::DrawToTargetWithShapeMask(GrTexture* texture,
maskMatrix.setIDiv(texture->width(), texture->height());
maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop));
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(paint.getColor(),
SkMatrix::I(),
dstRect, nullptr, &invert));
GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint));
pipelineBuilder.setUserStencil(&userStencilSettings);
GrPaint newPaint(paint);
newPaint.addCoverageFragmentProcessor(
pipelineBuilder.addCoverageFragmentProcessor(
GrSimpleTextureEffect::Make(texture,
nullptr,
maskMatrix,
GrTextureParams::kNone_FilterMode,
kDevice_GrCoordSet));
drawContext->drawBatch(newPaint, clip, userStencilSettings, batch);
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(paint.getColor(),
SkMatrix::I(),
dstRect, nullptr, &invert));
drawContext->drawBatch(pipelineBuilder, clip, batch);
}

View File

@ -8,6 +8,7 @@
#include "GrSoftwarePathRenderer.h"
#include "GrAuditTrail.h"
#include "GrClip.h"
#include "GrPipelineBuilder.h"
#include "GrSWMaskHelper.h"
#include "GrTextureProvider.h"
#include "batches/GrRectBatchFactory.h"
@ -72,7 +73,10 @@ void GrSoftwarePathRenderer::DrawNonAARect(GrDrawContext* drawContext,
viewMatrix, rect,
nullptr, &localMatrix));
drawContext->drawBatch(paint, clip, userStencilSettings, batch);
GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint));
pipelineBuilder.setUserStencil(&userStencilSettings);
drawContext->drawBatch(pipelineBuilder, clip, batch);
}
void GrSoftwarePathRenderer::DrawAroundInvPath(GrDrawContext* drawContext,
@ -137,6 +141,7 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
DrawAroundInvPath(args.fDrawContext, *args.fPaint, *args.fUserStencilSettings,
*args.fClip,
*args.fViewMatrix, devClipBounds, devShapeBounds);
}
return true;
}

View File

@ -17,6 +17,7 @@
#include "GrInvariantOutput.h"
#include "GrPathUtils.h"
#include "GrProcessor.h"
#include "GrPipelineBuilder.h"
#include "SkGeometry.h"
#include "SkPathPriv.h"
#include "SkString.h"
@ -1000,7 +1001,10 @@ bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
SkAutoTUnref<GrDrawBatch> batch(new AAConvexPathBatch(args.fPaint->getColor(),
*args.fViewMatrix, path));
args.fDrawContext->drawBatch(*args.fPaint, *args.fClip, *args.fUserStencilSettings, batch);
GrPipelineBuilder pipelineBuilder(*args.fPaint);
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
return true;

View File

@ -11,6 +11,7 @@
#include "GrBatchTest.h"
#include "GrBuffer.h"
#include "GrContext.h"
#include "GrPipelineBuilder.h"
#include "GrResourceProvider.h"
#include "GrSurfacePriv.h"
#include "GrSWMaskHelper.h"
@ -532,7 +533,10 @@ bool GrAADistanceFieldPathRenderer::onDrawPath(const DrawPathArgs& args) {
fAtlas, &fShapeCache, &fShapeList,
args.fGammaCorrect));
args.fDrawContext->drawBatch(*args.fPaint, *args.fClip, *args.fUserStencilSettings, batch);
GrPipelineBuilder pipelineBuilder(*args.fPaint);
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
return true;
}

View File

@ -14,6 +14,7 @@
#include "GrContext.h"
#include "GrDefaultGeoProcFactory.h"
#include "GrPathUtils.h"
#include "GrPipelineBuilder.h"
#include "GrProcessor.h"
#include "GrResourceProvider.h"
#include "SkGeometry.h"
@ -966,7 +967,10 @@ bool GrAAHairLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
*args.fViewMatrix, path,
args.fShape->style(), devClipBounds));
args.fDrawContext->drawBatch(*args.fPaint, *args.fClip, *args.fUserStencilSettings, batch);
GrPipelineBuilder pipelineBuilder(*args.fPaint);
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
return true;
}

View File

@ -16,6 +16,7 @@
#include "GrInvariantOutput.h"
#include "GrPathUtils.h"
#include "GrProcessor.h"
#include "GrPipelineBuilder.h"
#include "GrStyle.h"
#include "SkGeometry.h"
#include "SkString.h"
@ -337,7 +338,11 @@ bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
path, strokeWidth, join,
miterLimit));
args.fDrawContext->drawBatch(*args.fPaint, *args.fClip, *args.fUserStencilSettings, batch);
GrPipelineBuilder pipelineBuilder(*args.fPaint);
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
return true;
}

View File

@ -9,6 +9,7 @@
#include "GrAuditTrail.h"
#include "GrGpu.h"
#include "GrPipelineBuilder.h"
#include "effects/GrDashingEffect.h"
bool GrDashLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
@ -25,15 +26,9 @@ bool GrDashLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
"GrDashLinePathRenderer::onDrawPath");
SkTCopyOnFirstWrite<GrPaint> paint(*args.fPaint);
bool useHWAA = args.fDrawContext->isUnifiedMultisampled();
GrDashingEffect::AAMode aaMode;
if (useHWAA) {
if (!paint->isAntiAlias()) {
paint.writable()->setAntiAlias(true);
}
// We ignore args.fAntiAlias here and force anti aliasing when using MSAA. Otherwise,
// we can wind up with external edges antialiased and internal edges unantialiased.
aaMode = GrDashingEffect::AAMode::kCoverageWithMSAA;
@ -53,7 +48,9 @@ bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
return false;
}
SkASSERT(args.fDrawContext->mustUseHWAA(*paint) == useHWAA);
args.fDrawContext->drawBatch(*paint, *args.fClip, *args.fUserStencilSettings, batch);
GrPipelineBuilder pipelineBuilder(*args.fPaint, useHWAA);
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
return true;
}

View File

@ -13,6 +13,7 @@
#include "GrDefaultGeoProcFactory.h"
#include "GrMesh.h"
#include "GrPathUtils.h"
#include "GrPipelineBuilder.h"
#include "SkGeometry.h"
#include "SkString.h"
#include "SkStrokeRec.h"
@ -554,19 +555,25 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawContext* drawContext,
&localMatrix));
SkASSERT(GrDrawFace::kBoth == drawFace[p]);
drawContext->drawBatch(paint, clip, *passes[p], batch, drawFace[p]);
GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint));
pipelineBuilder.setDrawFace(drawFace[p]);
pipelineBuilder.setUserStencil(passes[p]);
drawContext->drawBatch(pipelineBuilder, clip, batch);
} else {
SkAutoTUnref<GrDrawBatch> batch(new DefaultPathBatch(paint.getColor(), path,
srcSpaceTol,
newCoverage, viewMatrix,
isHairline, devBounds));
SkTCopyOnFirstWrite<GrPaint> newPaint(paint);
GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint));
pipelineBuilder.setDrawFace(drawFace[p]);
pipelineBuilder.setUserStencil(passes[p]);
if (passCount > 1) {
newPaint.writable()->setXPFactory(GrDisableColorXPFactory::Make());
pipelineBuilder.setDisableColorXPFactory();
}
drawContext->drawBatch(*newPaint, clip, *passes[p], batch, drawFace[p]);
drawContext->drawBatch(pipelineBuilder, clip, batch);
}
}
return true;

View File

@ -13,6 +13,7 @@
#include "GrDefaultGeoProcFactory.h"
#include "GrPathStencilSettings.h"
#include "GrPathUtils.h"
#include "GrPipelineBuilder.h"
#include "GrMesh.h"
#include "SkGeometry.h"
#include "SkTraceEvent.h"
@ -656,7 +657,10 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext,
GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewM, bounds, nullptr,
&localMatrix));
drawContext->drawBatch(paint, clip, *passes[p], batch);
GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint));
pipelineBuilder.setUserStencil(passes[p]);
drawContext->drawBatch(pipelineBuilder, clip, batch);
} else {
SkAutoTUnref<MSAAPathBatch> batch(new MSAAPathBatch(paint.getColor(), path,
viewMatrix, devBounds));
@ -664,12 +668,13 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext,
return false;
}
SkTCopyOnFirstWrite<GrPaint> newPaint(paint);
GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint));
pipelineBuilder.setUserStencil(passes[p]);
if (passCount > 1) {
newPaint.writable()->setXPFactory(GrDisableColorXPFactory::Make());
pipelineBuilder.setDisableColorXPFactory();
}
drawContext->drawBatch(*newPaint, clip, *passes[p], batch);
drawContext->drawBatch(pipelineBuilder, clip, batch);
}
}
return true;

View File

@ -22,6 +22,7 @@
#include "GrInvariantOutput.h"
#include "GrPathUtils.h"
#include "GrProcessor.h"
#include "GrPipelineBuilder.h"
#include "GrStyle.h"
#include "GrTessellator.h"
#include "batches/GrVertexBatch.h"
@ -950,7 +951,10 @@ bool GrPLSPathRenderer::onDrawPath(const DrawPathArgs& args) {
SkAutoTUnref<GrDrawBatch> batch(new PLSPathBatch(args.fPaint->getColor(),
path, *args.fViewMatrix));
args.fDrawContext->drawBatch(*args.fPaint, *args.fClip, *args.fUserStencilSettings, batch);
GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fDrawContext->mustUseHWAA(*args.fPaint));
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
SkDEBUGCODE(inPLSDraw = false;)
return true;

View File

@ -13,6 +13,7 @@
#include "GrDrawPathBatch.h"
#include "GrGpu.h"
#include "GrPath.h"
#include "GrPipelineBuilder.h"
#include "GrRenderTarget.h"
#include "GrResourceProvider.h"
#include "GrStencilPathBatch.h"
@ -136,9 +137,14 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
GrRectBatchFactory::CreateNonAAFill(args.fPaint->getColor(), viewM, bounds,
nullptr, &invert));
SkASSERT(args.fDrawContext->mustUseHWAA(*args.fPaint) ==
(args.fPaint->isAntiAlias() && !args.fDrawContext->hasMixedSamples()));
args.fDrawContext->drawBatch(*args.fPaint, *args.fClip, kInvertedCoverPass, coverBatch);
{
GrPipelineBuilder pipelineBuilder(*args.fPaint,
args.fPaint->isAntiAlias() &&
!args.fDrawContext->hasMixedSamples());
pipelineBuilder.setUserStencil(&kInvertedCoverPass);
args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, coverBatch);
}
} else {
static constexpr GrUserStencilSettings kCoverPass(
GrUserStencilSettings::StaticInit<
@ -153,9 +159,14 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
SkAutoTUnref<GrDrawBatch> batch(
GrDrawPathBatch::Create(viewMatrix, args.fPaint->getColor(), p->getFillType(), p));
SkASSERT(args.fDrawContext->mustUseHWAA(*args.fPaint) ==
(args.fPaint->isAntiAlias() || args.fAntiAlias));
args.fDrawContext->drawBatch(*args.fPaint, *args.fClip, kCoverPass, batch);
GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fPaint->isAntiAlias());
pipelineBuilder.setUserStencil(&kCoverPass);
if (args.fAntiAlias) {
SkASSERT(args.fDrawContext->isStencilBufferMultisampled());
pipelineBuilder.enableState(GrPipelineBuilder::kHWAntialias_Flag);
}
args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
}
return true;

View File

@ -14,6 +14,7 @@
#include "GrDefaultGeoProcFactory.h"
#include "GrMesh.h"
#include "GrPathUtils.h"
#include "GrPipelineBuilder.h"
#include "GrResourceCache.h"
#include "GrResourceProvider.h"
#include "GrTessellator.h"
@ -271,7 +272,10 @@ bool GrTessellatingPathRenderer::onDrawPath(const DrawPathArgs& args) {
*args.fShape,
*args.fViewMatrix, clipBounds));
args.fDrawContext->drawBatch(*args.fPaint, *args.fClip, *args.fUserStencilSettings, batch);
GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fDrawContext->mustUseHWAA(*args.fPaint));
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
return true;
}

View File

@ -10,6 +10,7 @@
#include "GrBlurUtils.h"
#include "GrContext.h"
#include "GrDrawContext.h"
#include "GrPipelineBuilder.h"
#include "GrTextUtils.h"
#include "SkColorFilter.h"
#include "SkDrawFilter.h"
@ -323,7 +324,9 @@ void GrAtlasTextBlob::flushRun(GrDrawContext* dc, const GrPaint& grPaint,
distanceAdjustTable, dc->isGammaCorrect(),
cache));
dc->drawBatch(grPaint, clip, GrUserStencilSettings::kUnused, batch);
GrPipelineBuilder pipelineBuilder(grPaint, dc->mustUseHWAA(grPaint));
dc->drawBatch(pipelineBuilder, clip, batch);
}
}

View File

@ -11,6 +11,7 @@
#include "GrDrawContext.h"
#include "GrPath.h"
#include "GrPathRange.h"
#include "GrPipelineBuilder.h"
#include "GrResourceProvider.h"
#include "GrTextUtils.h"
#include "SkAutoKern.h"
@ -642,8 +643,11 @@ void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx,
GrPathRendering::kWinding_FillType, glyphs, fInstanceData,
bounds));
SkASSERT(drawContext->mustUseHWAA(grPaint) == grPaint.isAntiAlias());
drawContext->drawBatch(grPaint, clip, kCoverPass, batch);
GrPipelineBuilder pipelineBuilder(grPaint);
pipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_Flag, grPaint.isAntiAlias());
pipelineBuilder.setUserStencil(&kCoverPass);
drawContext->drawBatch(pipelineBuilder, clip, batch);
}
if (fFallbackTextBlob) {