blob: 947ee7c8a3f93e8ded5402f90ceedbacd13b57ed [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"
Chris Daltonc3b67eb2020-02-10 21:09:58 -070013#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
Michael Ludwig69858532018-11-28 15:34:34 -050014
15class GrDrawOp;
16class GrPaint;
Michael Ludwigde4c58c2019-06-04 09:12:59 -040017class GrQuad;
Robert Phillipsb97da532019-02-12 15:24:12 -050018class GrRecordingContext;
Michael Ludwig69858532018-11-28 15:34:34 -050019struct GrUserStencilSettings;
20class SkMatrix;
21struct SkRect;
22
Michael Ludwig72ab3462018-12-10 12:43:36 -050023/**
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 */
Robert Phillips438d9862019-11-14 12:46:05 -050029class GrFillRectOp {
30public:
Chris Daltonc3b67eb2020-02-10 21:09:58 -070031 using InputFlags = GrSimpleMeshDrawOpHelper::InputFlags;
Michael Ludwig69858532018-11-28 15:34:34 -050032
Robert Phillips438d9862019-11-14 12:46:05 -050033 static std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context,
34 GrPaint&& paint,
35 GrAAType aaType,
Michael Ludwig6b45c5d2020-02-07 09:56:38 -050036 DrawQuad* quad,
Chris Daltonc3b67eb2020-02-10 21:09:58 -070037 const GrUserStencilSettings* stencil = nullptr,
38 InputFlags = InputFlags::kNone);
Michael Ludwigd9f917b2019-05-24 12:57:55 -040039
Robert Phillips438d9862019-11-14 12:46:05 -050040 // 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 std::unique_ptr<GrDrawOp> MakeNonAARect(GrRecordingContext* context,
44 GrPaint&& paint,
45 const SkMatrix& view,
46 const SkRect& rect,
47 const GrUserStencilSettings* stencil = nullptr);
Michael Ludwigaa1b6b32019-05-29 14:43:13 -040048
Robert Phillips438d9862019-11-14 12:46:05 -050049 // 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(GrRenderTargetContext*,
52 const GrClip& clip,
53 GrRecordingContext*,
54 GrPaint&&,
55 GrAAType,
56 const SkMatrix& viewMatrix,
57 const GrRenderTargetContext::QuadSetEntry quads[],
58 int quadCount,
59 const GrUserStencilSettings* = nullptr);
Michael Ludwig72ab3462018-12-10 12:43:36 -050060
Robert Phillips438d9862019-11-14 12:46:05 -050061#if GR_TEST_UTILS
62 static uint32_t ClassID();
63#endif
64
65private:
66 // Create a GrFillRectOp that uses as many quads as possible from 'quads' w/o exceeding
67 // any index buffer size limits.
68 static std::unique_ptr<GrDrawOp> MakeOp(GrRecordingContext*,
69 GrPaint&&,
70 GrAAType,
71 const SkMatrix& viewMatrix,
72 const GrRenderTargetContext::QuadSetEntry quads[],
73 int quadCount,
74 const GrUserStencilSettings*,
75 int* numConsumed);
76};
Michael Ludwig69858532018-11-28 15:34:34 -050077
78#endif // GrFillRectOp_DEFINED