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" |
| 12 | #include "src/gpu/GrRenderTargetContext.h" |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 13 | |
| 14 | class GrDrawOp; |
| 15 | class GrPaint; |
Michael Ludwig | de4c58c | 2019-06-04 09:12:59 -0400 | [diff] [blame] | 16 | class GrQuad; |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 17 | class GrRecordingContext; |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 18 | struct GrUserStencilSettings; |
| 19 | class SkMatrix; |
| 20 | struct SkRect; |
| 21 | |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 22 | /** |
| 23 | * A set of factory functions for drawing filled rectangles either coverage-antialiased, or |
| 24 | * non-antialiased. The non-antialiased ops can be used with MSAA. As with other GrDrawOp factories, |
| 25 | * the GrPaint is only consumed by these methods if a valid op is returned. If null is returned then |
| 26 | * the paint is unmodified and may still be used. |
| 27 | */ |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 28 | class GrFillRectOp { |
| 29 | public: |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 30 | |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 31 | static std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context, |
| 32 | GrPaint&& paint, |
| 33 | GrAAType aaType, |
Michael Ludwig | 6b45c5d | 2020-02-07 09:56:38 -0500 | [diff] [blame] | 34 | DrawQuad* quad, |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 35 | const GrUserStencilSettings* stencil = nullptr); |
Michael Ludwig | d9f917b | 2019-05-24 12:57:55 -0400 | [diff] [blame] | 36 | |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 37 | // Utility function to create a non-AA rect transformed by view. This is used commonly enough |
| 38 | // in testing and GMs that manage ops without going through GrRTC that it's worth the |
| 39 | // convenience. |
| 40 | static std::unique_ptr<GrDrawOp> MakeNonAARect(GrRecordingContext* context, |
| 41 | GrPaint&& paint, |
| 42 | const SkMatrix& view, |
| 43 | const SkRect& rect, |
| 44 | const GrUserStencilSettings* stencil = nullptr); |
Michael Ludwig | aa1b6b3 | 2019-05-29 14:43:13 -0400 | [diff] [blame] | 45 | |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 46 | // Bulk API for drawing quads with a single op |
| 47 | // TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer |
| 48 | static void AddFillRectOps(GrRenderTargetContext*, |
| 49 | const GrClip& clip, |
| 50 | GrRecordingContext*, |
| 51 | GrPaint&&, |
| 52 | GrAAType, |
| 53 | const SkMatrix& viewMatrix, |
| 54 | const GrRenderTargetContext::QuadSetEntry quads[], |
| 55 | int quadCount, |
| 56 | const GrUserStencilSettings* = nullptr); |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 57 | |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 58 | #if GR_TEST_UTILS |
| 59 | static uint32_t ClassID(); |
| 60 | #endif |
| 61 | |
| 62 | private: |
| 63 | // Create a GrFillRectOp that uses as many quads as possible from 'quads' w/o exceeding |
| 64 | // any index buffer size limits. |
| 65 | static std::unique_ptr<GrDrawOp> MakeOp(GrRecordingContext*, |
| 66 | GrPaint&&, |
| 67 | GrAAType, |
| 68 | const SkMatrix& viewMatrix, |
| 69 | const GrRenderTargetContext::QuadSetEntry quads[], |
| 70 | int quadCount, |
| 71 | const GrUserStencilSettings*, |
| 72 | int* numConsumed); |
| 73 | }; |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 74 | |
| 75 | #endif // GrFillRectOp_DEFINED |