Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 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 | |
Robert Phillips | fbf0214 | 2021-09-01 16:31:34 -0400 | [diff] [blame] | 8 | #ifndef FillRectOp_DEFINED |
| 9 | #define FillRectOp_DEFINED |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/private/GrTypesPriv.h" |
Chris Dalton | c3b67eb | 2020-02-10 21:09:58 -0700 | [diff] [blame] | 12 | #include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h" |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 13 | |
Robert Phillips | e40495d | 2021-07-20 09:40:13 -0400 | [diff] [blame] | 14 | struct DrawQuad; |
| 15 | class GrClip; |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 16 | class GrDrawOp; |
| 17 | class GrPaint; |
Michael Ludwig | de4c58c | 2019-06-04 09:12:59 -0400 | [diff] [blame] | 18 | class GrQuad; |
Robert Phillips | e40495d | 2021-07-20 09:40:13 -0400 | [diff] [blame] | 19 | struct GrQuadSetEntry; |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 20 | class GrRecordingContext; |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 21 | struct GrUserStencilSettings; |
| 22 | class SkMatrix; |
| 23 | struct SkRect; |
| 24 | |
Robert Phillips | fbf0214 | 2021-09-01 16:31:34 -0400 | [diff] [blame] | 25 | namespace skgpu::v1 { |
| 26 | |
| 27 | class SurfaceDrawContext; |
| 28 | |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 29 | /** |
| 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 Phillips | fbf0214 | 2021-09-01 16:31:34 -0400 | [diff] [blame] | 35 | class FillRectOp { |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 36 | public: |
Chris Dalton | c3b67eb | 2020-02-10 21:09:58 -0700 | [diff] [blame] | 37 | using InputFlags = GrSimpleMeshDrawOpHelper::InputFlags; |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 38 | |
Robert Phillips | 4dca831 | 2021-07-28 15:13:20 -0400 | [diff] [blame] | 39 | static GrOp::Owner Make(GrRecordingContext*, |
| 40 | GrPaint&&, |
| 41 | GrAAType, |
| 42 | DrawQuad*, |
| 43 | const GrUserStencilSettings* = nullptr, |
Herb Derby | c76d409 | 2020-10-07 16:46:15 -0400 | [diff] [blame] | 44 | InputFlags = InputFlags::kNone); |
Michael Ludwig | d9f917b | 2019-05-24 12:57:55 -0400 | [diff] [blame] | 45 | |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 46 | // 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 Phillips | 4dca831 | 2021-07-28 15:13:20 -0400 | [diff] [blame] | 49 | static GrOp::Owner MakeNonAARect(GrRecordingContext*, |
| 50 | GrPaint&&, |
Herb Derby | c76d409 | 2020-10-07 16:46:15 -0400 | [diff] [blame] | 51 | const SkMatrix& view, |
Robert Phillips | 4dca831 | 2021-07-28 15:13:20 -0400 | [diff] [blame] | 52 | const SkRect&, |
| 53 | const GrUserStencilSettings* = nullptr); |
Michael Ludwig | aa1b6b3 | 2019-05-29 14:43:13 -0400 | [diff] [blame] | 54 | |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 55 | // Bulk API for drawing quads with a single op |
| 56 | // TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer |
Robert Phillips | fbf0214 | 2021-09-01 16:31:34 -0400 | [diff] [blame] | 57 | static void AddFillRectOps(SurfaceDrawContext*, |
Robert Phillips | 4dca831 | 2021-07-28 15:13:20 -0400 | [diff] [blame] | 58 | const GrClip*, |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 59 | GrRecordingContext*, |
| 60 | GrPaint&&, |
| 61 | GrAAType, |
| 62 | const SkMatrix& viewMatrix, |
Robert Phillips | e40495d | 2021-07-20 09:40:13 -0400 | [diff] [blame] | 63 | const GrQuadSetEntry quads[], |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 64 | int quadCount, |
| 65 | const GrUserStencilSettings* = nullptr); |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 66 | |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 67 | #if GR_TEST_UTILS |
| 68 | static uint32_t ClassID(); |
| 69 | #endif |
| 70 | |
| 71 | private: |
Robert Phillips | fbf0214 | 2021-09-01 16:31:34 -0400 | [diff] [blame] | 72 | // Create a FillRectOp that uses as many quads as possible from 'quads' w/o exceeding |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 73 | // any index buffer size limits. |
Herb Derby | c76d409 | 2020-10-07 16:46:15 -0400 | [diff] [blame] | 74 | static GrOp::Owner MakeOp(GrRecordingContext*, |
| 75 | GrPaint&&, |
| 76 | GrAAType, |
| 77 | const SkMatrix& viewMatrix, |
Robert Phillips | e40495d | 2021-07-20 09:40:13 -0400 | [diff] [blame] | 78 | const GrQuadSetEntry quads[], |
Herb Derby | c76d409 | 2020-10-07 16:46:15 -0400 | [diff] [blame] | 79 | int quadCount, |
| 80 | const GrUserStencilSettings*, |
| 81 | int* numConsumed); |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 82 | }; |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 83 | |
Robert Phillips | fbf0214 | 2021-09-01 16:31:34 -0400 | [diff] [blame] | 84 | } // namespace skgpu::v1 |
| 85 | |
| 86 | #endif // FillRectOp_DEFINED |