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