blob: db3380b3a51293dad2fc6ca3df9b27a73cc9a9a9 [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
Robert Phillipsfbf02142021-09-01 16:31:34 -04008#ifndef FillRectOp_DEFINED
9#define FillRectOp_DEFINED
Michael Ludwig69858532018-11-28 15:34:34 -050010
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;
Michael Ludwig69858532018-11-28 15:34:34 -050021struct GrUserStencilSettings;
22class SkMatrix;
23struct SkRect;
24
Robert Phillipsfbf02142021-09-01 16:31:34 -040025namespace skgpu::v1 {
26
27class SurfaceDrawContext;
28
Michael Ludwig72ab3462018-12-10 12:43:36 -050029/**
30 * A set of factory functions for drawing filled rectangles either coverage-antialiased, or
31 * non-antialiased. The non-antialiased ops can be used with MSAA. As with other GrDrawOp factories,
32 * the GrPaint is only consumed by these methods if a valid op is returned. If null is returned then
33 * the paint is unmodified and may still be used.
34 */
Robert Phillipsfbf02142021-09-01 16:31:34 -040035class FillRectOp {
Robert Phillips438d9862019-11-14 12:46:05 -050036public:
Chris Daltonc3b67eb2020-02-10 21:09:58 -070037 using InputFlags = GrSimpleMeshDrawOpHelper::InputFlags;
Michael Ludwig69858532018-11-28 15:34:34 -050038
Robert Phillips4dca8312021-07-28 15:13:20 -040039 static GrOp::Owner Make(GrRecordingContext*,
40 GrPaint&&,
41 GrAAType,
42 DrawQuad*,
43 const GrUserStencilSettings* = nullptr,
Herb Derbyc76d4092020-10-07 16:46:15 -040044 InputFlags = InputFlags::kNone);
Michael Ludwigd9f917b2019-05-24 12:57:55 -040045
Robert Phillips438d9862019-11-14 12:46:05 -050046 // Utility function to create a non-AA rect transformed by view. This is used commonly enough
47 // in testing and GMs that manage ops without going through GrRTC that it's worth the
48 // convenience.
Robert Phillips4dca8312021-07-28 15:13:20 -040049 static GrOp::Owner MakeNonAARect(GrRecordingContext*,
50 GrPaint&&,
Herb Derbyc76d4092020-10-07 16:46:15 -040051 const SkMatrix& view,
Robert Phillips4dca8312021-07-28 15:13:20 -040052 const SkRect&,
53 const GrUserStencilSettings* = nullptr);
Michael Ludwigaa1b6b32019-05-29 14:43:13 -040054
Robert Phillips438d9862019-11-14 12:46:05 -050055 // Bulk API for drawing quads with a single op
56 // TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer
Robert Phillipsfbf02142021-09-01 16:31:34 -040057 static void AddFillRectOps(SurfaceDrawContext*,
Robert Phillips4dca8312021-07-28 15:13:20 -040058 const GrClip*,
Robert Phillips438d9862019-11-14 12:46:05 -050059 GrRecordingContext*,
60 GrPaint&&,
61 GrAAType,
62 const SkMatrix& viewMatrix,
Robert Phillipse40495d2021-07-20 09:40:13 -040063 const GrQuadSetEntry quads[],
Robert Phillips438d9862019-11-14 12:46:05 -050064 int quadCount,
65 const GrUserStencilSettings* = nullptr);
Michael Ludwig72ab3462018-12-10 12:43:36 -050066
Robert Phillips438d9862019-11-14 12:46:05 -050067#if GR_TEST_UTILS
68 static uint32_t ClassID();
69#endif
70
71private:
Robert Phillipsfbf02142021-09-01 16:31:34 -040072 // Create a FillRectOp that uses as many quads as possible from 'quads' w/o exceeding
Robert Phillips438d9862019-11-14 12:46:05 -050073 // any index buffer size limits.
Herb Derbyc76d4092020-10-07 16:46:15 -040074 static GrOp::Owner MakeOp(GrRecordingContext*,
75 GrPaint&&,
76 GrAAType,
77 const SkMatrix& viewMatrix,
Robert Phillipse40495d2021-07-20 09:40:13 -040078 const GrQuadSetEntry quads[],
Herb Derbyc76d4092020-10-07 16:46:15 -040079 int quadCount,
80 const GrUserStencilSettings*,
81 int* numConsumed);
Robert Phillips438d9862019-11-14 12:46:05 -050082};
Michael Ludwig69858532018-11-28 15:34:34 -050083
Robert Phillipsfbf02142021-09-01 16:31:34 -040084} // namespace skgpu::v1
85
86#endif // FillRectOp_DEFINED