diff options
author | joshualitt <joshualitt@chromium.org> | 2016-01-13 10:08:27 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-13 10:08:27 -0800 |
commit | 04194f32f4f5ec9029357a18c0f1f9dc3404fc0c (patch) | |
tree | 9dccf58152272d4b36c4279e2566ed526f98eb9b /src/gpu | |
parent | bb25b5324965d53253fc3ad9f43b7d6faa2f9100 (diff) |
Remove two varieties of drawNonAARect from GrDrawTarget
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1584703003
Review URL: https://codereview.chromium.org/1584703003
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrDrawContext.cpp | 62 | ||||
-rw-r--r-- | src/gpu/GrDrawTarget.cpp | 21 | ||||
-rw-r--r-- | src/gpu/GrDrawTarget.h | 12 | ||||
-rw-r--r-- | src/gpu/GrOvalRenderer.cpp | 5 | ||||
-rw-r--r-- | src/gpu/GrSWMaskHelper.cpp | 9 | ||||
-rw-r--r-- | src/gpu/GrSoftwarePathRenderer.cpp | 20 | ||||
-rw-r--r-- | src/gpu/GrTest.h | 3 | ||||
-rw-r--r-- | src/gpu/batches/GrDefaultPathRenderer.cpp | 6 | ||||
-rw-r--r-- | src/gpu/batches/GrStencilAndCoverPathRenderer.cpp | 7 |
9 files changed, 65 insertions, 80 deletions
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp index c471dca1be..6161626501 100644 --- a/src/gpu/GrDrawContext.cpp +++ b/src/gpu/GrDrawContext.cpp @@ -225,11 +225,10 @@ void GrDrawContext::drawPaint(const GrClip& clip, AutoCheckFlush acf(fDrawingManager); GrPipelineBuilder pipelineBuilder(*paint, fRenderTarget, clip); - this->getDrawTarget()->drawNonAARect(pipelineBuilder, - paint->getColor(), - SkMatrix::I(), - r, - localMatrix); + SkAutoTUnref<GrDrawBatch> batch( + GrRectBatchFactory::CreateNonAAFill(paint->getColor(), SkMatrix::I(), r, nullptr, + &localMatrix)); + this->getDrawTarget()->drawBatch(pipelineBuilder, batch); } } @@ -300,8 +299,8 @@ void GrDrawContext::drawRect(const GrClip& clip, GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); GrColor color = paint.getColor(); + SkAutoTUnref<GrDrawBatch> batch; if (should_apply_coverage_aa(paint, fRenderTarget)) { - SkAutoTUnref<GrDrawBatch> batch; if (width >= 0) { // The stroke path needs the rect to remain axis aligned (no rotation or skew). if (viewMatrix.rectStaysRect()) { @@ -317,34 +316,30 @@ void GrDrawContext::drawRect(const GrClip& clip, devBoundRect)); } } - if (batch) { - this->getDrawTarget()->drawBatch(pipelineBuilder, batch); - } else { + if (!batch) { SkPath path; path.setIsVolatile(true); path.addRect(rect); this->internalDrawPath(&pipelineBuilder, viewMatrix, color, true, path, *strokeInfo); SkASSERT(paint.isAntiAlias()); + return; } - return; - } - - if (width >= 0) { + } else if (width >= 0) { // Non-AA hairlines are snapped to pixel centers to make which pixels are hit deterministic bool snapToPixelCenters = (0 == width && !fRenderTarget->isUnifiedMultisampled()); - SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAStroke( - color, viewMatrix, rect, width, snapToPixelCenters)); + batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix, rect, width, + snapToPixelCenters)); // Depending on sub-pixel coordinates and the particular GPU, we may lose a corner of // hairline rects. We jam all the vertices to pixel centers to avoid this, but not when MSAA // is enabled because it can cause ugly artifacts. pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_Flag, snapToPixelCenters); - this->getDrawTarget()->drawBatch(pipelineBuilder, batch); } else { // filled BW rect - this->getDrawTarget()->drawNonAARect(pipelineBuilder, color, viewMatrix, rect); + batch.reset(GrRectBatchFactory::CreateNonAAFill(color, viewMatrix, rect, nullptr, nullptr)); } + this->getDrawTarget()->drawBatch(pipelineBuilder, batch); } void GrDrawContext::fillRectToRect(const GrClip& clip, @@ -360,19 +355,18 @@ void GrDrawContext::fillRectToRect(const GrClip& clip, AutoCheckFlush acf(fDrawingManager); GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); + SkAutoTUnref<GrDrawBatch> batch; if (should_apply_coverage_aa(paint, fRenderTarget) && view_matrix_ok_for_aa_fill_rect(viewMatrix)) { - SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::CreateWithLocalRect( - paint.getColor(), viewMatrix, rectToDraw, localRect)); - if (batch) { - this->drawBatch(&pipelineBuilder, batch); - } + batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), viewMatrix, rectToDraw, + localRect)); } else { - this->getDrawTarget()->drawNonAARect(pipelineBuilder, - paint.getColor(), - viewMatrix, - rectToDraw, - localRect); + batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, rectToDraw, + &localRect, nullptr)); + } + + if (batch) { + this->drawBatch(&pipelineBuilder, batch); } } @@ -390,18 +384,16 @@ void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); + SkAutoTUnref<GrDrawBatch> batch; if (should_apply_coverage_aa(paint, fRenderTarget) && view_matrix_ok_for_aa_fill_rect(viewMatrix)) { - SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::Create( - paint.getColor(), viewMatrix, localMatrix, rectToDraw)); - this->drawBatch(&pipelineBuilder, batch); + batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, localMatrix, + rectToDraw)); } else { - this->getDrawTarget()->drawNonAARect(pipelineBuilder, - paint.getColor(), - viewMatrix, - rectToDraw, - localMatrix); + batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, rectToDraw, + nullptr, &localMatrix)); } + this->getDrawTarget()->drawBatch(pipelineBuilder, batch); } void GrDrawContext::drawVertices(const GrClip& clip, diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index bae4cabaae..0389d92f48 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -359,27 +359,6 @@ void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder, this->drawBatch(pipelineBuilder, batch); } -void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder, - GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkMatrix& localMatrix) { - SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, viewMatrix, rect, - nullptr, &localMatrix)); - this->drawBatch(pipelineBuilder, batch); -} - -void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder, - GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect& localRect) { - SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, viewMatrix, rect, - &localRect, nullptr)); - this->drawBatch(pipelineBuilder, batch); -} - - void GrDrawTarget::drawAARect(const GrPipelineBuilder& pipelineBuilder, GrColor color, const SkMatrix& viewMatrix, diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index 72ab46e934..e64df28ad7 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -137,18 +137,6 @@ public: const SkMatrix& viewMatrix, const SkRect& rect); - void drawNonAARect(const GrPipelineBuilder& pipelineBuilder, - GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkMatrix& localMatrix); - - void drawNonAARect(const GrPipelineBuilder& pipelineBuilder, - GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect& localRect); - void drawNonAARect(const GrPipelineBuilder& ds, GrColor color, const SkMatrix& viewM, diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp index 3862900d4c..6cb203c05a 100644 --- a/src/gpu/GrOvalRenderer.cpp +++ b/src/gpu/GrOvalRenderer.cpp @@ -19,6 +19,7 @@ #include "SkRRect.h" #include "SkStrokeRec.h" #include "SkTLazy.h" +#include "batches/GrRectBatchFactory.h" #include "batches/GrVertexBatch.h" #include "effects/GrRRectEffect.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" @@ -1493,7 +1494,9 @@ bool GrOvalRenderer::DrawDRRect(GrDrawTarget* target, if (applyAA) { bounds.outset(SK_ScalarHalf, SK_ScalarHalf); } - target->drawNonAARect(pipelineBuilder, color, SkMatrix::I(), bounds, invert); + SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, SkMatrix::I(), + bounds, nullptr, &invert)); + target->drawBatch(pipelineBuilder, batch); return true; } diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp index 6692e3d833..34e4495286 100644 --- a/src/gpu/GrSWMaskHelper.cpp +++ b/src/gpu/GrSWMaskHelper.cpp @@ -7,17 +7,16 @@ #include "GrSWMaskHelper.h" -#include "GrPipelineBuilder.h" #include "GrCaps.h" #include "GrDrawTarget.h" #include "GrGpu.h" +#include "GrPipelineBuilder.h" #include "SkData.h" #include "SkDistanceFieldGen.h" #include "SkStrokeRec.h" -// TODO: try to remove this #include -#include "GrContext.h" +#include "batches/GrRectBatchFactory.h" namespace { @@ -372,5 +371,7 @@ void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture, GrTextureParams::kNone_FilterMode, kDevice_GrCoordSet))->unref(); - target->drawNonAARect(*pipelineBuilder, color, SkMatrix::I(), dstRect, invert); + SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, SkMatrix::I(), + dstRect, nullptr, &invert)); + target->drawBatch(*pipelineBuilder, batch); } diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp index a136886a64..28a4b9ccfe 100644 --- a/src/gpu/GrSoftwarePathRenderer.cpp +++ b/src/gpu/GrSoftwarePathRenderer.cpp @@ -10,6 +10,7 @@ #include "GrContext.h" #include "GrSWMaskHelper.h" #include "GrVertexBuffer.h" +#include "batches/GrRectBatchFactory.h" //////////////////////////////////////////////////////////////////////////////// bool GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { @@ -65,6 +66,17 @@ bool get_path_and_clip_bounds(const GrPipelineBuilder* pipelineBuilder, } //////////////////////////////////////////////////////////////////////////////// +static void draw_non_aa_rect(GrDrawTarget* drawTarget, + const GrPipelineBuilder& pipelineBuilder, + GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkMatrix& localMatrix) { + SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, viewMatrix, rect, + nullptr, &localMatrix)); + drawTarget->drawBatch(pipelineBuilder, batch); +} + void draw_around_inv_path(GrDrawTarget* target, GrPipelineBuilder* pipelineBuilder, GrColor color, @@ -80,22 +92,22 @@ void draw_around_inv_path(GrDrawTarget* target, if (devClipBounds.fTop < devPathBounds.fTop) { rect.iset(devClipBounds.fLeft, devClipBounds.fTop, devClipBounds.fRight, devPathBounds.fTop); - target->drawNonAARect(*pipelineBuilder, color, SkMatrix::I(), rect, invert); + draw_non_aa_rect(target, *pipelineBuilder, color, SkMatrix::I(), rect, invert); } if (devClipBounds.fLeft < devPathBounds.fLeft) { rect.iset(devClipBounds.fLeft, devPathBounds.fTop, devPathBounds.fLeft, devPathBounds.fBottom); - target->drawNonAARect(*pipelineBuilder, color, SkMatrix::I(), rect, invert); + draw_non_aa_rect(target, *pipelineBuilder, color, SkMatrix::I(), rect, invert); } if (devClipBounds.fRight > devPathBounds.fRight) { rect.iset(devPathBounds.fRight, devPathBounds.fTop, devClipBounds.fRight, devPathBounds.fBottom); - target->drawNonAARect(*pipelineBuilder, color, SkMatrix::I(), rect, invert); + draw_non_aa_rect(target, *pipelineBuilder, color, SkMatrix::I(), rect, invert); } if (devClipBounds.fBottom > devPathBounds.fBottom) { rect.iset(devClipBounds.fLeft, devPathBounds.fBottom, devClipBounds.fRight, devClipBounds.fBottom); - target->drawNonAARect(*pipelineBuilder, color, SkMatrix::I(), rect, invert); + draw_non_aa_rect(target, *pipelineBuilder, color, SkMatrix::I(), rect, invert); } } diff --git a/src/gpu/GrTest.h b/src/gpu/GrTest.h index 297f51c113..75eb53ac64 100644 --- a/src/gpu/GrTest.h +++ b/src/gpu/GrTest.h @@ -21,7 +21,8 @@ namespace GrTest { void SetupAlwaysEvictAtlas(GrContext*); }; -/** Allows a test to temporarily draw to a GrDrawTarget owned by a GrContext. Tests that use this +/** TODO Please do not use this if you can avoid it. We are in the process of deleting it. + Allows a test to temporarily draw to a GrDrawTarget owned by a GrContext. Tests that use this should be careful not to mix using the GrDrawTarget directly and drawing via SkCanvas or GrContext. In the future this object may provide some guards to prevent this. */ class GrTestTarget { diff --git a/src/gpu/batches/GrDefaultPathRenderer.cpp b/src/gpu/batches/GrDefaultPathRenderer.cpp index 638e03cb79..8ed3155a68 100644 --- a/src/gpu/batches/GrDefaultPathRenderer.cpp +++ b/src/gpu/batches/GrDefaultPathRenderer.cpp @@ -20,6 +20,7 @@ #include "SkTLazy.h" #include "SkTraceEvent.h" +#include "batches/GrRectBatchFactory.h" #include "batches/GrVertexBatch.h" GrDefaultPathRenderer::GrDefaultPathRenderer(bool separateStencilSupport, @@ -697,7 +698,10 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target, } const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? SkMatrix::I() : viewMatrix; - target->drawNonAARect(*pipelineBuilder, color, viewM, bounds, localMatrix); + SkAutoTUnref<GrDrawBatch> batch( + GrRectBatchFactory::CreateNonAAFill(color, viewM, bounds, nullptr, + &localMatrix)); + target->drawBatch(*pipelineBuilder, batch); } else { if (passCount > 1) { pipelineBuilder->setDisableColorXPFactory(); diff --git a/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp b/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp index 848c82104d..6abe41e997 100644 --- a/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp +++ b/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp @@ -16,6 +16,7 @@ #include "GrRenderTarget.h" #include "GrResourceProvider.h" #include "GrStrokeInfo.h" +#include "batches/GrRectBatchFactory.h" GrPathRenderer* GrStencilAndCoverPathRenderer::Create(GrResourceProvider* resourceProvider, const GrCaps& caps) { @@ -121,7 +122,11 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { if (pipelineBuilder->getRenderTarget()->hasMixedSamples()) { pipelineBuilder->disableState(GrPipelineBuilder::kHWAntialias_Flag); } - args.fTarget->drawNonAARect(*pipelineBuilder, args.fColor, viewM, bounds, invert); + + SkAutoTUnref<GrDrawBatch> batch( + GrRectBatchFactory::CreateNonAAFill(args.fColor, viewM, bounds, nullptr, + &invert)); + args.fTarget->drawBatch(*pipelineBuilder, batch); } else { GR_STATIC_CONST_SAME_STENCIL(kStencilPass, kZero_StencilOp, |