Flutter Engine
The Flutter Engine
SkNWayCanvas.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2011 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
9
14#include "include/core/SkRect.h"
22
23#include <algorithm>
24#include <iterator>
25#include <utility>
26
27namespace sktext {
28class GlyphRunList;
29}
30
31class SkData;
32class SkDrawable;
33class SkImage;
34class SkPaint;
35class SkPath;
36class SkPicture;
37class SkRRect;
38class SkRegion;
39class SkTextBlob;
40class SkVertices;
41enum class SkBlendMode;
42enum class SkClipOp;
43struct SkDrawShadowRec;
44
46
48 this->removeAll();
49}
50
52 if (!fList.empty()) {
53 // We are using the nway canvas as a wrapper for the originally added canvas, and the device
54 // on the nway may contradict calls for the device on this canvas. So, to add a second
55 // canvas, the devices on the first canvas, and the nway base device must be different.
56 SkASSERT(fList[0]->rootDevice() != this->rootDevice());
57 }
58 if (canvas) {
59 *fList.append() = canvas;
60 }
61}
62
64 auto found = std::find(fList.begin(), fList.end(), canvas);
65 if (found != fList.end()) {
67 }
68}
69
71 fList.reset();
72}
73
74///////////////////////////////////////////////////////////////////////////
75// These are forwarded to the N canvases we're referencing
76
78public:
79 Iter(const SkTDArray<SkCanvas*>& list) : fList(list) {
80 fIndex = 0;
81 }
82 bool next() {
83 if (fIndex < fList.size()) {
84 fCanvas = fList[fIndex++];
85 return true;
86 }
87 return false;
88 }
89 SkCanvas* operator->() { return fCanvas; }
90 SkCanvas* get() const { return fCanvas; }
91
92private:
93 const SkTDArray<SkCanvas*>& fList;
94 int fIndex;
95 SkCanvas* fCanvas;
96};
97
99 Iter iter(fList);
100 while (iter.next()) {
101 iter->save();
102 }
103
104 this->INHERITED::willSave();
105}
106
108 Iter iter(fList);
109 while (iter.next()) {
110 iter->saveLayer(rec);
111 }
112
114 // No need for a layer.
116}
117
119 Iter iter(fList);
120 while (iter.next()) {
122 }
123 this->INHERITED::onDoSaveBehind(bounds);
124 return false;
125}
126
128 Iter iter(fList);
129 while (iter.next()) {
130 iter->restore();
131 }
133}
134
136 Iter iter(fList);
137 while (iter.next()) {
138 iter->concat(m);
139 }
140}
141
143 Iter iter(fList);
144 while (iter.next()) {
145 iter->setMatrix(matrix);
146 }
147}
148
150 Iter iter(fList);
151 while (iter.next()) {
152 iter->translate(x, y);
153 }
154}
155
157 Iter iter(fList);
158 while (iter.next()) {
159 iter->scale(x, y);
160 }
161}
162
164 Iter iter(fList);
165 while (iter.next()) {
166 iter->clipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle);
167 }
168 this->INHERITED::onClipRect(rect, op, edgeStyle);
169}
170
172 Iter iter(fList);
173 while (iter.next()) {
174 iter->clipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle);
175 }
176 this->INHERITED::onClipRRect(rrect, op, edgeStyle);
177}
178
180 Iter iter(fList);
181 while (iter.next()) {
182 iter->clipPath(path, op, kSoft_ClipEdgeStyle == edgeStyle);
183 }
184 this->INHERITED::onClipPath(path, op, edgeStyle);
185}
186
188 Iter iter(fList);
189 while (iter.next()) {
190 iter->clipShader(sh, op);
191 }
192 this->INHERITED::onClipShader(std::move(sh), op);
193}
194
195void SkNWayCanvas::onClipRegion(const SkRegion& deviceRgn, SkClipOp op) {
196 Iter iter(fList);
197 while (iter.next()) {
198 iter->clipRegion(deviceRgn, op);
199 }
200 this->INHERITED::onClipRegion(deviceRgn, op);
201}
202
204 Iter iter(fList);
205 while (iter.next()) {
207 }
209}
210
212 Iter iter(fList);
213 while (iter.next()) {
214 iter->drawPaint(paint);
215 }
216}
217
219 Iter iter(fList);
220 while (iter.next()) {
222 }
223}
224
226 const SkPaint& paint) {
227 Iter iter(fList);
228 while (iter.next()) {
229 iter->drawPoints(mode, count, pts, paint);
230 }
231}
232
234 Iter iter(fList);
235 while (iter.next()) {
236 iter->drawRect(rect, paint);
237 }
238}
239
241 Iter iter(fList);
242 while (iter.next()) {
243 iter->drawRegion(region, paint);
244 }
245}
246
248 Iter iter(fList);
249 while (iter.next()) {
250 iter->drawOval(rect, paint);
251 }
252}
253
255 bool useCenter, const SkPaint& paint) {
256 Iter iter(fList);
257 while (iter.next()) {
258 iter->drawArc(rect, startAngle, sweepAngle, useCenter, paint);
259 }
260}
261
263 Iter iter(fList);
264 while (iter.next()) {
265 iter->drawRRect(rrect, paint);
266 }
267}
268
269void SkNWayCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint) {
270 Iter iter(fList);
271 while (iter.next()) {
272 iter->drawDRRect(outer, inner, paint);
273 }
274}
275
277 Iter iter(fList);
278 while (iter.next()) {
279 iter->drawPath(path, paint);
280 }
281}
282
284 const SkSamplingOptions& sampling, const SkPaint* paint) {
285 Iter iter(fList);
286 while (iter.next()) {
287 iter->drawImage(image, left, top, sampling, paint);
288 }
289}
290
293 SrcRectConstraint constraint) {
294 Iter iter(fList);
295 while (iter.next()) {
296 iter->drawImageRect(image, src, dst, sampling, paint, constraint);
297 }
298}
299
301 const SkRect& dst, SkFilterMode filter,
302 const SkPaint* paint) {
303 Iter iter(fList);
304 while (iter.next()) {
305 iter->drawImageLattice(image, lattice, dst, filter, paint);
306 }
307}
308
309void SkNWayCanvas::onDrawAtlas2(const SkImage* image, const SkRSXform xform[], const SkRect tex[],
310 const SkColor colors[], int count, SkBlendMode bmode,
311 const SkSamplingOptions& sampling, const SkRect* cull,
312 const SkPaint* paint) {
313 Iter iter(fList);
314 while (iter.next()) {
315 iter->drawAtlas(image, xform, tex, colors, count, bmode, sampling, cull, paint);
316 }
317}
318
320 const SkPaint &paint) {
321 Iter iter(fList);
322 while (iter.next()) {
323 iter->onDrawGlyphRunList(list, paint);
324 }
325}
326
328 const SkPaint &paint) {
329 Iter iter(fList);
330 while (iter.next()) {
331 iter->drawTextBlob(blob, x, y, paint);
332 }
333}
334
336 Iter iter(fList);
337 while (iter.next()) {
338 iter->drawSlug(slug, paint);
339 }
340}
341
343 const SkPaint* paint) {
344 Iter iter(fList);
345 while (iter.next()) {
347 }
348}
349
351 Iter iter(fList);
352 while (iter.next()) {
353 iter->drawDrawable(drawable, matrix);
354 }
355}
356
358 SkBlendMode bmode, const SkPaint& paint) {
359 Iter iter(fList);
360 while (iter.next()) {
361 iter->drawVertices(vertices, bmode, paint);
362 }
363}
364
365void SkNWayCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
366 const SkPoint texCoords[4], SkBlendMode bmode,
367 const SkPaint& paint) {
368 Iter iter(fList);
369 while (iter.next()) {
370 iter->drawPatch(cubics, colors, texCoords, bmode, paint);
371 }
372}
373
375 Iter iter(fList);
376 while (iter.next()) {
377 iter->private_draw_shadow_rec(path, rec);
378 }
379}
380
382 Iter iter(fList);
383 while (iter.next()) {
384 iter->drawAnnotation(rect, key, data);
385 }
386}
387
390 Iter iter(fList);
391 while (iter.next()) {
393 }
394}
395
397 const SkPoint dstClips[], const SkMatrix preViewMatrices[],
399 SrcRectConstraint constraint) {
400 Iter iter(fList);
401 while (iter.next()) {
404 }
405}
int count
Definition: FontMgrTest.cpp:50
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkBlendMode
Definition: SkBlendMode.h:38
SkClipOp
Definition: SkClipOp.h:13
uint32_t SkColor
Definition: SkColor.h:37
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
static bool left(const SkPoint &p0, const SkPoint &p1)
SkFilterMode
int find(T *array, int N, T item)
static void ResetClip(SkCanvas *canvas)
Definition: SkCanvasPriv.h:61
static void DrawBehind(SkCanvas *canvas, const SkPaint &paint)
Definition: SkCanvasPriv.h:56
static int SaveBehind(SkCanvas *canvas, const SkRect *subset)
Definition: SkCanvasPriv.h:53
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition: SkCanvas.cpp:496
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void drawOval(const SkRect &oval, const SkPaint &paint)
Definition: SkCanvas.cpp:1698
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
Definition: SkCanvas.cpp:1710
void drawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode mode, const SkPaint &paint)
Definition: SkCanvas.cpp:2529
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
virtual void onClipShader(sk_sp< SkShader >, SkClipOp)
Definition: SkCanvas.cpp:1505
void drawPaint(const SkPaint &paint)
Definition: SkCanvas.cpp:1668
void private_draw_shadow_rec(const SkPath &, const SkDrawShadowRec &)
Definition: SkCanvas.cpp:1831
void drawDrawable(SkDrawable *drawable, const SkMatrix *matrix=nullptr)
Definition: SkCanvas.cpp:2574
void drawAnnotation(const SkRect &rect, const char key[], SkData *value)
Definition: SkCanvas.cpp:1824
friend class SkNWayCanvas
Definition: SkCanvas.h:2492
virtual void onClipRect(const SkRect &rect, SkClipOp op, ClipEdgeStyle edgeStyle)
Definition: SkCanvas.cpp:1370
virtual void onResetClip()
Definition: SkCanvas.cpp:1424
SrcRectConstraint
Definition: SkCanvas.h:1541
void clipRegion(const SkRegion &deviceRgn, SkClipOp op=SkClipOp::kIntersect)
Definition: SkCanvas.cpp:1510
void experimental_DrawEdgeAAQuad(const SkRect &rect, const SkPoint clip[4], QuadAAFlags aaFlags, const SkColor4f &color, SkBlendMode mode)
Definition: SkCanvas.cpp:1845
SaveLayerStrategy
Definition: SkCanvas.h:2263
@ kNoLayer_SaveLayerStrategy
Definition: SkCanvas.h:2265
virtual void willRestore()
Definition: SkCanvas.h:2276
void experimental_DrawEdgeAAImageSet(const ImageSetEntry imageSet[], int cnt, const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkSamplingOptions &, const SkPaint *paint=nullptr, SrcRectConstraint constraint=kStrict_SrcRectConstraint)
Definition: SkCanvas.cpp:1853
void drawRRect(const SkRRect &rrect, const SkPaint &paint)
Definition: SkCanvas.cpp:1705
void drawArc(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint)
Definition: SkCanvas.cpp:2728
void drawImageLattice(const SkImage *image, const Lattice &lattice, const SkRect &dst, SkFilterMode filter, const SkPaint *paint=nullptr)
Definition: SkCanvas.cpp:1786
void clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1456
void drawRegion(const SkRegion &region, const SkPaint &paint)
Definition: SkCanvas.cpp:1685
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
Definition: SkCanvas.cpp:2333
int save()
Definition: SkCanvas.cpp:447
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
void drawAtlas(const SkImage *atlas, const SkRSXform xform[], const SkRect tex[], const SkColor colors[], int count, SkBlendMode mode, const SkSamplingOptions &sampling, const SkRect *cullRect, const SkPaint *paint)
Definition: SkCanvas.cpp:1810
void setMatrix(const SkM44 &matrix)
Definition: SkCanvas.cpp:1349
virtual void onClipRRect(const SkRRect &rrect, SkClipOp op, ClipEdgeStyle edgeStyle)
Definition: SkCanvas.cpp:1449
virtual void onClipPath(const SkPath &path, SkClipOp op, ClipEdgeStyle edgeStyle)
Definition: SkCanvas.cpp:1481
void drawDRRect(const SkRRect &outer, const SkRRect &inner, const SkPaint &paint)
Definition: SkCanvas.cpp:1645
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
@ kSoft_ClipEdgeStyle
Definition: SkCanvas.h:2337
virtual void onDrawGlyphRunList(const sktext::GlyphRunList &glyphRunList, const SkPaint &paint)
Definition: SkCanvas.cpp:2356
void drawPicture(const SkPicture *picture)
Definition: SkCanvas.h:1961
void clipShader(sk_sp< SkShader >, SkClipOp=SkClipOp::kIntersect)
Definition: SkCanvas.cpp:1488
virtual void willSave()
Definition: SkCanvas.h:2268
void drawVertices(const SkVertices *vertices, SkBlendMode mode, const SkPaint &paint)
Definition: SkCanvas.cpp:1720
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2484
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
virtual void onClipRegion(const SkRegion &deviceRgn, SkClipOp op)
Definition: SkCanvas.cpp:1515
void clipRRect(const SkRRect &rrect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1439
Definition: SkData.h:25
Definition: SkM44.h:150
Iter(const SkTDArray< SkCanvas * > &list)
SkCanvas * operator->()
SkCanvas * get() const
void onDrawDRRect(const SkRRect &, const SkRRect &, const SkPaint &) override
void onDrawRRect(const SkRRect &, const SkPaint &) override
void onResetClip() override
virtual void addCanvas(SkCanvas *)
void onDrawRect(const SkRect &, const SkPaint &) override
void onDrawVerticesObject(const SkVertices *, SkBlendMode, const SkPaint &) override
void onDrawArc(const SkRect &, SkScalar, SkScalar, bool, const SkPaint &) override
void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode, const SkPaint &paint) override
void onDrawPath(const SkPath &, const SkPaint &) override
void onDrawPicture(const SkPicture *, const SkMatrix *, const SkPaint *) override
void didScale(SkScalar, SkScalar) override
void onDrawImageLattice2(const SkImage *, const Lattice &, const SkRect &, SkFilterMode, const SkPaint *) override
void onDrawRegion(const SkRegion &, const SkPaint &) override
void onDrawAnnotation(const SkRect &, const char[], SkData *) override
void onDrawDrawable(SkDrawable *, const SkMatrix *) override
void onDrawBehind(const SkPaint &) override
virtual void removeCanvas(SkCanvas *)
~SkNWayCanvas() override
void onDrawImage2(const SkImage *, SkScalar, SkScalar, const SkSamplingOptions &, const SkPaint *) override
void onClipRect(const SkRect &, SkClipOp, ClipEdgeStyle) override
void onDrawAtlas2(const SkImage *, const SkRSXform[], const SkRect[], const SkColor[], int, SkBlendMode, const SkSamplingOptions &, const SkRect *, const SkPaint *) override
void onClipRegion(const SkRegion &, SkClipOp) override
virtual void removeAll()
void onClipRRect(const SkRRect &, SkClipOp, ClipEdgeStyle) override
SkTDArray< SkCanvas * > fList
Definition: SkNWayCanvas.h:60
void onDrawPaint(const SkPaint &) override
SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec &) override
void willRestore() override
void didTranslate(SkScalar, SkScalar) override
void onDrawShadowRec(const SkPath &, const SkDrawShadowRec &) override
void willSave() override
void onDrawEdgeAAImageSet2(const ImageSetEntry[], int count, const SkPoint[], const SkMatrix[], const SkSamplingOptions &, const SkPaint *, SrcRectConstraint) override
void onDrawImageRect2(const SkImage *, const SkRect &, const SkRect &, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint) override
void onDrawEdgeAAQuad(const SkRect &, const SkPoint[4], QuadAAFlags, const SkColor4f &, SkBlendMode) override
void onDrawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint) override
void onClipPath(const SkPath &, SkClipOp, ClipEdgeStyle) override
void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint &) override
void onDrawGlyphRunList(const sktext::GlyphRunList &, const SkPaint &) override
void didSetM44(const SkM44 &) override
void onDrawOval(const SkRect &, const SkPaint &) override
void onDrawSlug(const sktext::gpu::Slug *slug, const SkPaint &paint) override
void onClipShader(sk_sp< SkShader >, SkClipOp) override
void didConcat44(const SkM44 &) override
bool onDoSaveBehind(const SkRect *) override
bool onDoSaveBehind(const SkRect *) override
Definition: SkCanvas.cpp:2830
SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec &rec) override
Definition: SkCanvas.cpp:2825
Definition: SkPath.h:59
T * end()
Definition: SkTDArray.h:152
int size() const
Definition: SkTDArray.h:138
bool empty() const
Definition: SkTDArray.h:135
void reset()
Definition: SkTDArray.h:171
T * begin()
Definition: SkTDArray.h:150
T * append()
Definition: SkTDArray.h:191
void removeShuffle(int index)
Definition: SkTDArray.h:214
const Paint & paint
Definition: color_source.cc:38
DlColor color
float SkScalar
Definition: extension.cpp:12
double y
double x
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
Optional< SkRect > bounds
Definition: SkRecords.h:189
PODArray< SkPoint > dstClips
Definition: SkRecords.h:364
sk_sp< const SkImage > image
Definition: SkRecords.h:269
ClipOpAndAA opAA SkRegion region
Definition: SkRecords.h:238
sk_sp< const SkPicture > picture
Definition: SkRecords.h:299
SkRRect rrect
Definition: SkRecords.h:232
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
PODArray< SkMatrix > preViewMatrices
Definition: SkRecords.h:365
SkScalar startAngle
Definition: SkRecords.h:250
SkScalar sweepAngle
Definition: SkRecords.h:251
PODArray< SkColor > colors
Definition: SkRecords.h:276
SkSamplingOptions sampling
Definition: SkRecords.h:337
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Definition: switches.h:76
dst
Definition: cp.py:12
sh
Definition: run_sh.py:10
int32_t height
int32_t width
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63