forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 2
/
dl_op_spy.cc
138 lines (133 loc) · 4.53 KB
/
dl_op_spy.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/display_list/dl_op_spy.h"
namespace flutter {
bool DlOpSpy::did_draw() {
return did_draw_;
}
void DlOpSpy::setColor(DlColor color) {
if (color.isTransparent()) {
will_draw_ = false;
} else {
will_draw_ = true;
}
}
void DlOpSpy::setColorSource(const DlColorSource* source) {
if (!source) {
return;
}
const DlColorColorSource* color_source = source->asColor();
if (color_source && color_source->color().isTransparent()) {
will_draw_ = false;
return;
}
will_draw_ = true;
}
void DlOpSpy::save() {}
void DlOpSpy::saveLayer(const SkRect* bounds,
const SaveLayerOptions options,
const DlImageFilter* backdrop) {}
void DlOpSpy::restore() {}
void DlOpSpy::drawColor(DlColor color, DlBlendMode mode) {
did_draw_ |= !color.isTransparent();
}
void DlOpSpy::drawPaint() {
did_draw_ |= will_draw_;
}
// TODO(cyanglaz): check whether the shape (line, rect, oval, etc) needs to be
// evaluated. https://github.com/flutter/flutter/issues/123803
void DlOpSpy::drawLine(const SkPoint& p0, const SkPoint& p1) {
did_draw_ |= will_draw_;
}
void DlOpSpy::drawRect(const SkRect& rect) {
did_draw_ |= will_draw_;
}
void DlOpSpy::drawOval(const SkRect& bounds) {
did_draw_ |= will_draw_;
}
void DlOpSpy::drawCircle(const SkPoint& center, SkScalar radius) {
did_draw_ |= will_draw_;
}
void DlOpSpy::drawRRect(const SkRRect& rrect) {
did_draw_ |= will_draw_;
}
void DlOpSpy::drawDRRect(const SkRRect& outer, const SkRRect& inner) {
did_draw_ |= will_draw_;
}
void DlOpSpy::drawPath(const SkPath& path) {
did_draw_ |= will_draw_;
}
void DlOpSpy::drawArc(const SkRect& oval_bounds,
SkScalar start_degrees,
SkScalar sweep_degrees,
bool use_center) {
did_draw_ |= will_draw_;
}
void DlOpSpy::drawPoints(PointMode mode,
uint32_t count,
const SkPoint points[]) {
did_draw_ |= will_draw_;
}
void DlOpSpy::drawVertices(const DlVertices* vertices, DlBlendMode mode) {
did_draw_ |= will_draw_;
}
// In theory, below drawImage methods can produce a transparent screen when a
// transparent image is provided. The operation of determine whether an image is
// transparent needs examine all the pixels in the image object, which is slow.
// Drawing a completely transparent image is not a valid use case, thus, such
// case is ignored.
void DlOpSpy::drawImage(const sk_sp<DlImage> image,
const SkPoint point,
DlImageSampling sampling,
bool render_with_attributes) {
did_draw_ = true;
}
void DlOpSpy::drawImageRect(const sk_sp<DlImage> image,
const SkRect& src,
const SkRect& dst,
DlImageSampling sampling,
bool render_with_attributes,
SrcRectConstraint constraint) {
did_draw_ = true;
}
void DlOpSpy::drawImageNine(const sk_sp<DlImage> image,
const SkIRect& center,
const SkRect& dst,
DlFilterMode filter,
bool render_with_attributes) {
did_draw_ = true;
}
void DlOpSpy::drawAtlas(const sk_sp<DlImage> atlas,
const SkRSXform xform[],
const SkRect tex[],
const DlColor colors[],
int count,
DlBlendMode mode,
DlImageSampling sampling,
const SkRect* cull_rect,
bool render_with_attributes) {
did_draw_ = true;
}
void DlOpSpy::drawDisplayList(const sk_sp<DisplayList> display_list,
SkScalar opacity) {
if (did_draw_ || opacity == 0) {
return;
}
DlOpSpy receiver;
display_list->Dispatch(receiver);
did_draw_ |= receiver.did_draw();
}
void DlOpSpy::drawTextBlob(const sk_sp<SkTextBlob> blob,
SkScalar x,
SkScalar y) {
did_draw_ |= will_draw_;
}
void DlOpSpy::drawShadow(const SkPath& path,
const DlColor color,
const SkScalar elevation,
bool transparent_occluder,
SkScalar dpr) {
did_draw_ |= !color.isTransparent();
}
} // namespace flutter