Create separate entry points for the various flavors of drawRect
BUG=skia:
Review URL: https://codereview.chromium.org/1308503002
diff --git a/gm/bigrrectaaeffect.cpp b/gm/bigrrectaaeffect.cpp
index 41e4d05..f603abe 100644
--- a/gm/bigrrectaaeffect.cpp
+++ b/gm/bigrrectaaeffect.cpp
@@ -85,10 +85,10 @@
bounds.outset(2.f, 2.f);
bounds.offset(SkIntToScalar(x), SkIntToScalar(y));
- tt.target()->drawSimpleRect(pipelineBuilder,
- 0xff000000,
- SkMatrix::I(),
- bounds);
+ tt.target()->drawBWRect(pipelineBuilder,
+ 0xff000000,
+ SkMatrix::I(),
+ bounds);
}
canvas->restore();
x = x + kDrawOffset;
diff --git a/gm/constcolorprocessor.cpp b/gm/constcolorprocessor.cpp
index 26898be..9177ce5 100644
--- a/gm/constcolorprocessor.cpp
+++ b/gm/constcolorprocessor.cpp
@@ -115,10 +115,10 @@
GrPipelineBuilder pipelineBuilder(grPaint, rt, clip);
pipelineBuilder.addColorProcessor(fp);
- tt.target()->drawSimpleRect(pipelineBuilder,
- grPaint.getColor(),
- viewMatrix,
- renderRect);
+ tt.target()->drawBWRect(pipelineBuilder,
+ grPaint.getColor(),
+ viewMatrix,
+ renderRect);
// Draw labels for the input to the processor and the processor to the right of
// the test rect. The input label appears above the processor label.
diff --git a/gm/rrects.cpp b/gm/rrects.cpp
index a2a6308..fa7351b 100644
--- a/gm/rrects.cpp
+++ b/gm/rrects.cpp
@@ -120,10 +120,10 @@
SkRect bounds = rrect.getBounds();
bounds.outset(2.f, 2.f);
- tt.target()->drawSimpleRect(pipelineBuilder,
- 0xff000000,
- SkMatrix::I(),
- bounds);
+ tt.target()->drawBWRect(pipelineBuilder,
+ 0xff000000,
+ SkMatrix::I(),
+ bounds);
} else {
drew = false;
}
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index ed74dd7..63d7aef 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -130,10 +130,10 @@
pipelineBuilder.setRenderTarget(rt);
pipelineBuilder.addColorProcessor(fp);
- tt.target()->drawSimpleRect(pipelineBuilder,
- GrColor_WHITE,
- viewMatrix,
- renderRect);
+ tt.target()->drawBWRect(pipelineBuilder,
+ GrColor_WHITE,
+ viewMatrix,
+ renderRect);
x += renderRect.width() + kTestPad;
}
y += renderRect.height() + kTestPad;
diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp
index c0bb890..6f087e2 100644
--- a/gm/yuvtorgbeffect.cpp
+++ b/gm/yuvtorgbeffect.cpp
@@ -124,10 +124,10 @@
viewMatrix.setTranslate(x, y);
pipelineBuilder.setRenderTarget(rt);
pipelineBuilder.addColorProcessor(fp);
- tt.target()->drawSimpleRect(pipelineBuilder,
- GrColor_WHITE,
- viewMatrix,
- renderRect);
+ tt.target()->drawBWRect(pipelineBuilder,
+ GrColor_WHITE,
+ viewMatrix,
+ renderRect);
}
x += renderRect.width() + kTestPad;
}
diff --git a/include/gpu/GrDrawContext.h b/include/gpu/GrDrawContext.h
index 0f6552c..552cfd3 100644
--- a/include/gpu/GrDrawContext.h
+++ b/include/gpu/GrDrawContext.h
@@ -120,16 +120,13 @@
* @param viewMatrix transformation matrix which applies to rectToDraw
* @param rectToDraw the rectangle to draw
* @param localRect the rectangle of shader coordinates applied to rectToDraw
- * @param localMatrix an optional matrix to transform the shader coordinates before applying
- * to rectToDraw
*/
void drawNonAARectToRect(GrRenderTarget*,
const GrClip&,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rectToDraw,
- const SkRect& localRect,
- const SkMatrix* localMatrix = NULL);
+ const SkRect& localRect);
/**
* Draws a non-AA rect with paint and a localMatrix
@@ -139,9 +136,7 @@
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rect,
- const SkMatrix& localMatrix) {
- this->drawNonAARectToRect(rt, clip, paint, viewMatrix, rect, rect, &localMatrix);
- }
+ const SkMatrix& localMatrix);
/**
* Draw a roundrect using a paint.
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 3363795..8a5ee1d 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -410,8 +410,8 @@
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 @@
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 @@
*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 @@
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 @@
} 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 b7faf68..6fe2005 100644
--- a/src/gpu/GrDefaultPathRenderer.cpp
+++ b/src/gpu/GrDefaultPathRenderer.cpp
@@ -686,7 +686,7 @@
}
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 8b95647..7590328 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -199,8 +199,7 @@
paint->getColor(),
SkMatrix::I(),
r,
- NULL,
- &localMatrix);
+ localMatrix);
}
}
@@ -305,7 +304,7 @@
fDrawTarget->drawBatch(pipelineBuilder, batch);
} else {
// filled BW rect
- fDrawTarget->drawSimpleRect(pipelineBuilder, color, viewMatrix, rect);
+ fDrawTarget->drawBWRect(pipelineBuilder, color, viewMatrix, rect);
}
}
@@ -314,8 +313,7 @@
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)) {
@@ -327,7 +325,26 @@
paint.getColor(),
viewMatrix,
rectToDraw,
- &localRect,
+ 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)) {
+ return;
+ }
+
+ GrPipelineBuilder pipelineBuilder(paint, rt, clip);
+ fDrawTarget->drawBWRect(pipelineBuilder,
+ paint.getColor(),
+ viewMatrix,
+ rectToDraw,
localMatrix);
}
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index fed97a9..f5d4af6 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -312,14 +312,33 @@
void GrDrawTarget::drawBWRect(const GrPipelineBuilder& pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect* localRect,
- const SkMatrix* localMatrix) {
+ const SkRect& rect) {
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateFillBW(color, viewMatrix, rect,
- localRect, localMatrix));
+ nullptr, nullptr));
this->drawBatch(pipelineBuilder, batch);
}
+void GrDrawTarget::drawBWRect(const GrPipelineBuilder& pipelineBuilder,
+ GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkMatrix& localMatrix) {
+ SkAutoTUnref<GrDrawBatch> 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) {
+ SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateFillBW(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 14c7ae9..1f7e297 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -123,21 +123,31 @@
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 SkRect* localRect,
- const SkMatrix* localMatrix);
+ const SkMatrix& localMatrix);
+
+ void drawBWRect(const GrPipelineBuilder& pipelineBuilder,
+ GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ 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 c9d6f1f..364c567 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -1458,7 +1458,7 @@
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 df1f91b..7edcd6a 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -373,5 +373,5 @@
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 6e2babc..31f8fc4 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -81,22 +81,22 @@
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 6cd982c..e375944 100644
--- a/src/gpu/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/GrStencilAndCoverPathRenderer.cpp
@@ -137,7 +137,7 @@
}
}
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,