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 | |
| 8 | #ifndef GrFillRectOp_DEFINED |
| 9 | #define GrFillRectOp_DEFINED |
| 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; |
Robert Phillips | e40495d | 2021-07-20 09:40:13 -0400 | [diff] [blame^] | 21 | class GrSurfaceDrawContext; |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 22 | struct GrUserStencilSettings; |
| 23 | class SkMatrix; |
| 24 | struct SkRect; |
| 25 | |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 26 | /** |
| 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 Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 32 | class GrFillRectOp { |
| 33 | public: |
Chris Dalton | c3b67eb | 2020-02-10 21:09:58 -0700 | [diff] [blame] | 34 | using InputFlags = GrSimpleMeshDrawOpHelper::InputFlags; |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 35 | |
Herb Derby | c76d409 | 2020-10-07 16:46:15 -0400 | [diff] [blame] | 36 | 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 Ludwig | d9f917b | 2019-05-24 12:57:55 -0400 | [diff] [blame] | 42 | |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 43 | // 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 Derby | c76d409 | 2020-10-07 16:46:15 -0400 | [diff] [blame] | 46 | static GrOp::Owner MakeNonAARect(GrRecordingContext* context, |
| 47 | GrPaint&& paint, |
| 48 | const SkMatrix& view, |
| 49 | const SkRect& rect, |
| 50 | const GrUserStencilSettings* stencil = nullptr); |
Michael Ludwig | aa1b6b3 | 2019-05-29 14:43:13 -0400 | [diff] [blame] | 51 | |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 52 | // Bulk API for drawing quads with a single op |
| 53 | // TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer |
Brian Salomon | eebe735 | 2020-12-09 16:37:04 -0500 | [diff] [blame] | 54 | static void AddFillRectOps(GrSurfaceDrawContext*, |
Michael Ludwig | 7c12e28 | 2020-05-29 09:54:07 -0400 | [diff] [blame] | 55 | const GrClip* clip, |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 56 | GrRecordingContext*, |
| 57 | GrPaint&&, |
| 58 | GrAAType, |
| 59 | const SkMatrix& viewMatrix, |
Robert Phillips | e40495d | 2021-07-20 09:40:13 -0400 | [diff] [blame^] | 60 | const GrQuadSetEntry quads[], |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 61 | int quadCount, |
| 62 | const GrUserStencilSettings* = nullptr); |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 63 | |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 64 | #if GR_TEST_UTILS |
| 65 | static uint32_t ClassID(); |
| 66 | #endif |
| 67 | |
| 68 | private: |
| 69 | // Create a GrFillRectOp that uses as many quads as possible from 'quads' w/o exceeding |
| 70 | // any index buffer size limits. |
Herb Derby | c76d409 | 2020-10-07 16:46:15 -0400 | [diff] [blame] | 71 | static GrOp::Owner MakeOp(GrRecordingContext*, |
| 72 | GrPaint&&, |
| 73 | GrAAType, |
| 74 | const SkMatrix& viewMatrix, |
Robert Phillips | e40495d | 2021-07-20 09:40:13 -0400 | [diff] [blame^] | 75 | const GrQuadSetEntry quads[], |
Herb Derby | c76d409 | 2020-10-07 16:46:15 -0400 | [diff] [blame] | 76 | int quadCount, |
| 77 | const GrUserStencilSettings*, |
| 78 | int* numConsumed); |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 79 | }; |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 80 | |
| 81 | #endif // GrFillRectOp_DEFINED |