blob: 6ba4c102620fd1267fb07b225deb2e1f398fc613 [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"
Chris Daltonc3b67eb2020-02-10 21:09:58 -070012#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
Michael Ludwig69858532018-11-28 15:34:34 -050013
Robert Phillipse40495d2021-07-20 09:40:13 -040014struct DrawQuad;
15class GrClip;
Michael Ludwig69858532018-11-28 15:34:34 -050016class GrDrawOp;
17class GrPaint;
Michael Ludwigde4c58c2019-06-04 09:12:59 -040018class GrQuad;
Robert Phillipse40495d2021-07-20 09:40:13 -040019struct GrQuadSetEntry;
Robert Phillipsb97da532019-02-12 15:24:12 -050020class GrRecordingContext;
Robert Phillipse40495d2021-07-20 09:40:13 -040021class GrSurfaceDrawContext;
Michael Ludwig69858532018-11-28 15:34:34 -050022struct GrUserStencilSettings;
23class SkMatrix;
24struct SkRect;
25
Michael Ludwig72ab3462018-12-10 12:43:36 -050026/**
27 * A set of factory functions for drawing filled rectangles either coverage-antialiased, or
28 * non-antialiased. The non-antialiased ops can be used with MSAA. As with other GrDrawOp factories,
29 * the GrPaint is only consumed by these methods if a valid op is returned. If null is returned then
30 * the paint is unmodified and may still be used.
31 */
Robert Phillips438d9862019-11-14 12:46:05 -050032class GrFillRectOp {
33public:
Chris Daltonc3b67eb2020-02-10 21:09:58 -070034 using InputFlags = GrSimpleMeshDrawOpHelper::InputFlags;
Michael Ludwig69858532018-11-28 15:34:34 -050035
Herb Derbyc76d4092020-10-07 16:46:15 -040036 static GrOp::Owner Make(GrRecordingContext* context,
37 GrPaint&& paint,
38 GrAAType aaType,
39 DrawQuad* quad,
40 const GrUserStencilSettings* stencil = nullptr,
41 InputFlags = InputFlags::kNone);
Michael Ludwigd9f917b2019-05-24 12:57:55 -040042
Robert Phillips438d9862019-11-14 12:46:05 -050043 // Utility function to create a non-AA rect transformed by view. This is used commonly enough
44 // in testing and GMs that manage ops without going through GrRTC that it's worth the
45 // convenience.
Herb Derbyc76d4092020-10-07 16:46:15 -040046 static GrOp::Owner MakeNonAARect(GrRecordingContext* context,
47 GrPaint&& paint,
48 const SkMatrix& view,
49 const SkRect& rect,
50 const GrUserStencilSettings* stencil = nullptr);
Michael Ludwigaa1b6b32019-05-29 14:43:13 -040051
Robert Phillips438d9862019-11-14 12:46:05 -050052 // Bulk API for drawing quads with a single op
53 // TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer
Brian Salomoneebe7352020-12-09 16:37:04 -050054 static void AddFillRectOps(GrSurfaceDrawContext*,
Michael Ludwig7c12e282020-05-29 09:54:07 -040055 const GrClip* clip,
Robert Phillips438d9862019-11-14 12:46:05 -050056 GrRecordingContext*,
57 GrPaint&&,
58 GrAAType,
59 const SkMatrix& viewMatrix,
Robert Phillipse40495d2021-07-20 09:40:13 -040060 const GrQuadSetEntry quads[],
Robert Phillips438d9862019-11-14 12:46:05 -050061 int quadCount,
62 const GrUserStencilSettings* = nullptr);
Michael Ludwig72ab3462018-12-10 12:43:36 -050063
Robert Phillips438d9862019-11-14 12:46:05 -050064#if GR_TEST_UTILS
65 static uint32_t ClassID();
66#endif
67
68private:
69 // Create a GrFillRectOp that uses as many quads as possible from 'quads' w/o exceeding
70 // any index buffer size limits.
Herb Derbyc76d4092020-10-07 16:46:15 -040071 static GrOp::Owner MakeOp(GrRecordingContext*,
72 GrPaint&&,
73 GrAAType,
74 const SkMatrix& viewMatrix,
Robert Phillipse40495d2021-07-20 09:40:13 -040075 const GrQuadSetEntry quads[],
Herb Derbyc76d4092020-10-07 16:46:15 -040076 int quadCount,
77 const GrUserStencilSettings*,
78 int* numConsumed);
Robert Phillips438d9862019-11-14 12:46:05 -050079};
Michael Ludwig69858532018-11-28 15:34:34 -050080
81#endif // GrFillRectOp_DEFINED