blob: 27c6f9edd1ce7d81dde57d9cc90689844b9b1735 [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;
16struct GrUserStencilSettings;
17class SkMatrix;
18struct SkRect;
19
Michael Ludwig72ab3462018-12-10 12:43:36 -050020/**
21 * A set of factory functions for drawing filled rectangles either coverage-antialiased, or
22 * non-antialiased. The non-antialiased ops can be used with MSAA. As with other GrDrawOp factories,
23 * the GrPaint is only consumed by these methods if a valid op is returned. If null is returned then
24 * the paint is unmodified and may still be used.
25 */
Michael Ludwig69858532018-11-28 15:34:34 -050026namespace GrFillRectOp {
27
Michael Ludwig72ab3462018-12-10 12:43:36 -050028// General purpose factory functions that handle per-edge anti-aliasing
29std::unique_ptr<GrDrawOp> MakePerEdge(GrContext* context,
30 GrPaint&& paint,
31 GrAAType aaType,
32 GrQuadAAFlags edgeAA,
33 const SkMatrix& viewMatrix,
34 const SkRect& rect,
35 const GrUserStencilSettings* stencil = nullptr);
36
37std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalMatrix(GrContext* context,
38 GrPaint&& paint,
39 GrAAType aaType,
40 GrQuadAAFlags edgeAA,
41 const SkMatrix& viewMatrix,
42 const SkMatrix& localMatrix,
43 const SkRect& rect,
44 const GrUserStencilSettings* stl = nullptr);
45
46std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalRect(GrContext* context,
47 GrPaint&& paint,
48 GrAAType aaType,
49 GrQuadAAFlags edgeAA,
50 const SkMatrix& viewMatrix,
51 const SkRect& rect,
52 const SkRect& localRect,
53 const GrUserStencilSettings* stencil = nullptr);
54
55// Bulk API for drawing quads with a single op
Michael Ludwig75451902019-01-23 11:14:29 -050056// TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer
Michael Ludwig72ab3462018-12-10 12:43:36 -050057std::unique_ptr<GrDrawOp> MakeSet(GrContext* context,
58 GrPaint&& paint,
59 GrAAType aaType,
60 const SkMatrix& viewMatrix,
61 const GrRenderTargetContext::QuadSetEntry quads[],
62 int quadCount,
63 const GrUserStencilSettings* stencil = nullptr);
64
65// Specializations where all edges are treated the same. If the aa type is coverage, then the
66// edges will be anti-aliased, otherwise per-edge AA will be disabled.
Michael Ludwig69858532018-11-28 15:34:34 -050067std::unique_ptr<GrDrawOp> Make(GrContext* context,
68 GrPaint&& paint,
69 GrAAType aaType,
Michael Ludwig69858532018-11-28 15:34:34 -050070 const SkMatrix& viewMatrix,
71 const SkRect& rect,
72 const GrUserStencilSettings* stencil = nullptr);
73
74std::unique_ptr<GrDrawOp> MakeWithLocalMatrix(GrContext* context,
75 GrPaint&& paint,
76 GrAAType aaType,
Michael Ludwig69858532018-11-28 15:34:34 -050077 const SkMatrix& viewMatrix,
78 const SkMatrix& localMatrix,
79 const SkRect& rect,
80 const GrUserStencilSettings* stencil = nullptr);
81
82std::unique_ptr<GrDrawOp> MakeWithLocalRect(GrContext* context,
83 GrPaint&& paint,
84 GrAAType aaType,
Michael Ludwig69858532018-11-28 15:34:34 -050085 const SkMatrix& viewMatrix,
86 const SkRect& rect,
87 const SkRect& localRect,
88 const GrUserStencilSettings* stencil = nullptr);
89
Michael Ludwig72ab3462018-12-10 12:43:36 -050090} // namespace GrFillRectOp
Michael Ludwig69858532018-11-28 15:34:34 -050091
92#endif // GrFillRectOp_DEFINED