robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 8 | #ifndef GrRenderTargetContext_DEFINED |
| 9 | #define GrRenderTargetContext_DEFINED |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 10 | |
Brian Salomon | 7c8460e | 2017-05-12 11:36:10 -0400 | [diff] [blame] | 11 | #include "../private/GrRenderTargetProxy.h" |
csmartdalton | ecbc12b | 2016-06-08 10:08:43 -0700 | [diff] [blame] | 12 | #include "GrPaint.h" |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 13 | #include "GrSurfaceContext.h" |
Brian Salomon | 7c8460e | 2017-05-12 11:36:10 -0400 | [diff] [blame] | 14 | #include "GrTypesPriv.h" |
Brian Salomon | 467921e | 2017-03-06 16:17:12 -0500 | [diff] [blame] | 15 | #include "GrXferProcessor.h" |
Brian Salomon | 238069b | 2018-07-11 15:58:57 -0400 | [diff] [blame] | 16 | #include "SkCanvas.h" |
Greg Daniel | 64cc9aa | 2018-10-19 13:54:56 -0400 | [diff] [blame] | 17 | #include "SkDrawable.h" |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 18 | #include "SkRefCnt.h" |
Greg Daniel | bae7121 | 2019-03-01 15:24:35 -0500 | [diff] [blame] | 19 | #include "SkSurface.h" |
robertphillips | fcf7829 | 2015-06-19 11:49:52 -0700 | [diff] [blame] | 20 | #include "SkSurfaceProps.h" |
Herb Derby | c1b482c | 2018-08-09 15:02:27 -0400 | [diff] [blame] | 21 | #include "text/GrTextTarget.h" |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 22 | |
Greg Daniel | a5cb781 | 2017-06-16 09:45:32 -0400 | [diff] [blame] | 23 | class GrBackendSemaphore; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 24 | class GrClip; |
Brian Osman | 2240be9 | 2017-10-18 13:15:13 -0400 | [diff] [blame] | 25 | class GrColorSpaceXform; |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 26 | class GrCoverageCountingPathRenderer; |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 27 | class GrDrawingManager; |
Brian Salomon | 9afd371 | 2016-12-01 10:59:09 -0500 | [diff] [blame] | 28 | class GrDrawOp; |
csmartdalton | 29df760 | 2016-08-31 11:55:52 -0700 | [diff] [blame] | 29 | class GrFixedClip; |
Robert Phillips | 0d075de | 2019-03-04 11:08:13 -0500 | [diff] [blame] | 30 | class GrOp; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 31 | class GrRenderTarget; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 32 | class GrRenderTargetContextPriv; |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 33 | class GrRenderTargetOpList; |
Brian Salomon | 2fad74a | 2017-12-20 13:28:55 -0500 | [diff] [blame] | 34 | class GrShape; |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 35 | class GrStyle; |
Robert Phillips | eaa8625 | 2016-11-08 13:49:39 +0000 | [diff] [blame] | 36 | class GrTextureProxy; |
robertphillips | 4430239 | 2016-07-08 14:43:03 -0700 | [diff] [blame] | 37 | struct GrUserStencilSettings; |
Jim Van Verth | 3af1af9 | 2017-05-18 15:06:54 -0400 | [diff] [blame] | 38 | struct SkDrawShadowRec; |
Herb Derby | cddab25 | 2018-07-16 11:19:04 -0400 | [diff] [blame] | 39 | class SkGlyphRunList; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 40 | struct SkIPoint; |
| 41 | struct SkIRect; |
msarett | 10e3d9b | 2016-08-18 15:46:03 -0700 | [diff] [blame] | 42 | class SkLatticeIter; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 43 | class SkMatrix; |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 44 | class SkPaint; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 45 | class SkPath; |
| 46 | struct SkPoint; |
| 47 | struct SkRect; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 48 | class SkRegion; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 49 | class SkRRect; |
jvanverth | 31ff762 | 2015-08-07 10:09:28 -0700 | [diff] [blame] | 50 | struct SkRSXform; |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 51 | class SkTextBlob; |
Brian Salomon | 199fb87 | 2017-02-06 09:41:10 -0500 | [diff] [blame] | 52 | class SkVertices; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 53 | |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 54 | /** |
| 55 | * A helper object to orchestrate commands (draws, etc...) for GrSurfaces that are GrRenderTargets. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 56 | */ |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 57 | class SK_API GrRenderTargetContext : public GrSurfaceContext { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 58 | public: |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 59 | ~GrRenderTargetContext() override; |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 60 | |
Robert Phillips | e4643cc | 2018-08-14 13:01:29 -0400 | [diff] [blame] | 61 | virtual void drawGlyphRunList(const GrClip&, const SkMatrix& viewMatrix, const SkGlyphRunList&); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 62 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 63 | /** |
| 64 | * Provides a perfomance hint that the render target's contents are allowed |
| 65 | * to become undefined. |
| 66 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 67 | void discard(); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 68 | |
Chris Dalton | 344e903 | 2017-12-11 15:42:09 -0700 | [diff] [blame] | 69 | enum class CanClearFullscreen : bool { |
| 70 | kNo = false, |
| 71 | kYes = true |
| 72 | }; |
| 73 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 74 | /** |
| 75 | * Clear the entire or rect of the render target, ignoring any clips. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 76 | * @param rect the rect to clear or the whole thing if rect is NULL. |
| 77 | * @param color the color to clear to. |
Chris Dalton | 344e903 | 2017-12-11 15:42:09 -0700 | [diff] [blame] | 78 | * @param CanClearFullscreen allows partial clears to be converted to fullscreen clears on |
| 79 | * tiling platforms where that is an optimization. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 80 | */ |
Brian Osman | 9a9baae | 2018-11-05 15:06:26 -0500 | [diff] [blame] | 81 | void clear(const SkIRect* rect, const SkPMColor4f& color, CanClearFullscreen); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 82 | |
| 83 | /** |
| 84 | * Draw everywhere (respecting the clip) with the paint. |
| 85 | */ |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 86 | void drawPaint(const GrClip&, GrPaint&&, const SkMatrix& viewMatrix); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 87 | |
| 88 | /** |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 89 | * Draw the rect using a paint. |
| 90 | * @param paint describes how to color pixels. |
| 91 | * @param GrAA Controls whether rect is antialiased |
| 92 | * @param viewMatrix transformation matrix |
| 93 | * @param style The style to apply. Null means fill. Currently path effects are not |
| 94 | * allowed. |
| 95 | * The rects coords are used to access the paint (through texture matrix) |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 96 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 97 | void drawRect(const GrClip&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 98 | GrPaint&& paint, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 99 | GrAA, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 100 | const SkMatrix& viewMatrix, |
| 101 | const SkRect&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 102 | const GrStyle* style = nullptr); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 103 | |
| 104 | /** |
bsalomon | a2e69fc | 2015-11-05 10:41:43 -0800 | [diff] [blame] | 105 | * Maps a rectangle of shader coordinates to a rectangle and fills that rectangle. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 106 | * |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 107 | * @param paint describes how to color pixels. |
| 108 | * @param GrAA Controls whether rect is antialiased |
| 109 | * @param viewMatrix transformation matrix which applies to rectToDraw |
| 110 | * @param rectToDraw the rectangle to draw |
| 111 | * @param localRect the rectangle of shader coordinates applied to rectToDraw |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 112 | */ |
Michael Ludwig | 136f45a | 2019-02-19 11:44:41 -0500 | [diff] [blame] | 113 | void fillRectToRect(const GrClip& clip, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 114 | GrPaint&& paint, |
Michael Ludwig | 136f45a | 2019-02-19 11:44:41 -0500 | [diff] [blame] | 115 | GrAA aa, |
bsalomon | a2e69fc | 2015-11-05 10:41:43 -0800 | [diff] [blame] | 116 | const SkMatrix& viewMatrix, |
| 117 | const SkRect& rectToDraw, |
Michael Ludwig | 136f45a | 2019-02-19 11:44:41 -0500 | [diff] [blame] | 118 | const SkRect& localRect) { |
| 119 | this->fillRectWithEdgeAA(clip, std::move(paint), aa, |
| 120 | aa == GrAA::kYes ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone, |
| 121 | viewMatrix, rectToDraw, &localRect); |
| 122 | } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 123 | |
| 124 | /** |
bsalomon | a2e69fc | 2015-11-05 10:41:43 -0800 | [diff] [blame] | 125 | * Fills a rect with a paint and a localMatrix. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 126 | */ |
bsalomon | a2e69fc | 2015-11-05 10:41:43 -0800 | [diff] [blame] | 127 | void fillRectWithLocalMatrix(const GrClip& clip, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 128 | GrPaint&& paint, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 129 | GrAA, |
bsalomon | a2e69fc | 2015-11-05 10:41:43 -0800 | [diff] [blame] | 130 | const SkMatrix& viewMatrix, |
| 131 | const SkRect& rect, |
| 132 | const SkMatrix& localMatrix); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 133 | |
Michael Ludwig | 7545190 | 2019-01-23 11:14:29 -0500 | [diff] [blame] | 134 | /** |
| 135 | * Creates an op that draws a fill rect with per-edge control over anti-aliasing. |
Michael Ludwig | ce62dec | 2019-02-19 11:48:46 -0500 | [diff] [blame] | 136 | * |
| 137 | * This is a specialized version of fillQuadWithEdgeAA, but is kept separate since knowing |
| 138 | * the geometry is a rectangle affords more optimizations. |
Michael Ludwig | 7545190 | 2019-01-23 11:14:29 -0500 | [diff] [blame] | 139 | */ |
Michael Ludwig | 136f45a | 2019-02-19 11:44:41 -0500 | [diff] [blame] | 140 | void fillRectWithEdgeAA(const GrClip& clip, GrPaint&& paint, GrAA aa, GrQuadAAFlags edgeAA, |
| 141 | const SkMatrix& viewMatrix, const SkRect& rect, |
| 142 | const SkRect* optionalLocalRect = nullptr); |
Michael Ludwig | 7545190 | 2019-01-23 11:14:29 -0500 | [diff] [blame] | 143 | |
Michael Ludwig | ce62dec | 2019-02-19 11:48:46 -0500 | [diff] [blame] | 144 | /** |
| 145 | * Similar to fillRectWithEdgeAA but draws an arbitrary 2D convex quadrilateral transformed |
| 146 | * by 'viewMatrix', with per-edge control over anti-aliasing. The quad should follow the |
| 147 | * ordering used by SkRect::toQuad(), which determines how the edge AA is applied: |
| 148 | * - "top" = points [0] and [1] |
| 149 | * - "right" = points[1] and [2] |
| 150 | * - "bottom" = points[2] and [3] |
| 151 | * - "left" = points[3] and [0] |
| 152 | * |
| 153 | * The last argument, 'optionalLocalQuad', can be null if no separate local coordinates are |
| 154 | * necessary. |
| 155 | */ |
| 156 | void fillQuadWithEdgeAA(const GrClip& clip, GrPaint&& paint, GrAA aa, GrQuadAAFlags edgeAA, |
| 157 | const SkMatrix& viewMatrix, const SkPoint quad[4], |
| 158 | const SkPoint optionalLocalQuad[4]); |
| 159 | |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 160 | /** Used with drawQuadSet */ |
| 161 | struct QuadSetEntry { |
| 162 | SkRect fRect; |
| 163 | SkPMColor4f fColor; // Overrides any color on the GrPaint |
| 164 | SkMatrix fLocalMatrix; |
| 165 | GrQuadAAFlags fAAFlags; |
| 166 | }; |
| 167 | |
Michael Ludwig | 7545190 | 2019-01-23 11:14:29 -0500 | [diff] [blame] | 168 | // TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer |
Michael Ludwig | 6985853 | 2018-11-28 15:34:34 -0500 | [diff] [blame] | 169 | void drawQuadSet(const GrClip& clip, GrPaint&& paint, GrAA aa, const SkMatrix& viewMatrix, |
| 170 | const QuadSetEntry[], int cnt); |
| 171 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 172 | /** |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 173 | * Creates an op that draws a subrectangle of a texture. The passed color is modulated by the |
| 174 | * texture's color. 'srcRect' specifies the rectangle of the texture to draw. 'dstRect' |
| 175 | * specifies the rectangle to draw in local coords which will be transformed by 'viewMatrix' to |
Brian Salomon | be3c1d2 | 2018-05-21 12:54:39 -0400 | [diff] [blame] | 176 | * device space. |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 177 | */ |
Brian Osman | 3d139a4 | 2018-11-19 10:42:10 -0500 | [diff] [blame] | 178 | void drawTexture(const GrClip& clip, sk_sp<GrTextureProxy>, GrSamplerState::Filter, |
Michael Ludwig | d54ca8f | 2019-02-13 13:25:21 -0500 | [diff] [blame] | 179 | SkBlendMode mode, const SkPMColor4f&, const SkRect& srcRect, |
Michael Ludwig | 136f45a | 2019-02-19 11:44:41 -0500 | [diff] [blame] | 180 | const SkRect& dstRect, GrAA, GrQuadAAFlags, SkCanvas::SrcRectConstraint, |
Michael Ludwig | d54ca8f | 2019-02-13 13:25:21 -0500 | [diff] [blame] | 181 | const SkMatrix& viewMatrix, sk_sp<GrColorSpaceXform> texXform); |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 182 | |
Michael Ludwig | ce62dec | 2019-02-19 11:48:46 -0500 | [diff] [blame] | 183 | /** |
| 184 | * Variant of drawTexture that instead draws the texture applied to 'dstQuad' transformed by |
| 185 | * 'viewMatrix', using the 'srcQuad' texture coordinates clamped to the optional 'domain'. If |
| 186 | * 'domain' is null, it's equivalent to using the fast src rect constraint. If 'domain' is |
| 187 | * provided, the strict src rect constraint is applied using 'domain'. |
| 188 | */ |
| 189 | void drawTextureQuad(const GrClip& clip, sk_sp<GrTextureProxy>, GrSamplerState::Filter, |
| 190 | SkBlendMode mode, const SkPMColor4f&, const SkPoint srcQuad[4], |
| 191 | const SkPoint dstQuad[4], GrAA, GrQuadAAFlags, const SkRect* domain, |
| 192 | const SkMatrix& viewMatrix, sk_sp<GrColorSpaceXform> texXform); |
| 193 | |
Brian Salomon | d7065e7 | 2018-10-12 11:42:02 -0400 | [diff] [blame] | 194 | /** Used with drawTextureSet */ |
| 195 | struct TextureSetEntry { |
| 196 | sk_sp<GrTextureProxy> fProxy; |
| 197 | SkRect fSrcRect; |
| 198 | SkRect fDstRect; |
Michael Ludwig | 1433cfd | 2019-02-27 17:12:30 -0500 | [diff] [blame] | 199 | const SkPoint* fDstClipQuad; // Must be null, or point to an array of 4 points |
Michael Ludwig | 7ae2ab5 | 2019-03-05 16:00:20 -0500 | [diff] [blame] | 200 | const SkMatrix* fPreViewMatrix; // If not null, entry's CTM is 'viewMatrix' * fPreViewMatrix |
Brian Salomon | 1da5cad | 2018-11-21 09:21:18 -0500 | [diff] [blame] | 201 | float fAlpha; |
Brian Salomon | d7065e7 | 2018-10-12 11:42:02 -0400 | [diff] [blame] | 202 | GrQuadAAFlags fAAFlags; |
| 203 | }; |
| 204 | /** |
| 205 | * Draws a set of textures with a shared filter, color, view matrix, color xform, and |
| 206 | * texture color xform. The textures must all have the same GrTextureType and GrConfig. |
Michael Ludwig | ce62dec | 2019-02-19 11:48:46 -0500 | [diff] [blame] | 207 | * |
| 208 | * If any entries provide a non-null fDstClip array, it will be read from immediately based on |
| 209 | * fDstClipCount, so the pointer can become invalid after this returns. |
Brian Salomon | d7065e7 | 2018-10-12 11:42:02 -0400 | [diff] [blame] | 210 | */ |
| 211 | void drawTextureSet(const GrClip&, const TextureSetEntry[], int cnt, GrSamplerState::Filter, |
Michael Ludwig | 136f45a | 2019-02-19 11:44:41 -0500 | [diff] [blame] | 212 | SkBlendMode mode, GrAA aa, const SkMatrix& viewMatrix, |
Michael Ludwig | a3c45c7 | 2019-01-17 17:26:48 -0500 | [diff] [blame] | 213 | sk_sp<GrColorSpaceXform> texXform); |
Brian Salomon | d7065e7 | 2018-10-12 11:42:02 -0400 | [diff] [blame] | 214 | |
Brian Salomon | 3416969 | 2017-08-28 15:32:01 -0400 | [diff] [blame] | 215 | /** |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 216 | * Draw a roundrect using a paint. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 217 | * |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 218 | * @param paint describes how to color pixels. |
| 219 | * @param GrAA Controls whether rrect is antialiased. |
| 220 | * @param viewMatrix transformation matrix |
| 221 | * @param rrect the roundrect to draw |
| 222 | * @param style style to apply to the rrect. Currently path effects are not allowed. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 223 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 224 | void drawRRect(const GrClip&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 225 | GrPaint&&, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 226 | GrAA, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 227 | const SkMatrix& viewMatrix, |
| 228 | const SkRRect& rrect, |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 229 | const GrStyle& style); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 230 | |
| 231 | /** |
Jim Van Verth | 3af1af9 | 2017-05-18 15:06:54 -0400 | [diff] [blame] | 232 | * Use a fast method to render the ambient and spot shadows for a path. |
| 233 | * Will return false if not possible for the given path. |
Jim Van Verth | c590341 | 2016-11-17 15:27:09 -0500 | [diff] [blame] | 234 | * |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 235 | * @param viewMatrix transformation matrix |
Jim Van Verth | 3af1af9 | 2017-05-18 15:06:54 -0400 | [diff] [blame] | 236 | * @param path the path to shadow |
| 237 | * @param rec parameters for shadow rendering |
Jim Van Verth | c590341 | 2016-11-17 15:27:09 -0500 | [diff] [blame] | 238 | */ |
Jim Van Verth | 3af1af9 | 2017-05-18 15:06:54 -0400 | [diff] [blame] | 239 | bool drawFastShadow(const GrClip&, |
Jim Van Verth | 3af1af9 | 2017-05-18 15:06:54 -0400 | [diff] [blame] | 240 | const SkMatrix& viewMatrix, |
| 241 | const SkPath& path, |
| 242 | const SkDrawShadowRec& rec); |
Jim Van Verth | c590341 | 2016-11-17 15:27:09 -0500 | [diff] [blame] | 243 | |
| 244 | /** |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 245 | * Shortcut for filling a SkPath consisting of nested rrects using a paint. The result is |
| 246 | * undefined if outer does not contain inner. |
robertphillips | 0009589 | 2016-02-29 13:50:40 -0800 | [diff] [blame] | 247 | * |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 248 | * @param paint describes how to color pixels. |
| 249 | * @param GrAA Controls whether rrects edges are antialiased |
| 250 | * @param viewMatrix transformation matrix |
| 251 | * @param outer the outer roundrect |
| 252 | * @param inner the inner roundrect |
robertphillips | 0009589 | 2016-02-29 13:50:40 -0800 | [diff] [blame] | 253 | */ |
| 254 | void drawDRRect(const GrClip&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 255 | GrPaint&&, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 256 | GrAA, |
robertphillips | 0009589 | 2016-02-29 13:50:40 -0800 | [diff] [blame] | 257 | const SkMatrix& viewMatrix, |
| 258 | const SkRRect& outer, |
| 259 | const SkRRect& inner); |
| 260 | |
| 261 | /** |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 262 | * Draws a path. |
| 263 | * |
| 264 | * @param paint describes how to color pixels. |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 265 | * @param GrAA Controls whether the path is antialiased. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 266 | * @param viewMatrix transformation matrix |
| 267 | * @param path the path to draw |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 268 | * @param style style to apply to the path. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 269 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 270 | void drawPath(const GrClip&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 271 | GrPaint&&, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 272 | GrAA, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 273 | const SkMatrix& viewMatrix, |
| 274 | const SkPath&, |
Robert Phillips | 20390c3 | 2018-08-17 11:01:03 -0400 | [diff] [blame] | 275 | const GrStyle&); |
| 276 | |
| 277 | /** |
| 278 | * Draws a shape. |
| 279 | * |
| 280 | * @param paint describes how to color pixels. |
| 281 | * @param GrAA Controls whether the path is antialiased. |
| 282 | * @param viewMatrix transformation matrix |
| 283 | * @param shape the shape to draw |
| 284 | */ |
| 285 | void drawShape(const GrClip&, |
| 286 | GrPaint&&, |
| 287 | GrAA, |
| 288 | const SkMatrix& viewMatrix, |
| 289 | const GrShape&); |
| 290 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 291 | |
| 292 | /** |
| 293 | * Draws vertices with a paint. |
| 294 | * |
Brian Osman | ae0c50c | 2017-05-25 16:56:34 -0400 | [diff] [blame] | 295 | * @param paint describes how to color pixels. |
| 296 | * @param viewMatrix transformation matrix |
| 297 | * @param vertices specifies the mesh to draw. |
Ruiqi Mao | 4ec72f7 | 2018-07-10 17:21:07 -0400 | [diff] [blame] | 298 | * @param bones bone deformation matrices. |
| 299 | * @param boneCount number of bone matrices. |
Brian Osman | ae0c50c | 2017-05-25 16:56:34 -0400 | [diff] [blame] | 300 | * @param overridePrimType primitive type to draw. If NULL, derive prim type from vertices. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 301 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 302 | void drawVertices(const GrClip&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 303 | GrPaint&& paint, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 304 | const SkMatrix& viewMatrix, |
Brian Osman | ae0c50c | 2017-05-25 16:56:34 -0400 | [diff] [blame] | 305 | sk_sp<SkVertices> vertices, |
Ruiqi Mao | c97a339 | 2018-08-15 10:44:19 -0400 | [diff] [blame] | 306 | const SkVertices::Bone bones[], |
Ruiqi Mao | 4ec72f7 | 2018-07-10 17:21:07 -0400 | [diff] [blame] | 307 | int boneCount, |
Brian Osman | ae0c50c | 2017-05-25 16:56:34 -0400 | [diff] [blame] | 308 | GrPrimitiveType* overridePrimType = nullptr); |
Brian Salomon | 199fb87 | 2017-02-06 09:41:10 -0500 | [diff] [blame] | 309 | |
| 310 | /** |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 311 | * Draws textured sprites from an atlas with a paint. This currently does not support AA for the |
| 312 | * sprite rectangle edges. |
jvanverth | 31ff762 | 2015-08-07 10:09:28 -0700 | [diff] [blame] | 313 | * |
| 314 | * @param paint describes how to color pixels. |
| 315 | * @param viewMatrix transformation matrix |
| 316 | * @param spriteCount number of sprites. |
| 317 | * @param xform array of compressed transformation data, required. |
| 318 | * @param texRect array of texture rectangles used to access the paint. |
| 319 | * @param colors optional array of per-sprite colors, supercedes |
| 320 | * the paint's color field. |
| 321 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 322 | void drawAtlas(const GrClip&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 323 | GrPaint&& paint, |
jvanverth | 31ff762 | 2015-08-07 10:09:28 -0700 | [diff] [blame] | 324 | const SkMatrix& viewMatrix, |
| 325 | int spriteCount, |
| 326 | const SkRSXform xform[], |
| 327 | const SkRect texRect[], |
| 328 | const SkColor colors[]); |
msarett | cc319b9 | 2016-08-25 18:07:18 -0700 | [diff] [blame] | 329 | |
| 330 | /** |
| 331 | * Draws a region. |
| 332 | * |
| 333 | * @param paint describes how to color pixels |
| 334 | * @param viewMatrix transformation matrix |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 335 | * @param aa should the rects of the region be antialiased. |
msarett | cc319b9 | 2016-08-25 18:07:18 -0700 | [diff] [blame] | 336 | * @param region the region to be drawn |
| 337 | * @param style style to apply to the region |
| 338 | */ |
| 339 | void drawRegion(const GrClip&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 340 | GrPaint&& paint, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 341 | GrAA aa, |
msarett | cc319b9 | 2016-08-25 18:07:18 -0700 | [diff] [blame] | 342 | const SkMatrix& viewMatrix, |
| 343 | const SkRegion& region, |
Stan Iliev | 73d8fd9 | 2017-08-02 15:36:24 -0400 | [diff] [blame] | 344 | const GrStyle& style, |
| 345 | const GrUserStencilSettings* ss = nullptr); |
msarett | cc319b9 | 2016-08-25 18:07:18 -0700 | [diff] [blame] | 346 | |
jvanverth | 31ff762 | 2015-08-07 10:09:28 -0700 | [diff] [blame] | 347 | /** |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 348 | * Draws an oval. |
| 349 | * |
| 350 | * @param paint describes how to color pixels. |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 351 | * @param GrAA Controls whether the oval is antialiased. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 352 | * @param viewMatrix transformation matrix |
| 353 | * @param oval the bounding rect of the oval. |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 354 | * @param style style to apply to the oval. Currently path effects are not allowed. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 355 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 356 | void drawOval(const GrClip&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 357 | GrPaint&& paint, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 358 | GrAA, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 359 | const SkMatrix& viewMatrix, |
| 360 | const SkRect& oval, |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 361 | const GrStyle& style); |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 362 | /** |
| 363 | * Draws a partial arc of an oval. |
| 364 | * |
| 365 | * @param paint describes how to color pixels. |
Brian Salomon | 9950408 | 2016-12-09 15:51:31 -0500 | [diff] [blame] | 366 | * @param GrGrAA Controls whether the arc is antialiased. |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 367 | * @param viewMatrix transformation matrix. |
| 368 | * @param oval the bounding rect of the oval. |
| 369 | * @param startAngle starting angle in degrees. |
| 370 | * @param sweepAngle angle to sweep in degrees. Must be in (-360, 360) |
| 371 | * @param useCenter true means that the implied path begins at the oval center, connects as |
| 372 | * a line to the point indicated by the start contains the arc indicated by |
| 373 | * the sweep angle. If false the line beginning at the center point is |
| 374 | * omitted. |
| 375 | * @param style style to apply to the oval. |
| 376 | */ |
bsalomon | 4f3a0ca | 2016-08-22 13:14:26 -0700 | [diff] [blame] | 377 | void drawArc(const GrClip&, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 378 | GrPaint&& paint, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 379 | GrAA, |
bsalomon | 4f3a0ca | 2016-08-22 13:14:26 -0700 | [diff] [blame] | 380 | const SkMatrix& viewMatrix, |
| 381 | const SkRect& oval, |
| 382 | SkScalar startAngle, |
| 383 | SkScalar sweepAngle, |
| 384 | bool useCenter, |
| 385 | const GrStyle& style); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 386 | |
joshualitt | 33a5fce | 2015-11-18 13:28:51 -0800 | [diff] [blame] | 387 | /** |
bsalomon | 4f3a0ca | 2016-08-22 13:14:26 -0700 | [diff] [blame] | 388 | * Draw the image as a set of rects, specified by |iter|. |
joshualitt | 33a5fce | 2015-11-18 13:28:51 -0800 | [diff] [blame] | 389 | */ |
msarett | 10e3d9b | 2016-08-18 15:46:03 -0700 | [diff] [blame] | 390 | void drawImageLattice(const GrClip&, |
Brian Salomon | 2a943df | 2018-05-04 13:43:19 -0400 | [diff] [blame] | 391 | GrPaint&&, |
msarett | 10e3d9b | 2016-08-18 15:46:03 -0700 | [diff] [blame] | 392 | const SkMatrix& viewMatrix, |
Brian Salomon | 2a943df | 2018-05-04 13:43:19 -0400 | [diff] [blame] | 393 | sk_sp<GrTextureProxy>, |
| 394 | sk_sp<GrColorSpaceXform>, |
| 395 | GrSamplerState::Filter, |
| 396 | std::unique_ptr<SkLatticeIter>, |
msarett | 10e3d9b | 2016-08-18 15:46:03 -0700 | [diff] [blame] | 397 | const SkRect& dst); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 398 | |
robertphillips | 8c523e0 | 2016-07-26 07:41:00 -0700 | [diff] [blame] | 399 | /** |
Greg Daniel | 64cc9aa | 2018-10-19 13:54:56 -0400 | [diff] [blame] | 400 | * Adds the necessary signal and wait semaphores and adds the passed in SkDrawable to the |
| 401 | * command stream. |
| 402 | */ |
| 403 | void drawDrawable(std::unique_ptr<SkDrawable::GpuDrawHandler>, const SkRect& bounds); |
| 404 | |
| 405 | /** |
robertphillips | 8c523e0 | 2016-07-26 07:41:00 -0700 | [diff] [blame] | 406 | * After this returns any pending surface IO will be issued to the backend 3D API and |
| 407 | * if the surface has MSAA it will be resolved. |
| 408 | */ |
Greg Daniel | bae7121 | 2019-03-01 15:24:35 -0500 | [diff] [blame] | 409 | GrSemaphoresSubmitted prepareForExternalIO(SkSurface::BackendSurfaceAccess access, |
| 410 | SkSurface::FlushFlags flags, int numSemaphores, |
Greg Daniel | 5131678 | 2017-08-02 15:10:09 +0000 | [diff] [blame] | 411 | GrBackendSemaphore backendSemaphores[]); |
Greg Daniel | a5cb781 | 2017-06-16 09:45:32 -0400 | [diff] [blame] | 412 | |
| 413 | /** |
| 414 | * The next time this GrRenderTargetContext is flushed, the gpu will wait on the passed in |
| 415 | * semaphores before executing any commands. |
| 416 | */ |
Robert Phillips | bc4994a | 2019-02-14 08:36:56 -0500 | [diff] [blame] | 417 | bool waitOnSemaphores(int numSemaphores, const GrBackendSemaphore waitSemaphores[]); |
robertphillips | 8c523e0 | 2016-07-26 07:41:00 -0700 | [diff] [blame] | 418 | |
Robert Phillips | 65a88fa | 2017-08-08 08:36:22 -0400 | [diff] [blame] | 419 | void insertEventMarker(const SkString&); |
| 420 | |
Brian Salomon | 7c8460e | 2017-05-12 11:36:10 -0400 | [diff] [blame] | 421 | GrFSAAType fsaaType() const { return fRenderTargetProxy->fsaaType(); } |
Robert Phillips | be9aff2 | 2019-02-15 11:33:22 -0500 | [diff] [blame] | 422 | const GrCaps* caps() const; |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 423 | int width() const { return fRenderTargetProxy->width(); } |
| 424 | int height() const { return fRenderTargetProxy->height(); } |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 425 | int numColorSamples() const { return fRenderTargetProxy->numColorSamples(); } |
Brian Salomon | 50e66d4 | 2017-05-15 16:28:07 -0400 | [diff] [blame] | 426 | int numStencilSamples() const { return fRenderTargetProxy->numStencilSamples(); } |
robertphillips | ca6eafc | 2016-05-17 09:57:46 -0700 | [diff] [blame] | 427 | const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; } |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 428 | GrSurfaceOrigin origin() const { return fRenderTargetProxy->origin(); } |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 429 | bool wrapsVkSecondaryCB() const { return fRenderTargetProxy->wrapsVkSecondaryCB(); } |
Greg Daniel | e252f08 | 2017-10-23 16:05:23 -0400 | [diff] [blame] | 430 | GrMipMapped mipMapped() const; |
robertphillips | 7bceedc | 2015-12-01 12:51:26 -0800 | [diff] [blame] | 431 | |
Robert Phillips | 6504813 | 2017-08-10 08:44:49 -0400 | [diff] [blame] | 432 | void setNeedsStencil() { fRenderTargetProxy->setNeedsStencil(); } |
| 433 | |
Robert Phillips | be9aff2 | 2019-02-15 11:33:22 -0500 | [diff] [blame] | 434 | // This entry point should only be called if the backing GPU object is known to be |
| 435 | // instantiated. |
| 436 | GrRenderTarget* accessRenderTarget() { return fRenderTargetProxy->peekRenderTarget(); } |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 437 | |
Robert Phillips | f200a90 | 2017-01-30 13:27:37 -0500 | [diff] [blame] | 438 | GrSurfaceProxy* asSurfaceProxy() override { return fRenderTargetProxy.get(); } |
| 439 | const GrSurfaceProxy* asSurfaceProxy() const override { return fRenderTargetProxy.get(); } |
| 440 | sk_sp<GrSurfaceProxy> asSurfaceProxyRef() override { return fRenderTargetProxy; } |
| 441 | |
| 442 | GrTextureProxy* asTextureProxy() override; |
Greg Daniel | e252f08 | 2017-10-23 16:05:23 -0400 | [diff] [blame] | 443 | const GrTextureProxy* asTextureProxy() const override; |
Robert Phillips | f200a90 | 2017-01-30 13:27:37 -0500 | [diff] [blame] | 444 | sk_sp<GrTextureProxy> asTextureProxyRef() override; |
| 445 | |
| 446 | GrRenderTargetProxy* asRenderTargetProxy() override { return fRenderTargetProxy.get(); } |
| 447 | sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() override { return fRenderTargetProxy; } |
Robert Phillips | eaa8625 | 2016-11-08 13:49:39 +0000 | [diff] [blame] | 448 | |
Robert Phillips | d46697a | 2017-01-25 12:10:37 -0500 | [diff] [blame] | 449 | GrRenderTargetContext* asRenderTargetContext() override { return this; } |
| 450 | |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 451 | // Provides access to functions that aren't part of the public API. |
Brian Osman | 693a540 | 2016-10-27 15:13:22 -0400 | [diff] [blame] | 452 | GrRenderTargetContextPriv priv(); |
| 453 | const GrRenderTargetContextPriv priv() const; |
joshualitt | f5883a6 | 2016-01-13 07:47:38 -0800 | [diff] [blame] | 454 | |
Herb Derby | c1b482c | 2018-08-09 15:02:27 -0400 | [diff] [blame] | 455 | GrTextTarget* textTarget() { return fTextTarget.get(); } |
Brian Salomon | f18b1d8 | 2017-10-27 11:30:49 -0400 | [diff] [blame] | 456 | |
Robert Phillips | eaa8625 | 2016-11-08 13:49:39 +0000 | [diff] [blame] | 457 | bool isWrapped_ForTesting() const; |
| 458 | |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 459 | protected: |
Robert Phillips | 0d075de | 2019-03-04 11:08:13 -0500 | [diff] [blame] | 460 | GrRenderTargetContext(GrRecordingContext*, sk_sp<GrRenderTargetProxy>, |
| 461 | sk_sp<SkColorSpace>, const SkSurfaceProps*, |
| 462 | bool managedOpList = true); |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 463 | |
Robert Phillips | 2de8cfa | 2017-06-28 10:33:41 -0400 | [diff] [blame] | 464 | SkDEBUGCODE(void validate() const override;) |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 465 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 466 | private: |
Brian Salomon | f18b1d8 | 2017-10-27 11:30:49 -0400 | [diff] [blame] | 467 | class TextTarget; |
| 468 | |
Chris Dalton | 7d6748e | 2019-03-13 00:34:52 -0600 | [diff] [blame] | 469 | GrAAType chooseAAType(GrAA); |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 470 | |
Brian Salomon | 649a341 | 2017-03-09 13:50:43 -0500 | [diff] [blame] | 471 | friend class GrAtlasTextBlob; // for access to add[Mesh]DrawOp |
Brian Osman | 5d03474 | 2017-09-11 13:38:55 -0400 | [diff] [blame] | 472 | friend class GrClipStackClip; // for access to getOpList |
robertphillips | 55fdccc | 2016-06-06 06:16:20 -0700 | [diff] [blame] | 473 | |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 474 | friend class GrDrawingManager; // for ctor |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 475 | friend class GrRenderTargetContextPriv; |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 476 | |
Brian Salomon | 42521e8 | 2016-12-07 16:44:58 -0500 | [diff] [blame] | 477 | // All the path renderers currently make their own ops |
Brian Salomon | 649a341 | 2017-03-09 13:50:43 -0500 | [diff] [blame] | 478 | friend class GrSoftwarePathRenderer; // for access to add[Mesh]DrawOp |
| 479 | friend class GrAAConvexPathRenderer; // for access to add[Mesh]DrawOp |
| 480 | friend class GrDashLinePathRenderer; // for access to add[Mesh]DrawOp |
| 481 | friend class GrAAHairLinePathRenderer; // for access to add[Mesh]DrawOp |
| 482 | friend class GrAALinearizingConvexPathRenderer; // for access to add[Mesh]DrawOp |
Jim Van Verth | 8301046 | 2017-03-16 08:45:39 -0400 | [diff] [blame] | 483 | friend class GrSmallPathRenderer; // for access to add[Mesh]DrawOp |
Brian Salomon | 649a341 | 2017-03-09 13:50:43 -0500 | [diff] [blame] | 484 | friend class GrDefaultPathRenderer; // for access to add[Mesh]DrawOp |
Brian Salomon | 649a341 | 2017-03-09 13:50:43 -0500 | [diff] [blame] | 485 | friend class GrStencilAndCoverPathRenderer; // for access to add[Mesh]DrawOp |
| 486 | friend class GrTessellatingPathRenderer; // for access to add[Mesh]DrawOp |
Chris Dalton | 9414c96 | 2018-06-14 10:14:50 -0600 | [diff] [blame] | 487 | friend class GrCCPerFlushResources; // for access to addDrawOp |
Chris Dalton | 1a325d2 | 2017-07-14 15:17:41 -0600 | [diff] [blame] | 488 | friend class GrCoverageCountingPathRenderer; // for access to addDrawOp |
Brian Salomon | 5d4cd9e | 2017-02-09 11:16:46 -0500 | [diff] [blame] | 489 | // for a unit test |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 490 | friend void test_draw_op(GrContext*, |
| 491 | GrRenderTargetContext*, |
| 492 | std::unique_ptr<GrFragmentProcessor>, |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 493 | sk_sp<GrTextureProxy>); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 494 | |
Brian Osman | 9a9baae | 2018-11-05 15:06:26 -0500 | [diff] [blame] | 495 | void internalClear(const GrFixedClip&, const SkPMColor4f&, CanClearFullscreen); |
Michael Ludwig | c39d0c8 | 2019-01-15 10:03:43 -0500 | [diff] [blame] | 496 | void internalStencilClear(const GrFixedClip&, bool insideStencilMask); |
csmartdalton | 29df760 | 2016-08-31 11:55:52 -0700 | [diff] [blame] | 497 | |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 498 | // Only consumes the GrPaint if successful. |
robertphillips | 0009589 | 2016-02-29 13:50:40 -0800 | [diff] [blame] | 499 | bool drawFilledDRRect(const GrClip& clip, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 500 | GrPaint&& paint, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 501 | GrAA, |
robertphillips | 0009589 | 2016-02-29 13:50:40 -0800 | [diff] [blame] | 502 | const SkMatrix& viewMatrix, |
| 503 | const SkRRect& origOuter, |
| 504 | const SkRRect& origInner); |
| 505 | |
Michael Ludwig | 61a1651 | 2019-01-15 11:15:13 -0500 | [diff] [blame] | 506 | void drawFilledRect(const GrClip& clip, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 507 | GrPaint&& paint, |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 508 | GrAA, |
robertphillips | 4430239 | 2016-07-08 14:43:03 -0700 | [diff] [blame] | 509 | const SkMatrix& viewMatrix, |
| 510 | const SkRect& rect, |
Michael Ludwig | 61a1651 | 2019-01-15 11:15:13 -0500 | [diff] [blame] | 511 | const GrUserStencilSettings* ss = nullptr); |
| 512 | |
| 513 | // Only consumes the GrPaint if successful. |
| 514 | bool drawFilledRectAsClear(const GrClip& clip, |
| 515 | GrPaint&& paint, |
| 516 | GrAA aa, |
| 517 | const SkMatrix& viewMatrix, |
| 518 | const SkRect& rect); |
robertphillips | 4430239 | 2016-07-08 14:43:03 -0700 | [diff] [blame] | 519 | |
Brian Salomon | 2fad74a | 2017-12-20 13:28:55 -0500 | [diff] [blame] | 520 | void drawShapeUsingPathRenderer(const GrClip&, GrPaint&&, GrAA, const SkMatrix&, |
| 521 | const GrShape&); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 522 | |
Brian Salomon | 348a037 | 2018-10-31 10:42:18 -0400 | [diff] [blame] | 523 | // Allows caller of addDrawOp to know which op list an op will be added to. |
| 524 | using WillAddOpFn = void(GrOp*, uint32_t opListID); |
| 525 | // These perform processing specific to GrDrawOp-derived ops before recording them into an |
| 526 | // op list. Before adding the op to an op list the WillAddOpFn is called. Note that it |
| 527 | // will not be called in the event that the op is discarded. Moreover, the op may merge into |
| 528 | // another op after the function is called (either before addDrawOp returns or some time later). |
| 529 | void addDrawOp(const GrClip&, std::unique_ptr<GrDrawOp>, |
| 530 | const std::function<WillAddOpFn>& = std::function<WillAddOpFn>()); |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 531 | |
Robert Phillips | bf25d43 | 2017-04-07 10:08:53 -0400 | [diff] [blame] | 532 | // Makes a copy of the proxy if it is necessary for the draw and places the texture that should |
| 533 | // be used by GrXferProcessor to access the destination color in 'result'. If the return |
| 534 | // value is false then a texture copy could not be made. |
Robert Phillips | bb581ce | 2017-05-29 15:05:15 -0400 | [diff] [blame] | 535 | bool SK_WARN_UNUSED_RESULT setupDstProxy(GrRenderTargetProxy*, |
| 536 | const GrClip&, |
Brian Salomon | 09181ef | 2018-11-14 13:39:51 -0500 | [diff] [blame] | 537 | const GrOp& op, |
Robert Phillips | bb581ce | 2017-05-29 15:05:15 -0400 | [diff] [blame] | 538 | GrXferProcessor::DstProxy* result); |
Brian Salomon | 467921e | 2017-03-06 16:17:12 -0500 | [diff] [blame] | 539 | |
Robert Phillips | 2de8cfa | 2017-06-28 10:33:41 -0400 | [diff] [blame] | 540 | GrRenderTargetOpList* getRTOpList(); |
| 541 | GrOpList* getOpList() override; |
robertphillips | a106c62 | 2015-10-16 09:07:06 -0700 | [diff] [blame] | 542 | |
Herb Derby | c1b482c | 2018-08-09 15:02:27 -0400 | [diff] [blame] | 543 | std::unique_ptr<GrTextTarget> fTextTarget; |
Brian Salomon | f18b1d8 | 2017-10-27 11:30:49 -0400 | [diff] [blame] | 544 | sk_sp<GrRenderTargetProxy> fRenderTargetProxy; |
robertphillips | a106c62 | 2015-10-16 09:07:06 -0700 | [diff] [blame] | 545 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 546 | // In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 547 | // it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'. |
Brian Salomon | f18b1d8 | 2017-10-27 11:30:49 -0400 | [diff] [blame] | 548 | sk_sp<GrRenderTargetOpList> fOpList; |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 549 | |
Brian Salomon | f18b1d8 | 2017-10-27 11:30:49 -0400 | [diff] [blame] | 550 | SkSurfaceProps fSurfaceProps; |
| 551 | bool fManagedOpList; |
Robert Phillips | e305cc1f | 2016-12-14 12:19:05 -0500 | [diff] [blame] | 552 | |
| 553 | typedef GrSurfaceContext INHERITED; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 554 | }; |
| 555 | |
| 556 | #endif |