1
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
2
// Use of this source code is governed by a BSD-style license that can be
3
3
// found in the LICENSE file.
4
- // FLUTTER_NOLINT
5
4
6
5
#include " flutter/flow/instrumentation.h"
7
6
@@ -52,16 +51,18 @@ double Stopwatch::UnitFrameInterval(double raster_time_ms) const {
52
51
double Stopwatch::UnitHeight (double raster_time_ms,
53
52
double max_unit_interval) const {
54
53
double unitHeight = UnitFrameInterval (raster_time_ms) / max_unit_interval;
55
- if (unitHeight > 1.0 )
54
+ if (unitHeight > 1.0 ) {
56
55
unitHeight = 1.0 ;
56
+ }
57
57
return unitHeight;
58
58
}
59
59
60
60
fml::TimeDelta Stopwatch::MaxDelta () const {
61
61
fml::TimeDelta max_delta;
62
62
for (size_t i = 0 ; i < kMaxSamples ; i++) {
63
- if (laps_[i] > max_delta)
63
+ if (laps_[i] > max_delta) {
64
64
max_delta = laps_[i];
65
+ }
65
66
}
66
67
return max_delta;
67
68
}
@@ -135,7 +136,7 @@ void Stopwatch::InitVisualizeSurface(const SkRect& rect) const {
135
136
cache_canvas->drawPath (path, paint);
136
137
}
137
138
138
- void Stopwatch::Visualize (SkCanvas& canvas, const SkRect& rect) const {
139
+ void Stopwatch::Visualize (SkCanvas* canvas, const SkRect& rect) const {
139
140
// Initialize visualize cache if it has not yet been initialized.
140
141
InitVisualizeSurface (rect);
141
142
@@ -191,8 +192,9 @@ void Stopwatch::Visualize(SkCanvas& canvas, const SkRect& rect) const {
191
192
192
193
// Limit the number of markers displayed. After a certain point, the graph
193
194
// becomes crowded
194
- if (frame_marker_count > kMaxFrameMarkers )
195
+ if (frame_marker_count > kMaxFrameMarkers ) {
195
196
frame_marker_count = 1 ;
197
+ }
196
198
197
199
for (size_t frame_index = 0 ; frame_index < frame_marker_count;
198
200
frame_index++) {
@@ -224,7 +226,7 @@ void Stopwatch::Visualize(SkCanvas& canvas, const SkRect& rect) const {
224
226
225
227
// Draw the cached surface onto the output canvas.
226
228
paint.reset ();
227
- visualize_cache_surface_->draw (& canvas, rect.x (), rect.y (), &paint);
229
+ visualize_cache_surface_->draw (canvas, rect.x (), rect.y (), &paint);
228
230
}
229
231
230
232
CounterValues::CounterValues () : current_sample_(kMaxSamples - 1 ) {
@@ -238,7 +240,7 @@ void CounterValues::Add(int64_t value) {
238
240
values_[current_sample_] = value;
239
241
}
240
242
241
- void CounterValues::Visualize (SkCanvas& canvas, const SkRect& rect) const {
243
+ void CounterValues::Visualize (SkCanvas* canvas, const SkRect& rect) const {
242
244
size_t max_bytes = GetMaxValue ();
243
245
244
246
if (max_bytes == 0 ) {
@@ -252,7 +254,7 @@ void CounterValues::Visualize(SkCanvas& canvas, const SkRect& rect) const {
252
254
253
255
// Paint the background.
254
256
paint.setColor (0x99FFFFFF );
255
- canvas. drawRect (rect, paint);
257
+ canvas-> drawRect (rect, paint);
256
258
257
259
// Establish the graph position.
258
260
const SkScalar x = rect.x ();
@@ -268,10 +270,12 @@ void CounterValues::Visualize(SkCanvas& canvas, const SkRect& rect) const {
268
270
269
271
for (size_t i = 0 ; i < kMaxSamples ; ++i) {
270
272
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));
275
279
}
276
280
277
281
path.rLineTo (100 , 0 );
@@ -280,7 +284,7 @@ void CounterValues::Visualize(SkCanvas& canvas, const SkRect& rect) const {
280
284
281
285
// Draw the graph.
282
286
paint.setColor (0xAA0000FF );
283
- canvas. drawPath (path, paint);
287
+ canvas-> drawPath (path, paint);
284
288
285
289
// Paint the vertical marker for the current frame.
286
290
const double sample_unit_width = (1.0 / kMaxSamples );
@@ -294,7 +298,7 @@ void CounterValues::Visualize(SkCanvas& canvas, const SkRect& rect) const {
294
298
const auto marker_rect = SkRect::MakeLTRB (
295
299
sample_x, y,
296
300
sample_x + width * sample_unit_width + sample_margin_width * 2 , bottom);
297
- canvas. drawRect (marker_rect, paint);
301
+ canvas-> drawRect (marker_rect, paint);
298
302
}
299
303
300
304
int64_t CounterValues::GetCurrentValue () const {
0 commit comments