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

Commit d986b8d

Browse files
authored
Enable linting in several files (#20134)
1 parent cb4bb93 commit d986b8d

13 files changed

+79
-60
lines changed

flow/instrumentation.cc

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
// FLUTTER_NOLINT
54

65
#include "flutter/flow/instrumentation.h"
76

@@ -52,16 +51,18 @@ double Stopwatch::UnitFrameInterval(double raster_time_ms) const {
5251
double Stopwatch::UnitHeight(double raster_time_ms,
5352
double max_unit_interval) const {
5453
double unitHeight = UnitFrameInterval(raster_time_ms) / max_unit_interval;
55-
if (unitHeight > 1.0)
54+
if (unitHeight > 1.0) {
5655
unitHeight = 1.0;
56+
}
5757
return unitHeight;
5858
}
5959

6060
fml::TimeDelta Stopwatch::MaxDelta() const {
6161
fml::TimeDelta max_delta;
6262
for (size_t i = 0; i < kMaxSamples; i++) {
63-
if (laps_[i] > max_delta)
63+
if (laps_[i] > max_delta) {
6464
max_delta = laps_[i];
65+
}
6566
}
6667
return max_delta;
6768
}
@@ -135,7 +136,7 @@ void Stopwatch::InitVisualizeSurface(const SkRect& rect) const {
135136
cache_canvas->drawPath(path, paint);
136137
}
137138

138-
void Stopwatch::Visualize(SkCanvas& canvas, const SkRect& rect) const {
139+
void Stopwatch::Visualize(SkCanvas* canvas, const SkRect& rect) const {
139140
// Initialize visualize cache if it has not yet been initialized.
140141
InitVisualizeSurface(rect);
141142

@@ -191,8 +192,9 @@ void Stopwatch::Visualize(SkCanvas& canvas, const SkRect& rect) const {
191192

192193
// Limit the number of markers displayed. After a certain point, the graph
193194
// becomes crowded
194-
if (frame_marker_count > kMaxFrameMarkers)
195+
if (frame_marker_count > kMaxFrameMarkers) {
195196
frame_marker_count = 1;
197+
}
196198

197199
for (size_t frame_index = 0; frame_index < frame_marker_count;
198200
frame_index++) {
@@ -224,7 +226,7 @@ void Stopwatch::Visualize(SkCanvas& canvas, const SkRect& rect) const {
224226

225227
// Draw the cached surface onto the output canvas.
226228
paint.reset();
227-
visualize_cache_surface_->draw(&canvas, rect.x(), rect.y(), &paint);
229+
visualize_cache_surface_->draw(canvas, rect.x(), rect.y(), &paint);
228230
}
229231

230232
CounterValues::CounterValues() : current_sample_(kMaxSamples - 1) {
@@ -238,7 +240,7 @@ void CounterValues::Add(int64_t value) {
238240
values_[current_sample_] = value;
239241
}
240242

241-
void CounterValues::Visualize(SkCanvas& canvas, const SkRect& rect) const {
243+
void CounterValues::Visualize(SkCanvas* canvas, const SkRect& rect) const {
242244
size_t max_bytes = GetMaxValue();
243245

244246
if (max_bytes == 0) {
@@ -252,7 +254,7 @@ void CounterValues::Visualize(SkCanvas& canvas, const SkRect& rect) const {
252254

253255
// Paint the background.
254256
paint.setColor(0x99FFFFFF);
255-
canvas.drawRect(rect, paint);
257+
canvas->drawRect(rect, paint);
256258

257259
// Establish the graph position.
258260
const SkScalar x = rect.x();
@@ -268,10 +270,12 @@ void CounterValues::Visualize(SkCanvas& canvas, const SkRect& rect) const {
268270

269271
for (size_t i = 0; i < kMaxSamples; ++i) {
270272
int64_t current_bytes = values_[i];
271-
double ratio =
272-
(double)(current_bytes - min_bytes) / (max_bytes - min_bytes);
273-
path.lineTo(x + (((double)(i) / (double)kMaxSamples) * width),
274-
y + ((1.0 - ratio) * height));
273+
double ratio = static_cast<double>(current_bytes - min_bytes) /
274+
static_cast<double>(max_bytes - min_bytes);
275+
path.lineTo(
276+
x + ((static_cast<double>(i) / static_cast<double>(kMaxSamples)) *
277+
width),
278+
y + ((1.0 - ratio) * height));
275279
}
276280

277281
path.rLineTo(100, 0);
@@ -280,7 +284,7 @@ void CounterValues::Visualize(SkCanvas& canvas, const SkRect& rect) const {
280284

281285
// Draw the graph.
282286
paint.setColor(0xAA0000FF);
283-
canvas.drawPath(path, paint);
287+
canvas->drawPath(path, paint);
284288

285289
// Paint the vertical marker for the current frame.
286290
const double sample_unit_width = (1.0 / kMaxSamples);
@@ -294,7 +298,7 @@ void CounterValues::Visualize(SkCanvas& canvas, const SkRect& rect) const {
294298
const auto marker_rect = SkRect::MakeLTRB(
295299
sample_x, y,
296300
sample_x + width * sample_unit_width + sample_margin_width * 2, bottom);
297-
canvas.drawRect(marker_rect, paint);
301+
canvas->drawRect(marker_rect, paint);
298302
}
299303

300304
int64_t CounterValues::GetCurrentValue() const {

flow/instrumentation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Stopwatch {
3030

3131
void InitVisualizeSurface(const SkRect& rect) const;
3232

33-
void Visualize(SkCanvas& canvas, const SkRect& rect) const;
33+
void Visualize(SkCanvas* canvas, const SkRect& rect) const;
3434

3535
void Start();
3636

@@ -81,7 +81,7 @@ class CounterValues {
8181

8282
void Add(int64_t value);
8383

84-
void Visualize(SkCanvas& canvas, const SkRect& rect) const;
84+
void Visualize(SkCanvas* canvas, const SkRect& rect) const;
8585

8686
int64_t GetCurrentValue() const;
8787

flow/layers/layer_tree.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
// FLUTTER_NOLINT
54

65
#include "flutter/flow/layers/layer_tree.h"
76

@@ -117,7 +116,7 @@ void LayerTree::Paint(CompositorContext::ScopedFrame& frame,
117116
}
118117

119118
Layer::PaintContext context = {
120-
(SkCanvas*)&internal_nodes_canvas,
119+
static_cast<SkCanvas*>(&internal_nodes_canvas),
121120
frame.canvas(),
122121
frame.gr_context(),
123122
frame.view_embedder(),
@@ -129,8 +128,9 @@ void LayerTree::Paint(CompositorContext::ScopedFrame& frame,
129128
frame_physical_depth_,
130129
frame_device_pixel_ratio_};
131130

132-
if (root_layer_->needs_painting())
131+
if (root_layer_->needs_painting()) {
133132
root_layer_->Paint(context);
133+
}
134134
}
135135

136136
sk_sp<SkPicture> LayerTree::Flatten(const SkRect& bounds) {
@@ -171,7 +171,7 @@ sk_sp<SkPicture> LayerTree::Flatten(const SkRect& bounds) {
171171
internal_nodes_canvas.addCanvas(canvas);
172172

173173
Layer::PaintContext paint_context = {
174-
(SkCanvas*)&internal_nodes_canvas,
174+
static_cast<SkCanvas*>(&internal_nodes_canvas),
175175
canvas, // canvas
176176
nullptr,
177177
nullptr,

flow/layers/performance_overlay_layer.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
// FLUTTER_NOLINT
54

65
#include <iomanip>
76
#include <iostream>
@@ -14,7 +13,7 @@
1413
namespace flutter {
1514
namespace {
1615

17-
void VisualizeStopWatch(SkCanvas& canvas,
16+
void VisualizeStopWatch(SkCanvas* canvas,
1817
const Stopwatch& stopwatch,
1918
SkScalar x,
2019
SkScalar y,
@@ -37,7 +36,7 @@ void VisualizeStopWatch(SkCanvas& canvas,
3736
stopwatch, label_prefix, font_path);
3837
SkPaint paint;
3938
paint.setColor(SK_ColorGRAY);
40-
canvas.drawTextBlob(text, x + label_x, y + height + label_y, paint);
39+
canvas->drawTextBlob(text, x + label_x, y + height + label_y, paint);
4140
}
4241
}
4342

@@ -77,8 +76,9 @@ PerformanceOverlayLayer::PerformanceOverlayLayer(uint64_t options,
7776
void PerformanceOverlayLayer::Paint(PaintContext& context) const {
7877
const int padding = 8;
7978

80-
if (!options_)
79+
if (!options_) {
8180
return;
81+
}
8282

8383
TRACE_EVENT0("flutter", "PerformanceOverlayLayer::Paint");
8484
SkScalar x = paint_bounds().x() + padding;
@@ -88,11 +88,11 @@ void PerformanceOverlayLayer::Paint(PaintContext& context) const {
8888
SkAutoCanvasRestore save(context.leaf_nodes_canvas, true);
8989

9090
VisualizeStopWatch(
91-
*context.leaf_nodes_canvas, context.raster_time, x, y, width,
91+
context.leaf_nodes_canvas, context.raster_time, x, y, width,
9292
height - padding, options_ & kVisualizeRasterizerStatistics,
9393
options_ & kDisplayRasterizerStatistics, "Raster", font_path_);
9494

95-
VisualizeStopWatch(*context.leaf_nodes_canvas, context.ui_time, x, y + height,
95+
VisualizeStopWatch(context.leaf_nodes_canvas, context.ui_time, x, y + height,
9696
width, height - padding,
9797
options_ & kVisualizeEngineStatistics,
9898
options_ & kDisplayEngineStatistics, "UI", font_path_);

flow/matrix_decomposition.cc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
// FLUTTER_NOLINT
54

65
#include "flutter/flow/matrix_decomposition.h"
76

@@ -18,12 +17,12 @@ MatrixDecomposition::MatrixDecomposition(const SkMatrix& matrix)
1817
: MatrixDecomposition(SkM44{matrix}) {}
1918

2019
// Use custom normalize to avoid skia precision loss/normalize() privatization.
21-
static inline void SkV3Normalize(SkV3& v) {
22-
double mag = sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
20+
static inline void SkV3Normalize(SkV3* v) {
21+
double mag = sqrt(v->x * v->x + v->y * v->y + v->z * v->z);
2322
double scale = 1.0 / mag;
24-
v.x *= scale;
25-
v.y *= scale;
26-
v.z *= scale;
23+
v->x *= scale;
24+
v->y *= scale;
25+
v->z *= scale;
2726
}
2827

2928
MatrixDecomposition::MatrixDecomposition(SkM44 matrix) : valid_(false) {
@@ -71,14 +70,14 @@ MatrixDecomposition::MatrixDecomposition(SkM44 matrix) : valid_(false) {
7170

7271
scale_.x = row[0].length();
7372

74-
SkV3Normalize(row[0]);
73+
SkV3Normalize(&row[0]);
7574

7675
shear_.x = row[0].dot(row[1]);
7776
row[1] = SkV3Combine(row[1], 1.0, row[0], -shear_.x);
7877

7978
scale_.y = row[1].length();
8079

81-
SkV3Normalize(row[1]);
80+
SkV3Normalize(&row[1]);
8281

8382
shear_.x /= scale_.y;
8483

@@ -89,7 +88,7 @@ MatrixDecomposition::MatrixDecomposition(SkM44 matrix) : valid_(false) {
8988

9089
scale_.z = row[2].length();
9190

92-
SkV3Normalize(row[2]);
91+
SkV3Normalize(&row[2]);
9392

9493
shear_.y /= scale_.z;
9594
shear_.z /= scale_.z;

flow/matrix_decomposition_unittests.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
// FLUTTER_NOLINT
54

65
#include "flutter/fml/build_config.h"
76

@@ -98,7 +97,8 @@ TEST(MatrixDecomposition, Combination) {
9897

9998
TEST(MatrixDecomposition, ScaleFloatError) {
10099
constexpr float scale_increment = 0.00001f;
101-
for (float scale = 0.0001f; scale < 2.0f; scale += scale_increment) {
100+
float scale = 0.0001f;
101+
while (scale < 2.0f) {
102102
SkM44 matrix;
103103
matrix.setScale(scale, scale, 1.0f);
104104

@@ -111,11 +111,12 @@ TEST(MatrixDecomposition, ScaleFloatError) {
111111
ASSERT_FLOAT_EQ(0, decomposition3.rotation().x);
112112
ASSERT_FLOAT_EQ(0, decomposition3.rotation().y);
113113
ASSERT_FLOAT_EQ(0, decomposition3.rotation().z);
114+
scale += scale_increment;
114115
}
115116

116117
SkM44 matrix;
117-
const auto scale = 1.7734375f;
118-
matrix.setScale(scale, scale, 1.f);
118+
const auto scale1 = 1.7734375f;
119+
matrix.setScale(scale1, scale1, 1.f);
119120

120121
// Bug upper bound (empirical)
121122
const auto scale2 = 1.773437559603f;
@@ -136,8 +137,8 @@ TEST(MatrixDecomposition, ScaleFloatError) {
136137
flutter::MatrixDecomposition decomposition3(matrix3);
137138
ASSERT_TRUE(decomposition3.IsValid());
138139

139-
ASSERT_FLOAT_EQ(scale, decomposition.scale().x);
140-
ASSERT_FLOAT_EQ(scale, decomposition.scale().y);
140+
ASSERT_FLOAT_EQ(scale1, decomposition.scale().x);
141+
ASSERT_FLOAT_EQ(scale1, decomposition.scale().y);
141142
ASSERT_FLOAT_EQ(1.f, decomposition.scale().z);
142143
ASSERT_FLOAT_EQ(0, decomposition.rotation().x);
143144
ASSERT_FLOAT_EQ(0, decomposition.rotation().y);

flow/paint_utils.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
// FLUTTER_NOLINT
54

65
#include "flutter/flow/paint_utils.h"
76

flow/raster_cache.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
// FLUTTER_NOLINT
54

65
#include "flutter/flow/raster_cache.h"
76

@@ -160,10 +159,11 @@ std::unique_ptr<RasterCacheResult> RasterCache::RasterizeLayer(
160159
canvas_size.height());
161160
internal_nodes_canvas.addCanvas(canvas);
162161
Layer::PaintContext paintContext = {
163-
(SkCanvas*)&internal_nodes_canvas, // internal_nodes_canvas
164-
canvas, // leaf_nodes_canvas
165-
context->gr_context, // gr_context
166-
nullptr, // view_embedder
162+
/* internal_nodes_canvas= */ static_cast<SkCanvas*>(
163+
&internal_nodes_canvas),
164+
/* leaf_nodes_canvas= */ canvas,
165+
/* gr_context= */ context->gr_context,
166+
/* view_embedder= */ nullptr,
167167
context->raster_time,
168168
context->ui_time,
169169
context->texture_registry,
@@ -233,7 +233,7 @@ bool RasterCache::Draw(const SkPicture& picture, SkCanvas& canvas) const {
233233
entry.used_this_frame = true;
234234

235235
if (entry.image) {
236-
entry.image->draw(canvas);
236+
entry.image->draw(canvas, nullptr);
237237
return true;
238238
}
239239

flow/raster_cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class RasterCacheResult {
2222

2323
virtual ~RasterCacheResult() = default;
2424

25-
virtual void draw(SkCanvas& canvas, const SkPaint* paint = nullptr) const;
25+
virtual void draw(SkCanvas& canvas, const SkPaint* paint) const;
2626

2727
virtual SkISize image_dimensions() const {
2828
return image_ ? image_->dimensions() : SkISize::Make(0, 0);

0 commit comments

Comments
 (0)