Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c7a6c52

Browse files
matanlureyharryterkelsen
authored andcommitted
Tidy up DlPaint and friends. (#46120)
Closes flutter/flutter#135058. Work towards flutter/flutter#134969. All fixes are generated by `clang-tidy --fix`, and manual search/replace if that wasn't sufficient.
1 parent f9b6409 commit c7a6c52

File tree

2 files changed

+83
-82
lines changed

2 files changed

+83
-82
lines changed

display_list/dl_paint.cc

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,33 @@
77
namespace flutter {
88

99
DlPaint::DlPaint(DlColor color)
10-
: blendMode_(static_cast<unsigned>(DlBlendMode::kDefaultMode)),
11-
drawStyle_(static_cast<unsigned>(DlDrawStyle::kDefaultStyle)),
12-
strokeCap_(static_cast<unsigned>(DlStrokeCap::kDefaultCap)),
13-
strokeJoin_(static_cast<unsigned>(DlStrokeJoin::kDefaultJoin)),
14-
isAntiAlias_(false),
15-
isDither_(false),
16-
isInvertColors_(false),
10+
: blend_mode_(static_cast<unsigned>(DlBlendMode::kDefaultMode)),
11+
draw_style_(static_cast<unsigned>(DlDrawStyle::kDefaultStyle)),
12+
stroke_cap_(static_cast<unsigned>(DlStrokeCap::kDefaultCap)),
13+
stroke_join_(static_cast<unsigned>(DlStrokeJoin::kDefaultJoin)),
14+
is_anti_alias_(false),
15+
is_dither_(false),
16+
is_invert_colors_(false),
1717
color_(color),
18-
strokeWidth_(kDefaultWidth),
19-
strokeMiter_(kDefaultMiter) {}
18+
stroke_width_(kDefaultWidth),
19+
stroke_miter_(kDefaultMiter) {}
2020

2121
bool DlPaint::operator==(DlPaint const& other) const {
22-
return blendMode_ == other.blendMode_ && //
23-
drawStyle_ == other.drawStyle_ && //
24-
strokeCap_ == other.strokeCap_ && //
25-
strokeJoin_ == other.strokeJoin_ && //
26-
isAntiAlias_ == other.isAntiAlias_ && //
27-
isDither_ == other.isDither_ && //
28-
isInvertColors_ == other.isInvertColors_ && //
29-
color_ == other.color_ && //
30-
strokeWidth_ == other.strokeWidth_ && //
31-
strokeMiter_ == other.strokeMiter_ && //
32-
Equals(colorSource_, other.colorSource_) && //
33-
Equals(colorFilter_, other.colorFilter_) && //
34-
Equals(imageFilter_, other.imageFilter_) && //
35-
Equals(maskFilter_, other.maskFilter_) && //
36-
Equals(pathEffect_, other.pathEffect_);
22+
return blend_mode_ == other.blend_mode_ && //
23+
draw_style_ == other.draw_style_ && //
24+
stroke_cap_ == other.stroke_cap_ && //
25+
stroke_join_ == other.stroke_join_ && //
26+
is_anti_alias_ == other.is_anti_alias_ && //
27+
is_dither_ == other.is_dither_ && //
28+
is_invert_colors_ == other.is_invert_colors_ && //
29+
color_ == other.color_ && //
30+
stroke_width_ == other.stroke_width_ && //
31+
stroke_miter_ == other.stroke_miter_ && //
32+
Equals(color_source_, other.color_source_) && //
33+
Equals(color_filter_, other.color_filter_) && //
34+
Equals(image_filter_, other.image_filter_) && //
35+
Equals(mask_filter_, other.mask_filter_) && //
36+
Equals(path_effect_, other.path_effect_);
3737
}
3838

3939
const DlPaint DlPaint::kDefault;

display_list/dl_paint.h

Lines changed: 59 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define FLUTTER_DISPLAY_LIST_DL_PAINT_H_
77

88
#include <memory>
9+
#include <utility>
910
#include "flutter/display_list/dl_blend_mode.h"
1011
#include "flutter/display_list/dl_color.h"
1112
#include "flutter/display_list/effects/dl_color_filter.h"
@@ -52,23 +53,23 @@ class DlPaint {
5253
static const DlPaint kDefault;
5354

5455
DlPaint() : DlPaint(DlColor::kBlack()) {}
55-
DlPaint(DlColor color);
56+
explicit DlPaint(DlColor color);
5657

57-
bool isAntiAlias() const { return isAntiAlias_; }
58+
bool isAntiAlias() const { return is_anti_alias_; }
5859
DlPaint& setAntiAlias(bool isAntiAlias) {
59-
isAntiAlias_ = isAntiAlias;
60+
is_anti_alias_ = isAntiAlias;
6061
return *this;
6162
}
6263

63-
bool isDither() const { return isDither_; }
64+
bool isDither() const { return is_dither_; }
6465
DlPaint& setDither(bool isDither) {
65-
isDither_ = isDither;
66+
is_dither_ = isDither;
6667
return *this;
6768
}
6869

69-
bool isInvertColors() const { return isInvertColors_; }
70+
bool isInvertColors() const { return is_invert_colors_; }
7071
DlPaint& setInvertColors(bool isInvertColors) {
71-
isInvertColors_ = isInvertColors;
72+
is_invert_colors_ = isInvertColors;
7273
return *this;
7374
}
7475

@@ -87,111 +88,111 @@ class DlPaint {
8788
}
8889

8990
DlBlendMode getBlendMode() const {
90-
return static_cast<DlBlendMode>(blendMode_);
91+
return static_cast<DlBlendMode>(blend_mode_);
9192
}
9293
DlPaint& setBlendMode(DlBlendMode mode) {
93-
blendMode_ = static_cast<unsigned>(mode);
94+
blend_mode_ = static_cast<unsigned>(mode);
9495
return *this;
9596
}
9697

9798
DlDrawStyle getDrawStyle() const {
98-
return static_cast<DlDrawStyle>(drawStyle_);
99+
return static_cast<DlDrawStyle>(draw_style_);
99100
}
100101
DlPaint& setDrawStyle(DlDrawStyle style) {
101-
drawStyle_ = static_cast<unsigned>(style);
102+
draw_style_ = static_cast<unsigned>(style);
102103
return *this;
103104
}
104105

105106
DlStrokeCap getStrokeCap() const {
106-
return static_cast<DlStrokeCap>(strokeCap_);
107+
return static_cast<DlStrokeCap>(stroke_cap_);
107108
}
108109
DlPaint& setStrokeCap(DlStrokeCap cap) {
109-
strokeCap_ = static_cast<unsigned>(cap);
110+
stroke_cap_ = static_cast<unsigned>(cap);
110111
return *this;
111112
}
112113

113114
DlStrokeJoin getStrokeJoin() const {
114-
return static_cast<DlStrokeJoin>(strokeJoin_);
115+
return static_cast<DlStrokeJoin>(stroke_join_);
115116
}
116117
DlPaint& setStrokeJoin(DlStrokeJoin join) {
117-
strokeJoin_ = static_cast<unsigned>(join);
118+
stroke_join_ = static_cast<unsigned>(join);
118119
return *this;
119120
}
120121

121-
float getStrokeWidth() const { return strokeWidth_; }
122+
float getStrokeWidth() const { return stroke_width_; }
122123
DlPaint& setStrokeWidth(float width) {
123-
strokeWidth_ = width;
124+
stroke_width_ = width;
124125
return *this;
125126
}
126127

127-
float getStrokeMiter() const { return strokeMiter_; }
128+
float getStrokeMiter() const { return stroke_miter_; }
128129
DlPaint& setStrokeMiter(float miter) {
129-
strokeMiter_ = miter;
130+
stroke_miter_ = miter;
130131
return *this;
131132
}
132133

133134
std::shared_ptr<const DlColorSource> getColorSource() const {
134-
return colorSource_;
135+
return color_source_;
135136
}
136-
const DlColorSource* getColorSourcePtr() const { return colorSource_.get(); }
137+
const DlColorSource* getColorSourcePtr() const { return color_source_.get(); }
137138
DlPaint& setColorSource(std::shared_ptr<const DlColorSource> source) {
138-
colorSource_ = source;
139+
color_source_ = std::move(source);
139140
return *this;
140141
}
141142
DlPaint& setColorSource(const DlColorSource* source) {
142-
colorSource_ = source ? source->shared() : nullptr;
143+
color_source_ = source ? source->shared() : nullptr;
143144
return *this;
144145
}
145146

146147
std::shared_ptr<const DlColorFilter> getColorFilter() const {
147-
return colorFilter_;
148+
return color_filter_;
148149
}
149-
const DlColorFilter* getColorFilterPtr() const { return colorFilter_.get(); }
150-
DlPaint& setColorFilter(const std::shared_ptr<const DlColorFilter> filter) {
151-
colorFilter_ = filter;
150+
const DlColorFilter* getColorFilterPtr() const { return color_filter_.get(); }
151+
DlPaint& setColorFilter(const std::shared_ptr<const DlColorFilter>& filter) {
152+
color_filter_ = filter;
152153
return *this;
153154
}
154155
DlPaint& setColorFilter(const DlColorFilter* filter) {
155-
colorFilter_ = filter ? filter->shared() : nullptr;
156+
color_filter_ = filter ? filter->shared() : nullptr;
156157
return *this;
157158
}
158159

159160
std::shared_ptr<const DlImageFilter> getImageFilter() const {
160-
return imageFilter_;
161+
return image_filter_;
161162
}
162-
const DlImageFilter* getImageFilterPtr() const { return imageFilter_.get(); }
163-
DlPaint& setImageFilter(const std::shared_ptr<const DlImageFilter> filter) {
164-
imageFilter_ = filter;
163+
const DlImageFilter* getImageFilterPtr() const { return image_filter_.get(); }
164+
DlPaint& setImageFilter(const std::shared_ptr<const DlImageFilter>& filter) {
165+
image_filter_ = filter;
165166
return *this;
166167
}
167168
DlPaint& setImageFilter(const DlImageFilter* filter) {
168-
imageFilter_ = filter ? filter->shared() : nullptr;
169+
image_filter_ = filter ? filter->shared() : nullptr;
169170
return *this;
170171
}
171172

172173
std::shared_ptr<const DlMaskFilter> getMaskFilter() const {
173-
return maskFilter_;
174+
return mask_filter_;
174175
}
175-
const DlMaskFilter* getMaskFilterPtr() const { return maskFilter_.get(); }
176-
DlPaint& setMaskFilter(std::shared_ptr<DlMaskFilter> filter) {
177-
maskFilter_ = filter;
176+
const DlMaskFilter* getMaskFilterPtr() const { return mask_filter_.get(); }
177+
DlPaint& setMaskFilter(const std::shared_ptr<DlMaskFilter>& filter) {
178+
mask_filter_ = filter;
178179
return *this;
179180
}
180181
DlPaint& setMaskFilter(const DlMaskFilter* filter) {
181-
maskFilter_ = filter ? filter->shared() : nullptr;
182+
mask_filter_ = filter ? filter->shared() : nullptr;
182183
return *this;
183184
}
184185

185186
std::shared_ptr<const DlPathEffect> getPathEffect() const {
186-
return pathEffect_;
187+
return path_effect_;
187188
}
188-
const DlPathEffect* getPathEffectPtr() const { return pathEffect_.get(); }
189-
DlPaint& setPathEffect(std::shared_ptr<DlPathEffect> pathEffect) {
190-
pathEffect_ = pathEffect;
189+
const DlPathEffect* getPathEffectPtr() const { return path_effect_.get(); }
190+
DlPaint& setPathEffect(const std::shared_ptr<DlPathEffect>& pathEffect) {
191+
path_effect_ = pathEffect;
191192
return *this;
192193
}
193194
DlPaint& setPathEffect(const DlPathEffect* effect) {
194-
pathEffect_ = effect ? effect->shared() : nullptr;
195+
path_effect_ = effect ? effect->shared() : nullptr;
195196
return *this;
196197
}
197198

@@ -216,25 +217,25 @@ class DlPaint {
216217

217218
union {
218219
struct {
219-
unsigned blendMode_ : kBlendModeBits;
220-
unsigned drawStyle_ : kDrawStyleBits;
221-
unsigned strokeCap_ : kStrokeCapBits;
222-
unsigned strokeJoin_ : kStrokeJoinBits;
223-
unsigned isAntiAlias_ : 1;
224-
unsigned isDither_ : 1;
225-
unsigned isInvertColors_ : 1;
220+
unsigned blend_mode_ : kBlendModeBits;
221+
unsigned draw_style_ : kDrawStyleBits;
222+
unsigned stroke_cap_ : kStrokeCapBits;
223+
unsigned stroke_join_ : kStrokeJoinBits;
224+
unsigned is_anti_alias_ : 1;
225+
unsigned is_dither_ : 1;
226+
unsigned is_invert_colors_ : 1;
226227
};
227228
};
228229

229230
DlColor color_;
230-
float strokeWidth_;
231-
float strokeMiter_;
232-
233-
std::shared_ptr<const DlColorSource> colorSource_;
234-
std::shared_ptr<const DlColorFilter> colorFilter_;
235-
std::shared_ptr<const DlImageFilter> imageFilter_;
236-
std::shared_ptr<const DlMaskFilter> maskFilter_;
237-
std::shared_ptr<const DlPathEffect> pathEffect_;
231+
float stroke_width_;
232+
float stroke_miter_;
233+
234+
std::shared_ptr<const DlColorSource> color_source_;
235+
std::shared_ptr<const DlColorFilter> color_filter_;
236+
std::shared_ptr<const DlImageFilter> image_filter_;
237+
std::shared_ptr<const DlMaskFilter> mask_filter_;
238+
std::shared_ptr<const DlPathEffect> path_effect_;
238239
};
239240

240241
} // namespace flutter

0 commit comments

Comments
 (0)