Standardize BW to NonAA

TBR=bsalomon@google.com, robertphillips@google.com
BUG=skia:

Review URL: https://codereview.chromium.org/1310533004
This commit is contained in:
joshualitt 2015-08-21 10:53:34 -07:00 committed by Commit bot
parent 2244c27ea4
commit d2b23e0ee6
17 changed files with 118 additions and 123 deletions

View File

@ -85,10 +85,10 @@ protected:
bounds.outset(2.f, 2.f);
bounds.offset(SkIntToScalar(x), SkIntToScalar(y));
tt.target()->drawBWRect(pipelineBuilder,
0xff000000,
SkMatrix::I(),
bounds);
tt.target()->drawNonAARect(pipelineBuilder,
0xff000000,
SkMatrix::I(),
bounds);
}
canvas->restore();
x = x + kDrawOffset;

View File

@ -115,10 +115,10 @@ protected:
GrPipelineBuilder pipelineBuilder(grPaint, rt, clip);
pipelineBuilder.addColorProcessor(fp);
tt.target()->drawBWRect(pipelineBuilder,
grPaint.getColor(),
viewMatrix,
renderRect);
tt.target()->drawNonAARect(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.

View File

@ -120,10 +120,10 @@ protected:
SkRect bounds = rrect.getBounds();
bounds.outset(2.f, 2.f);
tt.target()->drawBWRect(pipelineBuilder,
0xff000000,
SkMatrix::I(),
bounds);
tt.target()->drawNonAARect(pipelineBuilder,
0xff000000,
SkMatrix::I(),
bounds);
} else {
drew = false;
}

View File

@ -130,10 +130,10 @@ protected:
pipelineBuilder.setRenderTarget(rt);
pipelineBuilder.addColorProcessor(fp);
tt.target()->drawBWRect(pipelineBuilder,
GrColor_WHITE,
viewMatrix,
renderRect);
tt.target()->drawNonAARect(pipelineBuilder,
GrColor_WHITE,
viewMatrix,
renderRect);
x += renderRect.width() + kTestPad;
}
y += renderRect.height() + kTestPad;

View File

@ -124,10 +124,10 @@ protected:
viewMatrix.setTranslate(x, y);
pipelineBuilder.setRenderTarget(rt);
pipelineBuilder.addColorProcessor(fp);
tt.target()->drawBWRect(pipelineBuilder,
GrColor_WHITE,
viewMatrix,
renderRect);
tt.target()->drawNonAARect(pipelineBuilder,
GrColor_WHITE,
viewMatrix,
renderRect);
}
x += renderRect.width() + kTestPad;
}

View File

@ -410,8 +410,8 @@ bool GrClipMaskManager::drawElement(GrPipelineBuilder* pipelineBuilder,
fClipTarget->drawAARect(*pipelineBuilder, color, viewMatrix,
element->getRect(), devRect);
} else {
fClipTarget->drawBWRect(*pipelineBuilder, color, viewMatrix,
element->getRect());
fClipTarget->drawNonAARect(*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->drawBWRect(*pipelineBuilder,
GrColor_WHITE,
SkMatrix::I(),
SkRect::Make(dstBound));
fClipTarget->drawNonAARect(*pipelineBuilder,
GrColor_WHITE,
SkMatrix::I(),
SkRect::Make(dstBound));
}
GrTexture* GrClipMaskManager::createTempMask(int width, int height) {
@ -690,8 +690,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.
fClipTarget->drawSimpleRect(backgroundPipelineBuilder, GrColor_WHITE, translate,
clipSpaceIBounds);
fClipTarget->drawNonAARect(backgroundPipelineBuilder, GrColor_WHITE, translate,
clipSpaceIBounds);
}
} else {
GrPipelineBuilder pipelineBuilder;
@ -827,10 +827,10 @@ bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt,
*pipelineBuilder.stencil() = gDrawToStencil;
// We need this AGP until everything is in GrBatch
fClipTarget->drawBWRect(pipelineBuilder,
GrColor_WHITE,
viewMatrix,
element->getRect());
fClipTarget->drawNonAARect(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->drawBWRect(pipelineBuilder,
GrColor_WHITE,
viewMatrix,
element->getRect());
fClipTarget->drawNonAARect(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->drawBWRect(pipelineBuilder,
GrColor_WHITE,
viewMatrix,
SkRect::Make(clipSpaceIBounds));
fClipTarget->drawNonAARect(pipelineBuilder,
GrColor_WHITE,
viewMatrix,
SkRect::Make(clipSpaceIBounds));
}
}
}

