blob: 556a4a9d0883360018c2e853800e1ded69011c72 [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 Osman11052242016-10-27 14:47:55 -04008#ifndef GrRenderTargetContext_DEFINED
9#define GrRenderTargetContext_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"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050021#include "src/gpu/GrSurfaceContext.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;
Brian Osman45580d32016-11-23 09:37:01 -050033class GrRenderTargetContextPriv;
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 Salomon3b8486a2020-04-21 12:43:26 -040059class GrRenderTargetContext : public GrSurfaceContext, public GrOpsTaskClosedObserver {
robertphillipsea461502015-05-26 11:38:03 -070060public:
Greg Daniele20fcad2020-01-08 11:52:34 -050061 static std::unique_ptr<GrRenderTargetContext> Make(
Greg Danielba0ff782020-01-07 15:42:57 -050062 GrRecordingContext*, GrColorType, sk_sp<SkColorSpace>, sk_sp<GrSurfaceProxy>,
63 GrSurfaceOrigin, const SkSurfaceProps*, bool managedOps = true);
64
Brian Salomona56a7462020-02-07 14:17:25 -050065 static std::unique_ptr<GrRenderTargetContext> Make(GrRecordingContext*,
66 GrColorType,
67 sk_sp<SkColorSpace>,
68 SkBackingFit,
69 SkISize dimensions,
70 const GrBackendFormat&,
71 int sampleCnt,
72 GrMipMapped,
73 GrProtected,
74 GrSurfaceOrigin,
75 SkBudgeted,
76 const SkSurfaceProps*);
Greg Daniele20fcad2020-01-08 11:52:34 -050077
78 // Same as above but will use the default GrBackendFormat for the given GrColorType
79 static std::unique_ptr<GrRenderTargetContext> Make(
Brian Salomona56a7462020-02-07 14:17:25 -050080 GrRecordingContext*,
81 GrColorType,
82 sk_sp<SkColorSpace>,
83 SkBackingFit,
84 SkISize dimensions,
85 int sampleCnt = 1,
86 GrMipMapped = GrMipMapped::kNo,
87 GrProtected = GrProtected::kNo,
88 GrSurfaceOrigin = kBottomLeft_GrSurfaceOrigin,
89 SkBudgeted = SkBudgeted::kYes,
90 const SkSurfaceProps* = nullptr);
Greg Daniele20fcad2020-01-08 11:52:34 -050091
Brian Salomond005b692020-04-01 15:47:05 -040092 static std::tuple<GrColorType, GrBackendFormat> GetFallbackColorTypeAndFormat(GrImageContext*,
Brian Salomon0029db02020-04-03 10:41:24 -040093 GrColorType,
94 int sampleCnt);
Brian Salomond005b692020-04-01 15:47:05 -040095
Greg Daniele20fcad2020-01-08 11:52:34 -050096 // Same as previous factory but will try to use fallback GrColorTypes if the one passed in
97 // fails. The fallback GrColorType will have at least the number of channels and precision per
98 // channel as the passed in GrColorType. It may also swizzle the changes (e.g., BGRA -> RGBA).
99 // SRGB-ness will be preserved.
100 static std::unique_ptr<GrRenderTargetContext> MakeWithFallback(
Brian Salomona56a7462020-02-07 14:17:25 -0500101 GrRecordingContext*,
102 GrColorType,
103 sk_sp<SkColorSpace>,
104 SkBackingFit,
105 SkISize dimensions,
106 int sampleCnt = 1,
107 GrMipMapped = GrMipMapped::kNo,
108 GrProtected = GrProtected::kNo,
109 GrSurfaceOrigin = kBottomLeft_GrSurfaceOrigin,
110 SkBudgeted = SkBudgeted::kYes,
111 const SkSurfaceProps* = nullptr);
Greg Daniele20fcad2020-01-08 11:52:34 -0500112
Greg Danielba0ff782020-01-07 15:42:57 -0500113 // These match the definitions in SkSurface & GrSurface.h, for whence they came
114 typedef void* ReleaseContext;
115 typedef void (*ReleaseProc)(ReleaseContext);
116
117 // Creates a GrRenderTargetContext that wraps the passed in GrBackendTexture.
118 static std::unique_ptr<GrRenderTargetContext> MakeFromBackendTexture(
119 GrRecordingContext*, GrColorType, sk_sp<SkColorSpace>, const GrBackendTexture&,
Robert Phillipsa1121332020-06-29 13:05:29 -0400120 int sampleCnt, GrSurfaceOrigin, const SkSurfaceProps*,
121 sk_sp<GrRefCntedCallback> releaseHelper);
Greg Danielba0ff782020-01-07 15:42:57 -0500122
123 static std::unique_ptr<GrRenderTargetContext> MakeFromBackendTextureAsRenderTarget(
124 GrRecordingContext*, GrColorType, sk_sp<SkColorSpace>, const GrBackendTexture&,
125 int sampleCnt, GrSurfaceOrigin, const SkSurfaceProps*);
126
127 static std::unique_ptr<GrRenderTargetContext> MakeFromBackendRenderTarget(
128 GrRecordingContext*, GrColorType, sk_sp<SkColorSpace>, const GrBackendRenderTarget&,
129 GrSurfaceOrigin, const SkSurfaceProps*, ReleaseProc releaseProc,
130 ReleaseContext releaseCtx);
131
132 static std::unique_ptr<GrRenderTargetContext> MakeFromVulkanSecondaryCB(
133 GrRecordingContext*, const SkImageInfo&, const GrVkDrawableInfo&,
134 const SkSurfaceProps*);
135
Greg Daniel3912a4b2020-01-14 09:56:04 -0500136 GrRenderTargetContext(GrRecordingContext*, GrSurfaceProxyView readView,
Brian Salomon8afde5f2020-04-01 16:22:00 -0400137 GrSurfaceProxyView writeView, GrColorType, sk_sp<SkColorSpace>,
Greg Daniel3912a4b2020-01-14 09:56:04 -0500138 const SkSurfaceProps*, bool managedOpsTask = true);
Greg Danielbfa19c42019-12-19 16:41:40 -0500139
Brian Osman11052242016-10-27 14:47:55 -0400140 ~GrRenderTargetContext() override;
robertphillips2334fb62015-06-17 05:43:33 -0700141
Michael Ludwig7c12e282020-05-29 09:54:07 -0400142 virtual void drawGlyphRunList(const GrClip*, const SkMatrixProvider&, const SkGlyphRunList&);
robertphillipsea461502015-05-26 11:38:03 -0700143
robertphillipsea461502015-05-26 11:38:03 -0700144 /**
145 * Provides a perfomance hint that the render target's contents are allowed
146 * to become undefined.
147 */
robertphillips2e1e51f2015-10-15 08:01:48 -0700148 void discard();
robertphillipsea461502015-05-26 11:38:03 -0700149
150 /**
Michael Ludwig81d41722020-05-26 16:57:38 -0400151 * Clear the rect of the render target to the given color.
152 * @param rect the rect to clear to
robertphillipsea461502015-05-26 11:38:03 -0700153 * @param color the color to clear to.
robertphillipsea461502015-05-26 11:38:03 -0700154 */
Michael Ludwig81d41722020-05-26 16:57:38 -0400155 void clear(const SkIRect& rect, const SkPMColor4f& color) {
156 this->internalClear(&rect, color);
157 }
158 // Clears the entire render target to the color.
Chris Dalton0493fbd2019-09-18 15:49:46 -0600159 void clear(const SkPMColor4f& color) {
Michael Ludwig81d41722020-05-26 16:57:38 -0400160 this->internalClear(nullptr, color);
Chris Dalton0493fbd2019-09-18 15:49:46 -0600161 }
162
robertphillipsea461502015-05-26 11:38:03 -0700163 /**
164 * Draw everywhere (respecting the clip) with the paint.
165 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400166 void drawPaint(const GrClip*, GrPaint&&, const SkMatrix& viewMatrix);
robertphillipsea461502015-05-26 11:38:03 -0700167
168 /**
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500169 * Draw the rect using a paint.
170 * @param paint describes how to color pixels.
171 * @param GrAA Controls whether rect is antialiased
172 * @param viewMatrix transformation matrix
173 * @param style The style to apply. Null means fill. Currently path effects are not
174 * allowed.
175 * The rects coords are used to access the paint (through texture matrix)
robertphillipsea461502015-05-26 11:38:03 -0700176 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400177 void drawRect(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500178 GrPaint&& paint,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500179 GrAA,
robertphillipsea461502015-05-26 11:38:03 -0700180 const SkMatrix& viewMatrix,
181 const SkRect&,
Brian Salomon82f44312017-01-11 13:42:54 -0500182 const GrStyle* style = nullptr);
robertphillipsea461502015-05-26 11:38:03 -0700183
184 /**
bsalomona2e69fc2015-11-05 10:41:43 -0800185 * Maps a rectangle of shader coordinates to a rectangle and fills that rectangle.
robertphillipsea461502015-05-26 11:38:03 -0700186 *
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500187 * @param paint describes how to color pixels.
188 * @param GrAA Controls whether rect is antialiased
189 * @param viewMatrix transformation matrix which applies to rectToDraw
190 * @param rectToDraw the rectangle to draw
191 * @param localRect the rectangle of shader coordinates applied to rectToDraw
robertphillipsea461502015-05-26 11:38:03 -0700192 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400193 void fillRectToRect(const GrClip* clip,
Brian Salomon82f44312017-01-11 13:42:54 -0500194 GrPaint&& paint,
Michael Ludwig136f45a2019-02-19 11:44:41 -0500195 GrAA aa,
bsalomona2e69fc2015-11-05 10:41:43 -0800196 const SkMatrix& viewMatrix,
197 const SkRect& rectToDraw,
Michael Ludwig136f45a2019-02-19 11:44:41 -0500198 const SkRect& localRect) {
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500199 DrawQuad quad{GrQuad::MakeFromRect(rectToDraw, viewMatrix), GrQuad(localRect),
200 aa == GrAA::kYes ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone};
201 this->drawFilledQuad(clip, std::move(paint), aa, &quad);
Michael Ludwig136f45a2019-02-19 11:44:41 -0500202 }
robertphillipsea461502015-05-26 11:38:03 -0700203
204 /**
bsalomona2e69fc2015-11-05 10:41:43 -0800205 * Fills a rect with a paint and a localMatrix.
robertphillipsea461502015-05-26 11:38:03 -0700206 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400207 void fillRectWithLocalMatrix(const GrClip* clip,
Brian Salomon82f44312017-01-11 13:42:54 -0500208 GrPaint&& paint,
Michael Ludwig61328202019-06-19 14:48:58 +0000209 GrAA aa,
bsalomona2e69fc2015-11-05 10:41:43 -0800210 const SkMatrix& viewMatrix,
211 const SkRect& rect,
Michael Ludwig61328202019-06-19 14:48:58 +0000212 const SkMatrix& localMatrix) {
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500213 DrawQuad quad{GrQuad::MakeFromRect(rect, viewMatrix),
214 GrQuad::MakeFromRect(rect, localMatrix),
215 aa == GrAA::kYes ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone};
216 this->drawFilledQuad(clip, std::move(paint), aa, &quad);
Michael Ludwig61328202019-06-19 14:48:58 +0000217 }
robertphillipsea461502015-05-26 11:38:03 -0700218
Michael Ludwig75451902019-01-23 11:14:29 -0500219 /**
220 * Creates an op that draws a fill rect with per-edge control over anti-aliasing.
Michael Ludwigce62dec2019-02-19 11:48:46 -0500221 *
222 * This is a specialized version of fillQuadWithEdgeAA, but is kept separate since knowing
223 * the geometry is a rectangle affords more optimizations.
Michael Ludwig75451902019-01-23 11:14:29 -0500224 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400225 void fillRectWithEdgeAA(const GrClip* clip, GrPaint&& paint, GrAA aa, GrQuadAAFlags edgeAA,
Michael Ludwig136f45a2019-02-19 11:44:41 -0500226 const SkMatrix& viewMatrix, const SkRect& rect,
Michael Ludwig61328202019-06-19 14:48:58 +0000227 const SkRect* optionalLocalRect = nullptr) {
228 const SkRect& localRect = optionalLocalRect ? *optionalLocalRect : rect;
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500229 DrawQuad quad{GrQuad::MakeFromRect(rect, viewMatrix), GrQuad(localRect), edgeAA};
230 this->drawFilledQuad(clip, std::move(paint), aa, &quad);
Michael Ludwig61328202019-06-19 14:48:58 +0000231 }
Michael Ludwig75451902019-01-23 11:14:29 -0500232
Michael Ludwigce62dec2019-02-19 11:48:46 -0500233 /**
234 * Similar to fillRectWithEdgeAA but draws an arbitrary 2D convex quadrilateral transformed
235 * by 'viewMatrix', with per-edge control over anti-aliasing. The quad should follow the
236 * ordering used by SkRect::toQuad(), which determines how the edge AA is applied:
237 * - "top" = points [0] and [1]
238 * - "right" = points[1] and [2]
239 * - "bottom" = points[2] and [3]
240 * - "left" = points[3] and [0]
241 *
242 * The last argument, 'optionalLocalQuad', can be null if no separate local coordinates are
243 * necessary.
244 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400245 void fillQuadWithEdgeAA(const GrClip* clip, GrPaint&& paint, GrAA aa, GrQuadAAFlags edgeAA,
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500246 const SkMatrix& viewMatrix, const SkPoint points[4],
247 const SkPoint optionalLocalPoints[4]) {
248 const SkPoint* localPoints = optionalLocalPoints ? optionalLocalPoints : points;
249 DrawQuad quad{GrQuad::MakeFromSkQuad(points, viewMatrix),
250 GrQuad::MakeFromSkQuad(localPoints, SkMatrix::I()), edgeAA};
251 this->drawFilledQuad(clip, std::move(paint), aa, &quad);
Michael Ludwig61328202019-06-19 14:48:58 +0000252 }
Michael Ludwigce62dec2019-02-19 11:48:46 -0500253
Michael Ludwig69858532018-11-28 15:34:34 -0500254 /** Used with drawQuadSet */
255 struct QuadSetEntry {
256 SkRect fRect;
257 SkPMColor4f fColor; // Overrides any color on the GrPaint
258 SkMatrix fLocalMatrix;
259 GrQuadAAFlags fAAFlags;
260 };
261
Michael Ludwig75451902019-01-23 11:14:29 -0500262 // TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer
Michael Ludwig7c12e282020-05-29 09:54:07 -0400263 void drawQuadSet(const GrClip* clip, GrPaint&& paint, GrAA aa, const SkMatrix& viewMatrix,
Michael Ludwig69858532018-11-28 15:34:34 -0500264 const QuadSetEntry[], int cnt);
265
robertphillipsea461502015-05-26 11:38:03 -0700266 /**
Brian Salomon34169692017-08-28 15:32:01 -0400267 * Creates an op that draws a subrectangle of a texture. The passed color is modulated by the
268 * texture's color. 'srcRect' specifies the rectangle of the texture to draw. 'dstRect'
269 * specifies the rectangle to draw in local coords which will be transformed by 'viewMatrix' to
Brian Salomonbe3c1d22018-05-21 12:54:39 -0400270 * device space.
Brian Salomon34169692017-08-28 15:32:01 -0400271 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400272 void drawTexture(const GrClip* clip, GrSurfaceProxyView view, SkAlphaType srcAlphaType,
Greg Daniel40903af2020-01-30 14:55:05 -0500273 GrSamplerState::Filter filter, SkBlendMode mode, const SkPMColor4f& color,
274 const SkRect& srcRect, const SkRect& dstRect, GrAA aa, GrQuadAAFlags edgeAA,
275 SkCanvas::SrcRectConstraint constraint, const SkMatrix& viewMatrix,
276 sk_sp<GrColorSpaceXform> texXform) {
Brian Salomon2432d062020-04-16 20:48:09 -0400277 const SkRect* subset = constraint == SkCanvas::kStrict_SrcRectConstraint ?
Michael Ludwigaee26ea2019-07-08 16:22:48 +0000278 &srcRect : nullptr;
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500279 DrawQuad quad{GrQuad::MakeFromRect(dstRect, viewMatrix), GrQuad(srcRect), edgeAA};
280
Greg Daniel40903af2020-01-30 14:55:05 -0500281 this->drawTexturedQuad(clip, std::move(view), srcAlphaType, std::move(texXform),
Brian Salomon2432d062020-04-16 20:48:09 -0400282 filter, color, mode, aa, &quad, subset);
Michael Ludwigaee26ea2019-07-08 16:22:48 +0000283 }
Brian Salomon34169692017-08-28 15:32:01 -0400284
Michael Ludwigce62dec2019-02-19 11:48:46 -0500285 /**
286 * Variant of drawTexture that instead draws the texture applied to 'dstQuad' transformed by
Brian Salomon2432d062020-04-16 20:48:09 -0400287 * 'viewMatrix', using the 'srcQuad' texture coordinates clamped to the optional 'subset'. If
288 * 'subset' is null, it's equivalent to using the fast src rect constraint. If 'subset' is
289 * provided, the strict src rect constraint is applied using 'subset'.
Michael Ludwigce62dec2019-02-19 11:48:46 -0500290 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400291 void drawTextureQuad(const GrClip* clip, GrSurfaceProxyView view, GrColorType srcColorType,
Brian Salomonfc118442019-11-22 19:09:27 -0500292 SkAlphaType srcAlphaType, GrSamplerState::Filter filter, SkBlendMode mode,
293 const SkPMColor4f& color, const SkPoint srcQuad[4],
294 const SkPoint dstQuad[4], GrAA aa, GrQuadAAFlags edgeAA,
Brian Salomon2432d062020-04-16 20:48:09 -0400295 const SkRect* subset, const SkMatrix& viewMatrix,
Michael Ludwigaee26ea2019-07-08 16:22:48 +0000296 sk_sp<GrColorSpaceXform> texXform) {
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500297 DrawQuad quad{GrQuad::MakeFromSkQuad(dstQuad, viewMatrix),
298 GrQuad::MakeFromSkQuad(srcQuad, SkMatrix::I()), edgeAA};
Greg Daniel2f3cd4f2020-02-07 11:07:25 -0500299 this->drawTexturedQuad(clip, std::move(view), srcAlphaType, std::move(texXform),
Brian Salomon2432d062020-04-16 20:48:09 -0400300 filter, color, mode, aa, &quad, subset);
Michael Ludwigaee26ea2019-07-08 16:22:48 +0000301 }
Michael Ludwigce62dec2019-02-19 11:48:46 -0500302
Brian Salomond7065e72018-10-12 11:42:02 -0400303 /** Used with drawTextureSet */
304 struct TextureSetEntry {
Greg Daniel549325c2019-10-30 16:19:20 -0400305 GrSurfaceProxyView fProxyView;
Brian Salomonfc118442019-11-22 19:09:27 -0500306 SkAlphaType fSrcAlphaType;
Brian Salomond7065e72018-10-12 11:42:02 -0400307 SkRect fSrcRect;
308 SkRect fDstRect;
Michael Ludwig1433cfd2019-02-27 17:12:30 -0500309 const SkPoint* fDstClipQuad; // Must be null, or point to an array of 4 points
Michael Ludwig7ae2ab52019-03-05 16:00:20 -0500310 const SkMatrix* fPreViewMatrix; // If not null, entry's CTM is 'viewMatrix' * fPreViewMatrix
Michael Ludwig1c66ad92020-07-10 08:59:44 -0400311 SkPMColor4f fColor; // {a,a,a,a} for rgb textures, {r,g,b,a} for alpha-only textures
Brian Salomond7065e72018-10-12 11:42:02 -0400312 GrQuadAAFlags fAAFlags;
313 };
314 /**
315 * Draws a set of textures with a shared filter, color, view matrix, color xform, and
316 * texture color xform. The textures must all have the same GrTextureType and GrConfig.
Michael Ludwigce62dec2019-02-19 11:48:46 -0500317 *
318 * If any entries provide a non-null fDstClip array, it will be read from immediately based on
319 * fDstClipCount, so the pointer can become invalid after this returns.
Michael Ludwig379e4962019-12-06 13:21:26 -0500320 *
Hal Canary425929c2019-12-09 11:55:40 -0500321 * 'proxRunCnt' is the number of proxy changes encountered in the entry array. Technically this
Michael Ludwig379e4962019-12-06 13:21:26 -0500322 * can be inferred from the array within this function, but the information is already known
323 * by SkGpuDevice, so no need to incur another iteration over the array.
Brian Salomond7065e72018-10-12 11:42:02 -0400324 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400325 void drawTextureSet(const GrClip*, TextureSetEntry[], int cnt, int proxyRunCnt,
Michael Ludwig379e4962019-12-06 13:21:26 -0500326 GrSamplerState::Filter, SkBlendMode mode, GrAA aa,
327 SkCanvas::SrcRectConstraint, const SkMatrix& viewMatrix,
328 sk_sp<GrColorSpaceXform> texXform);
Brian Salomond7065e72018-10-12 11:42:02 -0400329
Brian Salomon34169692017-08-28 15:32:01 -0400330 /**
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500331 * Draw a roundrect using a paint.
robertphillipsea461502015-05-26 11:38:03 -0700332 *
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500333 * @param paint describes how to color pixels.
334 * @param GrAA Controls whether rrect is antialiased.
335 * @param viewMatrix transformation matrix
336 * @param rrect the roundrect to draw
337 * @param style style to apply to the rrect. Currently path effects are not allowed.
robertphillipsea461502015-05-26 11:38:03 -0700338 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400339 void drawRRect(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500340 GrPaint&&,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500341 GrAA,
robertphillipsea461502015-05-26 11:38:03 -0700342 const SkMatrix& viewMatrix,
343 const SkRRect& rrect,
bsalomon6663acf2016-05-10 09:14:17 -0700344 const GrStyle& style);
robertphillipsea461502015-05-26 11:38:03 -0700345
346 /**
Jim Van Verth3af1af92017-05-18 15:06:54 -0400347 * Use a fast method to render the ambient and spot shadows for a path.
348 * Will return false if not possible for the given path.
Jim Van Verthc5903412016-11-17 15:27:09 -0500349 *
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500350 * @param viewMatrix transformation matrix
Jim Van Verth3af1af92017-05-18 15:06:54 -0400351 * @param path the path to shadow
352 * @param rec parameters for shadow rendering
Jim Van Verthc5903412016-11-17 15:27:09 -0500353 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400354 bool drawFastShadow(const GrClip*,
Jim Van Verth3af1af92017-05-18 15:06:54 -0400355 const SkMatrix& viewMatrix,
356 const SkPath& path,
357 const SkDrawShadowRec& rec);
Jim Van Verthc5903412016-11-17 15:27:09 -0500358
359 /**
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500360 * Shortcut for filling a SkPath consisting of nested rrects using a paint. The result is
361 * undefined if outer does not contain inner.
robertphillips00095892016-02-29 13:50:40 -0800362 *
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500363 * @param paint describes how to color pixels.
364 * @param GrAA Controls whether rrects edges are antialiased
365 * @param viewMatrix transformation matrix
366 * @param outer the outer roundrect
367 * @param inner the inner roundrect
robertphillips00095892016-02-29 13:50:40 -0800368 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400369 void drawDRRect(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500370 GrPaint&&,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500371 GrAA,
robertphillips00095892016-02-29 13:50:40 -0800372 const SkMatrix& viewMatrix,
373 const SkRRect& outer,
374 const SkRRect& inner);
375
376 /**
robertphillipsea461502015-05-26 11:38:03 -0700377 * Draws a path.
378 *
379 * @param paint describes how to color pixels.
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500380 * @param GrAA Controls whether the path is antialiased.
robertphillipsea461502015-05-26 11:38:03 -0700381 * @param viewMatrix transformation matrix
382 * @param path the path to draw
bsalomon6663acf2016-05-10 09:14:17 -0700383 * @param style style to apply to the path.
robertphillipsea461502015-05-26 11:38:03 -0700384 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400385 void drawPath(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500386 GrPaint&&,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500387 GrAA,
robertphillipsea461502015-05-26 11:38:03 -0700388 const SkMatrix& viewMatrix,
389 const SkPath&,
Robert Phillips20390c32018-08-17 11:01:03 -0400390 const GrStyle&);
391
392 /**
393 * Draws a shape.
394 *
395 * @param paint describes how to color pixels.
396 * @param GrAA Controls whether the path is antialiased.
397 * @param viewMatrix transformation matrix
398 * @param shape the shape to draw
399 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400400 void drawShape(const GrClip*,
Robert Phillips20390c32018-08-17 11:01:03 -0400401 GrPaint&&,
402 GrAA,
403 const SkMatrix& viewMatrix,
Michael Ludwig2686d692020-04-17 20:21:37 +0000404 const GrStyledShape&);
Robert Phillips20390c32018-08-17 11:01:03 -0400405
robertphillipsea461502015-05-26 11:38:03 -0700406
407 /**
408 * Draws vertices with a paint.
409 *
Brian Osmanae0c50c2017-05-25 16:56:34 -0400410 * @param paint describes how to color pixels.
411 * @param viewMatrix transformation matrix
412 * @param vertices specifies the mesh to draw.
413 * @param overridePrimType primitive type to draw. If NULL, derive prim type from vertices.
Brian Osman3c358422020-03-23 10:44:12 -0400414 * @param effect runtime effect that will handle custom vertex attributes.
robertphillipsea461502015-05-26 11:38:03 -0700415 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400416 void drawVertices(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500417 GrPaint&& paint,
Brian Osman449b1152020-04-15 16:43:00 -0400418 const SkMatrixProvider& matrixProvider,
Brian Osmanae0c50c2017-05-25 16:56:34 -0400419 sk_sp<SkVertices> vertices,
Brian Osman3c358422020-03-23 10:44:12 -0400420 GrPrimitiveType* overridePrimType = nullptr,
Brian Osman449b1152020-04-15 16:43:00 -0400421 const SkRuntimeEffect* effect = nullptr);
Brian Salomon199fb872017-02-06 09:41:10 -0500422
423 /**
Brian Osman4d92b892019-03-24 00:53:23 +0000424 * Draws textured sprites from an atlas with a paint. This currently does not support AA for the
425 * sprite rectangle edges.
426 *
427 * @param paint describes how to color pixels.
428 * @param viewMatrix transformation matrix
429 * @param spriteCount number of sprites.
430 * @param xform array of compressed transformation data, required.
431 * @param texRect array of texture rectangles used to access the paint.
432 * @param colors optional array of per-sprite colors, supercedes
433 * the paint's color field.
434 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400435 void drawAtlas(const GrClip*,
Brian Osman4d92b892019-03-24 00:53:23 +0000436 GrPaint&& paint,
437 const SkMatrix& viewMatrix,
438 int spriteCount,
439 const SkRSXform xform[],
440 const SkRect texRect[],
441 const SkColor colors[]);
442
443 /**
msarettcc319b92016-08-25 18:07:18 -0700444 * Draws a region.
445 *
446 * @param paint describes how to color pixels
447 * @param viewMatrix transformation matrix
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500448 * @param aa should the rects of the region be antialiased.
msarettcc319b92016-08-25 18:07:18 -0700449 * @param region the region to be drawn
450 * @param style style to apply to the region
451 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400452 void drawRegion(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500453 GrPaint&& paint,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500454 GrAA aa,
msarettcc319b92016-08-25 18:07:18 -0700455 const SkMatrix& viewMatrix,
456 const SkRegion& region,
Stan Iliev73d8fd92017-08-02 15:36:24 -0400457 const GrStyle& style,
458 const GrUserStencilSettings* ss = nullptr);
msarettcc319b92016-08-25 18:07:18 -0700459
jvanverth31ff7622015-08-07 10:09:28 -0700460 /**
robertphillipsea461502015-05-26 11:38:03 -0700461 * Draws an oval.
462 *
463 * @param paint describes how to color pixels.
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500464 * @param GrAA Controls whether the oval is antialiased.
robertphillipsea461502015-05-26 11:38:03 -0700465 * @param viewMatrix transformation matrix
466 * @param oval the bounding rect of the oval.
bsalomon6663acf2016-05-10 09:14:17 -0700467 * @param style style to apply to the oval. Currently path effects are not allowed.
robertphillipsea461502015-05-26 11:38:03 -0700468 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400469 void drawOval(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500470 GrPaint&& paint,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500471 GrAA,
robertphillipsea461502015-05-26 11:38:03 -0700472 const SkMatrix& viewMatrix,
473 const SkRect& oval,
bsalomon6663acf2016-05-10 09:14:17 -0700474 const GrStyle& style);
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500475 /**
476 * Draws a partial arc of an oval.
477 *
478 * @param paint describes how to color pixels.
Brian Salomon99504082016-12-09 15:51:31 -0500479 * @param GrGrAA Controls whether the arc is antialiased.
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500480 * @param viewMatrix transformation matrix.
481 * @param oval the bounding rect of the oval.
482 * @param startAngle starting angle in degrees.
483 * @param sweepAngle angle to sweep in degrees. Must be in (-360, 360)
484 * @param useCenter true means that the implied path begins at the oval center, connects as
485 * a line to the point indicated by the start contains the arc indicated by
486 * the sweep angle. If false the line beginning at the center point is
487 * omitted.
488 * @param style style to apply to the oval.
489 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400490 void drawArc(const GrClip*,
Brian Salomon82f44312017-01-11 13:42:54 -0500491 GrPaint&& paint,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500492 GrAA,
bsalomon4f3a0ca2016-08-22 13:14:26 -0700493 const SkMatrix& viewMatrix,
494 const SkRect& oval,
495 SkScalar startAngle,
496 SkScalar sweepAngle,
497 bool useCenter,
498 const GrStyle& style);
robertphillipsea461502015-05-26 11:38:03 -0700499
joshualitt33a5fce2015-11-18 13:28:51 -0800500 /**
bsalomon4f3a0ca2016-08-22 13:14:26 -0700501 * Draw the image as a set of rects, specified by |iter|.
joshualitt33a5fce2015-11-18 13:28:51 -0800502 */
Michael Ludwig7c12e282020-05-29 09:54:07 -0400503 void drawImageLattice(const GrClip*,
Brian Salomon2a943df2018-05-04 13:43:19 -0400504 GrPaint&&,
msarett10e3d9b2016-08-18 15:46:03 -0700505 const SkMatrix& viewMatrix,
Greg Danieled96bca2019-12-05 15:05:54 -0500506 GrSurfaceProxyView,
Greg Daniel82c6b102020-01-21 10:33:22 -0500507 SkAlphaType alphaType,
Brian Salomon2a943df2018-05-04 13:43:19 -0400508 sk_sp<GrColorSpaceXform>,
509 GrSamplerState::Filter,
510 std::unique_ptr<SkLatticeIter>,
msarett10e3d9b2016-08-18 15:46:03 -0700511 const SkRect& dst);
robertphillipsea461502015-05-26 11:38:03 -0700512
robertphillips8c523e02016-07-26 07:41:00 -0700513 /**
Greg Daniel46cfbc62019-06-07 11:43:30 -0400514 * Draws the src texture with no matrix. The dstRect is the dstPoint with the width and height
515 * of the srcRect. The srcRect and dstRect are clipped to the bounds of the src and dst surfaces
516 * respectively.
517 */
Greg Daniel573312e2020-02-07 17:22:35 -0500518 bool blitTexture(GrSurfaceProxyView view, const SkIRect& srcRect, const SkIPoint& dstPoint);
Greg Daniel46cfbc62019-06-07 11:43:30 -0400519
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
Greg Daniela5cb7812017-06-16 09:45:32 -0400526 /**
527 * The next time this GrRenderTargetContext is flushed, the gpu will wait on the passed in
528 * semaphores before executing any commands.
529 */
Greg Daniel414418d2020-07-08 11:44:25 -0400530 bool waitOnSemaphores(int numSemaphores, const GrBackendSemaphore waitSemaphores[],
531 bool deleteSemaphoresAfterWait);
robertphillips8c523e02016-07-26 07:41:00 -0700532
Greg Daniel46e366a2019-12-16 14:38:36 -0500533 int numSamples() const { return this->asRenderTargetProxy()->numSamples(); }
robertphillipsca6eafc2016-05-17 09:57:46 -0700534 const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; }
Greg Daniel46e366a2019-12-16 14:38:36 -0500535 bool wrapsVkSecondaryCB() const { return this->asRenderTargetProxy()->wrapsVkSecondaryCB(); }
Greg Daniele252f082017-10-23 16:05:23 -0400536 GrMipMapped mipMapped() const;
robertphillips7bceedc2015-12-01 12:51:26 -0800537
Greg Daniel3912a4b2020-01-14 09:56:04 -0500538 // TODO: See if it makes sense for this to return a const& instead and require the callers to
539 // make a copy (which refs the proxy) if needed.
Brian Salomon8afde5f2020-04-01 16:22:00 -0400540 GrSurfaceProxyView writeSurfaceView() { return fWriteView; }
Greg Daniela83de582019-10-22 09:33:25 -0400541
Robert Phillipsbe9aff22019-02-15 11:33:22 -0500542 // This entry point should only be called if the backing GPU object is known to be
543 // instantiated.
Greg Daniel3912a4b2020-01-14 09:56:04 -0500544 GrRenderTarget* accessRenderTarget() { return this->asSurfaceProxy()->peekRenderTarget(); }
Robert Phillipseaa86252016-11-08 13:49:39 +0000545
Robert Phillipsd46697a2017-01-25 12:10:37 -0500546 GrRenderTargetContext* asRenderTargetContext() override { return this; }
547
robertphillips391395d2016-03-02 09:26:36 -0800548 // Provides access to functions that aren't part of the public API.
Brian Osman693a5402016-10-27 15:13:22 -0400549 GrRenderTargetContextPriv priv();
550 const GrRenderTargetContextPriv priv() const;
joshualittf5883a62016-01-13 07:47:38 -0800551
Brian Salomon3b8486a2020-04-21 12:43:26 -0400552 void wasClosed(const GrOpsTask& task) override;
553
Robert Phillipsb5204762019-06-19 14:12:13 -0400554#if GR_TEST_UTILS
Greg Daniel3912a4b2020-01-14 09:56:04 -0500555 bool testingOnly_IsInstantiated() const { return this->asSurfaceProxy()->isInstantiated(); }
Chris Dalton6b982802019-06-27 13:53:46 -0600556 void testingOnly_SetPreserveOpsOnFullClear() { fPreserveOpsOnFullClear_TestingOnly = true; }
Greg Danielf41b2bd2019-08-22 16:19:24 -0400557 GrOpsTask* testingOnly_PeekLastOpsTask() { return fOpsTask.get(); }
Robert Phillipsb5204762019-06-19 14:12:13 -0400558#endif
Robert Phillipseaa86252016-11-08 13:49:39 +0000559
robertphillipsea461502015-05-26 11:38:03 -0700560private:
Michael Ludwig61328202019-06-19 14:48:58 +0000561 enum class QuadOptimization;
Brian Salomonf18b1d82017-10-27 11:30:49 -0400562
Chris Dalton7d6748e2019-03-13 00:34:52 -0600563 GrAAType chooseAAType(GrAA);
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500564
Greg Danielf41b2bd2019-08-22 16:19:24 -0400565 friend class GrClipStackClip; // for access to getOpsTask
Chris Daltonc4b47352019-08-23 10:10:36 -0600566 friend class GrOnFlushResourceProvider; // for access to getOpsTask (http://skbug.com/9357)
robertphillips55fdccc2016-06-06 06:16:20 -0700567
Brian Osman11052242016-10-27 14:47:55 -0400568 friend class GrRenderTargetContextPriv;
robertphillips976f5f02016-06-03 10:59:20 -0700569
Herb Derbyba426ba2020-06-09 14:50:32 -0400570 // All the path and text renderers/ops currently make their own ops
Brian Salomon649a3412017-03-09 13:50:43 -0500571 friend class GrSoftwarePathRenderer; // for access to add[Mesh]DrawOp
572 friend class GrAAConvexPathRenderer; // for access to add[Mesh]DrawOp
573 friend class GrDashLinePathRenderer; // for access to add[Mesh]DrawOp
574 friend class GrAAHairLinePathRenderer; // for access to add[Mesh]DrawOp
575 friend class GrAALinearizingConvexPathRenderer; // for access to add[Mesh]DrawOp
Jim Van Verth83010462017-03-16 08:45:39 -0400576 friend class GrSmallPathRenderer; // for access to add[Mesh]DrawOp
Brian Salomon649a3412017-03-09 13:50:43 -0500577 friend class GrDefaultPathRenderer; // for access to add[Mesh]DrawOp
Brian Salomon649a3412017-03-09 13:50:43 -0500578 friend class GrStencilAndCoverPathRenderer; // for access to add[Mesh]DrawOp
Chris Dalton17dc4182020-03-25 16:18:16 -0600579 friend class GrTriangulatingPathRenderer; // for access to add[Mesh]DrawOp
Chris Dalton9414c962018-06-14 10:14:50 -0600580 friend class GrCCPerFlushResources; // for access to addDrawOp
Chris Dalton1a325d22017-07-14 15:17:41 -0600581 friend class GrCoverageCountingPathRenderer; // for access to addDrawOp
Robert Phillips438d9862019-11-14 12:46:05 -0500582 friend class GrFillRectOp; // for access to addDrawOp
Chris Dalton0a22b1e2020-03-26 11:52:15 -0600583 friend class GrTessellationPathRenderer; // for access to addDrawOp
Robert Phillipse837e612019-11-15 11:02:50 -0500584 friend class GrTextureOp; // for access to addDrawOp
Herb Derbyba426ba2020-06-09 14:50:32 -0400585 friend class GrAtlasTextOp; // for access to addDrawOp
Robert Phillips438d9862019-11-14 12:46:05 -0500586
Greg Daniel46e366a2019-12-16 14:38:36 -0500587 SkDEBUGCODE(void onValidate() const override;)
Greg Daniela83de582019-10-22 09:33:25 -0400588
589
Greg Danielf41b2bd2019-08-22 16:19:24 -0400590 GrOpsTask::CanDiscardPreviousOps canDiscardPreviousOpsOnFullClear() const;
Chris Dalton858cf232019-10-14 16:20:00 -0600591 void setNeedsStencil(bool useMixedSamplesIfNotMSAA);
Chris Dalton6b982802019-06-27 13:53:46 -0600592
Michael Ludwig81d41722020-05-26 16:57:38 -0400593 void internalClear(const SkIRect* scissor, const SkPMColor4f&,
594 bool upgradePartialToFull = false);
595 void internalStencilClear(const SkIRect* scissor, bool insideStencilMask);
csmartdalton29df7602016-08-31 11:55:52 -0700596
Brian Salomon82f44312017-01-11 13:42:54 -0500597 // Only consumes the GrPaint if successful.
Michael Ludwig7c12e282020-05-29 09:54:07 -0400598 bool drawFilledDRRect(const GrClip* clip,
Brian Salomon82f44312017-01-11 13:42:54 -0500599 GrPaint&& paint,
Brian Salomon0e8fc8b2016-12-09 15:10:07 -0500600 GrAA,
robertphillips00095892016-02-29 13:50:40 -0800601 const SkMatrix& viewMatrix,
602 const SkRRect& origOuter,
603 const SkRRect& origInner);
604
Michael Ludwig61328202019-06-19 14:48:58 +0000605 // If the drawn quad's paint is a const blended color, provide it as a non-null pointer to
606 // 'constColor', which enables the draw-as-clear optimization. Otherwise it is assumed the paint
607 // requires some form of shading that invalidates using a clear op.
608 //
609 // The non-const pointers should be the original draw request on input, and will be updated as
610 // appropriate depending on the returned optimization level.
611 //
Michael Ludwige08b4432019-06-19 18:00:48 -0400612 // 'stencilSettings' are provided merely for decision making purposes; When non-null,
613 // optimization strategies that submit special ops are avoided.
Michael Ludwig7c12e282020-05-29 09:54:07 -0400614 QuadOptimization attemptQuadOptimization(const GrClip* clip,
Michael Ludwig61328202019-06-19 14:48:58 +0000615 const SkPMColor4f* constColor,
Michael Ludwige08b4432019-06-19 18:00:48 -0400616 const GrUserStencilSettings* stencilSettings,
Michael Ludwig61328202019-06-19 14:48:58 +0000617 GrAA* aa,
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500618 DrawQuad* quad);
robertphillips44302392016-07-08 14:43:03 -0700619
Michael Ludwig61328202019-06-19 14:48:58 +0000620 // If stencil settings, 'ss', are non-null, AA controls MSAA or no AA. If they are null, then AA
621 // can choose between coverage, MSAA as per chooseAAType(). This will always attempt to apply
622 // quad optimizations, so all quad/rect public APIs should rely on this function for consistent
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500623 // clipping behavior. 'quad' will be modified in place to reflect final rendered geometry.
Michael Ludwig7c12e282020-05-29 09:54:07 -0400624 void drawFilledQuad(const GrClip* clip,
Michael Ludwig61328202019-06-19 14:48:58 +0000625 GrPaint&& paint,
626 GrAA aa,
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500627 DrawQuad* quad,
Michael Ludwig61328202019-06-19 14:48:58 +0000628 const GrUserStencilSettings* ss = nullptr);
Brian Salomon7694b902019-06-18 21:00:21 +0000629
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500630 // Like drawFilledQuad but does not require using a GrPaint or FP for texturing.
631 // 'quad' may be modified in place to reflect final geometry.
Michael Ludwig7c12e282020-05-29 09:54:07 -0400632 void drawTexturedQuad(const GrClip* clip,
Greg Daniel549325c2019-10-30 16:19:20 -0400633 GrSurfaceProxyView proxyView,
Brian Salomonfc118442019-11-22 19:09:27 -0500634 SkAlphaType alphaType,
Michael Ludwigaee26ea2019-07-08 16:22:48 +0000635 sk_sp<GrColorSpaceXform> textureXform,
636 GrSamplerState::Filter filter,
637 const SkPMColor4f& color,
638 SkBlendMode blendMode,
639 GrAA aa,
Michael Ludwig6b45c5d2020-02-07 09:56:38 -0500640 DrawQuad* quad,
Brian Salomon2432d062020-04-16 20:48:09 -0400641 const SkRect* subset = nullptr);
Michael Ludwigaee26ea2019-07-08 16:22:48 +0000642
Michael Ludwig6a6de652020-04-30 20:16:36 -0400643 // If 'attemptShapeFallback' is true, and the original shape had been simplfied, this
644 // will re-route through drawShape() to see if we can avoid path rendering one more time.
Michael Ludwig7c12e282020-05-29 09:54:07 -0400645 void drawShapeUsingPathRenderer(const GrClip*, GrPaint&&, GrAA, const SkMatrix&,
Michael Ludwig6a6de652020-04-30 20:16:36 -0400646 const GrStyledShape&, bool attemptShapeFallback = true);
robertphillipsea461502015-05-26 11:38:03 -0700647
Chris Dalton08755122019-08-05 16:13:47 -0600648 void addOp(std::unique_ptr<GrOp>);
649
Brian Salomon348a0372018-10-31 10:42:18 -0400650 // Allows caller of addDrawOp to know which op list an op will be added to.
Greg Danielf41b2bd2019-08-22 16:19:24 -0400651 using WillAddOpFn = void(GrOp*, uint32_t opsTaskID);
Brian Salomon348a0372018-10-31 10:42:18 -0400652 // These perform processing specific to GrDrawOp-derived ops before recording them into an
653 // op list. Before adding the op to an op list the WillAddOpFn is called. Note that it
654 // will not be called in the event that the op is discarded. Moreover, the op may merge into
655 // another op after the function is called (either before addDrawOp returns or some time later).
Michael Ludwig7c12e282020-05-29 09:54:07 -0400656 //
657 // If the clip pointer is null, no clipping will be performed.
658 void addDrawOp(const GrClip*, std::unique_ptr<GrDrawOp>,
Brian Salomon348a0372018-10-31 10:42:18 -0400659 const std::function<WillAddOpFn>& = std::function<WillAddOpFn>());
robertphillips2334fb62015-06-17 05:43:33 -0700660
Robert Phillipsbf25d432017-04-07 10:08:53 -0400661 // Makes a copy of the proxy if it is necessary for the draw and places the texture that should
662 // be used by GrXferProcessor to access the destination color in 'result'. If the return
663 // value is false then a texture copy could not be made.
Michael Ludwig28e5f112020-06-09 10:57:24 -0400664 //
665 // The op should have already had setClippedBounds called on it.
666 bool SK_WARN_UNUSED_RESULT setupDstProxyView(const GrOp& op,
Greg Daniel524e28b2019-11-01 11:48:53 -0400667 GrXferProcessor::DstProxyView* result);
Brian Salomon467921e2017-03-06 16:17:12 -0500668
Greg Danielf41b2bd2019-08-22 16:19:24 -0400669 GrOpsTask* getOpsTask();
robertphillipsa106c622015-10-16 09:07:06 -0700670
Herb Derbyd29207a2020-06-08 13:50:19 -0400671 SkGlyphRunListPainter* glyphPainter() { return &fGlyphPainter; }
672
Brian Salomon8afde5f2020-04-01 16:22:00 -0400673 GrSurfaceProxyView fWriteView;
robertphillipsa106c622015-10-16 09:07:06 -0700674
Greg Danielf41b2bd2019-08-22 16:19:24 -0400675 // In MDB-mode the GrOpsTask can be closed by some other renderTargetContext that has picked
676 // it up. For this reason, the GrOpsTask should only ever be accessed via 'getOpsTask'.
677 sk_sp<GrOpsTask> fOpsTask;
robertphillips2334fb62015-06-17 05:43:33 -0700678
Brian Salomonf18b1d82017-10-27 11:30:49 -0400679 SkSurfaceProps fSurfaceProps;
Greg Danielf41b2bd2019-08-22 16:19:24 -0400680 bool fManagedOpsTask;
Robert Phillipse305cc1f2016-12-14 12:19:05 -0500681
Chris Daltoneffee202019-07-01 22:28:03 -0600682 int fNumStencilSamples = 0;
Chris Dalton6b982802019-06-27 13:53:46 -0600683#if GR_TEST_UTILS
684 bool fPreserveOpsOnFullClear_TestingOnly = false;
685#endif
Herb Derbyd29207a2020-06-08 13:50:19 -0400686 SkGlyphRunListPainter fGlyphPainter;
Robert Phillipse305cc1f2016-12-14 12:19:05 -0500687 typedef GrSurfaceContext INHERITED;
robertphillipsea461502015-05-26 11:38:03 -0700688};
689
690#endif