blob: 68cfce142e47fc3b2b7c108d5e18ae982bfcbc52 [file] [log] [blame]
robertphillipsea461502015-05-26 11:38:03 -07001/*
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 Salomoneebe7352020-12-09 16:37:04 -05008#ifndef GrSurfaceDrawContext_DEFINED
9#define GrSurfaceDrawContext_DEFINED
robertphillipsea461502015-05-26 11:38:03 -070010
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkCanvas.h"
12#include "include/core/SkDrawable.h"
13#include "include/core/SkRefCnt.h"
14#include "include/core/SkSurface.h"
15#include "include/core/SkSurfaceProps.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050016#include "include/private/GrTypesPriv.h"
Herb Derbyd29207a2020-06-08 13:50:19 -040017#include "src/core/SkGlyphRunPainter.h"
Greg Danielf41b2bd2019-08-22 16:19:24 -040018#include "src/gpu/GrOpsTask.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050019#include "src/gpu/GrPaint.h"
Greg Danielf91aeb22019-06-18 09:58:02 -040020#include "src/gpu/GrRenderTargetProxy.h"
Brian Salomon590f5672020-12-16 11:44:47 -050021#include "src/gpu/GrSurfaceFillContext.h"
Greg Daniela83de582019-10-22 09:33:25 -040022#include "src/gpu/GrSurfaceProxyView.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050023#include "src/gpu/GrXferProcessor.h"
Michael Ludwig61328202019-06-19 14:48:58 +000024#include "src/gpu/geometry/GrQuad.h"
robertphillipsea461502015-05-26 11:38:03 -070025
Greg Daniela5cb7812017-06-16 09:45:32 -040026class GrBackendSemaphore;
robertphillipsea461502015-05-26 11:38:03 -070027class GrClip;
Brian Osman2240be92017-10-18 13:15:13 -040028class GrColorSpaceXform;
Chris Dalton1a325d22017-07-14 15:17:41 -060029class GrCoverageCountingPathRenderer;
Brian Salomon9afd3712016-12-01 10:59:09 -050030class GrDrawOp;
Robert Phillips0d075de2019-03-04 11:08:13 -050031class GrOp;
robertphillipsea461502015-05-26 11:38:03 -070032class GrRenderTarget;
Michael Ludwig2686d692020-04-17 20:21:37 +000033class GrStyledShape;
bsalomon6663acf2016-05-10 09:14:17 -070034class GrStyle;
Robert Phillipseaa86252016-11-08 13:49:39 +000035class GrTextureProxy;
robertphillips44302392016-07-08 14:43:03 -070036struct GrUserStencilSettings;
Jim Van Verth3af1af92017-05-18 15:06:54 -040037struct SkDrawShadowRec;
Herb Derbycddab252018-07-16 11:19:04 -040038class SkGlyphRunList;
robertphillipsea461502015-05-26 11:38:03 -070039struct SkIPoint;
40struct SkIRect;
msarett10e3d9b2016-08-18 15:46:03 -070041class SkLatticeIter;
Brian Osman449b1152020-04-15 16:43:00 -040042class SkMatrixProvider;
robertphillipsea461502015-05-26 11:38:03 -070043class SkMatrix;
robertphillips2334fb62015-06-17 05:43:33 -070044class SkPaint;
robertphillipsea461502015-05-26 11:38:03 -070045class SkPath;
46struct SkPoint;
47struct SkRect;
Brian Osman45580d32016-11-23 09:37:01 -050048class SkRegion;
robertphillipsea461502015-05-26 11:38:03 -070049class SkRRect;
jvanverth31ff7622015-08-07 10:09:28 -070050struct SkRSXform;
Brian Osman3c358422020-03-23 10:44:12 -040051class SkRuntimeEffect;
robertphillips2334fb62015-06-17 05:43:33 -070052class SkTextBlob;
Brian Salomon199fb872017-02-06 09:41:10 -050053class SkVertices;
robertphillipsea461502015-05-26 11:38:03 -070054
Brian Osman45580d32016-11-23 09:37:01 -050055/**
56 * A helper object to orchestrate commands (draws, etc...) for GrSurfaces that are GrRenderTargets.
robertphillipsea461502015-05-26 11:38:03 -070057 */
Brian Salomon590f5672020-12-16 11:44:47 -050058class GrSurfaceDrawContext : public GrSurfaceFillContext {
robertphillipsea461502015-05-26 11:38:03 -070059public:
Brian Salomoneebe7352020-12-09 16:37:04 -050060 static std::unique_ptr<GrSurfaceDrawContext> Make(GrRecordingContext*,
61 GrColorType,
62 sk_sp<SkColorSpace>,
63 sk_sp<GrSurfaceProxy>,
64 GrSurfaceOrigin,
Chris Daltonf5b87f92021-04-19 17:27:09 -060065 const SkSurfaceProps&,
Brian Salomoneebe7352020-12-09 16:37:04 -050066 bool flushTimeOpsTask = false);
Greg Daniele20fcad2020-01-08 11:52:34 -050067
Brian Salomon07bc9a22020-12-02 13:37:16 -050068 /* Uses the default texture format for the color type */
Brian Salomoneebe7352020-12-09 16:37:04 -050069 static std::unique_ptr<GrSurfaceDrawContext> Make(GrRecordingContext*,
70 GrColorType,
71 sk_sp<SkColorSpace>,
72 SkBackingFit,
73 SkISize dimensions,
Chris Daltonf5b87f92021-04-19 17:27:09 -060074 const SkSurfaceProps&,
Brian Salomoneebe7352020-12-09 16:37:04 -050075 int sampleCnt = 1,
76 GrMipmapped = GrMipmapped::kNo,
77 GrProtected = GrProtected::kNo,
78 GrSurfaceOrigin = kBottomLeft_GrSurfaceOrigin,
Chris Daltonf5b87f92021-04-19 17:27:09 -060079 SkBudgeted = SkBudgeted::kYes);
Greg Daniele20fcad2020-01-08 11:52:34 -050080
Brian Salomon07bc9a22020-12-02 13:37:16 -050081 /**
82 * Takes custom swizzles rather than determining swizzles from color type and format.
83 * It will have color type kUnknown.
84 */
Brian Salomoneebe7352020-12-09 16:37:04 -050085 static std::unique_ptr<GrSurfaceDrawContext> Make(GrRecordingContext*,
86 sk_sp<SkColorSpace>,
87 SkBackingFit,
88 SkISize dimensions,
89 const GrBackendFormat&,
90 int sampleCnt,
91 GrMipmapped,
92 GrProtected,
93 GrSwizzle readSwizzle,
94 GrSwizzle writeSwizzle,
95 GrSurfaceOrigin,
96 SkBudgeted,
Chris Daltonf5b87f92021-04-19 17:27:09 -060097 const SkSurfaceProps&);
Brian Salomon07bc9a22020-12-02 13:37:16 -050098
Greg Daniele20fcad2020-01-08 11:52:34 -050099 // Same as previous factory but will try to use fallback GrColorTypes if the one passed in
100 // fails. The fallback GrColorType will have at least the number of channels and precision per
101 // channel as the passed in GrColorType. It may also swizzle the changes (e.g., BGRA -> RGBA).
102 // SRGB-ness will be preserved.
Brian Salomoneebe7352020-12-09 16:37:04 -0500103 static std::unique_ptr<GrSurfaceDrawContext> MakeWithFallback(
Brian Salomona56a7462020-02-07 14:17:25 -0500104 GrRecordingContext*,
105 GrColorType,
106 sk_sp<SkColorSpace>,
107 SkBackingFit,
108 SkISize dimensions,
Chris Daltonf5b87f92021-04-19 17:27:09 -0600109 const SkSurfaceProps&,
Brian Salomona56a7462020-02-07 14:17:25 -0500110 int sampleCnt = 1,
Brian Salomon7e67dca2020-07-21 09:27:25 -0400111 GrMipmapped = GrMipmapped::kNo,
Brian Salomona56a7462020-02-07 14:17:25 -0500112 GrProtected = GrProtected::kNo,
113 GrSurfaceOrigin = kBottomLeft_GrSurfaceOrigin,
Chris Daltonf5b87f92021-04-19 17:27:09 -0600114 SkBudgeted = SkBudgeted::kYes);
Greg Daniele20fcad2020-01-08 11:52:34 -0500115
Greg Danielba0ff782020-01-07 15:42:57 -0500116 // These match the definitions in SkSurface & GrSurface.h, for whence they came
117 typedef void* ReleaseContext;
118 typedef void (*ReleaseProc)(ReleaseContext);
119
Brian Salomoneebe7352020-12-09 16:37:04 -0500120 // Creates a GrSurfaceDrawContext that wraps the passed in GrBackendTexture.
121 static std::unique_ptr<GrSurfaceDrawContext> MakeFromBackendTexture(
Greg Danielba0ff782020-01-07 15:42:57 -0500122 GrRecordingContext*, GrColorType, sk_sp<SkColorSpace>, const GrBackendTexture&,
Chris Daltonf5b87f92021-04-19 17:27:09 -0600123 int sampleCnt, GrSurfaceOrigin, const SkSurfaceProps&,
Robert Phillipsa1121332020-06-29 13:05:29 -0400124 sk_sp<GrRefCntedCallback> releaseHelper);
Greg Danielba0ff782020-01-07 15:42:57 -0500125
Brian Salomoneebe7352020-12-09 16:37:04 -0500126 GrSurfaceDrawContext(GrRecordingContext*,
127 GrSurfaceProxyView readView,
128 GrSurfaceProxyView writeView,
129 GrColorType,
130 sk_sp<SkColorSpace>,
Chris Daltonf5b87f92021-04-19 17:27:09 -0600131 const SkSurfaceProps&,
Brian Salomoneebe7352020-12-09 16:37:04 -0500132 bool flushTimeOpsTask = false);
Greg Danielbfa19c42019-12-19 16:41:40 -0500133
Brian Salomoneebe7352020-12-09 16:37:04 -0500134 ~GrSurfaceDrawContext() override;
robertphillips2334fb62015-06-17 05:43:33 -0700135
robertphillipsea461502015-05-26 11:38:03 -0700136 /**
robertphillipsea461502015-05-26 11:38:03 -0700137 * Draw everywhere (respecting the clip) with the paint.
138 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400139 void drawPaint(const GrClip*, GrPaint&&, const SkMatrix& viewMatrix);
robertphillipsea461502015-05-26 11:38:03 -0700140
141 /**
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500142 * Draw the rect using a paint.
143 * @param paint describes how to color pixels.
144 * @param GrAA Controls whether rect is antialiased
145 * @param viewMatrix transformation matrix
146 * @param style The style to apply. Null means fill. Currently path effects are not
147 * allowed.
148 * The rects coords are used to access the paint (through texture matrix)
robertphillipsea461502015-05-26 11:38:03 -0700149 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400150 void drawRect(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500151 GrPaint&& paint,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500152 GrAA,
robertphillipsea461502015-05-26 11:38:03 -0700153 const SkMatrix& viewMatrix,
154 const SkRect&,
Brian Salomon82f44312017-01-11 13:42:54 -0500155 const GrStyle* style = nullptr);
robertphillipsea461502015-05-26 11:38:03 -0700156
157 /**
bsalomona2e69fc2015-11-05 10:41:43 -0800158 * Maps a rectangle of shader coordinates to a rectangle and fills that rectangle.
robertphillipsea461502015-05-26 11:38:03 -0700159 *
Chris Dalton61d694d2021-03-22 00:00:52 -0600160 * @param GrPaint describes how to color pixels.
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500161 * @param GrAA Controls whether rect is antialiased
Chris Dalton61d694d2021-03-22 00:00:52 -0600162 * @param SkMatrix transformation matrix which applies to rectToDraw
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500163 * @param rectToDraw the rectangle to draw
164 * @param localRect the rectangle of shader coordinates applied to rectToDraw
robertphillipsea461502015-05-26 11:38:03 -0700165 */
Chris Dalton61d694d2021-03-22 00:00:52 -0600166 void fillRectToRect(const GrClip*,
167 GrPaint&&,
168 GrAA,
169 const SkMatrix&,
bsalomona2e69fc2015-11-05 10:41:43 -0800170 const SkRect& rectToDraw,
Chris Dalton61d694d2021-03-22 00:00:52 -0600171 const SkRect& localRect);
robertphillipsea461502015-05-26 11:38:03 -0700172
173 /**
Chris Dalton35619552021-03-10 19:20:43 -0700174 * Fills a block of pixels with a paint and a localMatrix, respecting the clip.
robertphillipsea461502015-05-26 11:38:03 -0700175 */
Chris Dalton35619552021-03-10 19:20:43 -0700176 void fillPixelsWithLocalMatrix(const GrClip* clip,
177 GrPaint&& paint,
178 const SkIRect& bounds,
179 const SkMatrix& localMatrix) {
180 SkRect rect = SkRect::Make(bounds);
181 DrawQuad quad{GrQuad::MakeFromRect(rect, SkMatrix::I()),
182 GrQuad::MakeFromRect(rect, localMatrix), GrQuadAAFlags::kNone};
183 this->drawFilledQuad(clip, std::move(paint), GrAA::kNo, &quad);
Michael Ludwig61328202019-06-19 14:48:58 +0000184 }
robertphillipsea461502015-05-26 11:38:03 -0700185
Michael Ludwig75451902019-01-23 11:14:29 -0500186 /**
187 * Creates an op that draws a fill rect with per-edge control over anti-aliasing.
Michael Ludwigce62dec2019-02-19 11:48:46 -0500188 *
189 * This is a specialized version of fillQuadWithEdgeAA, but is kept separate since knowing
190 * the geometry is a rectangle affords more optimizations.
Michael Ludwig75451902019-01-23 11:14:29 -0500191 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400192 void fillRectWithEdgeAA(const GrClip* clip, GrPaint&& paint, GrAA aa, GrQuadAAFlags edgeAA,
Michael Ludwig136f45a2019-02-19 11:44:41 -0500193 const SkMatrix& viewMatrix, const SkRect& rect,
Michael Ludwig61328202019-06-19 14:48:58 +0000194 const SkRect* optionalLocalRect = nullptr) {
Chris Dalton5c5f09b2021-04-13 16:17:58 -0600195 if (edgeAA == GrQuadAAFlags::kAll) {
196 this->fillRectToRect(clip, std::move(paint), aa, viewMatrix, rect,
197 (optionalLocalRect) ? *optionalLocalRect : rect);
198 return;
199 }
Michael Ludwig61328202019-06-19 14:48:58 +0000200 const SkRect& localRect = optionalLocalRect ? *optionalLocalRect : rect;
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500201 DrawQuad quad{GrQuad::MakeFromRect(rect, viewMatrix), GrQuad(localRect), edgeAA};
202 this->drawFilledQuad(clip, std::move(paint), aa, &quad);
Michael Ludwig61328202019-06-19 14:48:58 +0000203 }
Michael Ludwig75451902019-01-23 11:14:29 -0500204
Michael Ludwigce62dec2019-02-19 11:48:46 -0500205 /**
206 * Similar to fillRectWithEdgeAA but draws an arbitrary 2D convex quadrilateral transformed
207 * by 'viewMatrix', with per-edge control over anti-aliasing. The quad should follow the
208 * ordering used by SkRect::toQuad(), which determines how the edge AA is applied:
209 * - "top" = points [0] and [1]
210 * - "right" = points[1] and [2]
211 * - "bottom" = points[2] and [3]
212 * - "left" = points[3] and [0]
213 *
214 * The last argument, 'optionalLocalQuad', can be null if no separate local coordinates are
215 * necessary.
216 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400217 void fillQuadWithEdgeAA(const GrClip* clip, GrPaint&& paint, GrAA aa, GrQuadAAFlags edgeAA,
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500218 const SkMatrix& viewMatrix, const SkPoint points[4],
219 const SkPoint optionalLocalPoints[4]) {
220 const SkPoint* localPoints = optionalLocalPoints ? optionalLocalPoints : points;
221 DrawQuad quad{GrQuad::MakeFromSkQuad(points, viewMatrix),
222 GrQuad::MakeFromSkQuad(localPoints, SkMatrix::I()), edgeAA};
223 this->drawFilledQuad(clip, std::move(paint), aa, &quad);
Michael Ludwig61328202019-06-19 14:48:58 +0000224 }
Michael Ludwigce62dec2019-02-19 11:48:46 -0500225
Michael Ludwig69858532018-11-28 15:34:34 -0500226 /** Used with drawQuadSet */
227 struct QuadSetEntry {
228 SkRect fRect;
229 SkPMColor4f fColor; // Overrides any color on the GrPaint
230 SkMatrix fLocalMatrix;
231 GrQuadAAFlags fAAFlags;
232 };
233
Michael Ludwig75451902019-01-23 11:14:29 -0500234 // TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer
Michael Ludwig7c12e282020-05-29 09:54:07 -0400235 void drawQuadSet(const GrClip* clip, GrPaint&& paint, GrAA aa, const SkMatrix& viewMatrix,
Michael Ludwig69858532018-11-28 15:34:34 -0500236 const QuadSetEntry[], int cnt);
237
robertphillipsea461502015-05-26 11:38:03 -0700238 /**
Brian Salomon34169692017-08-28 15:32:01 -0400239 * Creates an op that draws a subrectangle of a texture. The passed color is modulated by the
240 * texture's color. 'srcRect' specifies the rectangle of the texture to draw. 'dstRect'
241 * specifies the rectangle to draw in local coords which will be transformed by 'viewMatrix' to
Brian Salomonbe3c1d22018-05-21 12:54:39 -0400242 * device space.
Brian Salomon34169692017-08-28 15:32:01 -0400243 */
Chris Dalton4718a8b2021-03-18 18:38:52 -0600244 void drawTexture(const GrClip*,
245 GrSurfaceProxyView,
246 SkAlphaType,
247 GrSamplerState::Filter,
248 GrSamplerState::MipmapMode,
249 SkBlendMode,
250 const SkPMColor4f&,
Brian Salomone69b9ef2020-07-22 11:18:06 -0400251 const SkRect& srcRect,
252 const SkRect& dstRect,
Chris Dalton4718a8b2021-03-18 18:38:52 -0600253 GrAA,
254 GrQuadAAFlags,
255 SkCanvas::SrcRectConstraint,
256 const SkMatrix&,
257 sk_sp<GrColorSpaceXform>);
Brian Salomon34169692017-08-28 15:32:01 -0400258
Michael Ludwigce62dec2019-02-19 11:48:46 -0500259 /**
260 * Variant of drawTexture that instead draws the texture applied to 'dstQuad' transformed by
Brian Salomon2432d062020-04-16 20:48:09 -0400261 * 'viewMatrix', using the 'srcQuad' texture coordinates clamped to the optional 'subset'. If
262 * 'subset' is null, it's equivalent to using the fast src rect constraint. If 'subset' is
263 * provided, the strict src rect constraint is applied using 'subset'.
Michael Ludwigce62dec2019-02-19 11:48:46 -0500264 */
Brian Salomone69b9ef2020-07-22 11:18:06 -0400265 void drawTextureQuad(const GrClip* clip,
266 GrSurfaceProxyView view,
267 GrColorType srcColorType,
268 SkAlphaType srcAlphaType,
269 GrSamplerState::Filter filter,
270 GrSamplerState::MipmapMode mm,
271 SkBlendMode mode,
272 const SkPMColor4f& color,
273 const SkPoint srcQuad[4],
274 const SkPoint dstQuad[4],
275 GrAA aa,
276 GrQuadAAFlags edgeAA,
277 const SkRect* subset,
278 const SkMatrix& viewMatrix,
Michael Ludwigaee26ea2019-07-08 16:22:48 +0000279 sk_sp<GrColorSpaceXform> texXform) {
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500280 DrawQuad quad{GrQuad::MakeFromSkQuad(dstQuad, viewMatrix),
281 GrQuad::MakeFromSkQuad(srcQuad, SkMatrix::I()), edgeAA};
Brian Salomone69b9ef2020-07-22 11:18:06 -0400282 this->drawTexturedQuad(clip, std::move(view), srcAlphaType, std::move(texXform), filter, mm,
283 color, mode, aa, &quad, subset);
Michael Ludwigaee26ea2019-07-08 16:22:48 +0000284 }
Michael Ludwigce62dec2019-02-19 11:48:46 -0500285
Brian Salomond7065e72018-10-12 11:42:02 -0400286 /** Used with drawTextureSet */
287 struct TextureSetEntry {
Greg Daniel549325c2019-10-30 16:19:20 -0400288 GrSurfaceProxyView fProxyView;
Brian Salomonfc118442019-11-22 19:09:27 -0500289 SkAlphaType fSrcAlphaType;
Brian Salomond7065e72018-10-12 11:42:02 -0400290 SkRect fSrcRect;
291 SkRect fDstRect;
Michael Ludwig1433cfd2019-02-27 17:12:30 -0500292 const SkPoint* fDstClipQuad; // Must be null, or point to an array of 4 points
Michael Ludwig7ae2ab52019-03-05 16:00:20 -0500293 const SkMatrix* fPreViewMatrix; // If not null, entry's CTM is 'viewMatrix' * fPreViewMatrix
Michael Ludwig1c66ad92020-07-10 08:59:44 -0400294 SkPMColor4f fColor; // {a,a,a,a} for rgb textures, {r,g,b,a} for alpha-only textures
Brian Salomond7065e72018-10-12 11:42:02 -0400295 GrQuadAAFlags fAAFlags;
296 };
297 /**
298 * Draws a set of textures with a shared filter, color, view matrix, color xform, and
299 * texture color xform. The textures must all have the same GrTextureType and GrConfig.
Michael Ludwigce62dec2019-02-19 11:48:46 -0500300 *
301 * If any entries provide a non-null fDstClip array, it will be read from immediately based on
302 * fDstClipCount, so the pointer can become invalid after this returns.
Michael Ludwig379e4962019-12-06 13:21:26 -0500303 *
Hal Canary425929c2019-12-09 11:55:40 -0500304 * 'proxRunCnt' is the number of proxy changes encountered in the entry array. Technically this
Michael Ludwig379e4962019-12-06 13:21:26 -0500305 * can be inferred from the array within this function, but the information is already known
306 * by SkGpuDevice, so no need to incur another iteration over the array.
Brian Salomond7065e72018-10-12 11:42:02 -0400307 */
Brian Salomone69b9ef2020-07-22 11:18:06 -0400308 void drawTextureSet(const GrClip*,
309 TextureSetEntry[],
310 int cnt,
311 int proxyRunCnt,
312 GrSamplerState::Filter,
313 GrSamplerState::MipmapMode,
314 SkBlendMode mode,
315 GrAA aa,
316 SkCanvas::SrcRectConstraint,
317 const SkMatrix& viewMatrix,
Michael Ludwig379e4962019-12-06 13:21:26 -0500318 sk_sp<GrColorSpaceXform> texXform);
Brian Salomond7065e72018-10-12 11:42:02 -0400319
Brian Salomon34169692017-08-28 15:32:01 -0400320 /**
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500321 * Draw a roundrect using a paint.
robertphillipsea461502015-05-26 11:38:03 -0700322 *
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500323 * @param paint describes how to color pixels.
324 * @param GrAA Controls whether rrect is antialiased.
325 * @param viewMatrix transformation matrix
326 * @param rrect the roundrect to draw
327 * @param style style to apply to the rrect. Currently path effects are not allowed.
robertphillipsea461502015-05-26 11:38:03 -0700328 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400329 void drawRRect(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500330 GrPaint&&,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500331 GrAA,
robertphillipsea461502015-05-26 11:38:03 -0700332 const SkMatrix& viewMatrix,
333 const SkRRect& rrect,
bsalomon6663acf2016-05-10 09:14:17 -0700334 const GrStyle& style);
robertphillipsea461502015-05-26 11:38:03 -0700335
336 /**
Jim Van Verth3af1af92017-05-18 15:06:54 -0400337 * Use a fast method to render the ambient and spot shadows for a path.
338 * Will return false if not possible for the given path.
Jim Van Verthc5903412016-11-17 15:27:09 -0500339 *
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500340 * @param viewMatrix transformation matrix
Jim Van Verth3af1af92017-05-18 15:06:54 -0400341 * @param path the path to shadow
342 * @param rec parameters for shadow rendering
Jim Van Verthc5903412016-11-17 15:27:09 -0500343 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400344 bool drawFastShadow(const GrClip*,
Jim Van Verth3af1af92017-05-18 15:06:54 -0400345 const SkMatrix& viewMatrix,
346 const SkPath& path,
347 const SkDrawShadowRec& rec);
Jim Van Verthc5903412016-11-17 15:27:09 -0500348
349 /**
robertphillipsea461502015-05-26 11:38:03 -0700350 * Draws a path.
351 *
352 * @param paint describes how to color pixels.
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500353 * @param GrAA Controls whether the path is antialiased.
robertphillipsea461502015-05-26 11:38:03 -0700354 * @param viewMatrix transformation matrix
355 * @param path the path to draw
bsalomon6663acf2016-05-10 09:14:17 -0700356 * @param style style to apply to the path.
robertphillipsea461502015-05-26 11:38:03 -0700357 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400358 void drawPath(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500359 GrPaint&&,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500360 GrAA,
robertphillipsea461502015-05-26 11:38:03 -0700361 const SkMatrix& viewMatrix,
362 const SkPath&,
Robert Phillips20390c32018-08-17 11:01:03 -0400363 const GrStyle&);
364
365 /**
366 * Draws a shape.
367 *
368 * @param paint describes how to color pixels.
369 * @param GrAA Controls whether the path is antialiased.
370 * @param viewMatrix transformation matrix
371 * @param shape the shape to draw
372 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400373 void drawShape(const GrClip*,
Robert Phillips20390c32018-08-17 11:01:03 -0400374 GrPaint&&,
375 GrAA,
376 const SkMatrix& viewMatrix,
Chris Dalton21859012021-01-29 23:44:53 -0700377 GrStyledShape&&);
Robert Phillips20390c32018-08-17 11:01:03 -0400378
robertphillipsea461502015-05-26 11:38:03 -0700379
380 /**
381 * Draws vertices with a paint.
382 *
Brian Osmanae0c50c2017-05-25 16:56:34 -0400383 * @param paint describes how to color pixels.
384 * @param viewMatrix transformation matrix
385 * @param vertices specifies the mesh to draw.
386 * @param overridePrimType primitive type to draw. If NULL, derive prim type from vertices.
Brian Osman3c358422020-03-23 10:44:12 -0400387 * @param effect runtime effect that will handle custom vertex attributes.
robertphillipsea461502015-05-26 11:38:03 -0700388 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400389 void drawVertices(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500390 GrPaint&& paint,
Brian Osman449b1152020-04-15 16:43:00 -0400391 const SkMatrixProvider& matrixProvider,
Brian Osmanae0c50c2017-05-25 16:56:34 -0400392 sk_sp<SkVertices> vertices,
Brian Osman3c358422020-03-23 10:44:12 -0400393 GrPrimitiveType* overridePrimType = nullptr,
Brian Osman449b1152020-04-15 16:43:00 -0400394 const SkRuntimeEffect* effect = nullptr);
Brian Salomon199fb872017-02-06 09:41:10 -0500395
396 /**
Brian Osman4d92b892019-03-24 00:53:23 +0000397 * Draws textured sprites from an atlas with a paint. This currently does not support AA for the
398 * sprite rectangle edges.
399 *
400 * @param paint describes how to color pixels.
401 * @param viewMatrix transformation matrix
402 * @param spriteCount number of sprites.
403 * @param xform array of compressed transformation data, required.
404 * @param texRect array of texture rectangles used to access the paint.
405 * @param colors optional array of per-sprite colors, supercedes
406 * the paint's color field.
407 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400408 void drawAtlas(const GrClip*,
Brian Osman4d92b892019-03-24 00:53:23 +0000409 GrPaint&& paint,
410 const SkMatrix& viewMatrix,
411 int spriteCount,
412 const SkRSXform xform[],
413 const SkRect texRect[],
414 const SkColor colors[]);
415
416 /**
msarettcc319b92016-08-25 18:07:18 -0700417 * Draws a region.
418 *
419 * @param paint describes how to color pixels
420 * @param viewMatrix transformation matrix
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500421 * @param aa should the rects of the region be antialiased.
msarettcc319b92016-08-25 18:07:18 -0700422 * @param region the region to be drawn
423 * @param style style to apply to the region
424 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400425 void drawRegion(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500426 GrPaint&& paint,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500427 GrAA aa,
msarettcc319b92016-08-25 18:07:18 -0700428 const SkMatrix& viewMatrix,
429 const SkRegion& region,
Stan Iliev73d8fd92017-08-02 15:36:24 -0400430 const GrStyle& style,
431 const GrUserStencilSettings* ss = nullptr);
msarettcc319b92016-08-25 18:07:18 -0700432
jvanverth31ff7622015-08-07 10:09:28 -0700433 /**
robertphillipsea461502015-05-26 11:38:03 -0700434 * Draws an oval.
435 *
436 * @param paint describes how to color pixels.
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500437 * @param GrAA Controls whether the oval is antialiased.
robertphillipsea461502015-05-26 11:38:03 -0700438 * @param viewMatrix transformation matrix
439 * @param oval the bounding rect of the oval.
bsalomon6663acf2016-05-10 09:14:17 -0700440 * @param style style to apply to the oval. Currently path effects are not allowed.
robertphillipsea461502015-05-26 11:38:03 -0700441 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400442 void drawOval(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500443 GrPaint&& paint,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500444 GrAA,
robertphillipsea461502015-05-26 11:38:03 -0700445 const SkMatrix& viewMatrix,
446 const SkRect& oval,
bsalomon6663acf2016-05-10 09:14:17 -0700447 const GrStyle& style);
Herb Derbyc1583cb2020-07-13 10:42:18 -0400448
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500449 /**
450 * Draws a partial arc of an oval.
451 *
452 * @param paint describes how to color pixels.
Brian Salomon99504082016-12-09 15:51:31 -0500453 * @param GrGrAA Controls whether the arc is antialiased.
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500454 * @param viewMatrix transformation matrix.
455 * @param oval the bounding rect of the oval.
456 * @param startAngle starting angle in degrees.
457 * @param sweepAngle angle to sweep in degrees. Must be in (-360, 360)
458 * @param useCenter true means that the implied path begins at the oval center, connects as
459 * a line to the point indicated by the start contains the arc indicated by
460 * the sweep angle. If false the line beginning at the center point is
461 * omitted.
462 * @param style style to apply to the oval.
463 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400464 void drawArc(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500465 GrPaint&& paint,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500466 GrAA,
bsalomon4f3a0ca2016-08-22 13:14:26 -0700467 const SkMatrix& viewMatrix,
468 const SkRect& oval,
469 SkScalar startAngle,
470 SkScalar sweepAngle,
471 bool useCenter,
472 const GrStyle& style);
robertphillipsea461502015-05-26 11:38:03 -0700473
joshualitt33a5fce2015-11-18 13:28:51 -0800474 /**
bsalomon4f3a0ca2016-08-22 13:14:26 -0700475 * Draw the image as a set of rects, specified by |iter|.
joshualitt33a5fce2015-11-18 13:28:51 -0800476 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400477 void drawImageLattice(const GrClip*,
Brian Salomon2a943df2018-05-04 13:43:19 -0400478 GrPaint&&,
msarett10e3d9b2016-08-18 15:46:03 -0700479 const SkMatrix& viewMatrix,
Greg Danieled96bca2019-12-05 15:05:54 -0500480 GrSurfaceProxyView,
Greg Daniel82c6b102020-01-21 10:33:22 -0500481 SkAlphaType alphaType,
Brian Salomon2a943df2018-05-04 13:43:19 -0400482 sk_sp<GrColorSpaceXform>,
483 GrSamplerState::Filter,
484 std::unique_ptr<SkLatticeIter>,
msarett10e3d9b2016-08-18 15:46:03 -0700485 const SkRect& dst);
robertphillipsea461502015-05-26 11:38:03 -0700486
robertphillips8c523e02016-07-26 07:41:00 -0700487 /**
Herb Derby411e7aa2020-07-09 16:02:08 -0400488 * Draw the text specified by the SkGlyphRunList.
489 *
490 * @param viewMatrix transformationMatrix
491 * @param glyphRunList text, text positions, and paint.
492 */
493 void drawGlyphRunList(const GrClip*,
494 const SkMatrixProvider& viewMatrix,
Herb Derby0da2c142021-03-22 15:28:23 -0400495 const SkGlyphRunList& glyphRunList,
496 const SkPaint& paint);
Herb Derby411e7aa2020-07-09 16:02:08 -0400497
498 /**
Herb Derby2e0b5bb2020-11-19 11:03:50 -0500499 * Draw the text specified by the SkGlyphRunList.
500 *
501 * @param viewMatrix transformationMatrix
502 * @param glyphRunList text, text positions, and paint.
503 */
504 void drawGlyphRunListWithCache(const GrClip*,
505 const SkMatrixProvider& viewMatrix,
Herb Derby0da2c142021-03-22 15:28:23 -0400506 const SkGlyphRunList& glyphRunList,
507 const SkPaint& paint);
Herb Derby2e0b5bb2020-11-19 11:03:50 -0500508
509 /**
510 * Draw the text specified by the SkGlyphRunList.
511 *
512 * @param viewMatrix transformationMatrix
513 * @param glyphRunList text, text positions, and paint.
514 */
515 void drawGlyphRunListNoCache(const GrClip*,
516 const SkMatrixProvider& viewMatrix,
Herb Derby0da2c142021-03-22 15:28:23 -0400517 const SkGlyphRunList& glyphRunList,
518 const SkPaint& paint);
Herb Derby2e0b5bb2020-11-19 11:03:50 -0500519
520 /**
Greg Daniel64cc9aa2018-10-19 13:54:56 -0400521 * Adds the necessary signal and wait semaphores and adds the passed in SkDrawable to the
522 * command stream.
523 */
524 void drawDrawable(std::unique_ptr<SkDrawable::GpuDrawHandler>, const SkRect& bounds);
525
Brian Salomon70fe17e2020-11-30 14:33:58 -0500526 // called to note the last clip drawn to the stencil buffer.
527 // TODO: remove after clipping overhaul.
528 void setLastClip(uint32_t clipStackGenID,
529 const SkIRect& devClipBounds,
530 int numClipAnalyticElements) {
531 GrOpsTask* opsTask = this->getOpsTask();
532 opsTask->fLastClipStackGenID = clipStackGenID;
533 opsTask->fLastDevClipBounds = devClipBounds;
534 opsTask->fLastClipNumAnalyticElements = numClipAnalyticElements;
535 }
536
537 // called to determine if we have to render the clip into SB.
538 // TODO: remove after clipping overhaul.
539 bool mustRenderClip(uint32_t clipStackGenID,
540 const SkIRect& devClipBounds,
541 int numClipAnalyticElements) {
542 GrOpsTask* opsTask = this->getOpsTask();
543 return opsTask->fLastClipStackGenID != clipStackGenID ||
544 !opsTask->fLastDevClipBounds.contains(devClipBounds) ||
545 opsTask->fLastClipNumAnalyticElements != numClipAnalyticElements;
546 }
547
Brian Salomon70fe17e2020-11-30 14:33:58 -0500548 void clearStencilClip(const SkIRect& scissor, bool insideStencilMask) {
549 this->internalStencilClear(&scissor, insideStencilMask);
550 }
551
552 // While this can take a general clip, since GrReducedClip relies on this function, it must take
553 // care to only provide hard clips or we could get stuck in a loop. The general clip is needed
554 // so that path renderers can use this function.
555 void stencilRect(const GrClip* clip,
556 const GrUserStencilSettings* ss,
557 GrPaint&& paint,
558 GrAA doStencilMSAA,
559 const SkMatrix& viewMatrix,
560 const SkRect& rect,
561 const SkMatrix* localMatrix = nullptr) {
562 // Since this provides stencil settings to drawFilledQuad, it performs a different AA type
563 // resolution compared to regular rect draws, which is the main reason it remains separate.
564 DrawQuad quad{GrQuad::MakeFromRect(rect, viewMatrix),
565 localMatrix ? GrQuad::MakeFromRect(rect, *localMatrix) : GrQuad(rect),
Michael Ludwig79aaa9b2021-04-08 15:05:29 -0400566 doStencilMSAA == GrAA::kYes ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone};
Brian Salomon70fe17e2020-11-30 14:33:58 -0500567 this->drawFilledQuad(clip, std::move(paint), doStencilMSAA, &quad, ss);
568 }
569
Chris Dalton7d592cd2021-03-11 22:49:33 -0700570 // Fills the user stencil bits with a non-zero value at every sample inside the path. This will
571 // likely be implemented with a Redbook algorithm, but it is not guaranteed. The samples being
572 // rendered to must be zero initially.
573 bool stencilPath(const GrHardClip*,
574 GrAA doStencilMSAA,
575 const SkMatrix& viewMatrix,
576 const SkPath&);
577
Brian Salomon70fe17e2020-11-30 14:33:58 -0500578 /**
579 * Draws a path, either AA or not, and touches the stencil buffer with the user stencil settings
580 * for each color sample written.
581 */
582 bool drawAndStencilPath(const GrHardClip*,
583 const GrUserStencilSettings*,
584 SkRegion::Op op,
585 bool invert,
586 GrAA doStencilMSAA,
587 const SkMatrix& viewMatrix,
588 const SkPath&);
589
590 SkBudgeted isBudgeted() const;
591
592 int maxWindowRectangles() const;
593
594 SkGlyphRunListPainter* glyphRunPainter() { return &fGlyphPainter; }
595
596 /*
597 * This unique ID will not change for a given RenderTargetContext. However, it is _NOT_
598 * guaranteed to match the uniqueID of the underlying GrRenderTarget - beware!
599 */
600 GrSurfaceProxy::UniqueID uniqueID() const { return this->asSurfaceProxy()->uniqueID(); }
601
Brian Salomon70fe17e2020-11-30 14:33:58 -0500602 // Allows caller of addDrawOp to know which op list an op will be added to.
603 using WillAddOpFn = void(GrOp*, uint32_t opsTaskID);
604 // These perform processing specific to GrDrawOp-derived ops before recording them into an
605 // op list. Before adding the op to an op list the WillAddOpFn is called. Note that it
606 // will not be called in the event that the op is discarded. Moreover, the op may merge into
607 // another op after the function is called (either before addDrawOp returns or some time later).
608 //
609 // If the clip pointer is null, no clipping will be performed.
610 void addDrawOp(const GrClip*,
611 GrOp::Owner,
612 const std::function<WillAddOpFn>& = std::function<WillAddOpFn>());
613 void addDrawOp(GrOp::Owner op) { this->addDrawOp(nullptr, std::move(op)); }
614
615 bool refsWrappedObjects() const { return this->asRenderTargetProxy()->refsWrappedObjects(); }
616
Greg Daniela5cb7812017-06-16 09:45:32 -0400617 /**
Brian Salomoneebe7352020-12-09 16:37:04 -0500618 * The next time this GrSurfaceDrawContext is flushed, the gpu will wait on the passed in
Greg Daniela5cb7812017-06-16 09:45:32 -0400619 * semaphores before executing any commands.
620 */
Greg Daniel414418d2020-07-08 11:44:25 -0400621 bool waitOnSemaphores(int numSemaphores, const GrBackendSemaphore waitSemaphores[],
622 bool deleteSemaphoresAfterWait);
robertphillips8c523e02016-07-26 07:41:00 -0700623
Greg Daniel46e366a2019-12-16 14:38:36 -0500624 int numSamples() const { return this->asRenderTargetProxy()->numSamples(); }
robertphillipsca6eafc2016-05-17 09:57:46 -0700625 const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; }
Chris Daltona7dffa12021-05-03 19:00:55 -0600626 bool canUseDynamicMSAA() const { return fCanUseDynamicMSAA; }
Greg Daniel46e366a2019-12-16 14:38:36 -0500627 bool wrapsVkSecondaryCB() const { return this->asRenderTargetProxy()->wrapsVkSecondaryCB(); }
Brian Salomon8c82a872020-07-21 12:09:58 -0400628 GrMipmapped mipmapped() const;
robertphillips7bceedc2015-12-01 12:51:26 -0800629
Chris Dalton94df5722021-04-19 17:40:40 -0600630 bool alwaysAntialias() const {
631 return fSurfaceProps.flags() & kDMSAA_SkSurfacePropsPrivateFlag;
632 }
633
634 GrAA chooseAA(const SkPaint& paint) {
635 return GrAA(paint.isAntiAlias() || this->alwaysAntialias());
636 }
637
Robert Phillipsbe9aff22019-02-15 11:33:22 -0500638 // This entry point should only be called if the backing GPU object is known to be
639 // instantiated.
Greg Daniel3912a4b2020-01-14 09:56:04 -0500640 GrRenderTarget* accessRenderTarget() { return this->asSurfaceProxy()->peekRenderTarget(); }
Robert Phillipseaa86252016-11-08 13:49:39 +0000641
Brian Salomoneebe7352020-12-09 16:37:04 -0500642 GrSurfaceDrawContext* asRenderTargetContext() override { return this; }
Robert Phillipsd46697a2017-01-25 12:10:37 -0500643
Robert Phillipsb5204762019-06-19 14:12:13 -0400644#if GR_TEST_UTILS
Chris Dalton6b982802019-06-27 13:53:46 -0600645 void testingOnly_SetPreserveOpsOnFullClear() { fPreserveOpsOnFullClear_TestingOnly = true; }
Robert Phillipsb5204762019-06-19 14:12:13 -0400646#endif
Robert Phillipseaa86252016-11-08 13:49:39 +0000647
robertphillipsea461502015-05-26 11:38:03 -0700648private:
Michael Ludwig61328202019-06-19 14:48:58 +0000649 enum class QuadOptimization;
Brian Salomonf18b1d82017-10-27 11:30:49 -0400650
Brian Salomon9a0da782021-04-23 13:41:55 -0400651 void willReplaceOpsTask(GrOpsTask* prevTask, GrOpsTask* nextTask) override;
652
Chris Dalton7d6748e2019-03-13 00:34:52 -0600653 GrAAType chooseAAType(GrAA);
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500654
Brian Salomon590f5672020-12-16 11:44:47 -0500655 GrOpsTask::CanDiscardPreviousOps canDiscardPreviousOpsOnFullClear() const override;
Chris Dalton57ab06c2021-04-22 12:57:28 -0600656 void setNeedsStencil();
Chris Dalton6b982802019-06-27 13:53:46 -0600657
Michael Ludwig81d41722020-05-26 16:57:38 -0400658 void internalStencilClear(const SkIRect* scissor, bool insideStencilMask);
csmartdalton29df7602016-08-31 11:55:52 -0700659
Michael Ludwige08b4432019-06-19 18:00:48 -0400660 // 'stencilSettings' are provided merely for decision making purposes; When non-null,
661 // optimization strategies that submit special ops are avoided.
Chris Dalton61d694d2021-03-22 00:00:52 -0600662 //
663 // 'aa' and 'quad' should be the original draw request on input, and will be updated as
664 // appropriate depending on the returned optimization level.
665 //
666 // If kSubmitted is returned, the provided paint was consumed. Otherwise it is left unchanged.
Michael Ludwig7c12e282020-05-29 09:54:07 -0400667 QuadOptimization attemptQuadOptimization(const GrClip* clip,
Michael Ludwige08b4432019-06-19 18:00:48 -0400668 const GrUserStencilSettings* stencilSettings,
Michael Ludwig61328202019-06-19 14:48:58 +0000669 GrAA* aa,
Chris Dalton61d694d2021-03-22 00:00:52 -0600670 DrawQuad* quad,
671 GrPaint* paint);
robertphillips44302392016-07-08 14:43:03 -0700672
Michael Ludwig61328202019-06-19 14:48:58 +0000673 // If stencil settings, 'ss', are non-null, AA controls MSAA or no AA. If they are null, then AA
674 // can choose between coverage, MSAA as per chooseAAType(). This will always attempt to apply
675 // quad optimizations, so all quad/rect public APIs should rely on this function for consistent
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500676 // clipping behavior. 'quad' will be modified in place to reflect final rendered geometry.
Michael Ludwig7c12e282020-05-29 09:54:07 -0400677 void drawFilledQuad(const GrClip* clip,
Michael Ludwig61328202019-06-19 14:48:58 +0000678 GrPaint&& paint,
679 GrAA aa,
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500680 DrawQuad* quad,
Michael Ludwig61328202019-06-19 14:48:58 +0000681 const GrUserStencilSettings* ss = nullptr);
Brian Salomon7694b902019-06-18 21:00:21 +0000682
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500683 // Like drawFilledQuad but does not require using a GrPaint or FP for texturing.
684 // 'quad' may be modified in place to reflect final geometry.
Michael Ludwig7c12e282020-05-29 09:54:07 -0400685 void drawTexturedQuad(const GrClip* clip,
Greg Daniel549325c2019-10-30 16:19:20 -0400686 GrSurfaceProxyView proxyView,
Brian Salomonfc118442019-11-22 19:09:27 -0500687 SkAlphaType alphaType,
Michael Ludwigaee26ea2019-07-08 16:22:48 +0000688 sk_sp<GrColorSpaceXform> textureXform,
689 GrSamplerState::Filter filter,
Brian Salomone69b9ef2020-07-22 11:18:06 -0400690 GrSamplerState::MipmapMode,
Michael Ludwigaee26ea2019-07-08 16:22:48 +0000691 const SkPMColor4f& color,
692 SkBlendMode blendMode,
693 GrAA aa,
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500694 DrawQuad* quad,
Brian Salomon2432d062020-04-16 20:48:09 -0400695 const SkRect* subset = nullptr);
Michael Ludwigaee26ea2019-07-08 16:22:48 +0000696
Chris Dalton319d0202021-01-29 23:49:47 -0700697 void drawStrokedLine(const GrClip*, GrPaint&&, GrAA, const SkMatrix&, const SkPoint[2],
698 const SkStrokeRec&);
699
Chris Daltonbfe0d372021-02-04 12:24:54 -0700700 // Tries to detect if the given shape is a simple, and draws it without path rendering if
701 // we know how.
702 bool drawSimpleShape(const GrClip*, GrPaint*, GrAA, const SkMatrix&, const GrStyledShape&);
703
Chris Dalton9f704a82021-02-04 15:07:56 -0700704 // If 'attemptDrawSimple' is true, of if the original shape is marked as having been simplfied,
705 // this will attempt to re-route through drawSimpleShape() to see if we can avoid path rendering
706 // one more time.
Michael Ludwig7c12e282020-05-29 09:54:07 -0400707 void drawShapeUsingPathRenderer(const GrClip*, GrPaint&&, GrAA, const SkMatrix&,
Chris Dalton9f704a82021-02-04 15:07:56 -0700708 GrStyledShape&&, bool attemptDrawSimple = false);
robertphillipsea461502015-05-26 11:38:03 -0700709
Robert Phillipsbf25d432017-04-07 10:08:53 -0400710 // Makes a copy of the proxy if it is necessary for the draw and places the texture that should
711 // be used by GrXferProcessor to access the destination color in 'result'. If the return
712 // value is false then a texture copy could not be made.
Michael Ludwig28e5f112020-06-09 10:57:24 -0400713 //
714 // The op should have already had setClippedBounds called on it.
715 bool SK_WARN_UNUSED_RESULT setupDstProxyView(const GrOp& op,
Greg Daniel524e28b2019-11-01 11:48:53 -0400716 GrXferProcessor::DstProxyView* result);
Brian Salomon467921e2017-03-06 16:17:12 -0500717
Herb Derbyd29207a2020-06-08 13:50:19 -0400718 SkGlyphRunListPainter* glyphPainter() { return &fGlyphPainter; }
719
Chris Dalton710e1c92021-04-23 13:07:52 -0600720 const SkSurfaceProps fSurfaceProps;
721 const bool fCanUseDynamicMSAA;
Robert Phillipse305cc1f2016-12-14 12:19:05 -0500722
Chris Dalton57ab06c2021-04-22 12:57:28 -0600723 bool fNeedsStencil = false;
Greg Danield358cbe2020-09-11 09:33:54 -0400724
725 GrDstSampleType fDstSampleType = GrDstSampleType::kNone;
726
Chris Dalton6b982802019-06-27 13:53:46 -0600727#if GR_TEST_UTILS
728 bool fPreserveOpsOnFullClear_TestingOnly = false;
729#endif
Herb Derbyd29207a2020-06-08 13:50:19 -0400730 SkGlyphRunListPainter fGlyphPainter;
Brian Salomon590f5672020-12-16 11:44:47 -0500731 using INHERITED = GrSurfaceFillContext;
robertphillipsea461502015-05-26 11:38:03 -0700732};
733
734#endif