View File

@ -686,7 +686,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
}
const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? SkMatrix::I() :
viewMatrix;
target->drawBWRect(*pipelineBuilder, color, viewM, bounds, localMatrix);
target->drawNonAARect(*pipelineBuilder, color, viewM, bounds, localMatrix);
} else {
if (passCount > 1) {
pipelineBuilder->setDisableColorXPFactory();

View File

@ -195,11 +195,11 @@ void GrDrawContext::drawPaint(GrRenderTarget* rt,
}
GrPipelineBuilder pipelineBuilder(*paint, rt, clip);
fDrawTarget->drawBWRect(pipelineBuilder,
paint->getColor(),
SkMatrix::I(),
r,
localMatrix);
fDrawTarget->drawNonAARect(pipelineBuilder,
paint->getColor(),
SkMatrix::I(),
r,
localMatrix);
}
}
@ -281,10 +281,10 @@ void GrDrawContext::drawRect(GrRenderTarget* rt,
viewMatrix.mapRect(&devBoundRect, rect);
SkAutoTUnref<GrDrawBatch> batch;
if (width >= 0) {
batch.reset(GrRectBatchFactory::CreateStrokeAA(color, viewMatrix, rect, devBoundRect,
batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix, rect, devBoundRect,
*strokeInfo));
} else {
batch.reset(GrRectBatchFactory::CreateFillAA(color, viewMatrix, rect, devBoundRect));
batch.reset(GrRectBatchFactory::CreateAAFill(color, viewMatrix, rect, devBoundRect));
}
fDrawTarget->drawBatch(pipelineBuilder, batch);
return;
@ -293,7 +293,7 @@ void GrDrawContext::drawRect(GrRenderTarget* rt,
if (width >= 0) {
// Non-AA hairlines are snapped to pixel centers to make which pixels are hit deterministic
bool snapToPixelCenters = (0 == width && !rt->isUnifiedMultisampled());
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateStrokeBW(
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAStroke(
color, viewMatrix, rect, width, snapToPixelCenters));
// Depending on sub-pixel coordinates and the particular GPU, we may lose a corner of
@ -304,7 +304,7 @@ void GrDrawContext::drawRect(GrRenderTarget* rt,
fDrawTarget->drawBatch(pipelineBuilder, batch);
} else {
// filled BW rect
fDrawTarget->drawBWRect(pipelineBuilder, color, viewMatrix, rect);
fDrawTarget->drawNonAARect(pipelineBuilder, color, viewMatrix, rect);
}
}
@ -321,11 +321,11 @@ void GrDrawContext::drawNonAARectToRect(GrRenderTarget* rt,
}
GrPipelineBuilder pipelineBuilder(paint, rt, clip);
fDrawTarget->drawBWRect(pipelineBuilder,
paint.getColor(),
viewMatrix,
rectToDraw,
localRect);
fDrawTarget->drawNonAARect(pipelineBuilder,
paint.getColor(),
viewMatrix,
rectToDraw,
localRect);
}
void GrDrawContext::drawNonAARectWithLocalMatrix(GrRenderTarget* rt,
@ -341,11 +341,11 @@ void GrDrawContext::drawNonAARectWithLocalMatrix(GrRenderTarget* rt,
}
GrPipelineBuilder pipelineBuilder(paint, rt, clip);
fDrawTarget->drawBWRect(pipelineBuilder,
paint.getColor(),
viewMatrix,
rectToDraw,
localMatrix);
fDrawTarget->drawNonAARect(pipelineBuilder,
paint.getColor(),
viewMatrix,
rectToDraw,
localMatrix);
}
void GrDrawContext::drawVertices(GrRenderTarget* rt,
@ -642,7 +642,7 @@ void GrDrawContext::drawPath(GrRenderTarget* rt,
SkRect rects[2];
if (is_nested_rects(viewMatrix, path, strokeInfo, rects)) {
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateFillNestedRectsAA(
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFillNestedRects(
color, viewMatrix, rects));
fDrawTarget->drawBatch(pipelineBuilder, batch);
return;

View File

@ -309,32 +309,32 @@ void GrDrawTarget::drawPaths(const GrPipelineBuilder& pipelineBuilder,
transformType, count, stencilSettings, pipelineInfo);
}
void GrDrawTarget::drawBWRect(const GrPipelineBuilder& pipelineBuilder,
void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect) {
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateFillBW(color, viewMatrix, rect,
nullptr, nullptr));
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, viewMatrix, rect,
nullptr, nullptr));
this->drawBatch(pipelineBuilder, batch);
}
void GrDrawTarget::drawBWRect(const GrPipelineBuilder& pipelineBuilder,
void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkMatrix& localMatrix) {
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateFillBW(color, viewMatrix, rect,
nullptr, &localMatrix));
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, viewMatrix, rect,
nullptr, &localMatrix));
this->drawBatch(pipelineBuilder, batch);
}
void GrDrawTarget::drawBWRect(const GrPipelineBuilder& pipelineBuilder,
void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect& localRect) {
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateFillBW(color, viewMatrix, rect,
&localRect, nullptr));
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, viewMatrix, rect,
&localRect, nullptr));
this->drawBatch(pipelineBuilder, batch);
}
@ -344,7 +344,7 @@ void GrDrawTarget::drawAARect(const GrPipelineBuilder& pipelineBuilder,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect& devRect) {
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateFillAA(color, viewMatrix, rect,
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill(color, viewMatrix, rect,
devRect));
this->drawBatch(pipelineBuilder, batch);
}
@ -378,7 +378,7 @@ void GrDrawTarget::clear(const SkIRect* rect,
GrPipelineBuilder pipelineBuilder;
pipelineBuilder.setRenderTarget(renderTarget);
this->drawSimpleRect(pipelineBuilder, color, SkMatrix::I(), *rect);
this->drawNonAARect(pipelineBuilder, color, SkMatrix::I(), *rect);
} else {
GrBatch* batch = SkNEW_ARGS(GrClearBatch, (*rect, color, renderTarget));
this->onDrawBatch(batch);

View File

@ -120,34 +120,29 @@ 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 drawNonAARect(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 drawNonAARect(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);
void drawNonAARect(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);
}
void drawSimpleRect(const GrPipelineBuilder& ds, GrColor color, const SkMatrix& viewM,
const SkIRect& irect) {
void drawNonAARect(const GrPipelineBuilder& ds,
GrColor color,
const SkMatrix& viewM,
const SkIRect& irect) {
SkRect rect = SkRect::Make(irect);
this->drawBWRect(ds, color, viewM, rect);
this->drawNonAARect(ds, color, viewM, rect);
}
void drawAARect(const GrPipelineBuilder& pipelineBuilder,

View File

@ -1458,7 +1458,7 @@ bool GrOvalRenderer::DrawDRRect(GrDrawTarget* target,
if (applyAA) {
bounds.outset(SK_ScalarHalf, SK_ScalarHalf);
}
target->drawBWRect(pipelineBuilder, color, SkMatrix::I(), bounds, invert);
target->drawNonAARect(pipelineBuilder, color, SkMatrix::I(), bounds, invert);
return true;
}

View File

@ -373,5 +373,5 @@ void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture,
GrTextureParams::kNone_FilterMode,
kDevice_GrCoordSet))->unref();
target->drawBWRect(*pipelineBuilder, color, SkMatrix::I(), dstRect, invert);
target->drawNonAARect(*pipelineBuilder, color, SkMatrix::I(), dstRect, invert);
}

