diff options
author | csmartdalton <csmartdalton@google.com> | 2016-06-08 10:08:43 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-08 10:08:43 -0700 |
commit | ecbc12b1c1c72de0cf7bba4a3f6a7cce4f43bf41 (patch) | |
tree | 82d33bb0118105ba8da507f814257b3ed44f434b | |
parent | 5c7d62d431a0ad7988f05fbdb206237729c0c308 (diff) |
Replace targetHasUnifiedMultisampling in GrPB constructor
Replaces targetHasUnifiedMultisampling with a simpler "useHWAA". Now
the code that creates a pipeline builder needs to decide on its own
whether it should enable multisampling, rather than relying on the
builder to try and guess.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2041283002
Review-Url: https://codereview.chromium.org/2041283002
-rw-r--r-- | gm/constcolorprocessor.cpp | 3 | ||||
-rw-r--r-- | include/gpu/GrDrawContext.h | 16 | ||||
-rw-r--r-- | src/gpu/GrDrawContext.cpp | 87 | ||||
-rw-r--r-- | src/gpu/GrPipelineBuilder.cpp | 5 | ||||
-rw-r--r-- | src/gpu/GrPipelineBuilder.h | 2 | ||||
-rw-r--r-- | src/gpu/GrSWMaskHelper.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrSoftwarePathRenderer.cpp | 2 | ||||
-rw-r--r-- | src/gpu/batches/GrAAConvexPathRenderer.cpp | 4 | ||||
-rw-r--r-- | src/gpu/batches/GrAADistanceFieldPathRenderer.cpp | 4 | ||||
-rw-r--r-- | src/gpu/batches/GrAAHairLinePathRenderer.cpp | 4 | ||||
-rw-r--r-- | src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp | 4 | ||||
-rw-r--r-- | src/gpu/batches/GrDashLinePathRenderer.cpp | 3 | ||||
-rw-r--r-- | src/gpu/batches/GrDefaultPathRenderer.cpp | 4 | ||||
-rw-r--r-- | src/gpu/batches/GrMSAAPathRenderer.cpp | 4 | ||||
-rw-r--r-- | src/gpu/batches/GrPLSPathRenderer.cpp | 2 | ||||
-rw-r--r-- | src/gpu/batches/GrStencilAndCoverPathRenderer.cpp | 28 | ||||
-rw-r--r-- | src/gpu/batches/GrTessellatingPathRenderer.cpp | 2 | ||||
-rw-r--r-- | src/gpu/text/GrAtlasTextBlob.cpp | 4 | ||||
-rw-r--r-- | src/gpu/text/GrStencilAndCoverTextContext.cpp | 6 |
19 files changed, 93 insertions, 93 deletions
diff --git a/gm/constcolorprocessor.cpp b/gm/constcolorprocessor.cpp index 57f17b2975..ce2ae6e9fd 100644 --- a/gm/constcolorprocessor.cpp +++ b/gm/constcolorprocessor.cpp @@ -107,8 +107,7 @@ protected: GrColor color = kColors[procColor]; SkAutoTUnref<GrFragmentProcessor> fp(GrConstColorProcessor::Create(color, mode)); - GrPipelineBuilder pipelineBuilder(grPaint, - drawContext->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(grPaint, drawContext->mustUseHWAA(grPaint)); pipelineBuilder.addColorFragmentProcessor(fp); SkAutoTUnref<GrDrawBatch> batch( diff --git a/include/gpu/GrDrawContext.h b/include/gpu/GrDrawContext.h index c4818e5d71..f56570b10b 100644 --- a/include/gpu/GrDrawContext.h +++ b/include/gpu/GrDrawContext.h @@ -9,6 +9,7 @@ #define GrDrawContext_DEFINED #include "GrColor.h" +#include "GrPaint.h" #include "GrRenderTarget.h" #include "SkRefCnt.h" #include "SkRegion.h" @@ -250,20 +251,16 @@ public: const SkIRect& center, const SkRect& dst); - /** - * Draws a batch - * - * @param paint describes how to color pixels. - * @param batch the batch to draw - */ - void drawBatch(const GrClip&, const GrPaint&, GrDrawBatch*); - bool isStencilBufferMultisampled() const { return fRenderTarget->isStencilBufferMultisampled(); } bool isUnifiedMultisampled() const { return fRenderTarget->isUnifiedMultisampled(); } bool hasMixedSamples() const { return fRenderTarget->hasMixedSamples(); } + bool mustUseHWAA(const GrPaint& paint) const { + return paint.isAntiAlias() && fRenderTarget->isUnifiedMultisampled(); + } + const GrSurfaceDesc& desc() const { return fRenderTarget->desc(); } int width() const { return fRenderTarget->width(); } int height() const { return fRenderTarget->height(); } @@ -326,7 +323,8 @@ private: GrDrawBatch* getFillRectBatch(const GrPaint& paint, const SkMatrix& viewMatrix, - const SkRect& rect); + const SkRect& rect, + bool* useHWAA); void internalDrawPath(const GrClip& clip, const GrPaint& paint, diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp index 263f0c8ddd..2f78d1e4f6 100644 --- a/src/gpu/GrDrawContext.cpp +++ b/src/gpu/GrDrawContext.cpp @@ -240,7 +240,7 @@ void GrDrawContext::drawPaint(const GrClip& clip, SkAutoTUnref<GrDrawBatch> batch( GrRectBatchFactory::CreateNonAAFill(paint->getColor(), SkMatrix::I(), r, nullptr, &localMatrix)); - GrPipelineBuilder pipelineBuilder(*paint, this->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(*paint); // Create a pipeline builder without hwaa. this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); } } @@ -254,16 +254,28 @@ static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) { return viewMatrix.preservesRightAngles(); } -static bool should_apply_coverage_aa(const GrPaint& paint, GrRenderTarget* rt) { - return paint.isAntiAlias() && !rt->isUnifiedMultisampled(); +static bool should_apply_coverage_aa(const GrPaint& paint, GrRenderTarget* rt, + bool* useHWAA = nullptr) { + if (!paint.isAntiAlias()) { + if (useHWAA) { + *useHWAA = false; + } + return false; + } else { + if (useHWAA) { + *useHWAA = rt->isUnifiedMultisampled(); + } + return !rt->isUnifiedMultisampled(); + } } GrDrawBatch* GrDrawContext::getFillRectBatch(const GrPaint& paint, const SkMatrix& viewMatrix, - const SkRect& rect) { + const SkRect& rect, + bool* useHWAA) { GrDrawBatch* batch = nullptr; - if (should_apply_coverage_aa(paint, fRenderTarget.get())) { + if (should_apply_coverage_aa(paint, fRenderTarget.get(), useHWAA)) { // The fill path can handle rotation but not skew. if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { SkRect devBoundRect; @@ -329,14 +341,15 @@ void GrDrawContext::drawRect(const GrClip& clip, } } + bool useHWAA; bool snapToPixelCenters = false; SkAutoTUnref<GrDrawBatch> batch; if (width < 0) { - batch.reset(this->getFillRectBatch(paint, viewMatrix, rect)); + batch.reset(this->getFillRectBatch(paint, viewMatrix, rect, &useHWAA)); } else { GrColor color = paint.getColor(); - if (should_apply_coverage_aa(paint, fRenderTarget.get())) { + if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) { // The stroke path needs the rect to remain axis aligned (no rotation or skew). if (viewMatrix.rectStaysRect()) { batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix, rect, @@ -356,7 +369,7 @@ void GrDrawContext::drawRect(const GrClip& clip, } if (batch) { - GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint, useHWAA); if (snapToPixelCenters) { pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_Flag, @@ -409,10 +422,12 @@ void GrDrawContextPriv::stencilRect(const GrFixedClip& clip, paint.setAntiAlias(doAA); SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create())); - SkAutoTUnref<GrDrawBatch> batch(fDrawContext->getFillRectBatch(paint, viewMatrix, rect)); + bool useHWAA; + SkAutoTUnref<GrDrawBatch> batch( + fDrawContext->getFillRectBatch(paint, viewMatrix, rect, &useHWAA)); SkASSERT(batch); - GrPipelineBuilder pipelineBuilder(paint, fDrawContext->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint, useHWAA); pipelineBuilder.setUserStencil(ss); fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, fDrawContext, clip, batch); @@ -436,9 +451,11 @@ bool GrDrawContextPriv::drawAndStencilRect(const GrFixedClip& clip, paint.setAntiAlias(doAA); paint.setCoverageSetOpXPFactory(op, invert); - SkAutoTUnref<GrDrawBatch> batch(fDrawContext->getFillRectBatch(paint, viewMatrix, rect)); + bool useHWAA; + SkAutoTUnref<GrDrawBatch> batch( + fDrawContext->getFillRectBatch(paint, viewMatrix, rect, &useHWAA)); if (batch) { - GrPipelineBuilder pipelineBuilder(paint, fDrawContext->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint, useHWAA); pipelineBuilder.setUserStencil(ss); fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, fDrawContext, clip, batch); @@ -463,8 +480,9 @@ void GrDrawContext::fillRectToRect(const GrClip& clip, AutoCheckFlush acf(fDrawingManager); + bool useHWAA; SkAutoTUnref<GrDrawBatch> batch; - if (should_apply_coverage_aa(paint, fRenderTarget.get()) && + if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA) && view_matrix_ok_for_aa_fill_rect(viewMatrix)) { batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), viewMatrix, rectToDraw, localRect)); @@ -474,7 +492,7 @@ void GrDrawContext::fillRectToRect(const GrClip& clip, } if (batch) { - GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint, useHWAA); this->drawBatch(pipelineBuilder, clip, batch); } } @@ -491,8 +509,9 @@ void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, AutoCheckFlush acf(fDrawingManager); + bool useHWAA; SkAutoTUnref<GrDrawBatch> batch; - if (should_apply_coverage_aa(paint, fRenderTarget.get()) && + if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA) && view_matrix_ok_for_aa_fill_rect(viewMatrix)) { batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, localMatrix, rectToDraw)); @@ -501,7 +520,7 @@ void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, nullptr, &localMatrix)); } - GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint, useHWAA); this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); } @@ -546,7 +565,7 @@ void GrDrawContext::drawVertices(const GrClip& clip, indexCount, colors, texCoords, bounds)); - GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint)); this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); } @@ -571,7 +590,7 @@ void GrDrawContext::drawAtlas(const GrClip& clip, SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatrix, spriteCount, xform, texRect, colors)); - GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint)); this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); } @@ -595,7 +614,8 @@ void GrDrawContext::drawRRect(const GrClip& clip, const SkStrokeRec stroke = style.strokeRec(); AutoCheckFlush acf(fDrawingManager); - if (should_apply_coverage_aa(paint, fRenderTarget.get())) { + bool useHWAA; + if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) { GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateRRectBatch(paint.getColor(), @@ -604,7 +624,7 @@ void GrDrawContext::drawRRect(const GrClip& clip, stroke, shaderCaps)); if (batch) { - GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint, useHWAA); this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); return; } @@ -721,7 +741,8 @@ void GrDrawContext::drawOval(const GrClip& clip, AutoCheckFlush acf(fDrawingManager); const SkStrokeRec& stroke = style.strokeRec(); - if (should_apply_coverage_aa(paint, fRenderTarget.get())) { + bool useHWAA; + if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) { GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(paint.getColor(), viewMatrix, @@ -729,7 +750,7 @@ void GrDrawContext::drawOval(const GrClip& clip, stroke, shaderCaps)); if (batch) { - GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint, useHWAA); this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); return; } @@ -759,7 +780,7 @@ void GrDrawContext::drawImageNine(const GrClip& clip, imageWidth, imageHeight, center, dst)); - GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint)); this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); } @@ -810,19 +831,6 @@ static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path return allEq || allGoE1; } -void GrDrawContext::drawBatch(const GrClip& clip, - const GrPaint& paint, GrDrawBatch* batch) { - ASSERT_SINGLE_OWNER - RETURN_IF_ABANDONED - SkDEBUGCODE(this->validate();) - GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); - - AutoCheckFlush acf(fDrawingManager); - - GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); - this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); -} - void GrDrawContext::drawPath(const GrClip& clip, const GrPaint& paint, const SkMatrix& viewMatrix, @@ -842,7 +850,8 @@ void GrDrawContext::drawPath(const GrClip& clip, AutoCheckFlush acf(fDrawingManager); - if (should_apply_coverage_aa(paint, fRenderTarget.get()) && !style.pathEffect()) { + bool useHWAA; + if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA) && !style.pathEffect()) { if (style.isSimpleFill() && !path.isConvex()) { // Concave AA paths are expensive - try to avoid them for special cases SkRect rects[2]; @@ -851,7 +860,7 @@ void GrDrawContext::drawPath(const GrClip& clip, SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFillNestedRects( paint.getColor(), viewMatrix, rects)); if (batch) { - GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint, useHWAA); this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); } return; @@ -868,7 +877,7 @@ void GrDrawContext::drawPath(const GrClip& clip, style.strokeRec(), shaderCaps)); if (batch) { - GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint, useHWAA); this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); return; } diff --git a/src/gpu/GrPipelineBuilder.cpp b/src/gpu/GrPipelineBuilder.cpp index 04967a780b..f7848ba9d6 100644 --- a/src/gpu/GrPipelineBuilder.cpp +++ b/src/gpu/GrPipelineBuilder.cpp @@ -22,7 +22,7 @@ GrPipelineBuilder::GrPipelineBuilder() SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) } -GrPipelineBuilder::GrPipelineBuilder(const GrPaint& paint, bool targetHasUnifiedMultisampling) +GrPipelineBuilder::GrPipelineBuilder(const GrPaint& paint, bool useHWAA) : GrPipelineBuilder() { SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) @@ -36,8 +36,7 @@ GrPipelineBuilder::GrPipelineBuilder(const GrPaint& paint, bool targetHasUnified fXPFactory.reset(SkSafeRef(paint.getXPFactory())); - this->setState(GrPipelineBuilder::kHWAntialias_Flag, - targetHasUnifiedMultisampling && paint.isAntiAlias()); + this->setState(GrPipelineBuilder::kHWAntialias_Flag, useHWAA); this->setState(GrPipelineBuilder::kDisableOutputConversionToSRGB_Flag, paint.getDisableOutputConversionToSRGB()); this->setState(GrPipelineBuilder::kAllowSRGBInputs_Flag, diff --git a/src/gpu/GrPipelineBuilder.h b/src/gpu/GrPipelineBuilder.h index 68e70ac6b9..cccbc2c47d 100644 --- a/src/gpu/GrPipelineBuilder.h +++ b/src/gpu/GrPipelineBuilder.h @@ -36,7 +36,7 @@ public: * no GrPaint equivalents are set to default values with the exception of vertex attribute state * which is unmodified by this function and clipping which will be enabled. */ - GrPipelineBuilder(const GrPaint&, bool targetHasUnifiedMultisampling); + GrPipelineBuilder(const GrPaint&, bool useHWAA = false); virtual ~GrPipelineBuilder(); diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp index a0ab7add3e..05e270f213 100644 --- a/src/gpu/GrSWMaskHelper.cpp +++ b/src/gpu/GrSWMaskHelper.cpp @@ -185,7 +185,7 @@ void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture, maskMatrix.setIDiv(texture->width(), texture->height()); maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop)); - GrPipelineBuilder pipelineBuilder(*paint, drawContext->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(*paint, drawContext->mustUseHWAA(*paint)); pipelineBuilder.setUserStencil(userStencilSettings); pipelineBuilder.addCoverageFragmentProcessor( diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp index 4bc592d3a6..fd25bbbca2 100644 --- a/src/gpu/GrSoftwarePathRenderer.cpp +++ b/src/gpu/GrSoftwarePathRenderer.cpp @@ -70,7 +70,7 @@ void GrSoftwarePathRenderer::DrawNonAARect(GrDrawContext* drawContext, SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, viewMatrix, rect, nullptr, &localMatrix)); - GrPipelineBuilder pipelineBuilder(*paint, drawContext->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(*paint, drawContext->mustUseHWAA(*paint)); pipelineBuilder.setUserStencil(userStencilSettings); drawContext->drawBatch(pipelineBuilder, clip, batch); diff --git a/src/gpu/batches/GrAAConvexPathRenderer.cpp b/src/gpu/batches/GrAAConvexPathRenderer.cpp index ef6c0ae659..e875f1c3ec 100644 --- a/src/gpu/batches/GrAAConvexPathRenderer.cpp +++ b/src/gpu/batches/GrAAConvexPathRenderer.cpp @@ -997,6 +997,8 @@ private: bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), "GrAAConvexPathRenderer::onDrawPath"); + SkASSERT(!args.fDrawContext->isUnifiedMultisampled()); + if (args.fPath->isEmpty()) { return true; } @@ -1008,7 +1010,7 @@ bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { SkAutoTUnref<GrDrawBatch> batch(AAConvexPathBatch::Create(geometry)); - GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fDrawContext->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(*args.fPaint); pipelineBuilder.setUserStencil(args.fUserStencilSettings); args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch); diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp index 9a5eada4b4..ed9902ca33 100644 --- a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp +++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp @@ -530,6 +530,8 @@ private: bool GrAADistanceFieldPathRenderer::onDrawPath(const DrawPathArgs& args) { GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), "GrAADistanceFieldPathRenderer::onDrawPath"); + SkASSERT(!args.fDrawContext->isUnifiedMultisampled()); + // we've already bailed on inverse filled paths, so this is safe if (args.fPath->isEmpty()) { return true; @@ -565,7 +567,7 @@ bool GrAADistanceFieldPathRenderer::onDrawPath(const DrawPathArgs& args) { &fPathCache, &fPathList, args.fGammaCorrect)); - GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fDrawContext->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(*args.fPaint); pipelineBuilder.setUserStencil(args.fUserStencilSettings); args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch); diff --git a/src/gpu/batches/GrAAHairLinePathRenderer.cpp b/src/gpu/batches/GrAAHairLinePathRenderer.cpp index 2faf1afa14..ac5ecc1614 100644 --- a/src/gpu/batches/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/batches/GrAAHairLinePathRenderer.cpp @@ -965,6 +965,8 @@ static GrDrawBatch* create_hairline_batch(GrColor color, bool GrAAHairLinePathRenderer::onDrawPath(const DrawPathArgs& args) { GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), "GrAAHairlinePathRenderer::onDrawPath"); + SkASSERT(!args.fDrawContext->isUnifiedMultisampled()); + SkIRect devClipBounds; args.fClip->getConservativeBounds(args.fDrawContext->width(), args.fDrawContext->height(), &devClipBounds); @@ -972,7 +974,7 @@ bool GrAAHairLinePathRenderer::onDrawPath(const DrawPathArgs& args) { SkAutoTUnref<GrDrawBatch> batch(create_hairline_batch(args.fColor, *args.fViewMatrix, *args.fPath, *args.fStyle, devClipBounds)); - GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fDrawContext->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(*args.fPaint); pipelineBuilder.setUserStencil(args.fUserStencilSettings); args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch); diff --git a/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp index a3e00d1b7a..227f86bf77 100644 --- a/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp +++ b/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp @@ -322,6 +322,8 @@ private: bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), "GrAALinearizingConvexPathRenderer::onDrawPath"); + SkASSERT(!args.fDrawContext->isUnifiedMultisampled()); + if (args.fPath->isEmpty()) { return true; } @@ -336,7 +338,7 @@ bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { SkAutoTUnref<GrDrawBatch> batch(AAFlatteningConvexPathBatch::Create(geometry)); - GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fDrawContext->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(*args.fPaint); pipelineBuilder.setUserStencil(args.fUserStencilSettings); args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch); diff --git a/src/gpu/batches/GrDashLinePathRenderer.cpp b/src/gpu/batches/GrDashLinePathRenderer.cpp index d5be49d439..a442b66559 100644 --- a/src/gpu/batches/GrDashLinePathRenderer.cpp +++ b/src/gpu/batches/GrDashLinePathRenderer.cpp @@ -44,8 +44,7 @@ bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) { return false; } - GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fDrawContext->isUnifiedMultisampled()); - pipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_Flag, useHWAA); + GrPipelineBuilder pipelineBuilder(*args.fPaint, useHWAA); pipelineBuilder.setUserStencil(args.fUserStencilSettings); args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch); diff --git a/src/gpu/batches/GrDefaultPathRenderer.cpp b/src/gpu/batches/GrDefaultPathRenderer.cpp index bab39ee7e8..c643c49e48 100644 --- a/src/gpu/batches/GrDefaultPathRenderer.cpp +++ b/src/gpu/batches/GrDefaultPathRenderer.cpp @@ -562,7 +562,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawContext* drawContext, GrRectBatchFactory::CreateNonAAFill(color, viewM, bounds, nullptr, &localMatrix)); - GrPipelineBuilder pipelineBuilder(paint, drawContext->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint)); pipelineBuilder.setDrawFace(drawFace[p]); if (passes[p]) { pipelineBuilder.setUserStencil(passes[p]); @@ -581,7 +581,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawContext* drawContext, viewMatrix, isHairline, devBounds)); - GrPipelineBuilder pipelineBuilder(paint, drawContext->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint)); pipelineBuilder.setDrawFace(drawFace[p]); if (passes[p]) { pipelineBuilder.setUserStencil(passes[p]); diff --git a/src/gpu/batches/GrMSAAPathRenderer.cpp b/src/gpu/batches/GrMSAAPathRenderer.cpp index 45971f568d..cd2713e98d 100644 --- a/src/gpu/batches/GrMSAAPathRenderer.cpp +++ b/src/gpu/batches/GrMSAAPathRenderer.cpp @@ -667,7 +667,7 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext, GrRectBatchFactory::CreateNonAAFill(color, viewM, bounds, nullptr, &localMatrix)); - GrPipelineBuilder pipelineBuilder(paint, drawContext->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint)); pipelineBuilder.setDrawFace(drawFace[p]); if (passes[p]) { pipelineBuilder.setUserStencil(passes[p]); @@ -688,7 +688,7 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext, return false; } - GrPipelineBuilder pipelineBuilder(paint, drawContext->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint)); pipelineBuilder.setDrawFace(drawFace[p]); if (passes[p]) { pipelineBuilder.setUserStencil(passes[p]); diff --git a/src/gpu/batches/GrPLSPathRenderer.cpp b/src/gpu/batches/GrPLSPathRenderer.cpp index 79da83c652..a81b8831ed 100644 --- a/src/gpu/batches/GrPLSPathRenderer.cpp +++ b/src/gpu/batches/GrPLSPathRenderer.cpp @@ -986,7 +986,7 @@ bool GrPLSPathRenderer::onDrawPath(const DrawPathArgs& args) { SkAutoTUnref<GrDrawBatch> batch(PLSPathBatch::Create(geometry)); - GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fDrawContext->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fDrawContext->mustUseHWAA(*args.fPaint)); pipelineBuilder.setUserStencil(args.fUserStencilSettings); args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch); diff --git a/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp b/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp index 1e6675a9a1..344748ceca 100644 --- a/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp +++ b/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp @@ -75,8 +75,7 @@ void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) { SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create())); paint.setAntiAlias(args.fIsAA); - GrPipelineBuilder pipelineBuilder(paint, args.fDrawContext->isUnifiedMultisampled()); - pipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_Flag, args.fIsAA); + const GrPipelineBuilder pipelineBuilder(paint, args.fIsAA); SkASSERT(!args.fPath->isInverseFillType()); SkAutoTUnref<GrPath> path(get_gr_path(fResourceProvider, *args.fPath, GrStyle::SimpleFill())); @@ -90,6 +89,7 @@ void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) { bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), "GrStencilAndCoverPathRenderer::onDrawPath"); + SkASSERT(!args.fPaint->isAntiAlias() || args.fDrawContext->isStencilBufferMultisampled()); SkASSERT(!args.fStyle->strokeRec().isHairlineStyle()); const SkPath& path = *args.fPath; const SkMatrix& viewMatrix = *args.fViewMatrix; @@ -112,13 +112,8 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { // fake inverse with a stencil and cover { - GrPipelineBuilder pipelineBuilder(*args.fPaint, - args.fDrawContext->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fPaint->isAntiAlias()); pipelineBuilder.setUserStencil(&kInvertedCoverPass); - if (args.fAntiAlias) { - SkASSERT(args.fDrawContext->isStencilBufferMultisampled()); - pipelineBuilder.enableState(GrPipelineBuilder::kHWAntialias_Flag); - } args.fDrawContext->drawContextPriv().stencilPath(pipelineBuilder, *args.fClip, viewMatrix, p, p->getFillType()); @@ -144,23 +139,17 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { } const SkMatrix& viewM = viewMatrix.hasPerspective() ? SkMatrix::I() : viewMatrix; - SkAutoTUnref<GrDrawBatch> batch( + SkAutoTUnref<GrDrawBatch> coverBatch( GrRectBatchFactory::CreateNonAAFill(args.fColor, viewM, bounds, nullptr, &invert)); { GrPipelineBuilder pipelineBuilder(*args.fPaint, - args.fDrawContext->isUnifiedMultisampled()); + args.fPaint->isAntiAlias() && + !args.fDrawContext->hasMixedSamples()); pipelineBuilder.setUserStencil(&kInvertedCoverPass); - if (args.fAntiAlias) { - SkASSERT(args.fDrawContext->isStencilBufferMultisampled()); - pipelineBuilder.enableState(GrPipelineBuilder::kHWAntialias_Flag); - } - if (args.fDrawContext->hasMixedSamples()) { - pipelineBuilder.disableState(GrPipelineBuilder::kHWAntialias_Flag); - } - args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch); + args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, coverBatch); } } else { static constexpr GrUserStencilSettings kCoverPass( @@ -176,8 +165,7 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { SkAutoTUnref<GrDrawBatch> batch( GrDrawPathBatch::Create(viewMatrix, args.fColor, p->getFillType(), p)); - GrPipelineBuilder pipelineBuilder(*args.fPaint, - args.fDrawContext->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fPaint->isAntiAlias()); pipelineBuilder.setUserStencil(&kCoverPass); if (args.fAntiAlias) { SkASSERT(args.fDrawContext->isStencilBufferMultisampled()); diff --git a/src/gpu/batches/GrTessellatingPathRenderer.cpp b/src/gpu/batches/GrTessellatingPathRenderer.cpp index 6d0525075c..e9c6e1ecf8 100644 --- a/src/gpu/batches/GrTessellatingPathRenderer.cpp +++ b/src/gpu/batches/GrTessellatingPathRenderer.cpp @@ -297,7 +297,7 @@ bool GrTessellatingPathRenderer::onDrawPath(const DrawPathArgs& args) { *args.fStyle, *args.fViewMatrix, clipBounds)); - GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fDrawContext->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fDrawContext->mustUseHWAA(*args.fPaint)); pipelineBuilder.setUserStencil(args.fUserStencilSettings); args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch); diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp index e4fa34973c..0ead354204 100644 --- a/src/gpu/text/GrAtlasTextBlob.cpp +++ b/src/gpu/text/GrAtlasTextBlob.cpp @@ -419,7 +419,7 @@ void GrAtlasTextBlob::flushCached(GrContext* context, SkScalar x, SkScalar y) { // We loop through the runs of the blob, flushing each. If any run is too large, then we flush // it as paths - GrPipelineBuilder pipelineBuilder(grPaint, dc->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(grPaint, dc->mustUseHWAA(grPaint)); GrColor color = grPaint.getColor(); @@ -448,7 +448,7 @@ void GrAtlasTextBlob::flushThrowaway(GrContext* context, const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x, SkScalar y) { - GrPipelineBuilder pipelineBuilder(grPaint, dc->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(grPaint, dc->mustUseHWAA(grPaint)); GrColor color = grPaint.getColor(); for (int run = 0; run < fRunCount; run++) { diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp index 5673c39346..aba854d5d9 100644 --- a/src/gpu/text/GrStencilAndCoverTextContext.cpp +++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp @@ -82,7 +82,7 @@ void GrStencilAndCoverTextContext::drawText(GrContext* context, GrDrawContext* d } else if (this->canDraw(skPaint, viewMatrix)) { if (skPaint.getTextSize() > 0) { TextRun run(skPaint); - GrPipelineBuilder pipelineBuilder(paint, dc->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint); run.setText(text, byteLength, x, y); run.draw(context, dc, &pipelineBuilder, clip, paint.getColor(), viewMatrix, props, 0, 0, clipBounds, fFallbackTextContext, skPaint); @@ -117,7 +117,7 @@ void GrStencilAndCoverTextContext::drawPosText(GrContext* context, GrDrawContext } else if (this->canDraw(skPaint, viewMatrix)) { if (skPaint.getTextSize() > 0) { TextRun run(skPaint); - GrPipelineBuilder pipelineBuilder(paint, dc->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint); run.setPosText(text, byteLength, pos, scalarsPerPosition, offset); run.draw(context, dc, &pipelineBuilder, clip, paint.getColor(), viewMatrix, props, 0, 0, clipBounds, fFallbackTextContext, skPaint); @@ -225,7 +225,7 @@ void GrStencilAndCoverTextContext::drawTextBlob(GrContext* context, GrDrawContex } const TextBlob& blob = this->findOrCreateTextBlob(skBlob, skPaint); - GrPipelineBuilder pipelineBuilder(paint, dc->isUnifiedMultisampled()); + GrPipelineBuilder pipelineBuilder(paint); TextBlob::Iter iter(blob); for (TextRun* run = iter.get(); run; run = iter.next()) { |