Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: cc/layers/heads_up_display_layer_impl.cc

Issue 1158433010: Reland: cc: Fix size_t to int truncations in layers/ output/ playback/ quads/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/heads_up_display_layer_impl.h" 5 #include "cc/layers/heads_up_display_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/numerics/safe_conversions.h"
10 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
11 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
12 #include "base/trace_event/trace_event_argument.h" 13 #include "base/trace_event/trace_event_argument.h"
13 #include "cc/debug/debug_colors.h" 14 #include "cc/debug/debug_colors.h"
14 #include "cc/debug/frame_rate_counter.h" 15 #include "cc/debug/frame_rate_counter.h"
15 #include "cc/debug/paint_time_counter.h" 16 #include "cc/debug/paint_time_counter.h"
16 #include "cc/output/begin_frame_args.h" 17 #include "cc/output/begin_frame_args.h"
17 #include "cc/output/renderer.h" 18 #include "cc/output/renderer.h"
18 #include "cc/quads/texture_draw_quad.h" 19 #include "cc/quads/texture_draw_quad.h"
19 #include "cc/resources/memory_history.h" 20 #include "cc/resources/memory_history.h"
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 SkRect HeadsUpDisplayLayerImpl::DrawFPSDisplay( 377 SkRect HeadsUpDisplayLayerImpl::DrawFPSDisplay(
377 SkCanvas* canvas, 378 SkCanvas* canvas,
378 const FrameRateCounter* fps_counter, 379 const FrameRateCounter* fps_counter,
379 int right, 380 int right,
380 int top) const { 381 int top) const {
381 const int kPadding = 4; 382 const int kPadding = 4;
382 const int kGap = 6; 383 const int kGap = 6;
383 384
384 const int kFontHeight = 15; 385 const int kFontHeight = 15;
385 386
386 const int kGraphWidth = fps_counter->time_stamp_history_size() - 2; 387 const int kGraphWidth =
388 base::saturated_cast<int>(fps_counter->time_stamp_history_size()) - 2;
387 const int kGraphHeight = 40; 389 const int kGraphHeight = 40;
388 390
389 const int kHistogramWidth = 37; 391 const int kHistogramWidth = 37;
390 392
391 int width = kGraphWidth + kHistogramWidth + 4 * kPadding; 393 int width = kGraphWidth + kHistogramWidth + 4 * kPadding;
392 int height = kFontHeight + kGraphHeight + 4 * kPadding + 2; 394 int height = kFontHeight + kGraphHeight + 4 * kPadding + 2;
393 int left = bounds().width() - width - right; 395 int left = bounds().width() - width - right;
394 SkRect area = SkRect::MakeXYWH(left, top, width, height); 396 SkRect area = SkRect::MakeXYWH(left, top, width, height);
395 397
396 SkPaint paint = CreatePaint(); 398 SkPaint paint = CreatePaint();
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 } 620 }
619 621
620 SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay( 622 SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay(
621 SkCanvas* canvas, 623 SkCanvas* canvas,
622 const PaintTimeCounter* paint_time_counter, 624 const PaintTimeCounter* paint_time_counter,
623 int right, 625 int right,
624 int top) const { 626 int top) const {
625 const int kPadding = 4; 627 const int kPadding = 4;
626 const int kFontHeight = 14; 628 const int kFontHeight = 14;
627 629
628 const int kGraphWidth = paint_time_counter->HistorySize(); 630 const int kGraphWidth =
631 base::saturated_cast<int>(paint_time_counter->HistorySize());
629 const int kGraphHeight = 40; 632 const int kGraphHeight = 40;
630 633
631 SkPaint paint = CreatePaint(); 634 SkPaint paint = CreatePaint();
632 635
633 const std::string title = "Compositor frame time (ms)"; 636 const std::string title = "Compositor frame time (ms)";
634 int title_text_width = MeasureText(&paint, title, kFontHeight); 637 int title_text_width = MeasureText(&paint, title, kFontHeight);
635 int contents_width = std::max(title_text_width, kGraphWidth); 638 int contents_width = std::max(title_text_width, kGraphWidth);
636 639
637 const int width = contents_width + 2 * kPadding; 640 const int width = contents_width + 2 * kPadding;
638 const int height = 641 const int height =
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 return "cc::HeadsUpDisplayLayerImpl"; 864 return "cc::HeadsUpDisplayLayerImpl";
862 } 865 }
863 866
864 void HeadsUpDisplayLayerImpl::AsValueInto( 867 void HeadsUpDisplayLayerImpl::AsValueInto(
865 base::trace_event::TracedValue* dict) const { 868 base::trace_event::TracedValue* dict) const {
866 LayerImpl::AsValueInto(dict); 869 LayerImpl::AsValueInto(dict);
867 dict->SetString("layer_name", "Heads Up Display Layer"); 870 dict->SetString("layer_name", "Heads Up Display Layer");
868 } 871 }
869 872
870 } // namespace cc 873 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698