Flutter Engine
The Flutter Engine
canvas_spy.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "flutter/shell/platform/fuchsia/flutter/canvas_spy.h"
6
7namespace flutter {
8
10 SkISize canvas_size = target_canvas->getBaseLayerSize();
11 n_way_canvas_ =
12 std::make_unique<SkNWayCanvas>(canvas_size.width(), canvas_size.height());
13 did_draw_canvas_ = std::make_unique<DidDrawCanvas>(canvas_size.width(),
14 canvas_size.height());
15 n_way_canvas_->addCanvas(target_canvas);
16 n_way_canvas_->addCanvas(did_draw_canvas_.get());
17 adapter_.set_canvas(n_way_canvas_.get());
18}
19
21 return &adapter_;
22}
23
25 return n_way_canvas_.get();
26};
27
30
32
33void DidDrawCanvas::MarkDrawIfNonTransparentPaint(const SkPaint& paint) {
34 bool isTransparent = paint.getAlpha() == 0;
35 did_draw_ |= !isTransparent;
36}
37
39 return did_draw_canvas_->DidDrawIntoCanvas();
40}
41
43 return did_draw_;
44}
45
46void DidDrawCanvas::willSave() {}
47
48SkCanvas::SaveLayerStrategy DidDrawCanvas::getSaveLayerStrategy(
49 const SaveLayerRec& rec) {
51}
52
53bool DidDrawCanvas::onDoSaveBehind(const SkRect* bounds) {
54 return false;
55}
56
57void DidDrawCanvas::willRestore() {}
58
59void DidDrawCanvas::didConcat44(const SkM44&) {}
60
61void DidDrawCanvas::didScale(SkScalar, SkScalar) {}
62
63void DidDrawCanvas::didTranslate(SkScalar, SkScalar) {}
64
65void DidDrawCanvas::onClipRect(const SkRect& rect,
66 SkClipOp op,
67 ClipEdgeStyle edgeStyle) {}
68
69void DidDrawCanvas::onClipRRect(const SkRRect& rrect,
70 SkClipOp op,
71 ClipEdgeStyle edgeStyle) {}
72
73void DidDrawCanvas::onClipPath(const SkPath& path,
74 SkClipOp op,
75 ClipEdgeStyle edgeStyle) {}
76
77void DidDrawCanvas::onClipRegion(const SkRegion& deviceRgn, SkClipOp op) {}
78
79void DidDrawCanvas::onDrawPaint(const SkPaint& paint) {
80 MarkDrawIfNonTransparentPaint(paint);
81}
82
83void DidDrawCanvas::onDrawBehind(const SkPaint& paint) {
84 MarkDrawIfNonTransparentPaint(paint);
85}
86
87void DidDrawCanvas::onDrawPoints(PointMode mode,
88 size_t count,
89 const SkPoint pts[],
90 const SkPaint& paint) {
91 MarkDrawIfNonTransparentPaint(paint);
92}
93
94void DidDrawCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) {
95 MarkDrawIfNonTransparentPaint(paint);
96}
97
98void DidDrawCanvas::onDrawRegion(const SkRegion& region, const SkPaint& paint) {
99 MarkDrawIfNonTransparentPaint(paint);
100}
101
102void DidDrawCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) {
103 MarkDrawIfNonTransparentPaint(paint);
104}
105
106void DidDrawCanvas::onDrawArc(const SkRect& rect,
109 bool useCenter,
110 const SkPaint& paint) {
111 MarkDrawIfNonTransparentPaint(paint);
112}
113
114void DidDrawCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
115 MarkDrawIfNonTransparentPaint(paint);
116}
117
118void DidDrawCanvas::onDrawDRRect(const SkRRect& outer,
119 const SkRRect& inner,
120 const SkPaint& paint) {
121 MarkDrawIfNonTransparentPaint(paint);
122}
123
124void DidDrawCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) {
125 MarkDrawIfNonTransparentPaint(paint);
126}
127
128#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
129void DidDrawCanvas::onDrawImage(const SkImage* image,
130 SkScalar left,
131 SkScalar top,
132 const SkPaint* paint) {
133 did_draw_ = true;
134}
135
136void DidDrawCanvas::onDrawImageRect(const SkImage* image,
137 const SkRect* src,
138 const SkRect& dst,
139 const SkPaint* paint,
140 SrcRectConstraint constraint) {
141 did_draw_ = true;
142}
143
144void DidDrawCanvas::onDrawImageLattice(const SkImage* image,
145 const Lattice& lattice,
146 const SkRect& dst,
147 const SkPaint* paint) {
148 did_draw_ = true;
149}
150
151void DidDrawCanvas::onDrawAtlas(const SkImage* image,
152 const SkRSXform xform[],
153 const SkRect tex[],
154 const SkColor colors[],
155 int count,
156 SkBlendMode bmode,
157 const SkRect* cull,
158 const SkPaint* paint) {
159 did_draw_ = true;
160}
161
162void DidDrawCanvas::onDrawEdgeAAImageSet(const ImageSetEntry set[],
163 int count,
164 const SkPoint dstClips[],
166 const SkPaint* paint,
167 SrcRectConstraint constraint) {
168 did_draw_ = true;
169}
170#endif
171
172void DidDrawCanvas::onDrawImage2(const SkImage* image,
173 SkScalar left,
174 SkScalar top,
175 const SkSamplingOptions&,
176 const SkPaint* paint) {
177 did_draw_ = true;
178}
179
180void DidDrawCanvas::onDrawImageRect2(const SkImage* image,
181 const SkRect& src,
182 const SkRect& dst,
183 const SkSamplingOptions&,
184 const SkPaint* paint,
185 SrcRectConstraint constraint) {
186 did_draw_ = true;
187}
188
189void DidDrawCanvas::onDrawImageLattice2(const SkImage* image,
190 const Lattice& lattice,
191 const SkRect& dst,
193 const SkPaint* paint) {
194 did_draw_ = true;
195}
196
198 SkScalar x,
199 SkScalar y,
200 const SkPaint& paint) {
201 MarkDrawIfNonTransparentPaint(paint);
202}
203
204void DidDrawCanvas::onDrawPicture(const SkPicture* picture,
205 const SkMatrix* matrix,
206 const SkPaint* paint) {
207 did_draw_ = true;
208}
209
210void DidDrawCanvas::onDrawDrawable(SkDrawable* drawable,
211 const SkMatrix* matrix) {
212 did_draw_ = true;
213}
214
215void DidDrawCanvas::onDrawVerticesObject(const SkVertices* vertices,
216 SkBlendMode bmode,
217 const SkPaint& paint) {
218 MarkDrawIfNonTransparentPaint(paint);
219}
220
222 const SkColor colors[4],
223 const SkPoint texCoords[4],
224 SkBlendMode bmode,
225 const SkPaint& paint) {
226 MarkDrawIfNonTransparentPaint(paint);
227}
228
229void DidDrawCanvas::onDrawAtlas2(const SkImage* image,
230 const SkRSXform xform[],
231 const SkRect tex[],
232 const SkColor colors[],
233 int count,
234 SkBlendMode bmode,
235 const SkSamplingOptions&,
236 const SkRect* cull,
237 const SkPaint* paint) {
238 did_draw_ = true;
239}
240
241void DidDrawCanvas::onDrawShadowRec(const SkPath& path,
242 const SkDrawShadowRec& rec) {
243 did_draw_ = true;
244}
245
246void DidDrawCanvas::onDrawAnnotation(const SkRect& rect,
247 const char key[],
248 SkData* data) {
249 did_draw_ = true;
250}
251
252void DidDrawCanvas::onDrawEdgeAAQuad(const SkRect& rect,
253 const SkPoint clip[4],
255 const SkColor4f& color,
257 did_draw_ = true;
258}
259
260void DidDrawCanvas::onDrawEdgeAAImageSet2(const ImageSetEntry set[],
261 int count,
262 const SkPoint dstClips[],
264 const SkSamplingOptions&,
265 const SkPaint* paint,
266 SrcRectConstraint constraint) {
267 did_draw_ = true;
268}
269
270} // namespace flutter
int count
Definition: FontMgrTest.cpp:50
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
SkFilterMode
virtual SkISize getBaseLayerSize() const
Definition: SkCanvas.cpp:369
SaveLayerStrategy
Definition: SkCanvas.h:2263
@ kNoLayer_SaveLayerStrategy
Definition: SkCanvas.h:2265
Definition: SkData.h:25
Definition: SkM44.h:150
Definition: SkPath.h:59
SkCanvas * GetRawSpyingCanvas()
The underlying Skia canvas that implements the spying (mainly for testing)
Definition: canvas_spy.cc:24
CanvasSpy(SkCanvas *target_canvas)
Definition: canvas_spy.cc:9
bool DidDrawIntoCanvas()
Returns true if any non transparent content has been drawn into the spying canvas....
Definition: canvas_spy.cc:38
DlCanvas * GetSpyingCanvas()
The returned canvas delegate all operations to the target canvas while spying on them.
Definition: canvas_spy.cc:20
virtual void onDrawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint) override
Definition: canvas_spy.cc:197
DidDrawCanvas(int width, int height)
Definition: canvas_spy.cc:28
~DidDrawCanvas() override
Definition: canvas_spy.cc:31
virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode, const SkPaint &paint) override
Definition: canvas_spy.cc:221
Developer-facing API for rendering anything within the engine.
Definition: dl_canvas.h:38
void set_canvas(SkCanvas *canvas)
Definition: dl_sk_canvas.cc:39
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
DlCanvas::PointMode PointMode
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
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition: switches.h:41
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
int32_t height
int32_t width
Definition: SkSize.h:16
constexpr int32_t width() const
Definition: SkSize.h:36
constexpr int32_t height() const
Definition: SkSize.h:37