• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 "include/private/GrTypesPriv.h"
12 #include "src/gpu/GrSurfaceDrawContext.h"
13 #include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
14 
15 class GrDrawOp;
16 class GrPaint;
17 class GrQuad;
18 class GrRecordingContext;
19 struct GrUserStencilSettings;
20 class SkMatrix;
21 struct SkRect;
22 
23 /**
24  * A set of factory functions for drawing filled rectangles either coverage-antialiased, or
25  * non-antialiased. The non-antialiased ops can be used with MSAA. As with other GrDrawOp factories,
26  * the GrPaint is only consumed by these methods if a valid op is returned. If null is returned then
27  * the paint is unmodified and may still be used.
28  */
29 class GrFillRectOp {
30 public:
31     using InputFlags = GrSimpleMeshDrawOpHelper::InputFlags;
32 
33     static GrOp::Owner Make(GrRecordingContext* context,
34                             GrPaint&& paint,
35                             GrAAType aaType,
36                             DrawQuad* quad,
37                             const GrUserStencilSettings* stencil = nullptr,
38                             InputFlags = InputFlags::kNone);
39 
40     // Utility function to create a non-AA rect transformed by view. This is used commonly enough
41     // in testing and GMs that manage ops without going through GrRTC that it's worth the
42     // convenience.
43     static GrOp::Owner MakeNonAARect(GrRecordingContext* context,
44                                      GrPaint&& paint,
45                                      const SkMatrix& view,
46                                      const SkRect& rect,
47                                      const GrUserStencilSettings* stencil = nullptr);
48 
49     // Bulk API for drawing quads with a single op
50     // TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer
51     static void AddFillRectOps(GrSurfaceDrawContext*,
52                                const GrClip* clip,
53                                GrRecordingContext*,
54                                GrPaint&&,
55                                GrAAType,
56                                const SkMatrix& viewMatrix,
57                                const GrSurfaceDrawContext::QuadSetEntry quads[],
58                                int quadCount,
59                                const GrUserStencilSettings* = nullptr);
60 
61 #if GR_TEST_UTILS
62     static uint32_t ClassID();
63 #endif
64 
65 private:
66     // Create a GrFillRectOp that uses as many quads as possible from 'quads' w/o exceeding
67     // any index buffer size limits.
68     static GrOp::Owner MakeOp(GrRecordingContext*,
69                               GrPaint&&,
70                               GrAAType,
71                               const SkMatrix& viewMatrix,
72                               const GrSurfaceDrawContext::QuadSetEntry quads[],
73                               int quadCount,
74                               const GrUserStencilSettings*,
75                               int* numConsumed);
76 };
77 
78 #endif // GrFillRectOp_DEFINED
79