aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2016-01-13 13:35:35 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-13 13:35:35 -0800
commita8b849911d093c35e10b704c29e73f493d2bf7c4 (patch)
tree9b0f80eb72bac8d3c02292e597ca6d135af06da5
parent65e5824d3a46c468530aba5de4c11b6c8de4cede (diff)
Remove remaining users of draw*Rect calls
-rw-r--r--src/gpu/GrClipMaskManager.cpp49
-rw-r--r--src/gpu/GrDrawTarget.cpp25
-rw-r--r--src/gpu/GrDrawTarget.h30
3 files changed, 33 insertions, 71 deletions
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 9eaf415cce..3168424cf8 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -20,6 +20,7 @@
#include "GrSWMaskHelper.h"
#include "SkRasterClip.h"
#include "SkTLazy.h"
+#include "batches/GrRectBatchFactory.h"
#include "effects/GrConvexPolyEffect.h"
#include "effects/GrPorterDuffXferProcessor.h"
#include "effects/GrRRectEffect.h"
@@ -47,6 +48,16 @@ static const GrFragmentProcessor* create_fp_for_mask(GrTexture* result, const Sk
kDevice_GrCoordSet);
}
+static void draw_non_aa_rect(GrDrawTarget* drawTarget,
+ const GrPipelineBuilder& pipelineBuilder,
+ GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect) {
+ SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, viewMatrix, rect,
+ nullptr, nullptr));
+ drawTarget->drawBatch(pipelineBuilder, batch);
+}
+
// Does the path in 'element' require SW rendering? If so, return true (and,
// optionally, set 'prOut' to NULL. If not, return false (and, optionally, set
// 'prOut' to the non-SW path renderer that will do the job).
@@ -506,20 +517,24 @@ bool GrClipMaskManager::drawElement(GrPipelineBuilder* pipelineBuilder,
case Element::kEmpty_Type:
SkDEBUGFAIL("Should never get here with an empty element.");
break;
- case Element::kRect_Type:
+ case Element::kRect_Type: {
// TODO: Do rects directly to the accumulator using a aa-rect GrProcessor that covers
// the entire mask bounds and writes 0 outside the rect.
if (element->isAA()) {
SkRect devRect = element->getRect();
viewMatrix.mapRect(&devRect);
- fDrawTarget->drawAARect(*pipelineBuilder, color, viewMatrix,
- element->getRect(), devRect);
+ SkAutoTUnref<GrDrawBatch> batch(
+ GrRectBatchFactory::CreateAAFill(color, viewMatrix, element->getRect(),
+ devRect));
+
+ fDrawTarget->drawBatch(*pipelineBuilder, batch);
} else {
- fDrawTarget->drawNonAARect(*pipelineBuilder, color, viewMatrix,
- element->getRect());
+ draw_non_aa_rect(fDrawTarget, *pipelineBuilder, color, viewMatrix,
+ element->getRect());
}
return true;
+ }
default: {
SkPath path;
element->asPath(&path);
@@ -691,8 +706,8 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
backgroundPipelineBuilder.setStencil(kDrawOutsideElement);
// The color passed in here does not matter since the coverageSetOpXP won't read it.
- fDrawTarget->drawNonAARect(backgroundPipelineBuilder, GrColor_WHITE, translate,
- clipSpaceIBounds);
+ draw_non_aa_rect(fDrawTarget, backgroundPipelineBuilder, GrColor_WHITE, translate,
+ SkRect::Make(clipSpaceIBounds));
}
} else {
GrPipelineBuilder pipelineBuilder;
@@ -831,11 +846,8 @@ bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt,
if (Element::kRect_Type == element->getType()) {
*pipelineBuilder.stencil() = gDrawToStencil;
- // We need this AGP until everything is in GrBatch
- fDrawTarget->drawNonAARect(pipelineBuilder,
- GrColor_WHITE,
- viewMatrix,
- element->getRect());
+ draw_non_aa_rect(fDrawTarget, pipelineBuilder, GrColor_WHITE, viewMatrix,
+ element->getRect());
} else {
if (!clipPath.isEmpty()) {
if (canRenderDirectToStencil) {
@@ -873,11 +885,8 @@ bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt,
if (canDrawDirectToClip) {
if (Element::kRect_Type == element->getType()) {
- // We need this AGP until everything is in GrBatch
- fDrawTarget->drawNonAARect(pipelineBuilder,
- GrColor_WHITE,
- viewMatrix,
- element->getRect());
+ draw_non_aa_rect(fDrawTarget, pipelineBuilder, GrColor_WHITE, viewMatrix,
+ element->getRect());
} else {
GrPathRenderer::DrawPathArgs args;
args.fTarget = fDrawTarget;
@@ -893,10 +902,8 @@ bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt,
} else {
// The view matrix is setup to do clip space -> stencil space translation, so
// draw rect in clip space.
- fDrawTarget->drawNonAARect(pipelineBuilder,
- GrColor_WHITE,
- viewMatrix,
- SkRect::Make(clipSpaceIBounds));
+ draw_non_aa_rect(fDrawTarget, pipelineBuilder, GrColor_WHITE, viewMatrix,
+ SkRect::Make(clipSpaceIBounds));
}
}
}
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 0389d92f48..e2e188eb12 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -350,25 +350,6 @@ void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder,
this->recordBatch(batch);
}
-void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder,
- GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect) {
- SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, viewMatrix, rect,
- nullptr, nullptr));
- this->drawBatch(pipelineBuilder, batch);
-}
-
-void GrDrawTarget::drawAARect(const GrPipelineBuilder& pipelineBuilder,
- GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& devRect) {
- SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill(color, viewMatrix, rect,
- devRect));
- this->drawBatch(pipelineBuilder, batch);
-}
-
void GrDrawTarget::clear(const SkIRect* rect,
GrColor color,
bool canIgnoreRect,
@@ -400,7 +381,11 @@ void GrDrawTarget::clear(const SkIRect* rect,
GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
pipelineBuilder.setRenderTarget(renderTarget);
- this->drawNonAARect(pipelineBuilder, color, SkMatrix::I(), *rect);
+ SkRect scalarRect = SkRect::Make(*rect);
+ SkAutoTUnref<GrDrawBatch> batch(
+ GrRectBatchFactory::CreateNonAAFill(color, SkMatrix::I(), scalarRect,
+ nullptr, nullptr));
+ this->drawBatch(pipelineBuilder, batch);
} else {
GrBatch* batch = new GrClearBatch(*rect, color, renderTarget);
this->recordBatch(batch);
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index e64df28ad7..d16d6e8c45 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -122,36 +122,6 @@ public:
void drawPathBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawPathBatchBase* batch);
/**
- * Helper function for drawing rects.
- *
- * @param rect the rect to draw
- * @param localRect optional rect that specifies local coords to map onto
- * rect. If nullptr then rect serves as the local coords.
- * @param localMatrix Optional local matrix. The local coordinates are specified by localRect,
- * or if it is nullptr by rect. This matrix applies to the coordinate implied by
- * that rectangle before it is input to GrCoordTransforms that read local
- * coordinates
- */
- void drawNonAARect(const GrPipelineBuilder& pipelineBuilder,
- GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect);
-
- void drawNonAARect(const GrPipelineBuilder& ds,
- GrColor color,
- const SkMatrix& viewM,
- const SkIRect& irect) {
- SkRect rect = SkRect::Make(irect);
- this->drawNonAARect(ds, color, viewM, rect);
- }
-
- void drawAARect(const GrPipelineBuilder& pipelineBuilder,
- GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& devRect);
-
- /**
* Clear the passed in render target. Ignores the GrPipelineBuilder and clip. Clears the whole
* thing if rect is nullptr, otherwise just the rect. If canIgnoreRect is set then the entire
* render target can be optionally cleared.