View File

@ -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, invert);
target->drawNonAARect(*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, invert);
target->drawNonAARect(*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, invert);
target->drawNonAARect(*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, invert);
target->drawNonAARect(*pipelineBuilder, color, SkMatrix::I(), rect, invert);
}
}

View File

@ -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, invert);
args.fTarget->drawNonAARect(*pipelineBuilder, args.fColor, viewM, bounds, invert);
} else {
GR_STATIC_CONST_SAME_STENCIL(kStencilPass,
kZero_StencilOp,

View File

@ -986,7 +986,7 @@ static void draw_aa_bitmap(GrDrawContext* drawContext, GrContext* context,
}
matrix.preConcat(dstRectToSrcRect);
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateFillAA(grPaint.getColor(),
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill(grPaint.getColor(),
viewMatrix,
matrix,
dstRect,

View File

@ -30,7 +30,7 @@ static GrDrawBatch* create_stroke_aa_batch(GrColor color,
namespace GrRectBatchFactory {
GrDrawBatch* CreateStrokeBW(GrColor color,
GrDrawBatch* CreateNonAAStroke(GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect,
SkScalar strokeWidth,
@ -43,7 +43,7 @@ GrDrawBatch* CreateStrokeBW(GrColor color,
return GrStrokeRectBatch::Create(geometry, snapToPixelCenters);
}
GrDrawBatch* CreateStrokeAA(GrColor color,
GrDrawBatch* CreateAAStroke(GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect& devRect,
@ -82,7 +82,7 @@ GrDrawBatch* CreateStrokeAA(GrColor color,
}
if (spare <= 0 && miterStroke) {
return CreateFillAA(color, viewMatrix, devOutside, devOutside);
return CreateAAFill(color, viewMatrix, devOutside, devOutside);
}
SkRect devInside(devRect);
@ -102,7 +102,7 @@ GrDrawBatch* CreateStrokeAA(GrColor color,
miterStroke);
}
GrDrawBatch* CreateFillNestedRectsAA(GrColor color,
GrDrawBatch* CreateAAFillNestedRects(GrColor color,
const SkMatrix& viewMatrix,
const SkRect rects[2]) {
SkASSERT(viewMatrix.rectStaysRect());
@ -113,7 +113,7 @@ GrDrawBatch* CreateFillNestedRectsAA(GrColor color,
viewMatrix.mapRect(&devInside, rects[1]);
if (devInside.isEmpty()) {
return CreateFillAA(color, viewMatrix, devOutside, devOutside);
return CreateAAFill(color, viewMatrix, devOutside, devOutside);
}
return create_stroke_aa_batch(color, viewMatrix, devOutside, devOutside, devInside, true);

View File

@ -22,22 +22,22 @@ class SkStrokeRec;
*/
namespace GrRectBatchFactory {
inline GrDrawBatch* CreateFillBW(GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect* localRect,
const SkMatrix* localMatrix) {
inline GrDrawBatch* CreateNonAAFill(GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect* localRect,
const SkMatrix* localMatrix) {
return GrBWFillRectBatch::Create(color, viewMatrix, rect, localRect, localMatrix);
}
inline GrDrawBatch* CreateFillAA(GrColor color,
inline GrDrawBatch* CreateAAFill(GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect& devRect) {
return GrAAFillRectBatch::Create(color, viewMatrix, rect, devRect);
}
inline GrDrawBatch* CreateFillAA(GrColor color,
inline GrDrawBatch* CreateAAFill(GrColor color,
const SkMatrix& viewMatrix,
const SkMatrix& localMatrix,
const SkRect& rect,
@ -45,20 +45,20 @@ inline GrDrawBatch* CreateFillAA(GrColor color,
return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRect);
}
GrDrawBatch* CreateStrokeBW(GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect,
SkScalar strokeWidth,
bool snapToPixelCenters);
GrDrawBatch* CreateNonAAStroke(GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect,
SkScalar strokeWidth,
bool snapToPixelCenters);
GrDrawBatch* CreateStrokeAA(GrColor,
GrDrawBatch* CreateAAStroke(GrColor,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect& devRect,
const SkStrokeRec& stroke);
// First rect is outer; second rect is inner
GrDrawBatch* CreateFillNestedRectsAA(GrColor,
GrDrawBatch* CreateAAFillNestedRects(GrColor,
const SkMatrix& viewMatrix,
const SkRect rects[2]);