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 | d9f917b | 2019-05-24 12:57:55 -0400 | [diff] [blame] | 16 | class GrPerspQuad; |
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 | */ |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 28 | namespace GrFillRectOp { |
| 29 | |
Michael Ludwig | d9f917b | 2019-05-24 12:57:55 -0400 | [diff] [blame] | 30 | // FIXME(michaelludwig) - To be renamed Make() after narrow functions are removed |
| 31 | std::unique_ptr<GrDrawOp> MakeGeneric(GrRecordingContext* context, |
| 32 | GrPaint&& paint, |
| 33 | GrAAType aaType, |
| 34 | GrQuadAAFlags aaFlags, |
| 35 | const GrPerspQuad& deviceQuad, |
| 36 | const GrPerspQuad& localQuad, |
| 37 | const GrUserStencilSettings* stencil = nullptr); |
| 38 | |
| 39 | // FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 40 | // General purpose factory functions that handle per-edge anti-aliasing |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 41 | std::unique_ptr<GrDrawOp> MakePerEdge(GrRecordingContext* context, |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 42 | GrPaint&& paint, |
| 43 | GrAAType aaType, |
| 44 | GrQuadAAFlags edgeAA, |
| 45 | const SkMatrix& viewMatrix, |
| 46 | const SkRect& rect, |
| 47 | const GrUserStencilSettings* stencil = nullptr); |
| 48 | |
Michael Ludwig | d9f917b | 2019-05-24 12:57:55 -0400 | [diff] [blame] | 49 | // FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 50 | std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalMatrix(GrRecordingContext* context, |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 51 | GrPaint&& paint, |
| 52 | GrAAType aaType, |
| 53 | GrQuadAAFlags edgeAA, |
| 54 | const SkMatrix& viewMatrix, |
| 55 | const SkMatrix& localMatrix, |
| 56 | const SkRect& rect, |
| 57 | const GrUserStencilSettings* stl = nullptr); |
| 58 | |
Michael Ludwig | d9f917b | 2019-05-24 12:57:55 -0400 | [diff] [blame] | 59 | // FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 60 | std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalRect(GrRecordingContext* context, |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 61 | GrPaint&& paint, |
| 62 | GrAAType aaType, |
| 63 | GrQuadAAFlags edgeAA, |
| 64 | const SkMatrix& viewMatrix, |
| 65 | const SkRect& rect, |
| 66 | const SkRect& localRect, |
| 67 | const GrUserStencilSettings* stencil = nullptr); |
| 68 | |
Michael Ludwig | 009b92e | 2019-02-15 16:03:53 -0500 | [diff] [blame] | 69 | // Generalization that accepts 2D convex quads instead of just rectangles. If 'localQuad' is not |
| 70 | // null, this is equivalent to the "WithLocalRect" versions. Quad arrays match SkRect::toQuad order. |
Michael Ludwig | d9f917b | 2019-05-24 12:57:55 -0400 | [diff] [blame] | 71 | // FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric |
Michael Ludwig | 009b92e | 2019-02-15 16:03:53 -0500 | [diff] [blame] | 72 | std::unique_ptr<GrDrawOp> MakePerEdgeQuad(GrRecordingContext* context, |
| 73 | GrPaint&& paint, |
| 74 | GrAAType aaType, |
| 75 | GrQuadAAFlags edgeAA, |
| 76 | const SkMatrix& viewMatrix, |
| 77 | const SkPoint quad[4], |
| 78 | const SkPoint localQuad[4], |
| 79 | const GrUserStencilSettings* stencil = nullptr); |
| 80 | |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 81 | // Bulk API for drawing quads with a single op |
Michael Ludwig | 7545190 | 2019-01-23 11:14:29 -0500 | [diff] [blame] | 82 | // TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 83 | std::unique_ptr<GrDrawOp> MakeSet(GrRecordingContext* context, |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 84 | GrPaint&& paint, |
| 85 | GrAAType aaType, |
| 86 | const SkMatrix& viewMatrix, |
| 87 | const GrRenderTargetContext::QuadSetEntry quads[], |
| 88 | int quadCount, |
| 89 | const GrUserStencilSettings* stencil = nullptr); |
| 90 | |
Michael Ludwig | d9f917b | 2019-05-24 12:57:55 -0400 | [diff] [blame] | 91 | // FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 92 | // Specializations where all edges are treated the same. If the aa type is coverage, then the |
| 93 | // edges will be anti-aliased, otherwise per-edge AA will be disabled. |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 94 | std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context, |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 95 | GrPaint&& paint, |
| 96 | GrAAType aaType, |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 97 | const SkMatrix& viewMatrix, |
| 98 | const SkRect& rect, |
| 99 | const GrUserStencilSettings* stencil = nullptr); |
Michael Ludwig | d9f917b | 2019-05-24 12:57:55 -0400 | [diff] [blame] | 100 | // FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 101 | std::unique_ptr<GrDrawOp> MakeWithLocalMatrix(GrRecordingContext* context, |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 102 | GrPaint&& paint, |
| 103 | GrAAType aaType, |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 104 | const SkMatrix& viewMatrix, |
| 105 | const SkMatrix& localMatrix, |
| 106 | const SkRect& rect, |
| 107 | const GrUserStencilSettings* stencil = nullptr); |
Michael Ludwig | d9f917b | 2019-05-24 12:57:55 -0400 | [diff] [blame] | 108 | // FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 109 | std::unique_ptr<GrDrawOp> MakeWithLocalRect(GrRecordingContext* context, |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 110 | GrPaint&& paint, |
| 111 | GrAAType aaType, |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 112 | const SkMatrix& viewMatrix, |
| 113 | const SkRect& rect, |
| 114 | const SkRect& localRect, |
| 115 | const GrUserStencilSettings* stencil = nullptr); |
| 116 | |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 117 | } // namespace GrFillRectOp |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 118 | |
| 119 | #endif // GrFillRectOp_DEFINED |