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 | |
| 11 | #include "GrRenderTargetContext.h" |
| 12 | #include "GrTypesPriv.h" |
| 13 | |
| 14 | class GrDrawOp; |
| 15 | class GrPaint; |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 16 | class GrRecordingContext; |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 17 | struct GrUserStencilSettings; |
| 18 | class SkMatrix; |
| 19 | struct SkRect; |
| 20 | |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 21 | /** |
| 22 | * A set of factory functions for drawing filled rectangles either coverage-antialiased, or |
| 23 | * non-antialiased. The non-antialiased ops can be used with MSAA. As with other GrDrawOp factories, |
| 24 | * the GrPaint is only consumed by these methods if a valid op is returned. If null is returned then |
| 25 | * the paint is unmodified and may still be used. |
| 26 | */ |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 27 | namespace GrFillRectOp { |
| 28 | |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 29 | // General purpose factory functions that handle per-edge anti-aliasing |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 30 | std::unique_ptr<GrDrawOp> MakePerEdge(GrRecordingContext* context, |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 31 | GrPaint&& paint, |
| 32 | GrAAType aaType, |
| 33 | GrQuadAAFlags edgeAA, |
| 34 | const SkMatrix& viewMatrix, |
| 35 | const SkRect& rect, |
| 36 | const GrUserStencilSettings* stencil = nullptr); |
| 37 | |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 38 | std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalMatrix(GrRecordingContext* context, |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 39 | GrPaint&& paint, |
| 40 | GrAAType aaType, |
| 41 | GrQuadAAFlags edgeAA, |
| 42 | const SkMatrix& viewMatrix, |
| 43 | const SkMatrix& localMatrix, |
| 44 | const SkRect& rect, |
| 45 | const GrUserStencilSettings* stl = nullptr); |
| 46 | |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 47 | std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalRect(GrRecordingContext* context, |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 48 | GrPaint&& paint, |
| 49 | GrAAType aaType, |
| 50 | GrQuadAAFlags edgeAA, |
| 51 | const SkMatrix& viewMatrix, |
| 52 | const SkRect& rect, |
| 53 | const SkRect& localRect, |
| 54 | const GrUserStencilSettings* stencil = nullptr); |
| 55 | |
| 56 | // Bulk API for drawing quads with a single op |
Michael Ludwig | 7545190 | 2019-01-23 11:14:29 -0500 | [diff] [blame] | 57 | // TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 58 | std::unique_ptr<GrDrawOp> MakeSet(GrRecordingContext* context, |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 59 | GrPaint&& paint, |
| 60 | GrAAType aaType, |
| 61 | const SkMatrix& viewMatrix, |
| 62 | const GrRenderTargetContext::QuadSetEntry quads[], |
| 63 | int quadCount, |
| 64 | const GrUserStencilSettings* stencil = nullptr); |
| 65 | |
| 66 | // Specializations where all edges are treated the same. If the aa type is coverage, then the |
| 67 | // edges will be anti-aliased, otherwise per-edge AA will be disabled. |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 68 | std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context, |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 69 | GrPaint&& paint, |
| 70 | GrAAType aaType, |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 71 | const SkMatrix& viewMatrix, |
| 72 | const SkRect& rect, |
| 73 | const GrUserStencilSettings* stencil = nullptr); |
| 74 | |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 75 | std::unique_ptr<GrDrawOp> MakeWithLocalMatrix(GrRecordingContext* context, |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 76 | GrPaint&& paint, |
| 77 | GrAAType aaType, |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 78 | const SkMatrix& viewMatrix, |
| 79 | const SkMatrix& localMatrix, |
| 80 | const SkRect& rect, |
| 81 | const GrUserStencilSettings* stencil = nullptr); |
| 82 | |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 83 | std::unique_ptr<GrDrawOp> MakeWithLocalRect(GrRecordingContext* context, |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 84 | GrPaint&& paint, |
| 85 | GrAAType aaType, |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 86 | const SkMatrix& viewMatrix, |
| 87 | const SkRect& rect, |
| 88 | const SkRect& localRect, |
| 89 | const GrUserStencilSettings* stencil = nullptr); |
| 90 | |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 91 | } // namespace GrFillRectOp |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 92 | |
| 93 | #endif // GrFillRectOp_DEFINED |