From b6b513b805c37dc80999261c5d03e7af1976542e Mon Sep 17 00:00:00 2001 From: joshualitt Date: Fri, 21 Aug 2015 10:25:18 -0700 Subject: Create separate entry points for the various flavors of drawRect BUG=skia: Review URL: https://codereview.chromium.org/1308503002 --- src/gpu/GrClipMaskManager.cpp | 36 +++++++++++++++---------------- src/gpu/GrDefaultPathRenderer.cpp | 2 +- src/gpu/GrDrawContext.cpp | 29 +++++++++++++++++++------ src/gpu/GrDrawTarget.cpp | 25 ++++++++++++++++++--- src/gpu/GrDrawTarget.h | 18 ++++++++++++---- src/gpu/GrOvalRenderer.cpp | 2 +- src/gpu/GrSWMaskHelper.cpp | 2 +- src/gpu/GrSoftwarePathRenderer.cpp | 8 +++---- src/gpu/GrStencilAndCoverPathRenderer.cpp | 2 +- 9 files changed, 85 insertions(+), 39 deletions(-) (limited to 'src/gpu') diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp index 3363795108..8a5ee1d66b 100644 --- a/src/gpu/GrClipMaskManager.cpp +++ b/src/gpu/GrClipMaskManager.cpp @@ -410,8 +410,8 @@ bool GrClipMaskManager::drawElement(GrPipelineBuilder* pipelineBuilder, fClipTarget->drawAARect(*pipelineBuilder, color, viewMatrix, element->getRect(), devRect); } else { - fClipTarget->drawSimpleRect(*pipelineBuilder, color, viewMatrix, - element->getRect()); + fClipTarget->drawBWRect(*pipelineBuilder, color, viewMatrix, + element->getRect()); } return true; default: { @@ -497,10 +497,10 @@ void GrClipMaskManager::mergeMask(GrPipelineBuilder* pipelineBuilder, GrTextureParams::kNone_FilterMode))->unref(); // The color passed in here does not matter since the coverageSetOpXP won't read it. - fClipTarget->drawSimpleRect(*pipelineBuilder, - GrColor_WHITE, - SkMatrix::I(), - SkRect::Make(dstBound)); + fClipTarget->drawBWRect(*pipelineBuilder, + GrColor_WHITE, + SkMatrix::I(), + SkRect::Make(dstBound)); } GrTexture* GrClipMaskManager::createTempMask(int width, int height) { @@ -827,10 +827,10 @@ bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt, *pipelineBuilder.stencil() = gDrawToStencil; // We need this AGP until everything is in GrBatch - fClipTarget->drawSimpleRect(pipelineBuilder, - GrColor_WHITE, - viewMatrix, - element->getRect()); + fClipTarget->drawBWRect(pipelineBuilder, + GrColor_WHITE, + viewMatrix, + element->getRect()); } else { if (!clipPath.isEmpty()) { if (canRenderDirectToStencil) { @@ -869,10 +869,10 @@ bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt, if (canDrawDirectToClip) { if (Element::kRect_Type == element->getType()) { // We need this AGP until everything is in GrBatch - fClipTarget->drawSimpleRect(pipelineBuilder, - GrColor_WHITE, - viewMatrix, - element->getRect()); + fClipTarget->drawBWRect(pipelineBuilder, + GrColor_WHITE, + viewMatrix, + element->getRect()); } else { GrPathRenderer::DrawPathArgs args; args.fTarget = fClipTarget; @@ -888,10 +888,10 @@ bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt, } else { // The view matrix is setup to do clip space -> stencil space translation, so // draw rect in clip space. - fClipTarget->drawSimpleRect(pipelineBuilder, - GrColor_WHITE, - viewMatrix, - SkRect::Make(clipSpaceIBounds)); + fClipTarget->drawBWRect(pipelineBuilder, + GrColor_WHITE, + viewMatrix, + SkRect::Make(clipSpaceIBounds)); } } } diff --git a/src/gpu/GrDefaultPathRenderer.cpp b/src/gpu/GrDefaultPathRenderer.cpp index b7faf68108..6fe2005054 100644 --- a/src/gpu/GrDefaultPathRenderer.cpp +++ b/src/gpu/GrDefaultPathRenderer.cpp @@ -686,7 +686,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target, } const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? SkMatrix::I() : viewMatrix; - target->drawBWRect(*pipelineBuilder, color, viewM, bounds, NULL, &localMatrix); + target->drawBWRect(*pipelineBuilder, color, viewM, bounds, localMatrix); } else { if (passCount > 1) { pipelineBuilder->setDisableColorXPFactory(); diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp index 8b95647631..7590328421 100644 --- a/src/gpu/GrDrawContext.cpp +++ b/src/gpu/GrDrawContext.cpp @@ -199,8 +199,7 @@ void GrDrawContext::drawPaint(GrRenderTarget* rt, paint->getColor(), SkMatrix::I(), r, - NULL, - &localMatrix); + localMatrix); } } @@ -305,7 +304,7 @@ void GrDrawContext::drawRect(GrRenderTarget* rt, fDrawTarget->drawBatch(pipelineBuilder, batch); } else { // filled BW rect - fDrawTarget->drawSimpleRect(pipelineBuilder, color, viewMatrix, rect); + fDrawTarget->drawBWRect(pipelineBuilder, color, viewMatrix, rect); } } @@ -314,8 +313,27 @@ void GrDrawContext::drawNonAARectToRect(GrRenderTarget* rt, const GrPaint& paint, const SkMatrix& viewMatrix, const SkRect& rectToDraw, - const SkRect& localRect, - const SkMatrix* localMatrix) { + const SkRect& localRect) { + RETURN_IF_ABANDONED + AutoCheckFlush acf(fContext); + if (!this->prepareToDraw(rt)) { + return; + } + + GrPipelineBuilder pipelineBuilder(paint, rt, clip); + fDrawTarget->drawBWRect(pipelineBuilder, + paint.getColor(), + viewMatrix, + rectToDraw, + localRect); +} + +void GrDrawContext::drawNonAARectWithLocalMatrix(GrRenderTarget* rt, + const GrClip& clip, + const GrPaint& paint, + const SkMatrix& viewMatrix, + const SkRect& rectToDraw, + const SkMatrix& localMatrix) { RETURN_IF_ABANDONED AutoCheckFlush acf(fContext); if (!this->prepareToDraw(rt)) { @@ -327,7 +345,6 @@ void GrDrawContext::drawNonAARectToRect(GrRenderTarget* rt, paint.getColor(), viewMatrix, rectToDraw, - &localRect, localMatrix); } diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index fed97a9b03..f5d4af6c4c 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -309,17 +309,36 @@ void GrDrawTarget::drawPaths(const GrPipelineBuilder& pipelineBuilder, transformType, count, stencilSettings, pipelineInfo); } +void GrDrawTarget::drawBWRect(const GrPipelineBuilder& pipelineBuilder, + GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect) { + SkAutoTUnref batch(GrRectBatchFactory::CreateFillBW(color, viewMatrix, rect, + nullptr, nullptr)); + this->drawBatch(pipelineBuilder, batch); +} + +void GrDrawTarget::drawBWRect(const GrPipelineBuilder& pipelineBuilder, + GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkMatrix& localMatrix) { + SkAutoTUnref batch(GrRectBatchFactory::CreateFillBW(color, viewMatrix, rect, + nullptr, &localMatrix)); + this->drawBatch(pipelineBuilder, batch); +} + void GrDrawTarget::drawBWRect(const GrPipelineBuilder& pipelineBuilder, GrColor color, const SkMatrix& viewMatrix, const SkRect& rect, - const SkRect* localRect, - const SkMatrix* localMatrix) { + const SkRect& localRect) { SkAutoTUnref batch(GrRectBatchFactory::CreateFillBW(color, viewMatrix, rect, - localRect, localMatrix)); + &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 14c7ae96f0..1f7e297e51 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -120,24 +120,34 @@ public: * that rectangle before it is input to GrCoordTransforms that read local * coordinates */ + void drawBWRect(const GrPipelineBuilder& pipelineBuilder, + GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect); + + void drawBWRect(const GrPipelineBuilder& pipelineBuilder, + GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkMatrix& localMatrix); + void drawBWRect(const GrPipelineBuilder& pipelineBuilder, GrColor color, const SkMatrix& viewMatrix, const SkRect& rect, - const SkRect* localRect, - const SkMatrix* localMatrix); + const SkRect& localRect); /** * Helper for drawRect when the caller doesn't need separate local rects or matrices. */ void drawSimpleRect(const GrPipelineBuilder& ds, GrColor color, const SkMatrix& viewM, const SkRect& rect) { - this->drawBWRect(ds, color, viewM, rect, NULL, NULL); + this->drawBWRect(ds, color, viewM, rect); } void drawSimpleRect(const GrPipelineBuilder& ds, GrColor color, const SkMatrix& viewM, const SkIRect& irect) { SkRect rect = SkRect::Make(irect); - this->drawBWRect(ds, color, viewM, rect, NULL, NULL); + this->drawBWRect(ds, color, viewM, rect); } void drawAARect(const GrPipelineBuilder& pipelineBuilder, diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp index c9d6f1fc09..364c5674c2 100644 --- a/src/gpu/GrOvalRenderer.cpp +++ b/src/gpu/GrOvalRenderer.cpp @@ -1458,7 +1458,7 @@ bool GrOvalRenderer::DrawDRRect(GrDrawTarget* target, if (applyAA) { bounds.outset(SK_ScalarHalf, SK_ScalarHalf); } - target->drawBWRect(pipelineBuilder, color, SkMatrix::I(), bounds, NULL, &invert); + target->drawBWRect(pipelineBuilder, color, SkMatrix::I(), bounds, invert); return true; } diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp index df1f91bb24..7edcd6af05 100644 --- a/src/gpu/GrSWMaskHelper.cpp +++ b/src/gpu/GrSWMaskHelper.cpp @@ -373,5 +373,5 @@ void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture, GrTextureParams::kNone_FilterMode, kDevice_GrCoordSet))->unref(); - target->drawBWRect(*pipelineBuilder, color, SkMatrix::I(), dstRect, NULL, &invert); + target->drawBWRect(*pipelineBuilder, color, SkMatrix::I(), dstRect, invert); } diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp index 6e2babc259..31f8fc427c 100644 --- a/src/gpu/GrSoftwarePathRenderer.cpp +++ b/src/gpu/GrSoftwarePathRenderer.cpp @@ -81,22 +81,22 @@ void draw_around_inv_path(GrDrawTarget* target, if (devClipBounds.fTop < devPathBounds.fTop) { rect.iset(devClipBounds.fLeft, devClipBounds.fTop, devClipBounds.fRight, devPathBounds.fTop); - target->drawBWRect(*pipelineBuilder, color, SkMatrix::I(), rect, NULL, &invert); + target->drawBWRect(*pipelineBuilder, color, SkMatrix::I(), rect, invert); } if (devClipBounds.fLeft < devPathBounds.fLeft) { rect.iset(devClipBounds.fLeft, devPathBounds.fTop, devPathBounds.fLeft, devPathBounds.fBottom); - target->drawBWRect(*pipelineBuilder, color, SkMatrix::I(), rect, NULL, &invert); + target->drawBWRect(*pipelineBuilder, color, SkMatrix::I(), rect, invert); } if (devClipBounds.fRight > devPathBounds.fRight) { rect.iset(devPathBounds.fRight, devPathBounds.fTop, devClipBounds.fRight, devPathBounds.fBottom); - target->drawBWRect(*pipelineBuilder, color, SkMatrix::I(), rect, NULL, &invert); + target->drawBWRect(*pipelineBuilder, color, SkMatrix::I(), rect, invert); } if (devClipBounds.fBottom > devPathBounds.fBottom) { rect.iset(devClipBounds.fLeft, devPathBounds.fBottom, devClipBounds.fRight, devClipBounds.fBottom); - target->drawBWRect(*pipelineBuilder, color, SkMatrix::I(), rect, NULL, &invert); + target->drawBWRect(*pipelineBuilder, color, SkMatrix::I(), rect, invert); } } diff --git a/src/gpu/GrStencilAndCoverPathRenderer.cpp b/src/gpu/GrStencilAndCoverPathRenderer.cpp index 6cd982c515..e375944b57 100644 --- a/src/gpu/GrStencilAndCoverPathRenderer.cpp +++ b/src/gpu/GrStencilAndCoverPathRenderer.cpp @@ -137,7 +137,7 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { } } const SkMatrix& viewM = viewMatrix.hasPerspective() ? SkMatrix::I() : viewMatrix; - args.fTarget->drawBWRect(*pipelineBuilder, args.fColor, viewM, bounds, NULL, &invert); + args.fTarget->drawBWRect(*pipelineBuilder, args.fColor, viewM, bounds, invert); } else { GR_STATIC_CONST_SAME_STENCIL(kStencilPass, kZero_StencilOp, -- cgit v1.2.3