1cb93a386Sopenharmony_ci/*
2cb93a386Sopenharmony_ci * Copyright 2015 Google Inc.
3cb93a386Sopenharmony_ci *
4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be
5cb93a386Sopenharmony_ci * found in the LICENSE file.
6cb93a386Sopenharmony_ci */
7cb93a386Sopenharmony_ci
8cb93a386Sopenharmony_ci#ifndef SurfaceDrawContext_v1_DEFINED
9cb93a386Sopenharmony_ci#define SurfaceDrawContext_v1_DEFINED
10cb93a386Sopenharmony_ci
11cb93a386Sopenharmony_ci#include "include/core/SkBlurTypes.h"
12cb93a386Sopenharmony_ci#include "include/core/SkCanvas.h"
13cb93a386Sopenharmony_ci#include "include/core/SkDrawable.h"
14cb93a386Sopenharmony_ci#include "include/core/SkRefCnt.h"
15cb93a386Sopenharmony_ci#include "include/core/SkSurface.h"
16cb93a386Sopenharmony_ci#include "include/core/SkSurfaceProps.h"
17cb93a386Sopenharmony_ci#include "include/private/GrTypesPriv.h"
18cb93a386Sopenharmony_ci#include "src/core/SkGlyphRunPainter.h"
19cb93a386Sopenharmony_ci#include "src/gpu/GrPaint.h"
20cb93a386Sopenharmony_ci#include "src/gpu/GrRenderTargetProxy.h"
21cb93a386Sopenharmony_ci#include "src/gpu/GrSurfaceProxyView.h"
22cb93a386Sopenharmony_ci#include "src/gpu/GrXferProcessor.h"
23cb93a386Sopenharmony_ci#include "src/gpu/geometry/GrQuad.h"
24cb93a386Sopenharmony_ci#include "src/gpu/ops/OpsTask.h"
25cb93a386Sopenharmony_ci#include "src/gpu/v1/SurfaceFillContext_v1.h"
26cb93a386Sopenharmony_ci
27cb93a386Sopenharmony_ciclass GrBackendSemaphore;
28cb93a386Sopenharmony_ciclass GrClip;
29cb93a386Sopenharmony_ciclass GrColorSpaceXform;
30cb93a386Sopenharmony_ciclass GrDrawOp;
31cb93a386Sopenharmony_ciclass GrDstProxyView;
32cb93a386Sopenharmony_ciclass GrHardClip;
33cb93a386Sopenharmony_ciclass GrOp;
34cb93a386Sopenharmony_cistruct GrQuadSetEntry;
35cb93a386Sopenharmony_ciclass GrRenderTarget;
36cb93a386Sopenharmony_ciclass GrStyledShape;
37cb93a386Sopenharmony_ciclass GrStyle;
38cb93a386Sopenharmony_ciclass GrTextureProxy;
39cb93a386Sopenharmony_cistruct GrTextureSetEntry;
40cb93a386Sopenharmony_cistruct GrUserStencilSettings;
41cb93a386Sopenharmony_cistruct SkDrawShadowRec;
42cb93a386Sopenharmony_ciclass SkGlyphRunList;
43cb93a386Sopenharmony_cistruct SkIPoint;
44cb93a386Sopenharmony_cistruct SkIRect;
45cb93a386Sopenharmony_ciclass SkLatticeIter;
46cb93a386Sopenharmony_ciclass SkMatrixProvider;
47cb93a386Sopenharmony_ciclass SkMatrix;
48cb93a386Sopenharmony_ciclass SkPaint;
49cb93a386Sopenharmony_ciclass SkPath;
50cb93a386Sopenharmony_cistruct SkPoint;
51cb93a386Sopenharmony_cistruct SkRect;
52cb93a386Sopenharmony_ciclass SkRegion;
53cb93a386Sopenharmony_ciclass SkRRect;
54cb93a386Sopenharmony_cistruct SkRSXform;
55cb93a386Sopenharmony_ciclass SkTextBlob;
56cb93a386Sopenharmony_ciclass SkVertices;
57cb93a386Sopenharmony_ci
58cb93a386Sopenharmony_cinamespace skgpu::v1 {
59cb93a386Sopenharmony_ci
60cb93a386Sopenharmony_ci/**
61cb93a386Sopenharmony_ci * A helper object to orchestrate commands (draws, etc...) for GrSurfaces that are GrRenderTargets.
62cb93a386Sopenharmony_ci */
63cb93a386Sopenharmony_ciclass SurfaceDrawContext final : public SurfaceFillContext {
64cb93a386Sopenharmony_cipublic:
65cb93a386Sopenharmony_ci    static std::unique_ptr<SurfaceDrawContext> Make(GrRecordingContext*,
66cb93a386Sopenharmony_ci                                                    GrColorType,
67cb93a386Sopenharmony_ci                                                    sk_sp<GrSurfaceProxy>,
68cb93a386Sopenharmony_ci                                                    sk_sp<SkColorSpace>,
69cb93a386Sopenharmony_ci                                                    GrSurfaceOrigin,
70cb93a386Sopenharmony_ci                                                    const SkSurfaceProps&,
71cb93a386Sopenharmony_ci                                                    bool flushTimeOpsTask = false);
72cb93a386Sopenharmony_ci
73cb93a386Sopenharmony_ci    /* Uses the default texture format for the color type */
74cb93a386Sopenharmony_ci    static std::unique_ptr<SurfaceDrawContext> Make(GrRecordingContext*,
75cb93a386Sopenharmony_ci                                                    GrColorType,
76cb93a386Sopenharmony_ci                                                    sk_sp<SkColorSpace>,
77cb93a386Sopenharmony_ci                                                    SkBackingFit,
78cb93a386Sopenharmony_ci                                                    SkISize dimensions,
79cb93a386Sopenharmony_ci                                                    const SkSurfaceProps&,
80cb93a386Sopenharmony_ci                                                    int sampleCnt = 1,
81cb93a386Sopenharmony_ci                                                    GrMipmapped = GrMipmapped::kNo,
82cb93a386Sopenharmony_ci                                                    GrProtected = GrProtected::kNo,
83cb93a386Sopenharmony_ci                                                    GrSurfaceOrigin = kBottomLeft_GrSurfaceOrigin,
84cb93a386Sopenharmony_ci                                                    SkBudgeted = SkBudgeted::kYes);
85cb93a386Sopenharmony_ci
86cb93a386Sopenharmony_ci    /**
87cb93a386Sopenharmony_ci     * Takes custom swizzles rather than determining swizzles from color type and format.
88cb93a386Sopenharmony_ci     * It will have color type kUnknown.
89cb93a386Sopenharmony_ci     */
90cb93a386Sopenharmony_ci    static std::unique_ptr<SurfaceDrawContext> Make(GrRecordingContext*,
91cb93a386Sopenharmony_ci                                                    sk_sp<SkColorSpace>,
92cb93a386Sopenharmony_ci                                                    SkBackingFit,
93cb93a386Sopenharmony_ci                                                    SkISize dimensions,
94cb93a386Sopenharmony_ci                                                    const GrBackendFormat&,
95cb93a386Sopenharmony_ci                                                    int sampleCnt,
96cb93a386Sopenharmony_ci                                                    GrMipmapped,
97cb93a386Sopenharmony_ci                                                    GrProtected,
98cb93a386Sopenharmony_ci                                                    GrSwizzle readSwizzle,
99cb93a386Sopenharmony_ci                                                    GrSwizzle writeSwizzle,
100cb93a386Sopenharmony_ci                                                    GrSurfaceOrigin,
101cb93a386Sopenharmony_ci                                                    SkBudgeted,
102cb93a386Sopenharmony_ci                                                    const SkSurfaceProps&);
103cb93a386Sopenharmony_ci
104cb93a386Sopenharmony_ci    // Same as previous factory but will try to use fallback GrColorTypes if the one passed in
105cb93a386Sopenharmony_ci    // fails. The fallback GrColorType will have at least the number of channels and precision per
106cb93a386Sopenharmony_ci    // channel as the passed in GrColorType. It may also swizzle the changes (e.g., BGRA -> RGBA).
107cb93a386Sopenharmony_ci    // SRGB-ness will be preserved.
108cb93a386Sopenharmony_ci    static std::unique_ptr<SurfaceDrawContext> MakeWithFallback(
109cb93a386Sopenharmony_ci            GrRecordingContext*,
110cb93a386Sopenharmony_ci            GrColorType,
111cb93a386Sopenharmony_ci            sk_sp<SkColorSpace>,
112cb93a386Sopenharmony_ci            SkBackingFit,
113cb93a386Sopenharmony_ci            SkISize dimensions,
114cb93a386Sopenharmony_ci            const SkSurfaceProps&,
115cb93a386Sopenharmony_ci            int sampleCnt = 1,
116cb93a386Sopenharmony_ci            GrMipmapped = GrMipmapped::kNo,
117cb93a386Sopenharmony_ci            GrProtected = GrProtected::kNo,
118cb93a386Sopenharmony_ci            GrSurfaceOrigin = kBottomLeft_GrSurfaceOrigin,
119cb93a386Sopenharmony_ci            SkBudgeted = SkBudgeted::kYes);
120cb93a386Sopenharmony_ci
121cb93a386Sopenharmony_ci    // Creates a SurfaceDrawContext that wraps the passed in GrBackendTexture.
122cb93a386Sopenharmony_ci    static std::unique_ptr<SurfaceDrawContext> MakeFromBackendTexture(
123cb93a386Sopenharmony_ci            GrRecordingContext*,
124cb93a386Sopenharmony_ci            GrColorType,
125cb93a386Sopenharmony_ci            sk_sp<SkColorSpace>,
126cb93a386Sopenharmony_ci            const GrBackendTexture&,
127cb93a386Sopenharmony_ci            int sampleCnt,
128cb93a386Sopenharmony_ci            GrSurfaceOrigin,
129cb93a386Sopenharmony_ci            const SkSurfaceProps&,
130cb93a386Sopenharmony_ci            sk_sp<GrRefCntedCallback> releaseHelper);
131cb93a386Sopenharmony_ci
132cb93a386Sopenharmony_ci    SurfaceDrawContext(GrRecordingContext*,
133cb93a386Sopenharmony_ci                       GrSurfaceProxyView readView,
134cb93a386Sopenharmony_ci                       GrSurfaceProxyView writeView,
135cb93a386Sopenharmony_ci                       GrColorType,
136cb93a386Sopenharmony_ci                       sk_sp<SkColorSpace>,
137cb93a386Sopenharmony_ci                       const SkSurfaceProps&,
138cb93a386Sopenharmony_ci                       bool flushTimeOpsTask = false);
139cb93a386Sopenharmony_ci
140cb93a386Sopenharmony_ci    ~SurfaceDrawContext() override;
141cb93a386Sopenharmony_ci
142cb93a386Sopenharmony_ci    /**
143cb93a386Sopenharmony_ci     *  Draw everywhere (respecting the clip) with the paint.
144cb93a386Sopenharmony_ci     */
145cb93a386Sopenharmony_ci    void drawPaint(const GrClip*, GrPaint&&, const SkMatrix& viewMatrix);
146cb93a386Sopenharmony_ci
147cb93a386Sopenharmony_ci    /**
148cb93a386Sopenharmony_ci     * Draw the rect using a paint.
149cb93a386Sopenharmony_ci     * @param paint        describes how to color pixels.
150cb93a386Sopenharmony_ci     * @param GrAA         Controls whether rect is antialiased
151cb93a386Sopenharmony_ci     * @param viewMatrix   transformation matrix
152cb93a386Sopenharmony_ci     * @param style        The style to apply. Null means fill. Currently path effects are not
153cb93a386Sopenharmony_ci     *                     allowed.
154cb93a386Sopenharmony_ci     * The rects coords are used to access the paint (through texture matrix)
155cb93a386Sopenharmony_ci     */
156cb93a386Sopenharmony_ci    void drawRect(const GrClip*,
157cb93a386Sopenharmony_ci                  GrPaint&& paint,
158cb93a386Sopenharmony_ci                  GrAA,
159cb93a386Sopenharmony_ci                  const SkMatrix& viewMatrix,
160cb93a386Sopenharmony_ci                  const SkRect&,
161cb93a386Sopenharmony_ci                  const GrStyle* style = nullptr);
162cb93a386Sopenharmony_ci
163cb93a386Sopenharmony_ci    /**
164cb93a386Sopenharmony_ci     * Maps a rectangle of shader coordinates to a rectangle and fills that rectangle.
165cb93a386Sopenharmony_ci     *
166cb93a386Sopenharmony_ci     * @param GrPaint      describes how to color pixels.
167cb93a386Sopenharmony_ci     * @param GrAA         Controls whether rect is antialiased
168cb93a386Sopenharmony_ci     * @param SkMatrix     transformation matrix which applies to rectToDraw
169cb93a386Sopenharmony_ci     * @param rectToDraw   the rectangle to draw
170cb93a386Sopenharmony_ci     * @param localRect    the rectangle of shader coordinates applied to rectToDraw
171cb93a386Sopenharmony_ci     */
172cb93a386Sopenharmony_ci    void fillRectToRect(const GrClip*,
173cb93a386Sopenharmony_ci                        GrPaint&&,
174cb93a386Sopenharmony_ci                        GrAA,
175cb93a386Sopenharmony_ci                        const SkMatrix&,
176cb93a386Sopenharmony_ci                        const SkRect& rectToDraw,
177cb93a386Sopenharmony_ci                        const SkRect& localRect);
178cb93a386Sopenharmony_ci
179cb93a386Sopenharmony_ci    /**
180cb93a386Sopenharmony_ci     * Fills a block of pixels with a paint and a localMatrix, respecting the clip.
181cb93a386Sopenharmony_ci     */
182cb93a386Sopenharmony_ci    void fillPixelsWithLocalMatrix(const GrClip* clip,
183cb93a386Sopenharmony_ci                                   GrPaint&& paint,
184cb93a386Sopenharmony_ci                                   const SkIRect& bounds,
185cb93a386Sopenharmony_ci                                   const SkMatrix& localMatrix) {
186cb93a386Sopenharmony_ci        SkRect rect = SkRect::Make(bounds);
187cb93a386Sopenharmony_ci        DrawQuad quad{GrQuad::MakeFromRect(rect, SkMatrix::I()),
188cb93a386Sopenharmony_ci                      GrQuad::MakeFromRect(rect, localMatrix), GrQuadAAFlags::kNone};
189cb93a386Sopenharmony_ci        this->drawFilledQuad(clip, std::move(paint), GrAA::kNo, &quad);
190cb93a386Sopenharmony_ci    }
191cb93a386Sopenharmony_ci
192cb93a386Sopenharmony_ci    /**
193cb93a386Sopenharmony_ci     * Creates an op that draws a fill rect with per-edge control over anti-aliasing.
194cb93a386Sopenharmony_ci     *
195cb93a386Sopenharmony_ci     * This is a specialized version of fillQuadWithEdgeAA, but is kept separate since knowing
196cb93a386Sopenharmony_ci     * the geometry is a rectangle affords more optimizations.
197cb93a386Sopenharmony_ci     */
198cb93a386Sopenharmony_ci    void fillRectWithEdgeAA(const GrClip* clip, GrPaint&& paint, GrAA aa, GrQuadAAFlags edgeAA,
199cb93a386Sopenharmony_ci                            const SkMatrix& viewMatrix, const SkRect& rect,
200cb93a386Sopenharmony_ci                            const SkRect* optionalLocalRect = nullptr) {
201cb93a386Sopenharmony_ci        if (edgeAA == GrQuadAAFlags::kAll) {
202cb93a386Sopenharmony_ci            this->fillRectToRect(clip, std::move(paint), aa, viewMatrix, rect,
203cb93a386Sopenharmony_ci                                 (optionalLocalRect) ? *optionalLocalRect : rect);
204cb93a386Sopenharmony_ci            return;
205cb93a386Sopenharmony_ci        }
206cb93a386Sopenharmony_ci        const SkRect& localRect = optionalLocalRect ? *optionalLocalRect : rect;
207cb93a386Sopenharmony_ci        DrawQuad quad{GrQuad::MakeFromRect(rect, viewMatrix), GrQuad(localRect), edgeAA};
208cb93a386Sopenharmony_ci        this->drawFilledQuad(clip, std::move(paint), aa, &quad);
209cb93a386Sopenharmony_ci    }
210cb93a386Sopenharmony_ci
211cb93a386Sopenharmony_ci    /**
212cb93a386Sopenharmony_ci     * Similar to fillRectWithEdgeAA but draws an arbitrary 2D convex quadrilateral transformed
213cb93a386Sopenharmony_ci     * by 'viewMatrix', with per-edge control over anti-aliasing. The quad should follow the
214cb93a386Sopenharmony_ci     * ordering used by SkRect::toQuad(), which determines how the edge AA is applied:
215cb93a386Sopenharmony_ci     *  - "top" = points [0] and [1]
216cb93a386Sopenharmony_ci     *  - "right" = points[1] and [2]
217cb93a386Sopenharmony_ci     *  - "bottom" = points[2] and [3]
218cb93a386Sopenharmony_ci     *  - "left" = points[3] and [0]
219cb93a386Sopenharmony_ci     *
220cb93a386Sopenharmony_ci     * The last argument, 'optionalLocalQuad', can be null if no separate local coordinates are
221cb93a386Sopenharmony_ci     * necessary.
222cb93a386Sopenharmony_ci     */
223cb93a386Sopenharmony_ci    void fillQuadWithEdgeAA(const GrClip* clip, GrPaint&& paint, GrAA aa, GrQuadAAFlags edgeAA,
224cb93a386Sopenharmony_ci                            const SkMatrix& viewMatrix, const SkPoint points[4],
225cb93a386Sopenharmony_ci                            const SkPoint optionalLocalPoints[4]) {
226cb93a386Sopenharmony_ci        const SkPoint* localPoints = optionalLocalPoints ? optionalLocalPoints : points;
227cb93a386Sopenharmony_ci        DrawQuad quad{GrQuad::MakeFromSkQuad(points, viewMatrix),
228cb93a386Sopenharmony_ci                      GrQuad::MakeFromSkQuad(localPoints, SkMatrix::I()), edgeAA};
229cb93a386Sopenharmony_ci        this->drawFilledQuad(clip, std::move(paint), aa, &quad);
230cb93a386Sopenharmony_ci    }
231cb93a386Sopenharmony_ci
232cb93a386Sopenharmony_ci    // TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer
233cb93a386Sopenharmony_ci    void drawQuadSet(const GrClip* clip, GrPaint&& paint, GrAA aa, const SkMatrix& viewMatrix,
234cb93a386Sopenharmony_ci                     const GrQuadSetEntry[], int cnt);
235cb93a386Sopenharmony_ci
236cb93a386Sopenharmony_ci    /**
237cb93a386Sopenharmony_ci     * Creates an op that draws a subrectangle of a texture. The passed color is modulated by the
238cb93a386Sopenharmony_ci     * texture's color. 'srcRect' specifies the rectangle of the texture to draw. 'dstRect'
239cb93a386Sopenharmony_ci     * specifies the rectangle to draw in local coords which will be transformed by 'viewMatrix' to
240cb93a386Sopenharmony_ci     * device space.
241cb93a386Sopenharmony_ci     */
242cb93a386Sopenharmony_ci    void drawTexture(const GrClip*,
243cb93a386Sopenharmony_ci                     GrSurfaceProxyView,
244cb93a386Sopenharmony_ci                     SkAlphaType,
245cb93a386Sopenharmony_ci                     GrSamplerState::Filter,
246cb93a386Sopenharmony_ci                     GrSamplerState::MipmapMode,
247cb93a386Sopenharmony_ci                     SkBlendMode,
248cb93a386Sopenharmony_ci                     const SkPMColor4f&,
249cb93a386Sopenharmony_ci                     const SkRect& srcRect,
250cb93a386Sopenharmony_ci                     const SkRect& dstRect,
251cb93a386Sopenharmony_ci                     GrAA,
252cb93a386Sopenharmony_ci                     GrQuadAAFlags,
253cb93a386Sopenharmony_ci                     SkCanvas::SrcRectConstraint,
254cb93a386Sopenharmony_ci                     const SkMatrix&,
255cb93a386Sopenharmony_ci                     sk_sp<GrColorSpaceXform>);
256cb93a386Sopenharmony_ci
257cb93a386Sopenharmony_ci    /**
258cb93a386Sopenharmony_ci     * Variant of drawTexture that instead draws the texture applied to 'dstQuad' transformed by
259cb93a386Sopenharmony_ci     * 'viewMatrix', using the 'srcQuad' texture coordinates clamped to the optional 'subset'. If
260cb93a386Sopenharmony_ci     * 'subset' is null, it's equivalent to using the fast src rect constraint. If 'subset' is
261cb93a386Sopenharmony_ci     * provided, the strict src rect constraint is applied using 'subset'.
262cb93a386Sopenharmony_ci     */
263cb93a386Sopenharmony_ci    void drawTextureQuad(const GrClip* clip,
264cb93a386Sopenharmony_ci                         GrSurfaceProxyView view,
265cb93a386Sopenharmony_ci                         GrColorType srcColorType,
266cb93a386Sopenharmony_ci                         SkAlphaType srcAlphaType,
267cb93a386Sopenharmony_ci                         GrSamplerState::Filter filter,
268cb93a386Sopenharmony_ci                         GrSamplerState::MipmapMode mm,
269cb93a386Sopenharmony_ci                         SkBlendMode mode,
270cb93a386Sopenharmony_ci                         const SkPMColor4f& color,
271cb93a386Sopenharmony_ci                         const SkPoint srcQuad[4],
272cb93a386Sopenharmony_ci                         const SkPoint dstQuad[4],
273cb93a386Sopenharmony_ci                         GrAA aa,
274cb93a386Sopenharmony_ci                         GrQuadAAFlags edgeAA,
275cb93a386Sopenharmony_ci                         const SkRect* subset,
276cb93a386Sopenharmony_ci                         const SkMatrix& viewMatrix,
277cb93a386Sopenharmony_ci                         sk_sp<GrColorSpaceXform> texXform) {
278cb93a386Sopenharmony_ci        DrawQuad quad{GrQuad::MakeFromSkQuad(dstQuad, viewMatrix),
279cb93a386Sopenharmony_ci                      GrQuad::MakeFromSkQuad(srcQuad, SkMatrix::I()), edgeAA};
280cb93a386Sopenharmony_ci        this->drawTexturedQuad(clip, std::move(view), srcAlphaType, std::move(texXform), filter, mm,
281cb93a386Sopenharmony_ci                               color, mode, aa, &quad, subset);
282cb93a386Sopenharmony_ci    }
283cb93a386Sopenharmony_ci
284cb93a386Sopenharmony_ci    /**
285cb93a386Sopenharmony_ci     * Draws a set of textures with a shared filter, color, view matrix, color xform, and
286cb93a386Sopenharmony_ci     * texture color xform. The textures must all have the same GrTextureType and GrConfig.
287cb93a386Sopenharmony_ci     *
288cb93a386Sopenharmony_ci     * If any entries provide a non-null fDstClip array, it will be read from immediately based on
289cb93a386Sopenharmony_ci     * fDstClipCount, so the pointer can become invalid after this returns.
290cb93a386Sopenharmony_ci     *
291cb93a386Sopenharmony_ci     * 'proxRunCnt' is the number of proxy changes encountered in the entry array. Technically this
292cb93a386Sopenharmony_ci     * can be inferred from the array within this function, but the information is already known
293cb93a386Sopenharmony_ci     * by SkGpuDevice, so no need to incur another iteration over the array.
294cb93a386Sopenharmony_ci     */
295cb93a386Sopenharmony_ci    void drawTextureSet(const GrClip*,
296cb93a386Sopenharmony_ci                        GrTextureSetEntry[],
297cb93a386Sopenharmony_ci                        int cnt,
298cb93a386Sopenharmony_ci                        int proxyRunCnt,
299cb93a386Sopenharmony_ci                        GrSamplerState::Filter,
300cb93a386Sopenharmony_ci                        GrSamplerState::MipmapMode,
301cb93a386Sopenharmony_ci                        SkBlendMode mode,
302cb93a386Sopenharmony_ci                        GrAA aa,
303cb93a386Sopenharmony_ci                        SkCanvas::SrcRectConstraint,
304cb93a386Sopenharmony_ci                        const SkMatrix& viewMatrix,
305cb93a386Sopenharmony_ci                        sk_sp<GrColorSpaceXform> texXform);
306cb93a386Sopenharmony_ci
307cb93a386Sopenharmony_ci    /**
308cb93a386Sopenharmony_ci     * Draw a roundrect using a paint.
309cb93a386Sopenharmony_ci     *
310cb93a386Sopenharmony_ci     * @param paint       describes how to color pixels.
311cb93a386Sopenharmony_ci     * @param GrAA        Controls whether rrect is antialiased.
312cb93a386Sopenharmony_ci     * @param viewMatrix  transformation matrix
313cb93a386Sopenharmony_ci     * @param rrect       the roundrect to draw
314cb93a386Sopenharmony_ci     * @param style       style to apply to the rrect. Currently path effects are not allowed.
315cb93a386Sopenharmony_ci     */
316cb93a386Sopenharmony_ci    void drawRRect(const GrClip*,
317cb93a386Sopenharmony_ci                   GrPaint&&,
318cb93a386Sopenharmony_ci                   GrAA,
319cb93a386Sopenharmony_ci                   const SkMatrix& viewMatrix,
320cb93a386Sopenharmony_ci                   const SkRRect& rrect,
321cb93a386Sopenharmony_ci                   const GrStyle& style);
322cb93a386Sopenharmony_ci
323cb93a386Sopenharmony_ci    /**
324cb93a386Sopenharmony_ci     * Use a fast method to render the ambient and spot shadows for a path.
325cb93a386Sopenharmony_ci     * Will return false if not possible for the given path.
326cb93a386Sopenharmony_ci     *
327cb93a386Sopenharmony_ci     * @param viewMatrix   transformation matrix
328cb93a386Sopenharmony_ci     * @param path         the path to shadow
329cb93a386Sopenharmony_ci     * @param rec          parameters for shadow rendering
330cb93a386Sopenharmony_ci     */
331cb93a386Sopenharmony_ci    bool drawFastShadow(const GrClip*,
332cb93a386Sopenharmony_ci                        const SkMatrix& viewMatrix,
333cb93a386Sopenharmony_ci                        const SkPath& path,
334cb93a386Sopenharmony_ci                        const SkDrawShadowRec& rec);
335cb93a386Sopenharmony_ci
336cb93a386Sopenharmony_ci    /**
337cb93a386Sopenharmony_ci     * Draws a path.
338cb93a386Sopenharmony_ci     *
339cb93a386Sopenharmony_ci     * @param paint         describes how to color pixels.
340cb93a386Sopenharmony_ci     * @param GrAA          Controls whether the path is antialiased.
341cb93a386Sopenharmony_ci     * @param viewMatrix    transformation matrix
342cb93a386Sopenharmony_ci     * @param path          the path to draw
343cb93a386Sopenharmony_ci     * @param style         style to apply to the path.
344cb93a386Sopenharmony_ci     */
345cb93a386Sopenharmony_ci    void drawPath(const GrClip*,
346cb93a386Sopenharmony_ci                  GrPaint&&,
347cb93a386Sopenharmony_ci                  GrAA,
348cb93a386Sopenharmony_ci                  const SkMatrix& viewMatrix,
349cb93a386Sopenharmony_ci                  const SkPath&,
350cb93a386Sopenharmony_ci                  const GrStyle&);
351cb93a386Sopenharmony_ci
352cb93a386Sopenharmony_ci    /**
353cb93a386Sopenharmony_ci     * Draws a shape.
354cb93a386Sopenharmony_ci     *
355cb93a386Sopenharmony_ci     * @param paint         describes how to color pixels.
356cb93a386Sopenharmony_ci     * @param GrAA          Controls whether the path is antialiased.
357cb93a386Sopenharmony_ci     * @param viewMatrix    transformation matrix
358cb93a386Sopenharmony_ci     * @param shape         the shape to draw
359cb93a386Sopenharmony_ci     */
360cb93a386Sopenharmony_ci    void drawShape(const GrClip*,
361cb93a386Sopenharmony_ci                   GrPaint&&,
362cb93a386Sopenharmony_ci                   GrAA,
363cb93a386Sopenharmony_ci                   const SkMatrix& viewMatrix,
364cb93a386Sopenharmony_ci                   GrStyledShape&&);
365cb93a386Sopenharmony_ci
366cb93a386Sopenharmony_ci    /**
367cb93a386Sopenharmony_ci     * Draws vertices with a paint.
368cb93a386Sopenharmony_ci     *
369cb93a386Sopenharmony_ci     * @param   paint            describes how to color pixels.
370cb93a386Sopenharmony_ci     * @param   viewMatrix       transformation matrix
371cb93a386Sopenharmony_ci     * @param   vertices         specifies the mesh to draw.
372cb93a386Sopenharmony_ci     * @param   overridePrimType primitive type to draw. If NULL, derive prim type from vertices.
373cb93a386Sopenharmony_ci     */
374cb93a386Sopenharmony_ci    void drawVertices(const GrClip*,
375cb93a386Sopenharmony_ci                      GrPaint&& paint,
376cb93a386Sopenharmony_ci                      const SkMatrixProvider& matrixProvider,
377cb93a386Sopenharmony_ci                      sk_sp<SkVertices> vertices,
378cb93a386Sopenharmony_ci                      GrPrimitiveType* overridePrimType = nullptr);
379cb93a386Sopenharmony_ci
380cb93a386Sopenharmony_ci    /**
381cb93a386Sopenharmony_ci     * Draws textured sprites from an atlas with a paint. This currently does not support AA for the
382cb93a386Sopenharmony_ci     * sprite rectangle edges.
383cb93a386Sopenharmony_ci     *
384cb93a386Sopenharmony_ci     * @param   paint           describes how to color pixels.
385cb93a386Sopenharmony_ci     * @param   viewMatrix      transformation matrix
386cb93a386Sopenharmony_ci     * @param   spriteCount     number of sprites.
387cb93a386Sopenharmony_ci     * @param   xform           array of compressed transformation data, required.
388cb93a386Sopenharmony_ci     * @param   texRect         array of texture rectangles used to access the paint.
389cb93a386Sopenharmony_ci     * @param   colors          optional array of per-sprite colors, supercedes
390cb93a386Sopenharmony_ci     *                          the paint's color field.
391cb93a386Sopenharmony_ci     */
392cb93a386Sopenharmony_ci    void drawAtlas(const GrClip*,
393cb93a386Sopenharmony_ci                   GrPaint&& paint,
394cb93a386Sopenharmony_ci                   const SkMatrix& viewMatrix,
395cb93a386Sopenharmony_ci                   int spriteCount,
396cb93a386Sopenharmony_ci                   const SkRSXform xform[],
397cb93a386Sopenharmony_ci                   const SkRect texRect[],
398cb93a386Sopenharmony_ci                   const SkColor colors[]);
399cb93a386Sopenharmony_ci
400cb93a386Sopenharmony_ci    /**
401cb93a386Sopenharmony_ci     * Draws a region.
402cb93a386Sopenharmony_ci     *
403cb93a386Sopenharmony_ci     * @param paint         describes how to color pixels
404cb93a386Sopenharmony_ci     * @param viewMatrix    transformation matrix
405cb93a386Sopenharmony_ci     * @param aa            should the rects of the region be antialiased.
406cb93a386Sopenharmony_ci     * @param region        the region to be drawn
407cb93a386Sopenharmony_ci     * @param style         style to apply to the region
408cb93a386Sopenharmony_ci     */
409cb93a386Sopenharmony_ci    void drawRegion(const GrClip*,
410cb93a386Sopenharmony_ci                    GrPaint&& paint,
411cb93a386Sopenharmony_ci                    GrAA aa,
412cb93a386Sopenharmony_ci                    const SkMatrix& viewMatrix,
413cb93a386Sopenharmony_ci                    const SkRegion& region,
414cb93a386Sopenharmony_ci                    const GrStyle& style,
415cb93a386Sopenharmony_ci                    const GrUserStencilSettings* ss = nullptr);
416cb93a386Sopenharmony_ci
417cb93a386Sopenharmony_ci    /**
418cb93a386Sopenharmony_ci     * Draws an oval.
419cb93a386Sopenharmony_ci     *
420cb93a386Sopenharmony_ci     * @param paint         describes how to color pixels.
421cb93a386Sopenharmony_ci     * @param GrAA          Controls whether the oval is antialiased.
422cb93a386Sopenharmony_ci     * @param viewMatrix    transformation matrix
423cb93a386Sopenharmony_ci     * @param oval          the bounding rect of the oval.
424cb93a386Sopenharmony_ci     * @param style         style to apply to the oval. Currently path effects are not allowed.
425cb93a386Sopenharmony_ci     */
426cb93a386Sopenharmony_ci    void drawOval(const GrClip*,
427cb93a386Sopenharmony_ci                  GrPaint&& paint,
428cb93a386Sopenharmony_ci                  GrAA,
429cb93a386Sopenharmony_ci                  const SkMatrix& viewMatrix,
430cb93a386Sopenharmony_ci                  const SkRect& oval,
431cb93a386Sopenharmony_ci                  const GrStyle& style);
432cb93a386Sopenharmony_ci
433cb93a386Sopenharmony_ci    /**
434cb93a386Sopenharmony_ci     * Draws a partial arc of an oval.
435cb93a386Sopenharmony_ci     *
436cb93a386Sopenharmony_ci     * @param paint         describes how to color pixels.
437cb93a386Sopenharmony_ci     * @param GrGrAA        Controls whether the arc is antialiased.
438cb93a386Sopenharmony_ci     * @param viewMatrix    transformation matrix.
439cb93a386Sopenharmony_ci     * @param oval          the bounding rect of the oval.
440cb93a386Sopenharmony_ci     * @param startAngle    starting angle in degrees.
441cb93a386Sopenharmony_ci     * @param sweepAngle    angle to sweep in degrees. Must be in (-360, 360)
442cb93a386Sopenharmony_ci     * @param useCenter     true means that the implied path begins at the oval center, connects as
443cb93a386Sopenharmony_ci     *                      a line to the point indicated by the start contains the arc indicated by
444cb93a386Sopenharmony_ci     *                      the sweep angle. If false the line beginning at the center point is
445cb93a386Sopenharmony_ci     *                      omitted.
446cb93a386Sopenharmony_ci     * @param style         style to apply to the oval.
447cb93a386Sopenharmony_ci     */
448cb93a386Sopenharmony_ci    void drawArc(const GrClip*,
449cb93a386Sopenharmony_ci                 GrPaint&& paint,
450cb93a386Sopenharmony_ci                 GrAA,
451cb93a386Sopenharmony_ci                 const SkMatrix& viewMatrix,
452cb93a386Sopenharmony_ci                 const SkRect& oval,
453cb93a386Sopenharmony_ci                 SkScalar startAngle,
454cb93a386Sopenharmony_ci                 SkScalar sweepAngle,
455cb93a386Sopenharmony_ci                 bool useCenter,
456cb93a386Sopenharmony_ci                 const GrStyle& style);
457cb93a386Sopenharmony_ci
458cb93a386Sopenharmony_ci    /**
459cb93a386Sopenharmony_ci     * Draw the image as a set of rects, specified by |iter|.
460cb93a386Sopenharmony_ci     */
461cb93a386Sopenharmony_ci    void drawImageLattice(const GrClip*,
462cb93a386Sopenharmony_ci                          GrPaint&&,
463cb93a386Sopenharmony_ci                          const SkMatrix& viewMatrix,
464cb93a386Sopenharmony_ci                          GrSurfaceProxyView,
465cb93a386Sopenharmony_ci                          SkAlphaType alphaType,
466cb93a386Sopenharmony_ci                          sk_sp<GrColorSpaceXform>,
467cb93a386Sopenharmony_ci                          GrSamplerState::Filter,
468cb93a386Sopenharmony_ci                          std::unique_ptr<SkLatticeIter>,
469cb93a386Sopenharmony_ci                          const SkRect& dst);
470cb93a386Sopenharmony_ci
471cb93a386Sopenharmony_ci    /**
472cb93a386Sopenharmony_ci     * Draw the text specified by the SkGlyphRunList.
473cb93a386Sopenharmony_ci     *
474cb93a386Sopenharmony_ci     * @param viewMatrix      transformationMatrix
475cb93a386Sopenharmony_ci     * @param glyphRunList    text, text positions, and paint.
476cb93a386Sopenharmony_ci     */
477cb93a386Sopenharmony_ci    void drawGlyphRunList(const GrClip*,
478cb93a386Sopenharmony_ci                          const SkMatrixProvider& viewMatrix,
479cb93a386Sopenharmony_ci                          const SkGlyphRunList& glyphRunList,
480cb93a386Sopenharmony_ci                          const SkPaint& paint);
481cb93a386Sopenharmony_ci
482cb93a386Sopenharmony_ci    /**
483cb93a386Sopenharmony_ci     * Draw the text specified by the SkGlyphRunList.
484cb93a386Sopenharmony_ci     *
485cb93a386Sopenharmony_ci     * @param viewMatrix      transformationMatrix
486cb93a386Sopenharmony_ci     * @param glyphRunList    text, text positions, and paint.
487cb93a386Sopenharmony_ci     */
488cb93a386Sopenharmony_ci    void drawGlyphRunListWithCache(const GrClip*,
489cb93a386Sopenharmony_ci                                   const SkMatrixProvider& viewMatrix,
490cb93a386Sopenharmony_ci                                   const SkGlyphRunList& glyphRunList,
491cb93a386Sopenharmony_ci                                   const SkPaint& paint);
492cb93a386Sopenharmony_ci
493cb93a386Sopenharmony_ci    /**
494cb93a386Sopenharmony_ci     * Draw the text specified by the SkGlyphRunList.
495cb93a386Sopenharmony_ci     *
496cb93a386Sopenharmony_ci     * @param viewMatrix      transformationMatrix
497cb93a386Sopenharmony_ci     * @param glyphRunList    text, text positions, and paint.
498cb93a386Sopenharmony_ci     */
499cb93a386Sopenharmony_ci    void drawGlyphRunListNoCache(const GrClip*,
500cb93a386Sopenharmony_ci                                 const SkMatrixProvider& viewMatrix,
501cb93a386Sopenharmony_ci                                 const SkGlyphRunList& glyphRunList,
502cb93a386Sopenharmony_ci                                 const SkPaint& paint);
503cb93a386Sopenharmony_ci
504cb93a386Sopenharmony_ci    /**
505cb93a386Sopenharmony_ci     * Adds the necessary signal and wait semaphores and adds the passed in SkDrawable to the
506cb93a386Sopenharmony_ci     * command stream.
507cb93a386Sopenharmony_ci     */
508cb93a386Sopenharmony_ci    void drawDrawable(std::unique_ptr<SkDrawable::GpuDrawHandler>, const SkRect& bounds);
509cb93a386Sopenharmony_ci
510cb93a386Sopenharmony_ci    // called to note the last clip drawn to the stencil buffer.
511cb93a386Sopenharmony_ci    // TODO: remove after clipping overhaul.
512cb93a386Sopenharmony_ci    void setLastClip(uint32_t clipStackGenID,
513cb93a386Sopenharmony_ci                     const SkIRect& devClipBounds,
514cb93a386Sopenharmony_ci                     int numClipAnalyticElements);
515cb93a386Sopenharmony_ci
516cb93a386Sopenharmony_ci    // called to determine if we have to render the clip into SB.
517cb93a386Sopenharmony_ci    // TODO: remove after clipping overhaul.
518cb93a386Sopenharmony_ci    bool mustRenderClip(uint32_t clipStackGenID,
519cb93a386Sopenharmony_ci                        const SkIRect& devClipBounds,
520cb93a386Sopenharmony_ci                        int numClipAnalyticElements);
521cb93a386Sopenharmony_ci
522cb93a386Sopenharmony_ci    void clearStencilClip(const SkIRect& scissor, bool insideStencilMask) {
523cb93a386Sopenharmony_ci        this->internalStencilClear(&scissor, insideStencilMask);
524cb93a386Sopenharmony_ci    }
525cb93a386Sopenharmony_ci
526cb93a386Sopenharmony_ci    // While this can take a general clip, since ClipStack relies on this function, it must take
527cb93a386Sopenharmony_ci    // care to only provide hard clips or we could get stuck in a loop. The general clip is needed
528cb93a386Sopenharmony_ci    // so that path renderers can use this function.
529cb93a386Sopenharmony_ci    void stencilRect(const GrClip* clip,
530cb93a386Sopenharmony_ci                     const GrUserStencilSettings* ss,
531cb93a386Sopenharmony_ci                     GrPaint&& paint,
532cb93a386Sopenharmony_ci                     GrAA doStencilMSAA,
533cb93a386Sopenharmony_ci                     const SkMatrix& viewMatrix,
534cb93a386Sopenharmony_ci                     const SkRect& rect,
535cb93a386Sopenharmony_ci                     const SkMatrix* localMatrix = nullptr) {
536cb93a386Sopenharmony_ci        // Since this provides stencil settings to drawFilledQuad, it performs a different AA type
537cb93a386Sopenharmony_ci        // resolution compared to regular rect draws, which is the main reason it remains separate.
538cb93a386Sopenharmony_ci        DrawQuad quad{GrQuad::MakeFromRect(rect, viewMatrix),
539cb93a386Sopenharmony_ci                      localMatrix ? GrQuad::MakeFromRect(rect, *localMatrix) : GrQuad(rect),
540cb93a386Sopenharmony_ci                      doStencilMSAA == GrAA::kYes ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone};
541cb93a386Sopenharmony_ci        this->drawFilledQuad(clip, std::move(paint), doStencilMSAA, &quad, ss);
542cb93a386Sopenharmony_ci    }
543cb93a386Sopenharmony_ci
544cb93a386Sopenharmony_ci    // Fills the user stencil bits with a non-zero value at every sample inside the path. This will
545cb93a386Sopenharmony_ci    // likely be implemented with a Redbook algorithm, but it is not guaranteed. The samples being
546cb93a386Sopenharmony_ci    // rendered to must be zero initially.
547cb93a386Sopenharmony_ci    bool stencilPath(const GrHardClip*,
548cb93a386Sopenharmony_ci                     GrAA doStencilMSAA,
549cb93a386Sopenharmony_ci                     const SkMatrix& viewMatrix,
550cb93a386Sopenharmony_ci                     const SkPath&);
551cb93a386Sopenharmony_ci
552cb93a386Sopenharmony_ci    /**
553cb93a386Sopenharmony_ci     * Draws a path, either AA or not, and touches the stencil buffer with the user stencil settings
554cb93a386Sopenharmony_ci     * for each color sample written.
555cb93a386Sopenharmony_ci     */
556cb93a386Sopenharmony_ci    bool drawAndStencilPath(const GrHardClip*,
557cb93a386Sopenharmony_ci                            const GrUserStencilSettings*,
558cb93a386Sopenharmony_ci                            SkRegion::Op op,
559cb93a386Sopenharmony_ci                            bool invert,
560cb93a386Sopenharmony_ci                            GrAA doStencilMSAA,
561cb93a386Sopenharmony_ci                            const SkMatrix& viewMatrix,
562cb93a386Sopenharmony_ci                            const SkPath&);
563cb93a386Sopenharmony_ci
564cb93a386Sopenharmony_ci    SkBudgeted isBudgeted() const;
565cb93a386Sopenharmony_ci
566cb93a386Sopenharmony_ci    int maxWindowRectangles() const;
567cb93a386Sopenharmony_ci
568cb93a386Sopenharmony_ci    SkGlyphRunListPainter* glyphRunPainter() { return &fGlyphPainter; }
569cb93a386Sopenharmony_ci
570cb93a386Sopenharmony_ci    /*
571cb93a386Sopenharmony_ci     * This unique ID will not change for a given SurfaceDrawContext. However, it is _NOT_
572cb93a386Sopenharmony_ci     * guaranteed to match the uniqueID of the underlying GrRenderTarget - beware!
573cb93a386Sopenharmony_ci     */
574cb93a386Sopenharmony_ci    GrSurfaceProxy::UniqueID uniqueID() const { return this->asSurfaceProxy()->uniqueID(); }
575cb93a386Sopenharmony_ci
576cb93a386Sopenharmony_ci    // Allows caller of addDrawOp to know which op list an op will be added to.
577cb93a386Sopenharmony_ci    using WillAddOpFn = void(GrOp*, uint32_t opsTaskID);
578cb93a386Sopenharmony_ci    // These perform processing specific to GrDrawOp-derived ops before recording them into an
579cb93a386Sopenharmony_ci    // op list. Before adding the op to an op list the WillAddOpFn is called. Note that it
580cb93a386Sopenharmony_ci    // will not be called in the event that the op is discarded. Moreover, the op may merge into
581cb93a386Sopenharmony_ci    // another op after the function is called (either before addDrawOp returns or some time later).
582cb93a386Sopenharmony_ci    //
583cb93a386Sopenharmony_ci    // If the clip pointer is null, no clipping will be performed.
584cb93a386Sopenharmony_ci    void addDrawOp(const GrClip*,
585cb93a386Sopenharmony_ci                   GrOp::Owner,
586cb93a386Sopenharmony_ci                   const std::function<WillAddOpFn>& = std::function<WillAddOpFn>());
587cb93a386Sopenharmony_ci    void addDrawOp(GrOp::Owner op) { this->addDrawOp(nullptr, std::move(op)); }
588cb93a386Sopenharmony_ci
589cb93a386Sopenharmony_ci    bool refsWrappedObjects() const { return this->asRenderTargetProxy()->refsWrappedObjects(); }
590cb93a386Sopenharmony_ci
591cb93a386Sopenharmony_ci    /**
592cb93a386Sopenharmony_ci     *  The next time this SurfaceDrawContext is flushed, the gpu will wait on the passed in
593cb93a386Sopenharmony_ci     *  semaphores before executing any commands.
594cb93a386Sopenharmony_ci     */
595cb93a386Sopenharmony_ci    bool waitOnSemaphores(int numSemaphores, const GrBackendSemaphore waitSemaphores[],
596cb93a386Sopenharmony_ci                          bool deleteSemaphoresAfterWait);
597cb93a386Sopenharmony_ci
598cb93a386Sopenharmony_ci    int numSamples() const { return this->asRenderTargetProxy()->numSamples(); }
599cb93a386Sopenharmony_ci    const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; }
600cb93a386Sopenharmony_ci    bool canUseDynamicMSAA() const { return fCanUseDynamicMSAA; }
601cb93a386Sopenharmony_ci    bool wrapsVkSecondaryCB() const { return this->asRenderTargetProxy()->wrapsVkSecondaryCB(); }
602cb93a386Sopenharmony_ci
603cb93a386Sopenharmony_ci    bool alwaysAntialias() const {
604cb93a386Sopenharmony_ci        return fSurfaceProps.flags() & SkSurfaceProps::kDynamicMSAA_Flag;
605cb93a386Sopenharmony_ci    }
606cb93a386Sopenharmony_ci
607cb93a386Sopenharmony_ci    GrAA chooseAA(const SkPaint& paint) {
608cb93a386Sopenharmony_ci        return GrAA(paint.isAntiAlias() || this->alwaysAntialias());
609cb93a386Sopenharmony_ci    }
610cb93a386Sopenharmony_ci
611cb93a386Sopenharmony_ci    GrAAType chooseAAType(GrAA aa) {
612cb93a386Sopenharmony_ci        if (this->numSamples() > 1 || fCanUseDynamicMSAA) {
613cb93a386Sopenharmony_ci            // Always trigger DMSAA when it's available. The coverage ops that know how to handle
614cb93a386Sopenharmony_ci            // both single and multisample targets without popping will do so without calling
615cb93a386Sopenharmony_ci            // chooseAAType.
616cb93a386Sopenharmony_ci            return GrAAType::kMSAA;
617cb93a386Sopenharmony_ci        }
618cb93a386Sopenharmony_ci        return (aa == GrAA::kYes) ? GrAAType::kCoverage : GrAAType::kNone;
619cb93a386Sopenharmony_ci    }
620cb93a386Sopenharmony_ci
621cb93a386Sopenharmony_ci    // This entry point should only be called if the backing GPU object is known to be
622cb93a386Sopenharmony_ci    // instantiated.
623cb93a386Sopenharmony_ci    GrRenderTarget* accessRenderTarget() { return this->asSurfaceProxy()->peekRenderTarget(); }
624cb93a386Sopenharmony_ci
625cb93a386Sopenharmony_ci#if GR_TEST_UTILS
626cb93a386Sopenharmony_ci    void testingOnly_SetPreserveOpsOnFullClear() { fPreserveOpsOnFullClear_TestingOnly = true; }
627cb93a386Sopenharmony_ci#endif
628cb93a386Sopenharmony_ci
629cb93a386Sopenharmony_ci    bool drawBlurImage(GrSurfaceProxyView proxyView, const SkBlurArg& blurArg);
630cb93a386Sopenharmony_ci
631cb93a386Sopenharmony_ciprivate:
632cb93a386Sopenharmony_ci    enum class QuadOptimization;
633cb93a386Sopenharmony_ci
634cb93a386Sopenharmony_ci    void willReplaceOpsTask(OpsTask* prevTask, OpsTask* nextTask) override;
635cb93a386Sopenharmony_ci
636cb93a386Sopenharmony_ci    OpsTask::CanDiscardPreviousOps canDiscardPreviousOpsOnFullClear() const override;
637cb93a386Sopenharmony_ci    void setNeedsStencil();
638cb93a386Sopenharmony_ci
639cb93a386Sopenharmony_ci    void internalStencilClear(const SkIRect* scissor, bool insideStencilMask);
640cb93a386Sopenharmony_ci
641cb93a386Sopenharmony_ci    // 'stencilSettings' are provided merely for decision making purposes; When non-null,
642cb93a386Sopenharmony_ci    // optimization strategies that submit special ops are avoided.
643cb93a386Sopenharmony_ci    //
644cb93a386Sopenharmony_ci    // 'aa' and 'quad' should be the original draw request on input, and will be updated as
645cb93a386Sopenharmony_ci    // appropriate depending on the returned optimization level.
646cb93a386Sopenharmony_ci    //
647cb93a386Sopenharmony_ci    // If kSubmitted is returned, the provided paint was consumed. Otherwise it is left unchanged.
648cb93a386Sopenharmony_ci    QuadOptimization attemptQuadOptimization(const GrClip* clip,
649cb93a386Sopenharmony_ci                                             const GrUserStencilSettings* stencilSettings,
650cb93a386Sopenharmony_ci                                             GrAA* aa,
651cb93a386Sopenharmony_ci                                             DrawQuad* quad,
652cb93a386Sopenharmony_ci                                             GrPaint* paint);
653cb93a386Sopenharmony_ci
654cb93a386Sopenharmony_ci    // If stencil settings, 'ss', are non-null, AA controls MSAA or no AA. If they are null, then AA
655cb93a386Sopenharmony_ci    // can choose between coverage, MSAA as per chooseAAType(). This will always attempt to apply
656cb93a386Sopenharmony_ci    // quad optimizations, so all quad/rect public APIs should rely on this function for consistent
657cb93a386Sopenharmony_ci    // clipping behavior. 'quad' will be modified in place to reflect final rendered geometry.
658cb93a386Sopenharmony_ci    void drawFilledQuad(const GrClip* clip,
659cb93a386Sopenharmony_ci                        GrPaint&& paint,
660cb93a386Sopenharmony_ci                        GrAA aa,
661cb93a386Sopenharmony_ci                        DrawQuad* quad,
662cb93a386Sopenharmony_ci                        const GrUserStencilSettings* ss = nullptr);
663cb93a386Sopenharmony_ci
664cb93a386Sopenharmony_ci    // Like drawFilledQuad but does not require using a GrPaint or FP for texturing.
665cb93a386Sopenharmony_ci    // 'quad' may be modified in place to reflect final geometry.
666cb93a386Sopenharmony_ci    void drawTexturedQuad(const GrClip* clip,
667cb93a386Sopenharmony_ci                          GrSurfaceProxyView proxyView,
668cb93a386Sopenharmony_ci                          SkAlphaType alphaType,
669cb93a386Sopenharmony_ci                          sk_sp<GrColorSpaceXform> textureXform,
670cb93a386Sopenharmony_ci                          GrSamplerState::Filter filter,
671cb93a386Sopenharmony_ci                          GrSamplerState::MipmapMode,
672cb93a386Sopenharmony_ci                          const SkPMColor4f& color,
673cb93a386Sopenharmony_ci                          SkBlendMode blendMode,
674cb93a386Sopenharmony_ci                          GrAA aa,
675cb93a386Sopenharmony_ci                          DrawQuad* quad,
676cb93a386Sopenharmony_ci                          const SkRect* subset = nullptr);
677cb93a386Sopenharmony_ci
678cb93a386Sopenharmony_ci    void drawStrokedLine(const GrClip*, GrPaint&&, GrAA, const SkMatrix&, const SkPoint[2],
679cb93a386Sopenharmony_ci                         const SkStrokeRec&);
680cb93a386Sopenharmony_ci
681cb93a386Sopenharmony_ci    // Tries to detect if the given shape is a simple, and draws it without path rendering if
682cb93a386Sopenharmony_ci    // we know how.
683cb93a386Sopenharmony_ci    bool drawSimpleShape(const GrClip*, GrPaint*, GrAA, const SkMatrix&, const GrStyledShape&);
684cb93a386Sopenharmony_ci
685cb93a386Sopenharmony_ci    // If 'attemptDrawSimple' is true, of if the original shape is marked as having been simplfied,
686cb93a386Sopenharmony_ci    // this will attempt to re-route through drawSimpleShape() to see if we can avoid path rendering
687cb93a386Sopenharmony_ci    // one more time.
688cb93a386Sopenharmony_ci    void drawShapeUsingPathRenderer(const GrClip*, GrPaint&&, GrAA, const SkMatrix&,
689cb93a386Sopenharmony_ci                                    GrStyledShape&&, bool attemptDrawSimple = false);
690cb93a386Sopenharmony_ci
691cb93a386Sopenharmony_ci    // Makes a copy of the proxy if it is necessary for the draw and places the texture that should
692cb93a386Sopenharmony_ci    // be used by GrXferProcessor to access the destination color in 'result'. If the return
693cb93a386Sopenharmony_ci    // value is false then a texture copy could not be made.
694cb93a386Sopenharmony_ci    //
695cb93a386Sopenharmony_ci    // The op should have already had setClippedBounds called on it.
696cb93a386Sopenharmony_ci    bool SK_WARN_UNUSED_RESULT setupDstProxyView(const SkRect& opBounds,
697cb93a386Sopenharmony_ci                                                 bool opRequiresMSAA,
698cb93a386Sopenharmony_ci                                                 GrDstProxyView* result);
699cb93a386Sopenharmony_ci
700cb93a386Sopenharmony_ci    OpsTask* replaceOpsTaskIfModifiesColor();
701cb93a386Sopenharmony_ci
702cb93a386Sopenharmony_ci    SkGlyphRunListPainter* glyphPainter() { return &fGlyphPainter; }
703cb93a386Sopenharmony_ci
704cb93a386Sopenharmony_ci    const SkSurfaceProps fSurfaceProps;
705cb93a386Sopenharmony_ci    const bool fCanUseDynamicMSAA;
706cb93a386Sopenharmony_ci
707cb93a386Sopenharmony_ci    bool fNeedsStencil = false;
708cb93a386Sopenharmony_ci
709cb93a386Sopenharmony_ci#if GR_TEST_UTILS
710cb93a386Sopenharmony_ci    bool fPreserveOpsOnFullClear_TestingOnly = false;
711cb93a386Sopenharmony_ci#endif
712cb93a386Sopenharmony_ci    SkGlyphRunListPainter fGlyphPainter;
713cb93a386Sopenharmony_ci};
714cb93a386Sopenharmony_ci
715cb93a386Sopenharmony_ci} // namespace skgpu::v1
716cb93a386Sopenharmony_ci
717cb93a386Sopenharmony_ci#endif // SurfaceDrawContext_v1_DEFINED
718