• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017 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 GrRectOpFactory_DEFINED
9 #define GrRectOpFactory_DEFINED
10 
11 #include <memory>
12 #include "GrTypes.h"
13 
14 enum class GrAAType : unsigned;
15 class GrDrawOp;
16 class GrPaint;
17 struct GrUserStencilSettings;
18 class SkMatrix;
19 struct SkRect;
20 class SkStrokeRec;
21 
22 /**
23  * 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.
27  */
28 namespace GrRectOpFactory {
29 /** AA Fill */
30 
31 std::unique_ptr<GrDrawOp> MakeAAFill(GrPaint&&, const SkMatrix&, const SkRect&,
32                                      const GrUserStencilSettings* = nullptr);
33 
34 std::unique_ptr<GrDrawOp> MakeAAFillWithLocalMatrix(GrPaint&&, const SkMatrix& viewMatrix,
35                                                     const SkMatrix& localMatrix, const SkRect&);
36 
37 std::unique_ptr<GrDrawOp> MakeAAFillWithLocalRect(GrPaint&&, const SkMatrix&, const SkRect& rect,
38                                                   const SkRect& localRect);
39 
40 /** Non-AA Fill - GrAAType must be either kNone or kMSAA. */
41 
42 std::unique_ptr<GrDrawOp> MakeNonAAFill(GrPaint&&, const SkMatrix& viewMatrix, const SkRect& rect,
43                                         GrAAType, const GrUserStencilSettings* = nullptr);
44 
45 std::unique_ptr<GrDrawOp> MakeNonAAFillWithLocalMatrix(GrPaint&&, const SkMatrix& viewMatrix,
46                                                        const SkMatrix& localMatrix, const SkRect&,
47                                                        GrAAType,
48                                                        const GrUserStencilSettings* = nullptr);
49 
50 std::unique_ptr<GrDrawOp> MakeNonAAFillWithLocalRect(GrPaint&&, const SkMatrix&, const SkRect& rect,
51                                                      const SkRect& localRect, GrAAType);
52 
53 /** AA Stroke */
54 
55 std::unique_ptr<GrDrawOp> MakeAAStroke(GrPaint&&, const SkMatrix&, const SkRect&,
56                                        const SkStrokeRec&);
57 
58 // rects[0] == outer rectangle, rects[1] == inner rectangle. Null return means there is nothing to
59 // draw rather than failure.
60 std::unique_ptr<GrDrawOp> MakeAAFillNestedRects(GrPaint&&, const SkMatrix&, const SkRect rects[2]);
61 
62 /** Non-AA Stroke - GrAAType must be either kNone or kMSAA. */
63 
64 std::unique_ptr<GrDrawOp> MakeNonAAStroke(GrPaint&&, const SkMatrix&, const SkRect&,
65                                           const SkStrokeRec&, GrAAType);
66 
67 }  // namespace GrRectOpFactory
68 
69 #endif
70