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 {
5251double 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
6060fml::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
230232CounterValues::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
300304int64_t CounterValues::GetCurrentValue () const {
0 commit comments