blob: d472d6b904968e42a61886b144a2b12a90a17d63 [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
Michael Ludwigaa1b6b32019-05-29 14:43:13 -040039// Utility function to create a non-AA rect transformed by view. This is used commonly enough in
40// testing and GMs that manage ops without going through GrRTC that it's worth the convenience.
41std::unique_ptr<GrDrawOp> MakeNonAARect(GrRecordingContext* context,
42 GrPaint&& paint,
43 const SkMatrix& view,
44 const SkRect& rect,
45 const GrUserStencilSettings* stencil = nullptr);
46
Michael Ludwigd9f917b2019-05-24 12:57:55 -040047// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
Michael Ludwig72ab3462018-12-10 12:43:36 -050048// General purpose factory functions that handle per-edge anti-aliasing
Robert Phillipsb97da532019-02-12 15:24:12 -050049std::unique_ptr<GrDrawOp> MakePerEdge(GrRecordingContext* context,
Michael Ludwig72ab3462018-12-10 12:43:36 -050050 GrPaint&& paint,
51 GrAAType aaType,
52 GrQuadAAFlags edgeAA,
53 const SkMatrix& viewMatrix,
54 const SkRect& rect,
55 const GrUserStencilSettings* stencil = nullptr);
56
Michael Ludwigd9f917b2019-05-24 12:57:55 -040057// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
Robert Phillipsb97da532019-02-12 15:24:12 -050058std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalMatrix(GrRecordingContext* context,
Michael Ludwig72ab3462018-12-10 12:43:36 -050059 GrPaint&& paint,
60 GrAAType aaType,
61 GrQuadAAFlags edgeAA,
62 const SkMatrix& viewMatrix,
63 const SkMatrix& localMatrix,
64 const SkRect& rect,
65 const GrUserStencilSettings* stl = nullptr);
66
Michael Ludwigd9f917b2019-05-24 12:57:55 -040067// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
Robert Phillipsb97da532019-02-12 15:24:12 -050068std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalRect(GrRecordingContext* context,
Michael Ludwig72ab3462018-12-10 12:43:36 -050069 GrPaint&& paint,
70 GrAAType aaType,
71 GrQuadAAFlags edgeAA,
72 const SkMatrix& viewMatrix,
73 const SkRect& rect,
74 const SkRect& localRect,
75 const GrUserStencilSettings* stencil = nullptr);
76
Michael Ludwig009b92e2019-02-15 16:03:53 -050077// Generalization that accepts 2D convex quads instead of just rectangles. If 'localQuad' is not
78// null, this is equivalent to the "WithLocalRect" versions. Quad arrays match SkRect::toQuad order.
Michael Ludwigd9f917b2019-05-24 12:57:55 -040079// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
Michael Ludwig009b92e2019-02-15 16:03:53 -050080std::unique_ptr<GrDrawOp> MakePerEdgeQuad(GrRecordingContext* context,
81 GrPaint&& paint,
82 GrAAType aaType,
83 GrQuadAAFlags edgeAA,
84 const SkMatrix& viewMatrix,
85 const SkPoint quad[4],
86 const SkPoint localQuad[4],
87 const GrUserStencilSettings* stencil = nullptr);
88
Michael Ludwig72ab3462018-12-10 12:43:36 -050089// Bulk API for drawing quads with a single op
Michael Ludwig75451902019-01-23 11:14:29 -050090// TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer
Robert Phillipsb97da532019-02-12 15:24:12 -050091std::unique_ptr<GrDrawOp> MakeSet(GrRecordingContext* context,
Michael Ludwig72ab3462018-12-10 12:43:36 -050092 GrPaint&& paint,
93 GrAAType aaType,
94 const SkMatrix& viewMatrix,
95 const GrRenderTargetContext::QuadSetEntry quads[],
96 int quadCount,
97 const GrUserStencilSettings* stencil = nullptr);
98
Michael Ludwigd9f917b2019-05-24 12:57:55 -040099// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
Michael Ludwig72ab3462018-12-10 12:43:36 -0500100// Specializations where all edges are treated the same. If the aa type is coverage, then the
101// edges will be anti-aliased, otherwise per-edge AA will be disabled.
Robert Phillipsb97da532019-02-12 15:24:12 -0500102std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context,
Michael Ludwig69858532018-11-28 15:34:34 -0500103 GrPaint&& paint,
104 GrAAType aaType,
Michael Ludwig69858532018-11-28 15:34:34 -0500105 const SkMatrix& viewMatrix,
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> MakeWithLocalMatrix(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 SkMatrix& localMatrix,
114 const SkRect& rect,
115 const GrUserStencilSettings* stencil = nullptr);
Michael Ludwigd9f917b2019-05-24 12:57:55 -0400116// FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric
Robert Phillipsb97da532019-02-12 15:24:12 -0500117std::unique_ptr<GrDrawOp> MakeWithLocalRect(GrRecordingContext* context,
Michael Ludwig69858532018-11-28 15:34:34 -0500118 GrPaint&& paint,
119 GrAAType aaType,
Michael Ludwig69858532018-11-28 15:34:34 -0500120 const SkMatrix& viewMatrix,
121 const SkRect& rect,
122 const SkRect& localRect,
123 const GrUserStencilSettings* stencil = nullptr);
124
Michael Ludwig72ab3462018-12-10 12:43:36 -0500125} // namespace GrFillRectOp
Michael Ludwig69858532018-11-28 15:34:34 -0500126
127#endif // GrFillRectOp_DEFINED