aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/ops/GrRectOpFactory.h
blob: e662ab108a605a6cc2341a7ed5a944207bcd4ed9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GrRectOpFactory_DEFINED
#define GrRectOpFactory_DEFINED

#include <memory>
#include "GrTypes.h"

enum class GrAAType : unsigned;
class GrDrawOp;
class GrPaint;
struct GrUserStencilSettings;
class SkMatrix;
struct SkRect;
class SkStrokeRec;

/**
 * A set of factory functions for drawing rectangles including fills, strokes, coverage-antialiased,
 * and non-antialiased. The non-antialiased ops can be used with MSAA. As with other GrDrawOp
 * factories, the GrPaint is only consumed by these methods if a valid op is returned. If null is
 * returned then the paint is unmodified and may still be used.
 */
namespace GrRectOpFactory {
/** AA Fill */

std::unique_ptr<GrDrawOp> MakeAAFill(GrPaint&&, const SkMatrix&, const SkRect&,
                                     const GrUserStencilSettings* = nullptr);

std::unique_ptr<GrDrawOp> MakeAAFillWithLocalMatrix(GrPaint&&, const SkMatrix& viewMatrix,
                                                    const SkMatrix& localMatrix, const SkRect&);

std::unique_ptr<GrDrawOp> MakeAAFillWithLocalRect(GrPaint&&, const SkMatrix&, const SkRect& rect,
                                                  const SkRect& localRect);

/** Non-AA Fill - GrAAType must be either kNone or kMSAA. */

std::unique_ptr<GrDrawOp> MakeNonAAFill(GrPaint&&, const SkMatrix& viewMatrix, const SkRect& rect,
                                        GrAAType, const GrUserStencilSettings* = nullptr);

std::unique_ptr<GrDrawOp> MakeNonAAFillWithLocalMatrix(GrPaint&&, const SkMatrix& viewMatrix,
                                                       const SkMatrix& localMatrix, const SkRect&,
                                                       GrAAType,
                                                       const GrUserStencilSettings* = nullptr);

std::unique_ptr<GrDrawOp> MakeNonAAFillWithLocalRect(GrPaint&&, const SkMatrix&, const SkRect& rect,
                                                     const SkRect& localRect, GrAAType);

/** AA Stroke */

std::unique_ptr<GrDrawOp> MakeAAStroke(GrPaint&&, const SkMatrix&, const SkRect&,
                                       const SkStrokeRec&);

// rects[0] == outer rectangle, rects[1] == inner rectangle. Null return means there is nothing to
// draw rather than failure.
std::unique_ptr<GrDrawOp> MakeAAFillNestedRects(GrPaint&&, const SkMatrix&, const SkRect rects[2]);

/** Non-AA Stroke - GrAAType must be either kNone or kMSAA. */

std::unique_ptr<GrDrawOp> MakeNonAAStroke(GrPaint&&, const SkMatrix&, const SkRect&,
                                          const SkStrokeRec&, GrAAType);

}  // namespace GrRectOpFactory

#endif