blob: ceda8be4838a285d31f388f45ff0fe7e68f456fc [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"
Herb Derby35c42b92020-07-10 10:48:57 -040025#include "src/gpu/text/GrTextBlob.h"
robertphillipsea461502015-05-26 11:38:03 -070026
Greg Daniela5cb7812017-06-16 09:45:32 -040027class GrBackendSemaphore;
robertphillipsea461502015-05-26 11:38:03 -070028class GrClip;
Brian Osman2240be92017-10-18 13:15:13 -040029class GrColorSpaceXform;
Chris Dalton1a325d22017-07-14 15:17:41 -060030class GrCoverageCountingPathRenderer;
Brian Salomon9afd3712016-12-01 10:59:09 -050031class GrDrawOp;
Robert Phillips0d075de2019-03-04 11:08:13 -050032class GrOp;
robertphillipsea461502015-05-26 11:38:03 -070033class GrRenderTarget;
Michael Ludwig2686d692020-04-17 20:21:37 +000034class GrStyledShape;
bsalomon6663acf2016-05-10 09:14:17 -070035class GrStyle;
Robert Phillipseaa86252016-11-08 13:49:39 +000036class GrTextureProxy;
robertphillips44302392016-07-08 14:43:03 -070037struct GrUserStencilSettings;
Jim Van Verth3af1af92017-05-18 15:06:54 -040038struct SkDrawShadowRec;
Herb Derbycddab252018-07-16 11:19:04 -040039class SkGlyphRunList;
robertphillipsea461502015-05-26 11:38:03 -070040struct SkIPoint;
41struct SkIRect;
msarett10e3d9b2016-08-18 15:46:03 -070042class SkLatticeIter;
Brian Osman449b1152020-04-15 16:43:00 -040043class SkMatrixProvider;
robertphillipsea461502015-05-26 11:38:03 -070044class SkMatrix;
robertphillips2334fb62015-06-17 05:43:33 -070045class SkPaint;
robertphillipsea461502015-05-26 11:38:03 -070046class SkPath;
47struct SkPoint;
48struct SkRect;
Brian Osman45580d32016-11-23 09:37:01 -050049class SkRegion;
robertphillipsea461502015-05-26 11:38:03 -070050class SkRRect;
jvanverth31ff7622015-08-07 10:09:28 -070051struct SkRSXform;
Brian Osman3c358422020-03-23 10:44:12 -040052class SkRuntimeEffect;
robertphillips2334fb62015-06-17 05:43:33 -070053class SkTextBlob;
Brian Salomon199fb872017-02-06 09:41:10 -050054class SkVertices;
robertphillipsea461502015-05-26 11:38:03 -070055
Brian Osman45580d32016-11-23 09:37:01 -050056/**
57 * A helper object to orchestrate commands (draws, etc...) for GrSurfaces that are GrRenderTargets.
robertphillipsea461502015-05-26 11:38:03 -070058 */
Brian Salomon590f5672020-12-16 11:44:47 -050059class GrSurfaceDrawContext : public GrSurfaceFillContext {
robertphillipsea461502015-05-26 11:38:03 -070060public:
Brian Salomoneebe7352020-12-09 16:37:04 -050061 static std::unique_ptr<GrSurfaceDrawContext> Make(GrRecordingContext*,
62 GrColorType,
63 sk_sp<SkColorSpace>,
64 sk_sp<GrSurfaceProxy>,
65 GrSurfaceOrigin,
66 const SkSurfaceProps*,
67 bool flushTimeOpsTask = false);
Greg Daniele20fcad2020-01-08 11:52:34 -050068
Brian Salomon07bc9a22020-12-02 13:37:16 -050069 /* Uses the default texture format for the color type */
Brian Salomoneebe7352020-12-09 16:37:04 -050070 static std::unique_ptr<GrSurfaceDrawContext> Make(GrRecordingContext*,
71 GrColorType,
72 sk_sp<SkColorSpace>,
73 SkBackingFit,
74 SkISize dimensions,
75 int sampleCnt = 1,
76 GrMipmapped = GrMipmapped::kNo,
77 GrProtected = GrProtected::kNo,
78 GrSurfaceOrigin = kBottomLeft_GrSurfaceOrigin,
79 SkBudgeted = SkBudgeted::kYes,
80 const SkSurfaceProps* = nullptr);
Greg Daniele20fcad2020-01-08 11:52:34 -050081
Brian Salomon07bc9a22020-12-02 13:37:16 -050082 /**
83 * Takes custom swizzles rather than determining swizzles from color type and format.
84 * It will have color type kUnknown.
85 */
Brian Salomoneebe7352020-12-09 16:37:04 -050086 static std::unique_ptr<GrSurfaceDrawContext> Make(GrRecordingContext*,
87 sk_sp<SkColorSpace>,
88 SkBackingFit,
89 SkISize dimensions,
90 const GrBackendFormat&,
91 int sampleCnt,
92 GrMipmapped,
93 GrProtected,
94 GrSwizzle readSwizzle,
95 GrSwizzle writeSwizzle,
96 GrSurfaceOrigin,
97 SkBudgeted,
98 const SkSurfaceProps*);
Brian Salomon07bc9a22020-12-02 13:37:16 -050099
Greg Daniele20fcad2020-01-08 11:52:34 -0500100 // Same as previous factory but will try to use fallback GrColorTypes if the one passed in
101 // fails. The fallback GrColorType will have at least the number of channels and precision per
102 // channel as the passed in GrColorType. It may also swizzle the changes (e.g., BGRA -> RGBA).
103 // SRGB-ness will be preserved.
Brian Salomoneebe7352020-12-09 16:37:04 -0500104 static std::unique_ptr<GrSurfaceDrawContext> MakeWithFallback(
Brian Salomona56a7462020-02-07 14:17:25 -0500105 GrRecordingContext*,
106 GrColorType,
107 sk_sp<SkColorSpace>,
108 SkBackingFit,
109 SkISize dimensions,
110 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,
114 SkBudgeted = SkBudgeted::kYes,
115 const SkSurfaceProps* = nullptr);
Greg Daniele20fcad2020-01-08 11:52:34 -0500116
Greg Danielba0ff782020-01-07 15:42:57 -0500117 // These match the definitions in SkSurface & GrSurface.h, for whence they came
118 typedef void* ReleaseContext;
119 typedef void (*ReleaseProc)(ReleaseContext);
120
Brian Salomoneebe7352020-12-09 16:37:04 -0500121 // Creates a GrSurfaceDrawContext that wraps the passed in GrBackendTexture.
122 static std::unique_ptr<GrSurfaceDrawContext> MakeFromBackendTexture(
Greg Danielba0ff782020-01-07 15:42:57 -0500123 GrRecordingContext*, GrColorType, sk_sp<SkColorSpace>, const GrBackendTexture&,
Robert Phillipsa1121332020-06-29 13:05:29 -0400124 int sampleCnt, GrSurfaceOrigin, const SkSurfaceProps*,
125 sk_sp<GrRefCntedCallback> releaseHelper);
Greg Danielba0ff782020-01-07 15:42:57 -0500126
Brian Salomoneebe7352020-12-09 16:37:04 -0500127 static std::unique_ptr<GrSurfaceDrawContext> MakeFromBackendRenderTarget(
Brian Salomon8ba54ea2020-10-01 09:48:21 -0400128 GrRecordingContext*,
129 GrColorType,
130 sk_sp<SkColorSpace>,
131 const GrBackendRenderTarget&,
132 GrSurfaceOrigin,
133 const SkSurfaceProps*,
134 sk_sp<GrRefCntedCallback> releaseHelper);
Greg Danielba0ff782020-01-07 15:42:57 -0500135
Brian Salomoneebe7352020-12-09 16:37:04 -0500136 static std::unique_ptr<GrSurfaceDrawContext> MakeFromVulkanSecondaryCB(
Greg Danielba0ff782020-01-07 15:42:57 -0500137 GrRecordingContext*, const SkImageInfo&, const GrVkDrawableInfo&,
138 const SkSurfaceProps*);
139
Brian Salomoneebe7352020-12-09 16:37:04 -0500140 GrSurfaceDrawContext(GrRecordingContext*,
141 GrSurfaceProxyView readView,
142 GrSurfaceProxyView writeView,
143 GrColorType,
144 sk_sp<SkColorSpace>,
145 const SkSurfaceProps*,
146 bool flushTimeOpsTask = false);
Greg Danielbfa19c42019-12-19 16:41:40 -0500147
Brian Salomoneebe7352020-12-09 16:37:04 -0500148 ~GrSurfaceDrawContext() override;
robertphillips2334fb62015-06-17 05:43:33 -0700149
robertphillipsea461502015-05-26 11:38:03 -0700150 /**
robertphillipsea461502015-05-26 11:38:03 -0700151 * Draw everywhere (respecting the clip) with the paint.
152 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400153 void drawPaint(const GrClip*, GrPaint&&, const SkMatrix& viewMatrix);
robertphillipsea461502015-05-26 11:38:03 -0700154
155 /**
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500156 * Draw the rect using a paint.
157 * @param paint describes how to color pixels.
158 * @param GrAA Controls whether rect is antialiased
159 * @param viewMatrix transformation matrix
160 * @param style The style to apply. Null means fill. Currently path effects are not
161 * allowed.
162 * The rects coords are used to access the paint (through texture matrix)
robertphillipsea461502015-05-26 11:38:03 -0700163 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400164 void drawRect(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500165 GrPaint&& paint,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500166 GrAA,
robertphillipsea461502015-05-26 11:38:03 -0700167 const SkMatrix& viewMatrix,
168 const SkRect&,
Brian Salomon82f44312017-01-11 13:42:54 -0500169 const GrStyle* style = nullptr);
robertphillipsea461502015-05-26 11:38:03 -0700170
171 /**
bsalomona2e69fc2015-11-05 10:41:43 -0800172 * Maps a rectangle of shader coordinates to a rectangle and fills that rectangle.
robertphillipsea461502015-05-26 11:38:03 -0700173 *
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500174 * @param paint describes how to color pixels.
175 * @param GrAA Controls whether rect is antialiased
176 * @param viewMatrix transformation matrix which applies to rectToDraw
177 * @param rectToDraw the rectangle to draw
178 * @param localRect the rectangle of shader coordinates applied to rectToDraw
robertphillipsea461502015-05-26 11:38:03 -0700179 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400180 void fillRectToRect(const GrClip* clip,
Brian Salomon82f44312017-01-11 13:42:54 -0500181 GrPaint&& paint,
Michael Ludwig136f45a2019-02-19 11:44:41 -0500182 GrAA aa,
bsalomona2e69fc2015-11-05 10:41:43 -0800183 const SkMatrix& viewMatrix,
184 const SkRect& rectToDraw,
Michael Ludwig136f45a2019-02-19 11:44:41 -0500185 const SkRect& localRect) {
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500186 DrawQuad quad{GrQuad::MakeFromRect(rectToDraw, viewMatrix), GrQuad(localRect),
187 aa == GrAA::kYes ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone};
188 this->drawFilledQuad(clip, std::move(paint), aa, &quad);
Michael Ludwig136f45a2019-02-19 11:44:41 -0500189 }
robertphillipsea461502015-05-26 11:38:03 -0700190
191 /**
bsalomona2e69fc2015-11-05 10:41:43 -0800192 * Fills a rect with a paint and a localMatrix.
robertphillipsea461502015-05-26 11:38:03 -0700193 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400194 void fillRectWithLocalMatrix(const GrClip* clip,
Brian Salomon82f44312017-01-11 13:42:54 -0500195 GrPaint&& paint,
Michael Ludwig61328202019-06-19 14:48:58 +0000196 GrAA aa,
bsalomona2e69fc2015-11-05 10:41:43 -0800197 const SkMatrix& viewMatrix,
198 const SkRect& rect,
Michael Ludwig61328202019-06-19 14:48:58 +0000199 const SkMatrix& localMatrix) {
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500200 DrawQuad quad{GrQuad::MakeFromRect(rect, viewMatrix),
201 GrQuad::MakeFromRect(rect, localMatrix),
202 aa == GrAA::kYes ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone};
203 this->drawFilledQuad(clip, std::move(paint), aa, &quad);
Michael Ludwig61328202019-06-19 14:48:58 +0000204 }
robertphillipsea461502015-05-26 11:38:03 -0700205
Michael Ludwig75451902019-01-23 11:14:29 -0500206 /**
207 * Creates an op that draws a fill rect with per-edge control over anti-aliasing.
Michael Ludwigce62dec2019-02-19 11:48:46 -0500208 *
209 * This is a specialized version of fillQuadWithEdgeAA, but is kept separate since knowing
210 * the geometry is a rectangle affords more optimizations.
Michael Ludwig75451902019-01-23 11:14:29 -0500211 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400212 void fillRectWithEdgeAA(const GrClip* clip, GrPaint&& paint, GrAA aa, GrQuadAAFlags edgeAA,
Michael Ludwig136f45a2019-02-19 11:44:41 -0500213 const SkMatrix& viewMatrix, const SkRect& rect,
Michael Ludwig61328202019-06-19 14:48:58 +0000214 const SkRect* optionalLocalRect = nullptr) {
215 const SkRect& localRect = optionalLocalRect ? *optionalLocalRect : rect;
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500216 DrawQuad quad{GrQuad::MakeFromRect(rect, viewMatrix), GrQuad(localRect), edgeAA};
217 this->drawFilledQuad(clip, std::move(paint), aa, &quad);
Michael Ludwig61328202019-06-19 14:48:58 +0000218 }
Michael Ludwig75451902019-01-23 11:14:29 -0500219
Michael Ludwigce62dec2019-02-19 11:48:46 -0500220 /**
221 * Similar to fillRectWithEdgeAA but draws an arbitrary 2D convex quadrilateral transformed
222 * by 'viewMatrix', with per-edge control over anti-aliasing. The quad should follow the
223 * ordering used by SkRect::toQuad(), which determines how the edge AA is applied:
224 * - "top" = points [0] and [1]
225 * - "right" = points[1] and [2]
226 * - "bottom" = points[2] and [3]
227 * - "left" = points[3] and [0]
228 *
229 * The last argument, 'optionalLocalQuad', can be null if no separate local coordinates are
230 * necessary.
231 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400232 void fillQuadWithEdgeAA(const GrClip* clip, GrPaint&& paint, GrAA aa, GrQuadAAFlags edgeAA,
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500233 const SkMatrix& viewMatrix, const SkPoint points[4],
234 const SkPoint optionalLocalPoints[4]) {
235 const SkPoint* localPoints = optionalLocalPoints ? optionalLocalPoints : points;
236 DrawQuad quad{GrQuad::MakeFromSkQuad(points, viewMatrix),
237 GrQuad::MakeFromSkQuad(localPoints, SkMatrix::I()), edgeAA};
238 this->drawFilledQuad(clip, std::move(paint), aa, &quad);
Michael Ludwig61328202019-06-19 14:48:58 +0000239 }
Michael Ludwigce62dec2019-02-19 11:48:46 -0500240
Michael Ludwig69858532018-11-28 15:34:34 -0500241 /** Used with drawQuadSet */
242 struct QuadSetEntry {
243 SkRect fRect;
244 SkPMColor4f fColor; // Overrides any color on the GrPaint
245 SkMatrix fLocalMatrix;
246 GrQuadAAFlags fAAFlags;
247 };
248
Michael Ludwig75451902019-01-23 11:14:29 -0500249 // TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer
Michael Ludwig7c12e282020-05-29 09:54:07 -0400250 void drawQuadSet(const GrClip* clip, GrPaint&& paint, GrAA aa, const SkMatrix& viewMatrix,
Michael Ludwig69858532018-11-28 15:34:34 -0500251 const QuadSetEntry[], int cnt);
252
robertphillipsea461502015-05-26 11:38:03 -0700253 /**
Brian Salomon34169692017-08-28 15:32:01 -0400254 * Creates an op that draws a subrectangle of a texture. The passed color is modulated by the
255 * texture's color. 'srcRect' specifies the rectangle of the texture to draw. 'dstRect'
256 * specifies the rectangle to draw in local coords which will be transformed by 'viewMatrix' to
Brian Salomonbe3c1d22018-05-21 12:54:39 -0400257 * device space.
Brian Salomon34169692017-08-28 15:32:01 -0400258 */
Brian Salomone69b9ef2020-07-22 11:18:06 -0400259 void drawTexture(const GrClip* clip,
260 GrSurfaceProxyView view,
261 SkAlphaType srcAlphaType,
262 GrSamplerState::Filter filter,
263 GrSamplerState::MipmapMode mm,
264 SkBlendMode mode,
265 const SkPMColor4f& color,
266 const SkRect& srcRect,
267 const SkRect& dstRect,
268 GrAA aa,
269 GrQuadAAFlags edgeAA,
270 SkCanvas::SrcRectConstraint constraint,
271 const SkMatrix& viewMatrix,
Greg Daniel40903af2020-01-30 14:55:05 -0500272 sk_sp<GrColorSpaceXform> texXform) {
Brian Salomon2432d062020-04-16 20:48:09 -0400273 const SkRect* subset = constraint == SkCanvas::kStrict_SrcRectConstraint ?
Michael Ludwigaee26ea2019-07-08 16:22:48 +0000274 &srcRect : nullptr;
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500275 DrawQuad quad{GrQuad::MakeFromRect(dstRect, viewMatrix), GrQuad(srcRect), edgeAA};
276
Brian Salomone69b9ef2020-07-22 11:18:06 -0400277 this->drawTexturedQuad(clip, std::move(view), srcAlphaType, std::move(texXform), filter, mm,
278 color, mode, aa, &quad, subset);
Michael Ludwigaee26ea2019-07-08 16:22:48 +0000279 }
Brian Salomon34169692017-08-28 15:32:01 -0400280
Michael Ludwigce62dec2019-02-19 11:48:46 -0500281 /**
282 * Variant of drawTexture that instead draws the texture applied to 'dstQuad' transformed by
Brian Salomon2432d062020-04-16 20:48:09 -0400283 * 'viewMatrix', using the 'srcQuad' texture coordinates clamped to the optional 'subset'. If
284 * 'subset' is null, it's equivalent to using the fast src rect constraint. If 'subset' is
285 * provided, the strict src rect constraint is applied using 'subset'.
Michael Ludwigce62dec2019-02-19 11:48:46 -0500286 */
Brian Salomone69b9ef2020-07-22 11:18:06 -0400287 void drawTextureQuad(const GrClip* clip,
288 GrSurfaceProxyView view,
289 GrColorType srcColorType,
290 SkAlphaType srcAlphaType,
291 GrSamplerState::Filter filter,
292 GrSamplerState::MipmapMode mm,
293 SkBlendMode mode,
294 const SkPMColor4f& color,
295 const SkPoint srcQuad[4],
296 const SkPoint dstQuad[4],
297 GrAA aa,
298 GrQuadAAFlags edgeAA,
299 const SkRect* subset,
300 const SkMatrix& viewMatrix,
Michael Ludwigaee26ea2019-07-08 16:22:48 +0000301 sk_sp<GrColorSpaceXform> texXform) {
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500302 DrawQuad quad{GrQuad::MakeFromSkQuad(dstQuad, viewMatrix),
303 GrQuad::MakeFromSkQuad(srcQuad, SkMatrix::I()), edgeAA};
Brian Salomone69b9ef2020-07-22 11:18:06 -0400304 this->drawTexturedQuad(clip, std::move(view), srcAlphaType, std::move(texXform), filter, mm,
305 color, mode, aa, &quad, subset);
Michael Ludwigaee26ea2019-07-08 16:22:48 +0000306 }
Michael Ludwigce62dec2019-02-19 11:48:46 -0500307
Brian Salomond7065e72018-10-12 11:42:02 -0400308 /** Used with drawTextureSet */
309 struct TextureSetEntry {
Greg Daniel549325c2019-10-30 16:19:20 -0400310 GrSurfaceProxyView fProxyView;
Brian Salomonfc118442019-11-22 19:09:27 -0500311 SkAlphaType fSrcAlphaType;
Brian Salomond7065e72018-10-12 11:42:02 -0400312 SkRect fSrcRect;
313 SkRect fDstRect;
Michael Ludwig1433cfd2019-02-27 17:12:30 -0500314 const SkPoint* fDstClipQuad; // Must be null, or point to an array of 4 points
Michael Ludwig7ae2ab52019-03-05 16:00:20 -0500315 const SkMatrix* fPreViewMatrix; // If not null, entry's CTM is 'viewMatrix' * fPreViewMatrix
Michael Ludwig1c66ad92020-07-10 08:59:44 -0400316 SkPMColor4f fColor; // {a,a,a,a} for rgb textures, {r,g,b,a} for alpha-only textures
Brian Salomond7065e72018-10-12 11:42:02 -0400317 GrQuadAAFlags fAAFlags;
318 };
319 /**
320 * Draws a set of textures with a shared filter, color, view matrix, color xform, and
321 * texture color xform. The textures must all have the same GrTextureType and GrConfig.
Michael Ludwigce62dec2019-02-19 11:48:46 -0500322 *
323 * If any entries provide a non-null fDstClip array, it will be read from immediately based on
324 * fDstClipCount, so the pointer can become invalid after this returns.
Michael Ludwig379e4962019-12-06 13:21:26 -0500325 *
Hal Canary425929c2019-12-09 11:55:40 -0500326 * 'proxRunCnt' is the number of proxy changes encountered in the entry array. Technically this
Michael Ludwig379e4962019-12-06 13:21:26 -0500327 * can be inferred from the array within this function, but the information is already known
328 * by SkGpuDevice, so no need to incur another iteration over the array.
Brian Salomond7065e72018-10-12 11:42:02 -0400329 */
Brian Salomone69b9ef2020-07-22 11:18:06 -0400330 void drawTextureSet(const GrClip*,
331 TextureSetEntry[],
332 int cnt,
333 int proxyRunCnt,
334 GrSamplerState::Filter,
335 GrSamplerState::MipmapMode,
336 SkBlendMode mode,
337 GrAA aa,
338 SkCanvas::SrcRectConstraint,
339 const SkMatrix& viewMatrix,
Michael Ludwig379e4962019-12-06 13:21:26 -0500340 sk_sp<GrColorSpaceXform> texXform);
Brian Salomond7065e72018-10-12 11:42:02 -0400341
Brian Salomon34169692017-08-28 15:32:01 -0400342 /**
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500343 * Draw a roundrect using a paint.
robertphillipsea461502015-05-26 11:38:03 -0700344 *
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500345 * @param paint describes how to color pixels.
346 * @param GrAA Controls whether rrect is antialiased.
347 * @param viewMatrix transformation matrix
348 * @param rrect the roundrect to draw
349 * @param style style to apply to the rrect. Currently path effects are not allowed.
robertphillipsea461502015-05-26 11:38:03 -0700350 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400351 void drawRRect(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500352 GrPaint&&,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500353 GrAA,
robertphillipsea461502015-05-26 11:38:03 -0700354 const SkMatrix& viewMatrix,
355 const SkRRect& rrect,
bsalomon6663acf2016-05-10 09:14:17 -0700356 const GrStyle& style);
robertphillipsea461502015-05-26 11:38:03 -0700357
358 /**
Jim Van Verth3af1af92017-05-18 15:06:54 -0400359 * Use a fast method to render the ambient and spot shadows for a path.
360 * Will return false if not possible for the given path.
Jim Van Verthc5903412016-11-17 15:27:09 -0500361 *
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500362 * @param viewMatrix transformation matrix
Jim Van Verth3af1af92017-05-18 15:06:54 -0400363 * @param path the path to shadow
364 * @param rec parameters for shadow rendering
Jim Van Verthc5903412016-11-17 15:27:09 -0500365 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400366 bool drawFastShadow(const GrClip*,
Jim Van Verth3af1af92017-05-18 15:06:54 -0400367 const SkMatrix& viewMatrix,
368 const SkPath& path,
369 const SkDrawShadowRec& rec);
Jim Van Verthc5903412016-11-17 15:27:09 -0500370
371 /**
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500372 * Shortcut for filling a SkPath consisting of nested rrects using a paint. The result is
373 * undefined if outer does not contain inner.
robertphillips00095892016-02-29 13:50:40 -0800374 *
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500375 * @param paint describes how to color pixels.
376 * @param GrAA Controls whether rrects edges are antialiased
377 * @param viewMatrix transformation matrix
378 * @param outer the outer roundrect
379 * @param inner the inner roundrect
robertphillips00095892016-02-29 13:50:40 -0800380 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400381 void drawDRRect(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500382 GrPaint&&,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500383 GrAA,
robertphillips00095892016-02-29 13:50:40 -0800384 const SkMatrix& viewMatrix,
385 const SkRRect& outer,
386 const SkRRect& inner);
387
388 /**
robertphillipsea461502015-05-26 11:38:03 -0700389 * Draws a path.
390 *
391 * @param paint describes how to color pixels.
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500392 * @param GrAA Controls whether the path is antialiased.
robertphillipsea461502015-05-26 11:38:03 -0700393 * @param viewMatrix transformation matrix
394 * @param path the path to draw
bsalomon6663acf2016-05-10 09:14:17 -0700395 * @param style style to apply to the path.
robertphillipsea461502015-05-26 11:38:03 -0700396 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400397 void drawPath(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500398 GrPaint&&,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500399 GrAA,
robertphillipsea461502015-05-26 11:38:03 -0700400 const SkMatrix& viewMatrix,
401 const SkPath&,
Robert Phillips20390c32018-08-17 11:01:03 -0400402 const GrStyle&);
403
404 /**
405 * Draws a shape.
406 *
407 * @param paint describes how to color pixels.
408 * @param GrAA Controls whether the path is antialiased.
409 * @param viewMatrix transformation matrix
410 * @param shape the shape to draw
411 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400412 void drawShape(const GrClip*,
Robert Phillips20390c32018-08-17 11:01:03 -0400413 GrPaint&&,
414 GrAA,
415 const SkMatrix& viewMatrix,
Chris Dalton21859012021-01-29 23:44:53 -0700416 GrStyledShape&&);
Robert Phillips20390c32018-08-17 11:01:03 -0400417
robertphillipsea461502015-05-26 11:38:03 -0700418
419 /**
420 * Draws vertices with a paint.
421 *
Brian Osmanae0c50c2017-05-25 16:56:34 -0400422 * @param paint describes how to color pixels.
423 * @param viewMatrix transformation matrix
424 * @param vertices specifies the mesh to draw.
425 * @param overridePrimType primitive type to draw. If NULL, derive prim type from vertices.
Brian Osman3c358422020-03-23 10:44:12 -0400426 * @param effect runtime effect that will handle custom vertex attributes.
robertphillipsea461502015-05-26 11:38:03 -0700427 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400428 void drawVertices(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500429 GrPaint&& paint,
Brian Osman449b1152020-04-15 16:43:00 -0400430 const SkMatrixProvider& matrixProvider,
Brian Osmanae0c50c2017-05-25 16:56:34 -0400431 sk_sp<SkVertices> vertices,
Brian Osman3c358422020-03-23 10:44:12 -0400432 GrPrimitiveType* overridePrimType = nullptr,
Brian Osman449b1152020-04-15 16:43:00 -0400433 const SkRuntimeEffect* effect = nullptr);
Brian Salomon199fb872017-02-06 09:41:10 -0500434
435 /**
Brian Osman4d92b892019-03-24 00:53:23 +0000436 * Draws textured sprites from an atlas with a paint. This currently does not support AA for the
437 * sprite rectangle edges.
438 *
439 * @param paint describes how to color pixels.
440 * @param viewMatrix transformation matrix
441 * @param spriteCount number of sprites.
442 * @param xform array of compressed transformation data, required.
443 * @param texRect array of texture rectangles used to access the paint.
444 * @param colors optional array of per-sprite colors, supercedes
445 * the paint's color field.
446 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400447 void drawAtlas(const GrClip*,
Brian Osman4d92b892019-03-24 00:53:23 +0000448 GrPaint&& paint,
449 const SkMatrix& viewMatrix,
450 int spriteCount,
451 const SkRSXform xform[],
452 const SkRect texRect[],
453 const SkColor colors[]);
454
455 /**
msarettcc319b92016-08-25 18:07:18 -0700456 * Draws a region.
457 *
458 * @param paint describes how to color pixels
459 * @param viewMatrix transformation matrix
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500460 * @param aa should the rects of the region be antialiased.
msarettcc319b92016-08-25 18:07:18 -0700461 * @param region the region to be drawn
462 * @param style style to apply to the region
463 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400464 void drawRegion(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500465 GrPaint&& paint,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500466 GrAA aa,
msarettcc319b92016-08-25 18:07:18 -0700467 const SkMatrix& viewMatrix,
468 const SkRegion& region,
Stan Iliev73d8fd92017-08-02 15:36:24 -0400469 const GrStyle& style,
470 const GrUserStencilSettings* ss = nullptr);
msarettcc319b92016-08-25 18:07:18 -0700471
jvanverth31ff7622015-08-07 10:09:28 -0700472 /**
robertphillipsea461502015-05-26 11:38:03 -0700473 * Draws an oval.
474 *
475 * @param paint describes how to color pixels.
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500476 * @param GrAA Controls whether the oval is antialiased.
robertphillipsea461502015-05-26 11:38:03 -0700477 * @param viewMatrix transformation matrix
478 * @param oval the bounding rect of the oval.
bsalomon6663acf2016-05-10 09:14:17 -0700479 * @param style style to apply to the oval. Currently path effects are not allowed.
robertphillipsea461502015-05-26 11:38:03 -0700480 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400481 void drawOval(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500482 GrPaint&& paint,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500483 GrAA,
robertphillipsea461502015-05-26 11:38:03 -0700484 const SkMatrix& viewMatrix,
485 const SkRect& oval,
bsalomon6663acf2016-05-10 09:14:17 -0700486 const GrStyle& style);
Herb Derbyc1583cb2020-07-13 10:42:18 -0400487
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500488 /**
489 * Draws a partial arc of an oval.
490 *
491 * @param paint describes how to color pixels.
Brian Salomon99504082016-12-09 15:51:31 -0500492 * @param GrGrAA Controls whether the arc is antialiased.
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500493 * @param viewMatrix transformation matrix.
494 * @param oval the bounding rect of the oval.
495 * @param startAngle starting angle in degrees.
496 * @param sweepAngle angle to sweep in degrees. Must be in (-360, 360)
497 * @param useCenter true means that the implied path begins at the oval center, connects as
498 * a line to the point indicated by the start contains the arc indicated by
499 * the sweep angle. If false the line beginning at the center point is
500 * omitted.
501 * @param style style to apply to the oval.
502 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400503 void drawArc(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500504 GrPaint&& paint,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500505 GrAA,
bsalomon4f3a0ca2016-08-22 13:14:26 -0700506 const SkMatrix& viewMatrix,
507 const SkRect& oval,
508 SkScalar startAngle,
509 SkScalar sweepAngle,
510 bool useCenter,
511 const GrStyle& style);
robertphillipsea461502015-05-26 11:38:03 -0700512
joshualitt33a5fce2015-11-18 13:28:51 -0800513 /**
bsalomon4f3a0ca2016-08-22 13:14:26 -0700514 * Draw the image as a set of rects, specified by |iter|.
joshualitt33a5fce2015-11-18 13:28:51 -0800515 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400516 void drawImageLattice(const GrClip*,
Brian Salomon2a943df2018-05-04 13:43:19 -0400517 GrPaint&&,
msarett10e3d9b2016-08-18 15:46:03 -0700518 const SkMatrix& viewMatrix,
Greg Danieled96bca2019-12-05 15:05:54 -0500519 GrSurfaceProxyView,
Greg Daniel82c6b102020-01-21 10:33:22 -0500520 SkAlphaType alphaType,
Brian Salomon2a943df2018-05-04 13:43:19 -0400521 sk_sp<GrColorSpaceXform>,
522 GrSamplerState::Filter,
523 std::unique_ptr<SkLatticeIter>,
msarett10e3d9b2016-08-18 15:46:03 -0700524 const SkRect& dst);
robertphillipsea461502015-05-26 11:38:03 -0700525
robertphillips8c523e02016-07-26 07:41:00 -0700526 /**
Herb Derby411e7aa2020-07-09 16:02:08 -0400527 * Draw the text specified by the SkGlyphRunList.
528 *
529 * @param viewMatrix transformationMatrix
530 * @param glyphRunList text, text positions, and paint.
531 */
532 void drawGlyphRunList(const GrClip*,
533 const SkMatrixProvider& viewMatrix,
534 const SkGlyphRunList& glyphRunList);
535
536 /**
Greg Daniel64cc9aa2018-10-19 13:54:56 -0400537 * Adds the necessary signal and wait semaphores and adds the passed in SkDrawable to the
538 * command stream.
539 */
540 void drawDrawable(std::unique_ptr<SkDrawable::GpuDrawHandler>, const SkRect& bounds);
541
Brian Salomon70fe17e2020-11-30 14:33:58 -0500542 // called to note the last clip drawn to the stencil buffer.
543 // TODO: remove after clipping overhaul.
544 void setLastClip(uint32_t clipStackGenID,
545 const SkIRect& devClipBounds,
546 int numClipAnalyticElements) {
547 GrOpsTask* opsTask = this->getOpsTask();
548 opsTask->fLastClipStackGenID = clipStackGenID;
549 opsTask->fLastDevClipBounds = devClipBounds;
550 opsTask->fLastClipNumAnalyticElements = numClipAnalyticElements;
551 }
552
553 // called to determine if we have to render the clip into SB.
554 // TODO: remove after clipping overhaul.
555 bool mustRenderClip(uint32_t clipStackGenID,
556 const SkIRect& devClipBounds,
557 int numClipAnalyticElements) {
558 GrOpsTask* opsTask = this->getOpsTask();
559 return opsTask->fLastClipStackGenID != clipStackGenID ||
560 !opsTask->fLastDevClipBounds.contains(devClipBounds) ||
561 opsTask->fLastClipNumAnalyticElements != numClipAnalyticElements;
562 }
563
Brian Salomon70fe17e2020-11-30 14:33:58 -0500564 void clearStencilClip(const SkIRect& scissor, bool insideStencilMask) {
565 this->internalStencilClear(&scissor, insideStencilMask);
566 }
567
568 // While this can take a general clip, since GrReducedClip relies on this function, it must take
569 // care to only provide hard clips or we could get stuck in a loop. The general clip is needed
570 // so that path renderers can use this function.
571 void stencilRect(const GrClip* clip,
572 const GrUserStencilSettings* ss,
573 GrPaint&& paint,
574 GrAA doStencilMSAA,
575 const SkMatrix& viewMatrix,
576 const SkRect& rect,
577 const SkMatrix* localMatrix = nullptr) {
578 // Since this provides stencil settings to drawFilledQuad, it performs a different AA type
579 // resolution compared to regular rect draws, which is the main reason it remains separate.
580 DrawQuad quad{GrQuad::MakeFromRect(rect, viewMatrix),
581 localMatrix ? GrQuad::MakeFromRect(rect, *localMatrix) : GrQuad(rect),
582 GrQuadAAFlags::kNone};
583 this->drawFilledQuad(clip, std::move(paint), doStencilMSAA, &quad, ss);
584 }
585
586 void stencilPath(const GrHardClip*,
587 GrAA doStencilMSAA,
588 const SkMatrix& viewMatrix,
589 sk_sp<const GrPath>);
590
591 /**
592 * Draws a path, either AA or not, and touches the stencil buffer with the user stencil settings
593 * for each color sample written.
594 */
595 bool drawAndStencilPath(const GrHardClip*,
596 const GrUserStencilSettings*,
597 SkRegion::Op op,
598 bool invert,
599 GrAA doStencilMSAA,
600 const SkMatrix& viewMatrix,
601 const SkPath&);
602
603 SkBudgeted isBudgeted() const;
604
605 int maxWindowRectangles() const;
606
607 SkGlyphRunListPainter* glyphRunPainter() { return &fGlyphPainter; }
608
609 /*
610 * This unique ID will not change for a given RenderTargetContext. However, it is _NOT_
611 * guaranteed to match the uniqueID of the underlying GrRenderTarget - beware!
612 */
613 GrSurfaceProxy::UniqueID uniqueID() const { return this->asSurfaceProxy()->uniqueID(); }
614
Brian Salomon70fe17e2020-11-30 14:33:58 -0500615 // Allows caller of addDrawOp to know which op list an op will be added to.
616 using WillAddOpFn = void(GrOp*, uint32_t opsTaskID);
617 // These perform processing specific to GrDrawOp-derived ops before recording them into an
618 // op list. Before adding the op to an op list the WillAddOpFn is called. Note that it
619 // will not be called in the event that the op is discarded. Moreover, the op may merge into
620 // another op after the function is called (either before addDrawOp returns or some time later).
621 //
622 // If the clip pointer is null, no clipping will be performed.
623 void addDrawOp(const GrClip*,
624 GrOp::Owner,
625 const std::function<WillAddOpFn>& = std::function<WillAddOpFn>());
626 void addDrawOp(GrOp::Owner op) { this->addDrawOp(nullptr, std::move(op)); }
627
628 bool refsWrappedObjects() const { return this->asRenderTargetProxy()->refsWrappedObjects(); }
629
Greg Daniela5cb7812017-06-16 09:45:32 -0400630 /**
Brian Salomoneebe7352020-12-09 16:37:04 -0500631 * The next time this GrSurfaceDrawContext is flushed, the gpu will wait on the passed in
Greg Daniela5cb7812017-06-16 09:45:32 -0400632 * semaphores before executing any commands.
633 */
Greg Daniel414418d2020-07-08 11:44:25 -0400634 bool waitOnSemaphores(int numSemaphores, const GrBackendSemaphore waitSemaphores[],
635 bool deleteSemaphoresAfterWait);
robertphillips8c523e02016-07-26 07:41:00 -0700636
Greg Daniel46e366a2019-12-16 14:38:36 -0500637 int numSamples() const { return this->asRenderTargetProxy()->numSamples(); }
robertphillipsca6eafc2016-05-17 09:57:46 -0700638 const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; }
Greg Daniel46e366a2019-12-16 14:38:36 -0500639 bool wrapsVkSecondaryCB() const { return this->asRenderTargetProxy()->wrapsVkSecondaryCB(); }
Brian Salomon8c82a872020-07-21 12:09:58 -0400640 GrMipmapped mipmapped() const;
robertphillips7bceedc2015-12-01 12:51:26 -0800641
Robert Phillipsbe9aff22019-02-15 11:33:22 -0500642 // This entry point should only be called if the backing GPU object is known to be
643 // instantiated.
Greg Daniel3912a4b2020-01-14 09:56:04 -0500644 GrRenderTarget* accessRenderTarget() { return this->asSurfaceProxy()->peekRenderTarget(); }
Robert Phillipseaa86252016-11-08 13:49:39 +0000645
Brian Salomoneebe7352020-12-09 16:37:04 -0500646 GrSurfaceDrawContext* asRenderTargetContext() override { return this; }
Robert Phillipsd46697a2017-01-25 12:10:37 -0500647
Robert Phillipsb5204762019-06-19 14:12:13 -0400648#if GR_TEST_UTILS
Chris Dalton6b982802019-06-27 13:53:46 -0600649 void testingOnly_SetPreserveOpsOnFullClear() { fPreserveOpsOnFullClear_TestingOnly = true; }
Robert Phillipsb5204762019-06-19 14:12:13 -0400650#endif
Robert Phillipseaa86252016-11-08 13:49:39 +0000651
robertphillipsea461502015-05-26 11:38:03 -0700652private:
Michael Ludwig61328202019-06-19 14:48:58 +0000653 enum class QuadOptimization;
Brian Salomonf18b1d82017-10-27 11:30:49 -0400654
Chris Dalton7d6748e2019-03-13 00:34:52 -0600655 GrAAType chooseAAType(GrAA);
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500656
Brian Salomon590f5672020-12-16 11:44:47 -0500657 GrOpsTask::CanDiscardPreviousOps canDiscardPreviousOpsOnFullClear() const override;
Chris Dalton858cf232019-10-14 16:20:00 -0600658 void setNeedsStencil(bool useMixedSamplesIfNotMSAA);
Chris Dalton6b982802019-06-27 13:53:46 -0600659
Michael Ludwig81d41722020-05-26 16:57:38 -0400660 void internalStencilClear(const SkIRect* scissor, bool insideStencilMask);
csmartdalton29df7602016-08-31 11:55:52 -0700661
Brian Salomon82f44312017-01-11 13:42:54 -0500662 // Only consumes the GrPaint if successful.
Michael Ludwig7c12e282020-05-29 09:54:07 -0400663 bool drawFilledDRRect(const GrClip* clip,
Brian Salomon82f44312017-01-11 13:42:54 -0500664 GrPaint&& paint,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500665 GrAA,
robertphillips00095892016-02-29 13:50:40 -0800666 const SkMatrix& viewMatrix,
667 const SkRRect& origOuter,
668 const SkRRect& origInner);
669
Michael Ludwig61328202019-06-19 14:48:58 +0000670 // If the drawn quad's paint is a const blended color, provide it as a non-null pointer to
671 // 'constColor', which enables the draw-as-clear optimization. Otherwise it is assumed the paint
672 // requires some form of shading that invalidates using a clear op.
673 //
674 // The non-const pointers should be the original draw request on input, and will be updated as
675 // appropriate depending on the returned optimization level.
676 //
Michael Ludwige08b4432019-06-19 18:00:48 -0400677 // 'stencilSettings' are provided merely for decision making purposes; When non-null,
678 // optimization strategies that submit special ops are avoided.
Michael Ludwig7c12e282020-05-29 09:54:07 -0400679 QuadOptimization attemptQuadOptimization(const GrClip* clip,
Michael Ludwig61328202019-06-19 14:48:58 +0000680 const SkPMColor4f* constColor,
Michael Ludwige08b4432019-06-19 18:00:48 -0400681 const GrUserStencilSettings* stencilSettings,
Michael Ludwig61328202019-06-19 14:48:58 +0000682 GrAA* aa,
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500683 DrawQuad* quad);
robertphillips44302392016-07-08 14:43:03 -0700684
Michael Ludwig61328202019-06-19 14:48:58 +0000685 // If stencil settings, 'ss', are non-null, AA controls MSAA or no AA. If they are null, then AA
686 // can choose between coverage, MSAA as per chooseAAType(). This will always attempt to apply
687 // quad optimizations, so all quad/rect public APIs should rely on this function for consistent
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500688 // clipping behavior. 'quad' will be modified in place to reflect final rendered geometry.
Michael Ludwig7c12e282020-05-29 09:54:07 -0400689 void drawFilledQuad(const GrClip* clip,
Michael Ludwig61328202019-06-19 14:48:58 +0000690 GrPaint&& paint,
691 GrAA aa,
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500692 DrawQuad* quad,
Michael Ludwig61328202019-06-19 14:48:58 +0000693 const GrUserStencilSettings* ss = nullptr);
Brian Salomon7694b902019-06-18 21:00:21 +0000694
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500695 // Like drawFilledQuad but does not require using a GrPaint or FP for texturing.
696 // 'quad' may be modified in place to reflect final geometry.
Michael Ludwig7c12e282020-05-29 09:54:07 -0400697 void drawTexturedQuad(const GrClip* clip,
Greg Daniel549325c2019-10-30 16:19:20 -0400698 GrSurfaceProxyView proxyView,
Brian Salomonfc118442019-11-22 19:09:27 -0500699 SkAlphaType alphaType,
Michael Ludwigaee26ea2019-07-08 16:22:48 +0000700 sk_sp<GrColorSpaceXform> textureXform,
701 GrSamplerState::Filter filter,
Brian Salomone69b9ef2020-07-22 11:18:06 -0400702 GrSamplerState::MipmapMode,
Michael Ludwigaee26ea2019-07-08 16:22:48 +0000703 const SkPMColor4f& color,
704 SkBlendMode blendMode,
705 GrAA aa,
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500706 DrawQuad* quad,
Brian Salomon2432d062020-04-16 20:48:09 -0400707 const SkRect* subset = nullptr);
Michael Ludwigaee26ea2019-07-08 16:22:48 +0000708
Chris Dalton319d0202021-01-29 23:49:47 -0700709 void drawStrokedLine(const GrClip*, GrPaint&&, GrAA, const SkMatrix&, const SkPoint[2],
710 const SkStrokeRec&);
711
Chris Daltonbfe0d372021-02-04 12:24:54 -0700712 // Tries to detect if the given shape is a simple, and draws it without path rendering if
713 // we know how.
714 bool drawSimpleShape(const GrClip*, GrPaint*, GrAA, const SkMatrix&, const GrStyledShape&);
715
Chris Dalton9f704a82021-02-04 15:07:56 -0700716 // If 'attemptDrawSimple' is true, of if the original shape is marked as having been simplfied,
717 // this will attempt to re-route through drawSimpleShape() to see if we can avoid path rendering
718 // one more time.
Michael Ludwig7c12e282020-05-29 09:54:07 -0400719 void drawShapeUsingPathRenderer(const GrClip*, GrPaint&&, GrAA, const SkMatrix&,
Chris Dalton9f704a82021-02-04 15:07:56 -0700720 GrStyledShape&&, bool attemptDrawSimple = false);
robertphillipsea461502015-05-26 11:38:03 -0700721
Robert Phillipsbf25d432017-04-07 10:08:53 -0400722 // Makes a copy of the proxy if it is necessary for the draw and places the texture that should
723 // be used by GrXferProcessor to access the destination color in 'result'. If the return
724 // value is false then a texture copy could not be made.
Michael Ludwig28e5f112020-06-09 10:57:24 -0400725 //
726 // The op should have already had setClippedBounds called on it.
727 bool SK_WARN_UNUSED_RESULT setupDstProxyView(const GrOp& op,
Greg Daniel524e28b2019-11-01 11:48:53 -0400728 GrXferProcessor::DstProxyView* result);
Brian Salomon467921e2017-03-06 16:17:12 -0500729
Herb Derbyd29207a2020-06-08 13:50:19 -0400730 SkGlyphRunListPainter* glyphPainter() { return &fGlyphPainter; }
731
Brian Salomonf18b1d82017-10-27 11:30:49 -0400732 SkSurfaceProps fSurfaceProps;
Robert Phillipse305cc1f2016-12-14 12:19:05 -0500733
Chris Daltoneffee202019-07-01 22:28:03 -0600734 int fNumStencilSamples = 0;
Greg Danield358cbe2020-09-11 09:33:54 -0400735
736 GrDstSampleType fDstSampleType = GrDstSampleType::kNone;
737
Chris Dalton6b982802019-06-27 13:53:46 -0600738#if GR_TEST_UTILS
739 bool fPreserveOpsOnFullClear_TestingOnly = false;
740#endif
Herb Derbyd29207a2020-06-08 13:50:19 -0400741 SkGlyphRunListPainter fGlyphPainter;
Brian Salomon590f5672020-12-16 11:44:47 -0500742 using INHERITED = GrSurfaceFillContext;
robertphillipsea461502015-05-26 11:38:03 -0700743};
744
745#endif