blob: 600e87b0a0e965203c93e0d660c8425442f39ad0 [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/private/GrTypesPriv.h"
12#include "src/gpu/GrRenderTargetContext.h"
Michael Ludwig69858532018-11-28 15:34:34 -050013
14class GrDrawOp;
15class GrPaint;
Michael Ludwigde4c58c2019-06-04 09:12:59 -040016class GrQuad;
Robert Phillipsb97da532019-02-12 15:24:12 -050017class GrRecordingContext;
Michael Ludwig69858532018-11-28 15:34:34 -050018struct GrUserStencilSettings;
19class SkMatrix;
20struct SkRect;
21
Michael Ludwig72ab3462018-12-10 12:43:36 -050022/**
23 * A set of factory functions for drawing filled rectangles either coverage-antialiased, or
24 * non-antialiased. The non-antialiased ops can be used with MSAA. As with other GrDrawOp factories,
25 * the GrPaint is only consumed by these methods if a valid op is returned. If null is returned then
26 * the paint is unmodified and may still be used.
27 */
Robert Phillips438d9862019-11-14 12:46:05 -050028class GrFillRectOp {
29public:
Michael Ludwig69858532018-11-28 15:34:34 -050030
Robert Phillips438d9862019-11-14 12:46:05 -050031 static std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context,
32 GrPaint&& paint,
33 GrAAType aaType,
34 GrQuadAAFlags aaFlags,
35 const GrQuad& deviceQuad,
36 const GrQuad& localQuad,
37 const GrUserStencilSettings* stencil = nullptr);
Michael Ludwigd9f917b2019-05-24 12:57:55 -040038
Robert Phillips438d9862019-11-14 12:46:05 -050039 // Utility function to create a non-AA rect transformed by view. This is used commonly enough
40 // in testing and GMs that manage ops without going through GrRTC that it's worth the
41 // convenience.
42 static std::unique_ptr<GrDrawOp> MakeNonAARect(GrRecordingContext* context,
43 GrPaint&& paint,
44 const SkMatrix& view,
45 const SkRect& rect,
46 const GrUserStencilSettings* stencil = nullptr);
Michael Ludwigaa1b6b32019-05-29 14:43:13 -040047
Robert Phillips438d9862019-11-14 12:46:05 -050048 // Bulk API for drawing quads with a single op
49 // TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer
50 static void AddFillRectOps(GrRenderTargetContext*,
51 const GrClip& clip,
52 GrRecordingContext*,
53 GrPaint&&,
54 GrAAType,
55 const SkMatrix& viewMatrix,
56 const GrRenderTargetContext::QuadSetEntry quads[],
57 int quadCount,
58 const GrUserStencilSettings* = nullptr);
Michael Ludwig72ab3462018-12-10 12:43:36 -050059
Robert Phillips438d9862019-11-14 12:46:05 -050060#if GR_TEST_UTILS
61 static uint32_t ClassID();
62#endif
63
64private:
65 // Create a GrFillRectOp that uses as many quads as possible from 'quads' w/o exceeding
66 // any index buffer size limits.
67 static std::unique_ptr<GrDrawOp> MakeOp(GrRecordingContext*,
68 GrPaint&&,
69 GrAAType,
70 const SkMatrix& viewMatrix,
71 const GrRenderTargetContext::QuadSetEntry quads[],
72 int quadCount,
73 const GrUserStencilSettings*,
74 int* numConsumed);
75};
Michael Ludwig69858532018-11-28 15:34:34 -050076
77#endif // GrFillRectOp_DEFINED