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

Commit 29ea28d

Browse files
authored
Add 'explicit' to header files (#29741)
1 parent d389ae4 commit 29ea28d

File tree

69 files changed

+137
-112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+137
-112
lines changed

benchmarking/benchmarking.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace benchmarking {
1111

1212
class ScopedPauseTiming {
1313
public:
14-
ScopedPauseTiming(::benchmark::State& state, bool enabled = true)
14+
explicit ScopedPauseTiming(::benchmark::State& state, bool enabled = true)
1515
: state_(state), enabled_(enabled) {
1616
if (enabled_) {
1717
state_.PauseTiming();

common/graphics/gl_context_switch.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class GLContextResult {
5757
bool GetResult();
5858

5959
protected:
60-
GLContextResult(bool static_result);
60+
explicit GLContextResult(bool static_result);
6161
bool result_;
6262

6363
FML_DISALLOW_COPY_AND_ASSIGN(GLContextResult);
@@ -78,7 +78,7 @@ class GLContextDefaultResult : public GLContextResult {
7878
///
7979
/// @param static_result a static value that will be returned from
8080
/// |GetResult|
81-
GLContextDefaultResult(bool static_result);
81+
explicit GLContextDefaultResult(bool static_result);
8282

8383
~GLContextDefaultResult() override;
8484

@@ -99,7 +99,7 @@ class GLContextSwitch final : public GLContextResult {
9999
/// @param context The context that is going to be set as the current
100100
/// context. The |GLContextSwitch| should not outlive the owner of the gl
101101
/// context wrapped inside the `context`.
102-
GLContextSwitch(std::unique_ptr<SwitchableGLContext> context);
102+
explicit GLContextSwitch(std::unique_ptr<SwitchableGLContext> context);
103103

104104
~GLContextSwitch() override;
105105

common/graphics/persistent_cache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class PersistentCache : public GrContextOptions::PersistentCache {
5959
static const uint32_t kSignature = 0xA869593F;
6060
static const uint32_t kVersion1 = 1;
6161

62-
CacheObjectHeader(uint32_t p_key_size) : key_size(p_key_size) {}
62+
explicit CacheObjectHeader(uint32_t p_key_size) : key_size(p_key_size) {}
6363

6464
uint32_t signature = kSignature;
6565
uint32_t version = kVersion1;
@@ -163,7 +163,7 @@ class PersistentCache : public GrContextOptions::PersistentCache {
163163

164164
bool IsValid() const;
165165

166-
PersistentCache(bool read_only = false);
166+
explicit PersistentCache(bool read_only = false);
167167

168168
// |GrContextOptions::PersistentCache|
169169
void store(const SkData& key, const SkData& data) override;

flow/compositor_context.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ class CompositorContext {
138138
FML_DISALLOW_COPY_AND_ASSIGN(ScopedFrame);
139139
};
140140

141-
CompositorContext(fml::Milliseconds frame_budget = fml::kDefaultFrameBudget);
141+
explicit CompositorContext(
142+
fml::Milliseconds frame_budget = fml::kDefaultFrameBudget);
142143

143144
virtual ~CompositorContext();
144145

flow/display_list.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ DEFINE_SET_ENUM_OP(Join)
105105
struct SetStyleOp final : DLOp {
106106
static const auto kType = DisplayListOpType::kSetStyle;
107107

108-
SetStyleOp(SkPaint::Style style) : style(style) {}
108+
explicit SetStyleOp(SkPaint::Style style) : style(style) {}
109109

110110
const SkPaint::Style style;
111111

@@ -115,7 +115,7 @@ struct SetStyleOp final : DLOp {
115115
struct SetStrokeWidthOp final : DLOp {
116116
static const auto kType = DisplayListOpType::kSetStrokeWidth;
117117

118-
SetStrokeWidthOp(SkScalar width) : width(width) {}
118+
explicit SetStrokeWidthOp(SkScalar width) : width(width) {}
119119

120120
const SkScalar width;
121121

@@ -127,7 +127,7 @@ struct SetStrokeWidthOp final : DLOp {
127127
struct SetStrokeMiterOp final : DLOp {
128128
static const auto kType = DisplayListOpType::kSetStrokeMiter;
129129

130-
SetStrokeMiterOp(SkScalar limit) : limit(limit) {}
130+
explicit SetStrokeMiterOp(SkScalar limit) : limit(limit) {}
131131

132132
const SkScalar limit;
133133

@@ -140,7 +140,7 @@ struct SetStrokeMiterOp final : DLOp {
140140
struct SetColorOp final : DLOp {
141141
static const auto kType = DisplayListOpType::kSetColor;
142142

143-
SetColorOp(SkColor color) : color(color) {}
143+
explicit SetColorOp(SkColor color) : color(color) {}
144144

145145
const SkColor color;
146146

@@ -150,7 +150,7 @@ struct SetColorOp final : DLOp {
150150
struct SetBlendModeOp final : DLOp {
151151
static const auto kType = DisplayListOpType::kSetBlendMode;
152152

153-
SetBlendModeOp(SkBlendMode mode) : mode(mode) {}
153+
explicit SetBlendModeOp(SkBlendMode mode) : mode(mode) {}
154154

155155
const SkBlendMode mode;
156156

@@ -224,7 +224,7 @@ struct SaveOp final : DLOp {
224224
struct SaveLayerOp final : DLOp {
225225
static const auto kType = DisplayListOpType::kSaveLayer;
226226

227-
SaveLayerOp(bool with_paint) : with_paint(with_paint) {}
227+
explicit SaveLayerOp(bool with_paint) : with_paint(with_paint) {}
228228

229229
bool with_paint;
230230

@@ -283,7 +283,7 @@ struct ScaleOp final : DLOp {
283283
struct RotateOp final : DLOp {
284284
static const auto kType = DisplayListOpType::kRotate;
285285

286-
RotateOp(SkScalar degrees) : degrees(degrees) {}
286+
explicit RotateOp(SkScalar degrees) : degrees(degrees) {}
287287

288288
const SkScalar degrees;
289289

@@ -454,7 +454,7 @@ DEFINE_DRAW_1ARG_OP(RRect, SkRRect, rrect)
454454
struct DrawPathOp final : DLOp {
455455
static const auto kType = DisplayListOpType::kDrawPath;
456456

457-
DrawPathOp(SkPath path) : path(path) {}
457+
explicit DrawPathOp(SkPath path) : path(path) {}
458458

459459
const SkPath path;
460460

@@ -804,7 +804,7 @@ struct DrawSkPictureMatrixOp final : DLOp {
804804
struct DrawDisplayListOp final : DLOp {
805805
static const auto kType = DisplayListOpType::kDrawDisplayList;
806806

807-
DrawDisplayListOp(const sk_sp<DisplayList> display_list)
807+
explicit DrawDisplayListOp(const sk_sp<DisplayList> display_list)
808808
: display_list(std::move(display_list)) {}
809809

810810
sk_sp<DisplayList> display_list;

flow/display_list.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ class DisplayListOpFlags : DisplayListFlags {
747747
// the DisplayListCanvasRecorder class.
748748
class DisplayListBuilder final : public virtual Dispatcher, public SkRefCnt {
749749
public:
750-
DisplayListBuilder(const SkRect& cull_rect = kMaxCullRect_);
750+
explicit DisplayListBuilder(const SkRect& cull_rect = kMaxCullRect_);
751751
~DisplayListBuilder();
752752

753753
void setAntiAlias(bool aa) override {

flow/display_list_canvas.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace flutter {
2727
class DisplayListCanvasDispatcher : public virtual Dispatcher,
2828
public SkPaintDispatchHelper {
2929
public:
30-
DisplayListCanvasDispatcher(SkCanvas* canvas) : canvas_(canvas) {}
30+
explicit DisplayListCanvasDispatcher(SkCanvas* canvas) : canvas_(canvas) {}
3131

3232
void save() override;
3333
void restore() override;
@@ -123,7 +123,7 @@ class DisplayListCanvasRecorder
123123
public SkRefCnt,
124124
DisplayListOpFlags {
125125
public:
126-
DisplayListCanvasRecorder(const SkRect& bounds);
126+
explicit DisplayListCanvasRecorder(const SkRect& bounds);
127127

128128
const sk_sp<DisplayListBuilder> builder() { return builder_; }
129129

flow/display_list_utils.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class ClipBoundsDispatchHelper : public virtual Dispatcher,
199199
public:
200200
ClipBoundsDispatchHelper() : ClipBoundsDispatchHelper(nullptr) {}
201201

202-
ClipBoundsDispatchHelper(const SkRect* cull_rect)
202+
explicit ClipBoundsDispatchHelper(const SkRect* cull_rect)
203203
: has_clip_(cull_rect),
204204
bounds_(cull_rect && !cull_rect->isEmpty() ? *cull_rect
205205
: SkRect::MakeEmpty()) {}
@@ -279,7 +279,7 @@ class DisplayListBoundsCalculator final
279279
// queried using |isUnbounded| if an alternate plan is available
280280
// for such cases.
281281
// The flag should never be set if a cull_rect is provided.
282-
DisplayListBoundsCalculator(const SkRect* cull_rect = nullptr);
282+
explicit DisplayListBoundsCalculator(const SkRect* cull_rect = nullptr);
283283

284284
void setStrokeCap(SkPaint::Cap cap) override;
285285
void setStrokeJoin(SkPaint::Join join) override;
@@ -403,7 +403,8 @@ class DisplayListBoundsCalculator final
403403
// the stack.
404404
// Some layers may substitute their own accumulator to compute
405405
// their own local bounds while they are on the stack.
406-
LayerData(BoundsAccumulator* outer) : outer_(outer), is_unbounded_(false) {}
406+
explicit LayerData(BoundsAccumulator* outer)
407+
: outer_(outer), is_unbounded_(false) {}
407408
virtual ~LayerData() = default;
408409

409410
// The accumulator to use while this layer is put in play by

flow/frame_timings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class FrameTimingsRecorder {
4141
FrameTimingsRecorder();
4242

4343
/// Constructor with a pre-populated frame number.
44-
FrameTimingsRecorder(uint64_t frame_number);
44+
explicit FrameTimingsRecorder(uint64_t frame_number);
4545

4646
~FrameTimingsRecorder();
4747

flow/instrumentation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace flutter {
1616

1717
class Stopwatch {
1818
public:
19-
Stopwatch(fml::Milliseconds frame_budget = fml::kDefaultFrameBudget);
19+
explicit Stopwatch(fml::Milliseconds frame_budget = fml::kDefaultFrameBudget);
2020

2121
~Stopwatch();
2222

flow/layers/clip_path_layer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ namespace flutter {
1111

1212
class ClipPathLayer : public ContainerLayer {
1313
public:
14-
ClipPathLayer(const SkPath& clip_path, Clip clip_behavior = Clip::antiAlias);
14+
explicit ClipPathLayer(const SkPath& clip_path,
15+
Clip clip_behavior = Clip::antiAlias);
1516

1617
void Diff(DiffContext* context, const Layer* old_layer) override;
1718

flow/layers/color_filter_layer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace flutter {
1212

1313
class ColorFilterLayer : public ContainerLayer {
1414
public:
15-
ColorFilterLayer(sk_sp<SkColorFilter> filter);
15+
explicit ColorFilterLayer(sk_sp<SkColorFilter> filter);
1616

1717
void Diff(DiffContext* context, const Layer* old_layer) override;
1818

flow/layers/image_filter_layer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace flutter {
1212

1313
class ImageFilterLayer : public MergedContainerLayer {
1414
public:
15-
ImageFilterLayer(sk_sp<SkImageFilter> filter);
15+
explicit ImageFilterLayer(sk_sp<SkImageFilter> filter);
1616

1717
void Diff(DiffContext* context, const Layer* old_layer) override;
1818

flow/layers/transform_layer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace flutter {
1313
// at all. Hence |set_transform| must be called with an initialized SkMatrix.
1414
class TransformLayer : public ContainerLayer {
1515
public:
16-
TransformLayer(const SkMatrix& transform);
16+
explicit TransformLayer(const SkMatrix& transform);
1717

1818
void Diff(DiffContext* context, const Layer* old_layer) override;
1919

flow/testing/gl_context_switch_test.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class GLContextSwitchTest : public ::testing::Test {
2020
/// The renderer context used for testing
2121
class TestSwitchableGLContext : public SwitchableGLContext {
2222
public:
23-
TestSwitchableGLContext(int context);
23+
explicit TestSwitchableGLContext(int context);
2424

2525
~TestSwitchableGLContext() override;
2626

flow/testing/mock_layer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ namespace testing {
1616
// verify the data against expected values.
1717
class MockLayer : public Layer {
1818
public:
19-
MockLayer(SkPath path,
20-
SkPaint paint = SkPaint(),
21-
bool fake_has_platform_view = false,
22-
bool fake_reads_surface = false);
19+
explicit MockLayer(SkPath path,
20+
SkPaint paint = SkPaint(),
21+
bool fake_has_platform_view = false,
22+
bool fake_reads_surface = false);
2323

2424
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
2525
void Paint(PaintContext& context) const override;

flow/testing/mock_raster_cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace testing {
2424
*/
2525
class MockRasterCacheResult : public RasterCacheResult {
2626
public:
27-
MockRasterCacheResult(SkIRect device_rect);
27+
explicit MockRasterCacheResult(SkIRect device_rect);
2828

2929
void draw(SkCanvas& canvas, const SkPaint* paint = nullptr) const override{};
3030

fml/closure.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class ScopedCleanupClosure {
3333
public:
3434
ScopedCleanupClosure() = default;
3535

36-
ScopedCleanupClosure(const fml::closure& closure) : closure_(closure) {}
36+
explicit ScopedCleanupClosure(const fml::closure& closure)
37+
: closure_(closure) {}
3738

3839
~ScopedCleanupClosure() {
3940
if (closure_) {

fml/concurrent_message_loop.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ConcurrentMessageLoop
4646
std::map<std::thread::id, std::vector<fml::closure>> thread_tasks_;
4747
bool shutdown_ = false;
4848

49-
ConcurrentMessageLoop(size_t worker_count);
49+
explicit ConcurrentMessageLoop(size_t worker_count);
5050

5151
void WorkerMain();
5252

@@ -61,7 +61,7 @@ class ConcurrentMessageLoop
6161

6262
class ConcurrentTaskRunner : public BasicTaskRunner {
6363
public:
64-
ConcurrentTaskRunner(std::weak_ptr<ConcurrentMessageLoop> weak_loop);
64+
explicit ConcurrentTaskRunner(std::weak_ptr<ConcurrentMessageLoop> weak_loop);
6565

6666
virtual ~ConcurrentTaskRunner();
6767

fml/log_settings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ int GetMinLogLevel();
3737

3838
class ScopedSetLogSettings {
3939
public:
40-
ScopedSetLogSettings(const LogSettings& settings);
40+
explicit ScopedSetLogSettings(const LogSettings& settings);
4141
~ScopedSetLogSettings();
4242

4343
private:

fml/mapping.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ class FileMapping final : public Mapping {
4444
kExecute,
4545
};
4646

47-
FileMapping(const fml::UniqueFD& fd,
48-
std::initializer_list<Protection> protection = {
49-
Protection::kRead});
47+
explicit FileMapping(const fml::UniqueFD& fd,
48+
std::initializer_list<Protection> protection = {
49+
Protection::kRead});
5050

5151
~FileMapping() override;
5252

@@ -91,9 +91,9 @@ class FileMapping final : public Mapping {
9191

9292
class DataMapping final : public Mapping {
9393
public:
94-
DataMapping(std::vector<uint8_t> data);
94+
explicit DataMapping(std::vector<uint8_t> data);
9595

96-
DataMapping(const std::string& string);
96+
explicit DataMapping(const std::string& string);
9797

9898
~DataMapping() override;
9999

fml/memory/ref_ptr.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ template <typename T>
6565
class RefPtr final {
6666
public:
6767
RefPtr() : ptr_(nullptr) {}
68-
RefPtr(std::nullptr_t)
69-
: ptr_(nullptr) {} // NOLINT(google-explicit-constructor)
68+
RefPtr(std::nullptr_t) // NOLINT(google-explicit-constructor)
69+
: ptr_(nullptr) {}
7070

7171
// Explicit constructor from a plain pointer (to an object that must have
7272
// already been adopted). (Note that in |T::T()|, references to |this| cannot
@@ -80,22 +80,25 @@ class RefPtr final {
8080
}
8181

8282
// Copy constructor.
83-
RefPtr(const RefPtr<T>& r) : ptr_(r.ptr_) {
83+
RefPtr(const RefPtr<T>& r) // NOLINT(google-explicit-constructor)
84+
: ptr_(r.ptr_) {
8485
if (ptr_) {
8586
ptr_->AddRef();
8687
}
8788
}
8889

8990
template <typename U>
90-
RefPtr(const RefPtr<U>& r)
91-
: ptr_(r.ptr_) { // NOLINT(google-explicit-constructor)
91+
RefPtr(const RefPtr<U>& r) // NOLINT(google-explicit-constructor)
92+
: ptr_(r.ptr_) {
9293
if (ptr_) {
9394
ptr_->AddRef();
9495
}
9596
}
9697

9798
// Move constructor.
98-
RefPtr(RefPtr<T>&& r) : ptr_(r.ptr_) { r.ptr_ = nullptr; }
99+
RefPtr(RefPtr<T>&& r) : ptr_(r.ptr_) { // NOLINT(google-explicit-constructor)
100+
r.ptr_ = nullptr;
101+
}
99102

100103
template <typename U>
101104
RefPtr(RefPtr<U>&& r) : ptr_(r.ptr_) { // NOLINT(google-explicit-constructor)

0 commit comments

Comments
 (0)