Remove old GrFillRectOp factories
Also renames MakeGeneric() back to Make() and updates tests
Change-Id: I493c40d84ef1a075bddca72939f46a81bea5dea7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215091
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index c936949..a8fb70d 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -409,7 +409,8 @@
// Use the disabled clip; the rect geometry already matches the clear rectangle and
// if it were added to a scissor, that would be intersected with the logical surface
// bounds and not the worst case dimensions required here.
- fRenderTargetContext->addDrawOp(GrFixedClip::Disabled(),
+ fRenderTargetContext->addDrawOp(
+ GrFixedClip::Disabled(),
GrFillRectOp::MakeNonAARect(fRenderTargetContext->fContext, std::move(paint),
SkMatrix::I(), SkRect::Make(rtRect)));
} else {
@@ -431,7 +432,8 @@
// width and height like in internalClear().
GrPaint paint;
clear_to_grpaint(color, &paint);
- fRenderTargetContext->addDrawOp(GrFixedClip::Disabled(),
+ fRenderTargetContext->addDrawOp(
+ GrFixedClip::Disabled(),
GrFillRectOp::MakeNonAARect(fRenderTargetContext->fContext, std::move(paint),
SkMatrix::I(), SkRect::Make(rtRect)));
} else {
@@ -495,7 +497,7 @@
}
AutoCheckFlush acf(this->drawingManager());
- std::unique_ptr<GrDrawOp> op = GrFillRectOp::MakeGeneric(
+ std::unique_ptr<GrDrawOp> op = GrFillRectOp::Make(
fContext, std::move(paint), GrAAType::kNone, GrQuadAAFlags::kNone,
GrPerspQuad(r), GrPerspQuad::MakeFromRect(r, localMatrix));
this->addDrawOp(clip, std::move(op));
@@ -692,8 +694,8 @@
aa = edgeFlags == GrQuadAAFlags::kNone ? GrAA::kNo : GrAA::kYes;
GrAAType aaType = this->chooseAAType(aa);
this->addDrawOp(GrFixedClip::Disabled(),
- GrFillRectOp::MakeGeneric(fContext, std::move(paint), aaType, edgeFlags,
- GrPerspQuad(combinedRect), GrPerspQuad(combinedRect)));
+ GrFillRectOp::Make(fContext, std::move(paint), aaType, edgeFlags,
+ GrPerspQuad(combinedRect), GrPerspQuad(combinedRect)));
return true;
}
@@ -719,9 +721,11 @@
}
GrAAType aaType = this->chooseAAType(aa);
- this->addDrawOp(clip, GrFillRectOp::MakeGeneric(fContext, std::move(paint), aaType,
- aa == GrAA::kYes ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone,
- GrPerspQuad::MakeFromRect(croppedRect, viewMatrix), GrPerspQuad(croppedRect), ss));
+ GrQuadAAFlags edgeFlags = aa == GrAA::kYes ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone;
+ this->addDrawOp(clip,
+ GrFillRectOp::Make(fContext, std::move(paint), aaType, edgeFlags,
+ GrPerspQuad::MakeFromRect(croppedRect, viewMatrix),
+ GrPerspQuad(croppedRect), ss));
}
void GrRenderTargetContext::drawRect(const GrClip& clip,
@@ -906,7 +910,7 @@
GrPerspQuad localQuad = localMatrix ? GrPerspQuad::MakeFromRect(rect, *localMatrix)
: GrPerspQuad(rect);
- std::unique_ptr<GrDrawOp> op = GrFillRectOp::MakeGeneric(
+ std::unique_ptr<GrDrawOp> op = GrFillRectOp::Make(
fRenderTargetContext->fContext, std::move(paint), aaType, GrQuadAAFlags::kNone,
GrPerspQuad::MakeFromRect(rect, viewMatrix), localQuad, ss);
fRenderTargetContext->addDrawOp(clip, std::move(op));
@@ -932,9 +936,9 @@
&croppedLocalRect)) {
return;
}
- op = GrFillRectOp::MakeGeneric(fContext, std::move(paint), aaType, edgeAA,
- GrPerspQuad::MakeFromRect(croppedRect, viewMatrix),
- GrPerspQuad(croppedLocalRect));
+ op = GrFillRectOp::Make(fContext, std::move(paint), aaType, edgeAA,
+ GrPerspQuad::MakeFromRect(croppedRect, viewMatrix),
+ GrPerspQuad(croppedLocalRect));
} else {
// If aaType turns into MSAA, make sure to keep quads with no AA edges as MSAA. Sending
// those to drawFilledRect() would have it turn off MSAA in that case, which breaks seaming
@@ -952,8 +956,9 @@
if (!crop_filled_rect(this->width(), this->height(), clip, viewMatrix, &croppedRect)) {
return;
}
- op = GrFillRectOp::MakeGeneric(fContext, std::move(paint), aaType, edgeAA,
- GrPerspQuad::MakeFromRect(croppedRect, viewMatrix), GrPerspQuad(croppedRect));
+ op = GrFillRectOp::Make(fContext, std::move(paint), aaType, edgeAA,
+ GrPerspQuad::MakeFromRect(croppedRect, viewMatrix),
+ GrPerspQuad(croppedRect));
}
AutoCheckFlush acf(this->drawingManager());
@@ -972,9 +977,10 @@
AutoCheckFlush acf(this->drawingManager());
const SkPoint* localPoints = localQuad ? localQuad : quad;
- this->addDrawOp(clip, GrFillRectOp::MakeGeneric(fContext, std::move(paint), aaType, edgeAA,
- GrPerspQuad::MakeFromSkQuad(quad, viewMatrix),
- GrPerspQuad::MakeFromSkQuad(localPoints, SkMatrix::I())));
+ this->addDrawOp(clip,
+ GrFillRectOp::Make(fContext, std::move(paint), aaType, edgeAA,
+ GrPerspQuad::MakeFromSkQuad(quad, viewMatrix),
+ GrPerspQuad::MakeFromSkQuad(localPoints, SkMatrix::I())));
}
// Creates a paint for GrFillRectOp that matches behavior of GrTextureOp
@@ -1040,8 +1046,9 @@
draw_texture_to_grpaint(std::move(proxy),
constraint == SkCanvas::kStrict_SrcRectConstraint ? &srcRect : nullptr,
filter, mode, color, std::move(textureColorSpaceXform), &paint);
- op = GrFillRectOp::MakeGeneric(fContext, std::move(paint), aaType, aaFlags,
- GrPerspQuad::MakeFromRect(clippedDstRect, viewMatrix), GrPerspQuad(clippedSrcRect));
+ op = GrFillRectOp::Make(fContext, std::move(paint), aaType, aaFlags,
+ GrPerspQuad::MakeFromRect(clippedDstRect, viewMatrix),
+ GrPerspQuad(clippedSrcRect));
} else {
// Can use a lighter weight op that can chain across proxies
op = GrTextureOp::Make(fContext, std::move(proxy), filter, color, clippedSrcRect,
@@ -1079,9 +1086,9 @@
GrPaint paint;
draw_texture_to_grpaint(
std::move(proxy), domain, filter, mode, color, std::move(texXform), &paint);
- op = GrFillRectOp::MakeGeneric(fContext, std::move(paint), aaType, aaFlags,
- GrPerspQuad::MakeFromSkQuad(dstQuad, viewMatrix),
- GrPerspQuad::MakeFromSkQuad(srcQuad, SkMatrix::I()));
+ op = GrFillRectOp::Make(fContext, std::move(paint), aaType, aaFlags,
+ GrPerspQuad::MakeFromSkQuad(dstQuad, viewMatrix),
+ GrPerspQuad::MakeFromSkQuad(srcQuad, SkMatrix::I()));
} else {
// Use lighter weight GrTextureOp
op = GrTextureOp::MakeQuad(fContext, std::move(proxy), filter, color, srcQuad, dstQuad,
@@ -1158,10 +1165,11 @@
AutoCheckFlush acf(this->drawingManager());
GrAAType aaType = this->chooseAAType(aa);
- this->addDrawOp(clip, GrFillRectOp::MakeGeneric(fContext, std::move(paint), aaType,
- aa == GrAA::kYes ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone,
- GrPerspQuad::MakeFromRect(croppedRect, viewMatrix),
- GrPerspQuad::MakeFromRect(croppedRect, localMatrix)));
+ GrQuadAAFlags edgeFlags = aa == GrAA::kYes ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone;
+ this->addDrawOp(clip,
+ GrFillRectOp::Make(fContext, std::move(paint), aaType, edgeFlags,
+ GrPerspQuad::MakeFromRect(croppedRect, viewMatrix),
+ GrPerspQuad::MakeFromRect(croppedRect, localMatrix)));
}
void GrRenderTargetContext::drawVertices(const GrClip& clip,
diff --git a/src/gpu/ops/GrFillRectOp.cpp b/src/gpu/ops/GrFillRectOp.cpp
index 50dd1c0..949187d 100644
--- a/src/gpu/ops/GrFillRectOp.cpp
+++ b/src/gpu/ops/GrFillRectOp.cpp
@@ -345,13 +345,13 @@
namespace GrFillRectOp {
-std::unique_ptr<GrDrawOp> MakeGeneric(GrRecordingContext* context,
- GrPaint&& paint,
- GrAAType aaType,
- GrQuadAAFlags aaFlags,
- const GrPerspQuad& deviceQuad,
- const GrPerspQuad& localQuad,
- const GrUserStencilSettings* stencil) {
+std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context,
+ GrPaint&& paint,
+ GrAAType aaType,
+ GrQuadAAFlags aaFlags,
+ const GrPerspQuad& deviceQuad,
+ const GrPerspQuad& localQuad,
+ const GrUserStencilSettings* stencil) {
return FillRectOp::Make(context, std::move(paint), aaType, aaFlags, stencil,
deviceQuad, localQuad);
}
@@ -361,60 +361,8 @@
const SkMatrix& view,
const SkRect& rect,
const GrUserStencilSettings* stencil) {
- return MakeGeneric(context, std::move(paint), GrAAType::kNone, GrQuadAAFlags::kNone,
- GrPerspQuad::MakeFromRect(rect, view), GrPerspQuad(rect), stencil);
-}
-
-std::unique_ptr<GrDrawOp> MakePerEdge(GrRecordingContext* context,
- GrPaint&& paint,
- GrAAType aaType,
- GrQuadAAFlags edgeAA,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const GrUserStencilSettings* stencilSettings) {
- return MakeGeneric(context, std::move(paint), aaType, edgeAA,
- GrPerspQuad::MakeFromRect(rect, viewMatrix),
- GrPerspQuad(rect), stencilSettings);
-}
-
-std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalMatrix(GrRecordingContext* context,
- GrPaint&& paint,
- GrAAType aaType,
- GrQuadAAFlags edgeAA,
- const SkMatrix& viewMatrix,
- const SkMatrix& localMatrix,
- const SkRect& rect,
- const GrUserStencilSettings* stencilSettings) {
- return MakeGeneric(context, std::move(paint), aaType, edgeAA,
- GrPerspQuad::MakeFromRect(rect, viewMatrix),
- GrPerspQuad::MakeFromRect(rect, localMatrix), stencilSettings);
-}
-
-std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalRect(GrRecordingContext* context,
- GrPaint&& paint,
- GrAAType aaType,
- GrQuadAAFlags edgeAA,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& localRect,
- const GrUserStencilSettings* stencilSettings) {
- return MakeGeneric(context, std::move(paint), aaType, edgeAA,
- GrPerspQuad::MakeFromRect(rect, viewMatrix),
- GrPerspQuad(localRect), stencilSettings);
-}
-
-std::unique_ptr<GrDrawOp> MakePerEdgeQuad(GrRecordingContext* context,
- GrPaint&& paint,
- GrAAType aaType,
- GrQuadAAFlags edgeAA,
- const SkMatrix& viewMatrix,
- const SkPoint quad[4],
- const SkPoint localQuad[4],
- const GrUserStencilSettings* stencilSettings) {
- const SkPoint* localPoints = localQuad ? localQuad : quad;
- return MakeGeneric(context, std::move(paint), aaType, edgeAA,
- GrPerspQuad::MakeFromSkQuad(quad, viewMatrix),
- GrPerspQuad::MakeFromSkQuad(localPoints, SkMatrix::I()), stencilSettings);
+ return FillRectOp::Make(context, std::move(paint), GrAAType::kNone, GrQuadAAFlags::kNone,
+ stencil, GrPerspQuad::MakeFromRect(rect, view), GrPerspQuad(rect));
}
std::unique_ptr<GrDrawOp> MakeSet(GrRecordingContext* context,
@@ -451,41 +399,6 @@
return op;
}
-std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context,
- GrPaint&& paint,
- GrAAType aaType,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const GrUserStencilSettings* stencil) {
- return MakePerEdge(context, std::move(paint), aaType,
- aaType == GrAAType::kCoverage ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone,
- viewMatrix, rect, stencil);
-}
-
-std::unique_ptr<GrDrawOp> MakeWithLocalMatrix(GrRecordingContext* context,
- GrPaint&& paint,
- GrAAType aaType,
- const SkMatrix& viewMatrix,
- const SkMatrix& localMatrix,
- const SkRect& rect,
- const GrUserStencilSettings* stencil) {
- return MakePerEdgeWithLocalMatrix(context, std::move(paint), aaType,
- aaType == GrAAType::kCoverage ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone,
- viewMatrix, localMatrix, rect, stencil);
-}
-
-std::unique_ptr<GrDrawOp> MakeWithLocalRect(GrRecordingContext* context,
- GrPaint&& paint,
- GrAAType aaType,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& localRect,
- const GrUserStencilSettings* stencil) {
- return MakePerEdgeWithLocalRect(context, std::move(paint), aaType,
- aaType == GrAAType::kCoverage ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone,
- viewMatrix, rect, localRect, stencil);
-}
-
} // namespace GrFillRectOp
#if GR_TEST_UTILS
@@ -537,21 +450,22 @@
} else {
// Single local matrix
SkMatrix localMatrix = GrTest::TestMatrixInvertible(random);
- return GrFillRectOp::MakePerEdgeWithLocalMatrix(context, std::move(paint), aaType,
- aaFlags, viewMatrix, localMatrix,
- rect, stencil);
+ return GrFillRectOp::Make(context, std::move(paint), aaType, aaFlags,
+ GrPerspQuad::MakeFromRect(rect, viewMatrix),
+ GrPerspQuad::MakeFromRect(rect, localMatrix), stencil);
}
} else {
// Pass local rect directly
SkRect localRect = GrTest::TestRect(random);
- return GrFillRectOp::MakePerEdgeWithLocalRect(context, std::move(paint), aaType,
- aaFlags, viewMatrix, rect, localRect,
- stencil);
+ return GrFillRectOp::Make(context, std::move(paint), aaType, aaFlags,
+ GrPerspQuad::MakeFromRect(rect, viewMatrix),
+ GrPerspQuad(localRect), stencil);
}
} else {
// The simplest constructor
- return GrFillRectOp::MakePerEdge(context, std::move(paint), aaType, aaFlags, viewMatrix,
- rect, stencil);
+ return GrFillRectOp::Make(context, std::move(paint), aaType, aaFlags,
+ GrPerspQuad::MakeFromRect(rect, viewMatrix),
+ GrPerspQuad(rect), stencil);
}
}
diff --git a/src/gpu/ops/GrFillRectOp.h b/src/gpu/ops/GrFillRectOp.h
index d472d6b..3422631 100644
--- a/src/gpu/ops/GrFillRectOp.h
+++ b/src/gpu/ops/GrFillRectOp.h
@@ -27,14 +27,13 @@
*/
namespace GrFillRectOp {
-// FIXME(michaelludwig) - To be renamed Make() after narrow functions are removed
-std::unique_ptr<GrDrawOp> MakeGeneric(GrRecordingContext* context,
- GrPaint&& paint,
- GrAAType aaType,
- GrQuadAAFlags aaFlags,
- const GrPerspQuad& deviceQuad,
- const GrPerspQuad& localQuad,
- const GrUserStencilSettings* stencil = nullptr);
+std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context,
+ GrPaint&& paint,
+ GrAAType aaType,
+ GrQuadAAFlags aaFlags,
+ const GrPerspQuad& deviceQuad,
+ const GrPerspQuad& localQuad,
+ const GrUserStencilSettings* stencil = nullptr);
// Utility function to create a non-AA rect transformed by view. This is used commonly enough in
// testing and GMs that manage ops without going through GrRTC that it's worth the convenience.
@@ -44,48 +43,6 @@
const SkRect& rect,
const GrUserStencilSettings* stencil = nullptr);
-// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
-// General purpose factory functions that handle per-edge anti-aliasing
-std::unique_ptr<GrDrawOp> MakePerEdge(GrRecordingContext* context,
- GrPaint&& paint,
- GrAAType aaType,
- GrQuadAAFlags edgeAA,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const GrUserStencilSettings* stencil = nullptr);
-
-// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
-std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalMatrix(GrRecordingContext* context,
- GrPaint&& paint,
- GrAAType aaType,
- GrQuadAAFlags edgeAA,
- const SkMatrix& viewMatrix,
- const SkMatrix& localMatrix,
- const SkRect& rect,
- const GrUserStencilSettings* stl = nullptr);
-
-// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
-std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalRect(GrRecordingContext* context,
- GrPaint&& paint,
- GrAAType aaType,
- GrQuadAAFlags edgeAA,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& localRect,
- const GrUserStencilSettings* stencil = nullptr);
-
-// Generalization that accepts 2D convex quads instead of just rectangles. If 'localQuad' is not
-// null, this is equivalent to the "WithLocalRect" versions. Quad arrays match SkRect::toQuad order.
-// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
-std::unique_ptr<GrDrawOp> MakePerEdgeQuad(GrRecordingContext* context,
- GrPaint&& paint,
- GrAAType aaType,
- GrQuadAAFlags edgeAA,
- const SkMatrix& viewMatrix,
- const SkPoint quad[4],
- const SkPoint localQuad[4],
- const GrUserStencilSettings* stencil = nullptr);
-
// Bulk API for drawing quads with a single op
// TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer
std::unique_ptr<GrDrawOp> MakeSet(GrRecordingContext* context,
@@ -96,32 +53,6 @@
int quadCount,
const GrUserStencilSettings* stencil = nullptr);
-// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
-// Specializations where all edges are treated the same. If the aa type is coverage, then the
-// edges will be anti-aliased, otherwise per-edge AA will be disabled.
-std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context,
- GrPaint&& paint,
- GrAAType aaType,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const GrUserStencilSettings* stencil = nullptr);
-// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
-std::unique_ptr<GrDrawOp> MakeWithLocalMatrix(GrRecordingContext* context,
- GrPaint&& paint,
- GrAAType aaType,
- const SkMatrix& viewMatrix,
- const SkMatrix& localMatrix,
- const SkRect& rect,
- const GrUserStencilSettings* stencil = nullptr);
-// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
-std::unique_ptr<GrDrawOp> MakeWithLocalRect(GrRecordingContext* context,
- GrPaint&& paint,
- GrAAType aaType,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& localRect,
- const GrUserStencilSettings* stencil = nullptr);
-
} // namespace GrFillRectOp
#endif // GrFillRectOp_DEFINED
diff --git a/src/gpu/ops/GrStrokeRectOp.cpp b/src/gpu/ops/GrStrokeRectOp.cpp
index 407c323..1dd2bd6 100644
--- a/src/gpu/ops/GrStrokeRectOp.cpp
+++ b/src/gpu/ops/GrStrokeRectOp.cpp
@@ -774,10 +774,10 @@
if (devOutside.isEmpty()) {
return nullptr;
}
- return GrFillRectOp::MakeGeneric(context, std::move(paint), GrAAType::kCoverage,
- GrQuadAAFlags::kAll,
- GrPerspQuad::MakeFromRect(rects[0], viewMatrix),
- GrPerspQuad(rects[0]));
+ return GrFillRectOp::Make(context, std::move(paint), GrAAType::kCoverage,
+ GrQuadAAFlags::kAll,
+ GrPerspQuad::MakeFromRect(rects[0], viewMatrix),
+ GrPerspQuad(rects[0]));
}
return AAStrokeRectOp::Make(context, std::move(paint), viewMatrix, devOutside, devInside);