blob: 289172061b18c46f43fd631e281d10ea662f31c2 [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
11#include "GrRenderTargetContext.h"
12#include "GrTypesPriv.h"
13
14class GrDrawOp;
15class GrPaint;
Robert Phillipsb97da532019-02-12 15:24:12 -050016class GrRecordingContext;
Michael Ludwig69858532018-11-28 15:34:34 -050017struct GrUserStencilSettings;
18class SkMatrix;
19struct SkRect;
20
Michael Ludwig72ab3462018-12-10 12:43:36 -050021/**
22 * A set of factory functions for drawing filled rectangles either coverage-antialiased, or
23 * non-antialiased. The non-antialiased ops can be used with MSAA. As with other GrDrawOp factories,
24 * the GrPaint is only consumed by these methods if a valid op is returned. If null is returned then
25 * the paint is unmodified and may still be used.
26 */
Michael Ludwig69858532018-11-28 15:34:34 -050027namespace GrFillRectOp {
28
Michael Ludwig72ab3462018-12-10 12:43:36 -050029// General purpose factory functions that handle per-edge anti-aliasing
Robert Phillipsb97da532019-02-12 15:24:12 -050030std::unique_ptr<GrDrawOp> MakePerEdge(GrRecordingContext* context,
Michael Ludwig72ab3462018-12-10 12:43:36 -050031 GrPaint&& paint,
32 GrAAType aaType,
33 GrQuadAAFlags edgeAA,
34 const SkMatrix& viewMatrix,
35 const SkRect& rect,
36 const GrUserStencilSettings* stencil = nullptr);
37
Robert Phillipsb97da532019-02-12 15:24:12 -050038std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalMatrix(GrRecordingContext* context,
Michael Ludwig72ab3462018-12-10 12:43:36 -050039 GrPaint&& paint,
40 GrAAType aaType,
41 GrQuadAAFlags edgeAA,
42 const SkMatrix& viewMatrix,
43 const SkMatrix& localMatrix,
44 const SkRect& rect,
45 const GrUserStencilSettings* stl = nullptr);
46
Robert Phillipsb97da532019-02-12 15:24:12 -050047std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalRect(GrRecordingContext* context,
Michael Ludwig72ab3462018-12-10 12:43:36 -050048 GrPaint&& paint,
49 GrAAType aaType,
50 GrQuadAAFlags edgeAA,
51 const SkMatrix& viewMatrix,
52 const SkRect& rect,
53 const SkRect& localRect,
54 const GrUserStencilSettings* stencil = nullptr);
55
Michael Ludwig009b92e2019-02-15 16:03:53 -050056// Generalization that accepts 2D convex quads instead of just rectangles. If 'localQuad' is not
57// null, this is equivalent to the "WithLocalRect" versions. Quad arrays match SkRect::toQuad order.
58std::unique_ptr<GrDrawOp> MakePerEdgeQuad(GrRecordingContext* context,
59 GrPaint&& paint,
60 GrAAType aaType,
61 GrQuadAAFlags edgeAA,
62 const SkMatrix& viewMatrix,
63 const SkPoint quad[4],
64 const SkPoint localQuad[4],
65 const GrUserStencilSettings* stencil = nullptr);
66
Michael Ludwig72ab3462018-12-10 12:43:36 -050067// Bulk API for drawing quads with a single op
Michael Ludwig75451902019-01-23 11:14:29 -050068// TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer
Robert Phillipsb97da532019-02-12 15:24:12 -050069std::unique_ptr<GrDrawOp> MakeSet(GrRecordingContext* context,
Michael Ludwig72ab3462018-12-10 12:43:36 -050070 GrPaint&& paint,
71 GrAAType aaType,
72 const SkMatrix& viewMatrix,
73 const GrRenderTargetContext::QuadSetEntry quads[],
74 int quadCount,
75 const GrUserStencilSettings* stencil = nullptr);
76
77// Specializations where all edges are treated the same. If the aa type is coverage, then the
78// edges will be anti-aliased, otherwise per-edge AA will be disabled.
Robert Phillipsb97da532019-02-12 15:24:12 -050079std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context,
Michael Ludwig69858532018-11-28 15:34:34 -050080 GrPaint&& paint,
81 GrAAType aaType,
Michael Ludwig69858532018-11-28 15:34:34 -050082 const SkMatrix& viewMatrix,
83 const SkRect& rect,
84 const GrUserStencilSettings* stencil = nullptr);
85
Robert Phillipsb97da532019-02-12 15:24:12 -050086std::unique_ptr<GrDrawOp> MakeWithLocalMatrix(GrRecordingContext* context,
Michael Ludwig69858532018-11-28 15:34:34 -050087 GrPaint&& paint,
88 GrAAType aaType,
Michael Ludwig69858532018-11-28 15:34:34 -050089 const SkMatrix& viewMatrix,
90 const SkMatrix& localMatrix,
91 const SkRect& rect,
92 const GrUserStencilSettings* stencil = nullptr);
93
Robert Phillipsb97da532019-02-12 15:24:12 -050094std::unique_ptr<GrDrawOp> MakeWithLocalRect(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 SkRect& localRect,
100 const GrUserStencilSettings* stencil = nullptr);
101
Michael Ludwig72ab3462018-12-10 12:43:36 -0500102} // namespace GrFillRectOp
Michael Ludwig69858532018-11-28 15:34:34 -0500103
104#endif // GrFillRectOp_DEFINED