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 | |
Michael Ludwig | aa1b6b3 | 2019-05-29 14:43:13 -0400 | [diff] [blame^] | 39 | // Utility function to create a non-AA rect transformed by view. This is used commonly enough in |
| 40 | // testing and GMs that manage ops without going through GrRTC that it's worth the convenience. |
| 41 | std::unique_ptr<GrDrawOp> MakeNonAARect(GrRecordingContext* context, |
| 42 | GrPaint&& paint, |
| 43 | const SkMatrix& view, |
| 44 | const SkRect& rect, |
| 45 | const GrUserStencilSettings* stencil = nullptr); |
| 46 | |
Michael Ludwig | d9f917b | 2019-05-24 12:57:55 -0400 | [diff] [blame] | 47 | // FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 48 | // General purpose factory functions that handle per-edge anti-aliasing |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 49 | std::unique_ptr<GrDrawOp> MakePerEdge(GrRecordingContext* context, |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 50 | GrPaint&& paint, |
| 51 | GrAAType aaType, |
| 52 | GrQuadAAFlags edgeAA, |
| 53 | const SkMatrix& viewMatrix, |
| 54 | const SkRect& rect, |
| 55 | const GrUserStencilSettings* stencil = nullptr); |
| 56 | |
Michael Ludwig | d9f917b | 2019-05-24 12:57:55 -0400 | [diff] [blame] | 57 | // FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 58 | std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalMatrix(GrRecordingContext* context, |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 59 | GrPaint&& paint, |
| 60 | GrAAType aaType, |
| 61 | GrQuadAAFlags edgeAA, |
| 62 | const SkMatrix& viewMatrix, |
| 63 | const SkMatrix& localMatrix, |
| 64 | const SkRect& rect, |
| 65 | const GrUserStencilSettings* stl = nullptr); |
| 66 | |
Michael Ludwig | d9f917b | 2019-05-24 12:57:55 -0400 | [diff] [blame] | 67 | // FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 68 | std::unique_ptr<GrDrawOp> MakePerEdgeWithLocalRect(GrRecordingContext* context, |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 69 | GrPaint&& paint, |
| 70 | GrAAType aaType, |
| 71 | GrQuadAAFlags edgeAA, |
| 72 | const SkMatrix& viewMatrix, |
| 73 | const SkRect& rect, |
| 74 | const SkRect& localRect, |
| 75 | const GrUserStencilSettings* stencil = nullptr); |
| 76 | |
Michael Ludwig | 009b92e | 2019-02-15 16:03:53 -0500 | [diff] [blame] | 77 | // Generalization that accepts 2D convex quads instead of just rectangles. If 'localQuad' is not |
| 78 | // 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] | 79 | // FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric |
Michael Ludwig | 009b92e | 2019-02-15 16:03:53 -0500 | [diff] [blame] | 80 | std::unique_ptr<GrDrawOp> MakePerEdgeQuad(GrRecordingContext* context, |
| 81 | GrPaint&& paint, |
| 82 | GrAAType aaType, |
| 83 | GrQuadAAFlags edgeAA, |
| 84 | const SkMatrix& viewMatrix, |
| 85 | const SkPoint quad[4], |
| 86 | const SkPoint localQuad[4], |
| 87 | const GrUserStencilSettings* stencil = nullptr); |
| 88 | |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 89 | // Bulk API for drawing quads with a single op |
Michael Ludwig | 7545190 | 2019-01-23 11:14:29 -0500 | [diff] [blame] | 90 | // TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 91 | std::unique_ptr<GrDrawOp> MakeSet(GrRecordingContext* context, |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 92 | GrPaint&& paint, |
| 93 | GrAAType aaType, |
| 94 | const SkMatrix& viewMatrix, |
| 95 | const GrRenderTargetContext::QuadSetEntry quads[], |
| 96 | int quadCount, |
| 97 | const GrUserStencilSettings* stencil = nullptr); |
| 98 | |
Michael Ludwig | d9f917b | 2019-05-24 12:57:55 -0400 | [diff] [blame] | 99 | // FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 100 | // Specializations where all edges are treated the same. If the aa type is coverage, then the |
| 101 | // edges will be anti-aliased, otherwise per-edge AA will be disabled. |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 102 | std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context, |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 103 | GrPaint&& paint, |
| 104 | GrAAType aaType, |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 105 | const SkMatrix& viewMatrix, |
| 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> MakeWithLocalMatrix(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 SkMatrix& localMatrix, |
| 114 | const SkRect& rect, |
| 115 | const GrUserStencilSettings* stencil = nullptr); |
Michael Ludwig | d9f917b | 2019-05-24 12:57:55 -0400 | [diff] [blame] | 116 | // FIXME(michaelludwig) - To be removed after usages replaced with MakeGeneric |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 117 | std::unique_ptr<GrDrawOp> MakeWithLocalRect(GrRecordingContext* context, |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 118 | GrPaint&& paint, |
| 119 | GrAAType aaType, |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 120 | const SkMatrix& viewMatrix, |
| 121 | const SkRect& rect, |
| 122 | const SkRect& localRect, |
| 123 | const GrUserStencilSettings* stencil = nullptr); |
| 124 | |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 125 | } // namespace GrFillRectOp |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 126 | |
| 127 | #endif // GrFillRectOp_DEFINED |