Flutter Engine
The Flutter Engine
dl_op_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/common/dl_op_spy.h"
6
7namespace flutter {
8
10 return did_draw_;
11}
12
13void DlOpSpy::setColor(DlColor color) {
14 if (color.isTransparent()) {
15 will_draw_ = false;
16 } else {
17 will_draw_ = true;
18 }
19}
20void DlOpSpy::setColorSource(const DlColorSource* source) {
21 if (!source) {
22 return;
23 }
24 const DlColorColorSource* color_source = source->asColor();
25 if (color_source && color_source->color().isTransparent()) {
26 will_draw_ = false;
27 return;
28 }
29 will_draw_ = true;
30}
31void DlOpSpy::save() {}
32void DlOpSpy::saveLayer(const SkRect& bounds,
34 const DlImageFilter* backdrop) {}
35void DlOpSpy::restore() {}
36void DlOpSpy::drawColor(DlColor color, DlBlendMode mode) {
37 did_draw_ |= !color.isTransparent();
38}
39void DlOpSpy::drawPaint() {
40 did_draw_ |= will_draw_;
41}
42// TODO(cyanglaz): check whether the shape (line, rect, oval, etc) needs to be
43// evaluated. https://github.com/flutter/flutter/issues/123803
44void DlOpSpy::drawLine(const SkPoint& p0, const SkPoint& p1) {
45 did_draw_ |= will_draw_;
46}
47void DlOpSpy::drawDashedLine(const DlPoint& p0,
48 const DlPoint& p1,
49 DlScalar on_length,
50 DlScalar off_length) {
51 did_draw_ |= will_draw_;
52}
53void DlOpSpy::drawRect(const SkRect& rect) {
54 did_draw_ |= will_draw_;
55}
56void DlOpSpy::drawOval(const SkRect& bounds) {
57 did_draw_ |= will_draw_;
58}
59void DlOpSpy::drawCircle(const SkPoint& center, SkScalar radius) {
60 did_draw_ |= will_draw_;
61}
62void DlOpSpy::drawRRect(const SkRRect& rrect) {
63 did_draw_ |= will_draw_;
64}
65void DlOpSpy::drawDRRect(const SkRRect& outer, const SkRRect& inner) {
66 did_draw_ |= will_draw_;
67}
68void DlOpSpy::drawPath(const SkPath& path) {
69 did_draw_ |= will_draw_;
70}
71void DlOpSpy::drawArc(const SkRect& oval_bounds,
72 SkScalar start_degrees,
73 SkScalar sweep_degrees,
74 bool use_center) {
75 did_draw_ |= will_draw_;
76}
77void DlOpSpy::drawPoints(PointMode mode,
78 uint32_t count,
79 const SkPoint points[]) {
80 did_draw_ |= will_draw_;
81}
82void DlOpSpy::drawVertices(const DlVertices* vertices, DlBlendMode mode) {
83 did_draw_ |= will_draw_;
84}
85// In theory, below drawImage methods can produce a transparent screen when a
86// transparent image is provided. The operation of determine whether an image is
87// transparent needs examine all the pixels in the image object, which is slow.
88// Drawing a completely transparent image is not a valid use case, thus, such
89// case is ignored.
90void DlOpSpy::drawImage(const sk_sp<DlImage> image,
91 const SkPoint point,
93 bool render_with_attributes) {
94 did_draw_ = true;
95}
96void DlOpSpy::drawImageRect(const sk_sp<DlImage> image,
97 const SkRect& src,
98 const SkRect& dst,
100 bool render_with_attributes,
101 SrcRectConstraint constraint) {
102 did_draw_ = true;
103}
104void DlOpSpy::drawImageNine(const sk_sp<DlImage> image,
105 const SkIRect& center,
106 const SkRect& dst,
107 DlFilterMode filter,
108 bool render_with_attributes) {
109 did_draw_ = true;
110}
111void DlOpSpy::drawAtlas(const sk_sp<DlImage> atlas,
112 const SkRSXform xform[],
113 const SkRect tex[],
114 const DlColor colors[],
115 int count,
118 const SkRect* cull_rect,
119 bool render_with_attributes) {
120 did_draw_ = true;
121}
122void DlOpSpy::drawDisplayList(const sk_sp<DisplayList> display_list,
123 SkScalar opacity) {
124 if (did_draw_ || opacity == 0) {
125 return;
126 }
127 DlOpSpy receiver;
128 display_list->Dispatch(receiver);
129 did_draw_ |= receiver.did_draw();
130}
131void DlOpSpy::drawTextBlob(const sk_sp<SkTextBlob> blob,
132 SkScalar x,
133 SkScalar y) {
134 did_draw_ |= will_draw_;
135}
136
137void DlOpSpy::drawTextFrame(
138 const std::shared_ptr<impeller::TextFrame>& text_frame,
139 SkScalar x,
140 SkScalar y) {
141 did_draw_ |= will_draw_;
142}
143
144void DlOpSpy::drawShadow(const SkPath& path,
145 const DlColor color,
146 const SkScalar elevation,
147 bool transparent_occluder,
148 SkScalar dpr) {
149 did_draw_ |= !color.isTransparent();
150}
151
152} // namespace flutter
const char * options
int count
Definition: FontMgrTest.cpp:50
static const int points[]
Definition: SkPath.h:59
bool did_draw()
Returns true if any non transparent content has been drawn.
Definition: dl_op_spy.cc:9
DlColor color
SkBitmap source
Definition: examples.cpp:28
float SkScalar
Definition: extension.cpp:12
double y
double x
sk_sp< const SkImage > atlas
Definition: SkRecords.h:331
Optional< SkRect > bounds
Definition: SkRecords.h:189
sk_sp< const SkImage > image
Definition: SkRecords.h:269
sk_sp< const SkImageFilter > backdrop
Definition: SkRecords.h:191
SkRRect rrect
Definition: SkRecords.h:232
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
PODArray< SkColor > colors
Definition: SkRecords.h:276
SkSamplingOptions sampling
Definition: SkRecords.h:337
DlCanvas::PointMode PointMode
impeller::Scalar DlScalar
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
impeller::Point DlPoint
dst
Definition: cp.py:12
flutter::DlColor DlColor
flutter::SaveLayerOptions SaveLayerOptions
Definition: SkRect.h:32