Add generic factory function to GrFillRectOp
Bug: skia:
Change-Id: Iaa56cdb8107dc278e585807ec10aeae53150b97a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214720
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/ops/GrFillRectOp.cpp b/src/gpu/ops/GrFillRectOp.cpp
index aad26c1..9cdf3f0 100644
--- a/src/gpu/ops/GrFillRectOp.cpp
+++ b/src/gpu/ops/GrFillRectOp.cpp
@@ -345,6 +345,17 @@
namespace GrFillRectOp {
+std::unique_ptr<GrDrawOp> MakeGeneric(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);
+}
+
std::unique_ptr<GrDrawOp> MakePerEdge(GrRecordingContext* context,
GrPaint&& paint,
GrAAType aaType,
@@ -352,8 +363,9 @@
const SkMatrix& viewMatrix,
const SkRect& rect,
const GrUserStencilSettings* stencilSettings) {
- return FillRectOp::Make(context, std::move(paint), aaType, edgeAA, stencilSettings,
- GrPerspQuad::MakeFromRect(rect, viewMatrix), GrPerspQuad(rect));
+ return MakeGeneric(context, std::move(paint), aaType, edgeAA,
+ GrPerspQuad::MakeFromRect(rect, viewMatrix),
+ GrPerspQuad(rect), stencilSettings);
}
std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalMatrix(GrRecordingContext* context,
@@ -364,9 +376,9 @@
const SkMatrix& localMatrix,
const SkRect& rect,
const GrUserStencilSettings* stencilSettings) {
- return FillRectOp::Make(context, std::move(paint), aaType, edgeAA, stencilSettings,
- GrPerspQuad::MakeFromRect(rect, viewMatrix),
- GrPerspQuad::MakeFromRect(rect, localMatrix));
+ return MakeGeneric(context, std::move(paint), aaType, edgeAA,
+ GrPerspQuad::MakeFromRect(rect, viewMatrix),
+ GrPerspQuad::MakeFromRect(rect, localMatrix), stencilSettings);
}
std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalRect(GrRecordingContext* context,
@@ -377,8 +389,9 @@
const SkRect& rect,
const SkRect& localRect,
const GrUserStencilSettings* stencilSettings) {
- return FillRectOp::Make(context, std::move(paint), aaType, edgeAA, stencilSettings,
- GrPerspQuad::MakeFromRect(rect, viewMatrix), GrPerspQuad(localRect));
+ return MakeGeneric(context, std::move(paint), aaType, edgeAA,
+ GrPerspQuad::MakeFromRect(rect, viewMatrix),
+ GrPerspQuad(localRect), stencilSettings);
}
std::unique_ptr<GrDrawOp> MakePerEdgeQuad(GrRecordingContext* context,
@@ -389,10 +402,10 @@
const SkPoint quad[4],
const SkPoint localQuad[4],
const GrUserStencilSettings* stencilSettings) {
- return FillRectOp::Make(context, std::move(paint), aaType, edgeAA, stencilSettings,
- GrPerspQuad::MakeFromSkQuad(quad, viewMatrix),
- GrPerspQuad::MakeFromSkQuad(localQuad ? localQuad : quad,
- SkMatrix::I()));
+ const SkPoint* localPoints = localQuad ? localQuad : quad;
+ return MakeGeneric(context, std::move(paint), aaType, edgeAA,
+ GrPerspQuad::MakeFromSkQuad(quad, viewMatrix),
+ GrPerspQuad::MakeFromSkQuad(localPoints, SkMatrix::I()), stencilSettings);
}
std::unique_ptr<GrDrawOp> MakeSet(GrRecordingContext* context,
diff --git a/src/gpu/ops/GrFillRectOp.h b/src/gpu/ops/GrFillRectOp.h
index 686d14e..824fd8b 100644
--- a/src/gpu/ops/GrFillRectOp.h
+++ b/src/gpu/ops/GrFillRectOp.h
@@ -13,6 +13,7 @@
class GrDrawOp;
class GrPaint;
+class GrPerspQuad;
class GrRecordingContext;
struct GrUserStencilSettings;
class SkMatrix;
@@ -26,6 +27,16 @@
*/
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);
+
+// 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,
@@ -35,6 +46,7 @@
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,
@@ -44,6 +56,7 @@
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,
@@ -55,6 +68,7 @@
// 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,
@@ -74,6 +88,7 @@
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,
@@ -82,7 +97,7 @@
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,
@@ -90,7 +105,7 @@
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,