blob: 29ac10e33158263c8ae9ed96727c641185a64f23 [file] [log] [blame]
Brian Salomon6a639042016-12-14 11:08:17 -05001/*
Brian Salomonbaaf4392017-06-15 09:59:23 -04002 * Copyright 2017 Google Inc.
Brian Salomon6a639042016-12-14 11:08:17 -05003 *
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 GrRectOpFactory_DEFINED
9#define GrRectOpFactory_DEFINED
10
Brian Salomonbaaf4392017-06-15 09:59:23 -040011#include <memory>
12#include "GrTypes.h"
Brian Salomon6a639042016-12-14 11:08:17 -050013
Brian Salomonbaaf4392017-06-15 09:59:23 -040014enum class GrAAType : unsigned;
15class GrDrawOp;
16class GrPaint;
17struct GrUserStencilSettings;
18class SkMatrix;
Brian Salomon6a639042016-12-14 11:08:17 -050019struct SkRect;
20class SkStrokeRec;
21
22/**
Brian Salomonbaaf4392017-06-15 09:59:23 -040023 * A set of factory functions for drawing rectangles including fills, strokes, coverage-antialiased,
24 * and non-antialiased. The non-antialiased ops can be used with MSAA. As with other GrDrawOp
25 * factories, the GrPaint is only consumed by these methods if a valid op is returned. If null is
26 * returned then the paint is unmodified and may still be used.
Brian Salomon6a639042016-12-14 11:08:17 -050027 */
28namespace GrRectOpFactory {
Brian Salomonbaaf4392017-06-15 09:59:23 -040029/** AA Fill */
Brian Salomon6a639042016-12-14 11:08:17 -050030
Robert Phillips7c525e62018-06-12 10:11:12 -040031std::unique_ptr<GrDrawOp> MakeAAFill(GrContext*,
32 GrPaint&&,
33 const SkMatrix&,
34 const SkRect&,
Brian Salomonbaaf4392017-06-15 09:59:23 -040035 const GrUserStencilSettings* = nullptr);
Brian Salomon6a639042016-12-14 11:08:17 -050036
Robert Phillips7c525e62018-06-12 10:11:12 -040037std::unique_ptr<GrDrawOp> MakeAAFillWithLocalMatrix(GrContext*,
38 GrPaint&&,
39 const SkMatrix& viewMatrix,
40 const SkMatrix& localMatrix,
41 const SkRect&);
Brian Salomon6a639042016-12-14 11:08:17 -050042
Robert Phillips7c525e62018-06-12 10:11:12 -040043std::unique_ptr<GrDrawOp> MakeAAFillWithLocalRect(GrContext*,
44 GrPaint&&,
45 const SkMatrix&,
46 const SkRect& rect,
Brian Salomonbaaf4392017-06-15 09:59:23 -040047 const SkRect& localRect);
Brian Salomon6a639042016-12-14 11:08:17 -050048
Brian Salomonbaaf4392017-06-15 09:59:23 -040049/** Non-AA Fill - GrAAType must be either kNone or kMSAA. */
50
Robert Phillips7c525e62018-06-12 10:11:12 -040051std::unique_ptr<GrDrawOp> MakeNonAAFill(GrContext*,
52 GrPaint&&,
53 const SkMatrix& viewMatrix,
54 const SkRect& rect,
55 GrAAType,
56 const GrUserStencilSettings* = nullptr);
Brian Salomonbaaf4392017-06-15 09:59:23 -040057
Robert Phillips7c525e62018-06-12 10:11:12 -040058std::unique_ptr<GrDrawOp> MakeNonAAFillWithLocalMatrix(GrContext*,
59 GrPaint&&,
60 const SkMatrix& viewMatrix,
61 const SkMatrix& localMatrix,
62 const SkRect&,
Brian Salomonbaaf4392017-06-15 09:59:23 -040063 GrAAType,
64 const GrUserStencilSettings* = nullptr);
65
Robert Phillips7c525e62018-06-12 10:11:12 -040066std::unique_ptr<GrDrawOp> MakeNonAAFillWithLocalRect(GrContext*,
67 GrPaint&&,
68 const SkMatrix&,
69 const SkRect& rect,
70 const SkRect& localRect,
71 GrAAType);
Brian Salomonbaaf4392017-06-15 09:59:23 -040072
73/** AA Stroke */
74
Robert Phillips7c525e62018-06-12 10:11:12 -040075std::unique_ptr<GrDrawOp> MakeAAStroke(GrContext*,
76 GrPaint&&,
77 const SkMatrix&,
78 const SkRect&,
Brian Salomonbaaf4392017-06-15 09:59:23 -040079 const SkStrokeRec&);
80
81// rects[0] == outer rectangle, rects[1] == inner rectangle. Null return means there is nothing to
82// draw rather than failure.
Robert Phillips7c525e62018-06-12 10:11:12 -040083std::unique_ptr<GrDrawOp> MakeAAFillNestedRects(GrContext*,
84 GrPaint&&,
85 const SkMatrix&,
86 const SkRect rects[2]);
Brian Salomonbaaf4392017-06-15 09:59:23 -040087
88/** Non-AA Stroke - GrAAType must be either kNone or kMSAA. */
89
Robert Phillips7c525e62018-06-12 10:11:12 -040090std::unique_ptr<GrDrawOp> MakeNonAAStroke(GrContext*,
91 GrPaint&&,
92 const SkMatrix&,
93 const SkRect&,
94 const SkStrokeRec&,
95 GrAAType);
Brian Salomonbaaf4392017-06-15 09:59:23 -040096
97} // namespace GrRectOpFactory
Brian Salomon6a639042016-12-14 11:08:17 -050098
99#endif