blob: 824fd8bafc06100fffaf1765f57942e6b565558a [file] [log] [blame]
Michael Ludwig69858532018-11-28 15:34:34 -05001/*
2 * Copyright 2018 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrFillRectOp_DEFINED
9#define GrFillRectOp_DEFINED
10
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/private/GrTypesPriv.h"
12#include "src/gpu/GrRenderTargetContext.h"
Michael Ludwig69858532018-11-28 15:34:34 -050013
14class GrDrawOp;
15class GrPaint;
Michael Ludwigd9f917b2019-05-24 12:57:55 -040016class GrPerspQuad;
Robert Phillipsb97da532019-02-12 15:24:12 -050017class GrRecordingContext;
Michael Ludwig69858532018-11-28 15:34:34 -050018struct GrUserStencilSettings;
19class SkMatrix;
20struct SkRect;
21
Michael Ludwig72ab3462018-12-10 12:43:36 -050022/**
23 * A set of factory functions for drawing filled rectangles either coverage-antialiased, or
24 * non-antialiased. The non-antialiased ops can be used with MSAA. As with other GrDrawOp factories,
25 * the GrPaint is only consumed by these methods if a valid op is returned. If null is returned then
26 * the paint is unmodified and may still be used.
27 */
Michael Ludwig69858532018-11-28 15:34:34 -050028namespace GrFillRectOp {
29
Michael Ludwigd9f917b2019-05-24 12:57:55 -040030// FIXME(michaelludwig) - To be renamed Make() after narrow functions are removed
31std::unique_ptr<GrDrawOp> MakeGeneric(GrRecordingContext* context,
32 GrPaint&& paint,
33 GrAAType aaType,
34 GrQuadAAFlags aaFlags,
35 const GrPerspQuad& deviceQuad,
36 const GrPerspQuad& localQuad,
37 const GrUserStencilSettings* stencil = nullptr);
38
39// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
Michael Ludwig72ab3462018-12-10 12:43:36 -050040// General purpose factory functions that handle per-edge anti-aliasing
Robert Phillipsb97da532019-02-12 15:24:12 -050041std::unique_ptr<GrDrawOp> MakePerEdge(GrRecordingContext* context,
Michael Ludwig72ab3462018-12-10 12:43:36 -050042 GrPaint&& paint,
43 GrAAType aaType,
44 GrQuadAAFlags edgeAA,
45 const SkMatrix& viewMatrix,
46 const SkRect& rect,
47 const GrUserStencilSettings* stencil = nullptr);
48
Michael Ludwigd9f917b2019-05-24 12:57:55 -040049// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
Robert Phillipsb97da532019-02-12 15:24:12 -050050std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalMatrix(GrRecordingContext* context,
Michael Ludwig72ab3462018-12-10 12:43:36 -050051 GrPaint&& paint,
52 GrAAType aaType,
53 GrQuadAAFlags edgeAA,
54 const SkMatrix& viewMatrix,
55 const SkMatrix& localMatrix,
56 const SkRect& rect,
57 const GrUserStencilSettings* stl = nullptr);
58
Michael Ludwigd9f917b2019-05-24 12:57:55 -040059// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
Robert Phillipsb97da532019-02-12 15:24:12 -050060std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalRect(GrRecordingContext* context,
Michael Ludwig72ab3462018-12-10 12:43:36 -050061 GrPaint&& paint,
62 GrAAType aaType,
63 GrQuadAAFlags edgeAA,
64 const SkMatrix& viewMatrix,
65 const SkRect& rect,
66 const SkRect& localRect,
67 const GrUserStencilSettings* stencil = nullptr);
68
Michael Ludwig009b92e2019-02-15 16:03:53 -050069// Generalization that accepts 2D convex quads instead of just rectangles. If 'localQuad' is not
70// null, this is equivalent to the "WithLocalRect" versions. Quad arrays match SkRect::toQuad order.
Michael Ludwigd9f917b2019-05-24 12:57:55 -040071// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
Michael Ludwig009b92e2019-02-15 16:03:53 -050072std::unique_ptr<GrDrawOp> MakePerEdgeQuad(GrRecordingContext* context,
73 GrPaint&& paint,
74 GrAAType aaType,
75 GrQuadAAFlags edgeAA,
76 const SkMatrix& viewMatrix,
77 const SkPoint quad[4],
78 const SkPoint localQuad[4],
79 const GrUserStencilSettings* stencil = nullptr);
80
Michael Ludwig72ab3462018-12-10 12:43:36 -050081// Bulk API for drawing quads with a single op
Michael Ludwig75451902019-01-23 11:14:29 -050082// TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer
Robert Phillipsb97da532019-02-12 15:24:12 -050083std::unique_ptr<GrDrawOp> MakeSet(GrRecordingContext* context,
Michael Ludwig72ab3462018-12-10 12:43:36 -050084 GrPaint&& paint,
85 GrAAType aaType,
86 const SkMatrix& viewMatrix,
87 const GrRenderTargetContext::QuadSetEntry quads[],
88 int quadCount,
89 const GrUserStencilSettings* stencil = nullptr);
90
Michael Ludwigd9f917b2019-05-24 12:57:55 -040091// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
Michael Ludwig72ab3462018-12-10 12:43:36 -050092// Specializations where all edges are treated the same. If the aa type is coverage, then the
93// edges will be anti-aliased, otherwise per-edge AA will be disabled.
Robert Phillipsb97da532019-02-12 15:24:12 -050094std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context,
Michael Ludwig69858532018-11-28 15:34:34 -050095 GrPaint&& paint,
96 GrAAType aaType,
Michael Ludwig69858532018-11-28 15:34:34 -050097 const SkMatrix& viewMatrix,
98 const SkRect& rect,
99 const GrUserStencilSettings* stencil = nullptr);
Michael Ludwigd9f917b2019-05-24 12:57:55 -0400100// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
Robert Phillipsb97da532019-02-12 15:24:12 -0500101std::unique_ptr<GrDrawOp> MakeWithLocalMatrix(GrRecordingContext* context,
Michael Ludwig69858532018-11-28 15:34:34 -0500102 GrPaint&& paint,
103 GrAAType aaType,
Michael Ludwig69858532018-11-28 15:34:34 -0500104 const SkMatrix& viewMatrix,
105 const SkMatrix& localMatrix,
106 const SkRect& rect,
107 const GrUserStencilSettings* stencil = nullptr);
Michael Ludwigd9f917b2019-05-24 12:57:55 -0400108// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
Robert Phillipsb97da532019-02-12 15:24:12 -0500109std::unique_ptr<GrDrawOp> MakeWithLocalRect(GrRecordingContext* context,
Michael Ludwig69858532018-11-28 15:34:34 -0500110 GrPaint&& paint,
111 GrAAType aaType,
Michael Ludwig69858532018-11-28 15:34:34 -0500112 const SkMatrix& viewMatrix,
113 const SkRect& rect,
114 const SkRect& localRect,
115 const GrUserStencilSettings* stencil = nullptr);
116
Michael Ludwig72ab3462018-12-10 12:43:36 -0500117} // namespace GrFillRectOp
Michael Ludwig69858532018-11-28 15:34:34 -0500118
119#endif // GrFillRectOp_DEFINED