OLD | NEW |
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" | |
11 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
12 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
13 #include "base/trace_event/trace_event_argument.h" | 12 #include "base/trace_event/trace_event_argument.h" |
14 #include "cc/debug/debug_colors.h" | 13 #include "cc/debug/debug_colors.h" |
15 #include "cc/debug/frame_rate_counter.h" | 14 #include "cc/debug/frame_rate_counter.h" |
16 #include "cc/debug/paint_time_counter.h" | 15 #include "cc/debug/paint_time_counter.h" |
17 #include "cc/output/begin_frame_args.h" | 16 #include "cc/output/begin_frame_args.h" |
18 #include "cc/output/renderer.h" | 17 #include "cc/output/renderer.h" |
19 #include "cc/quads/texture_draw_quad.h" | 18 #include "cc/quads/texture_draw_quad.h" |
20 #include "cc/resources/memory_history.h" | 19 #include "cc/resources/memory_history.h" |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 SkRect HeadsUpDisplayLayerImpl::DrawFPSDisplay( | 376 SkRect HeadsUpDisplayLayerImpl::DrawFPSDisplay( |
378 SkCanvas* canvas, | 377 SkCanvas* canvas, |
379 const FrameRateCounter* fps_counter, | 378 const FrameRateCounter* fps_counter, |
380 int right, | 379 int right, |
381 int top) const { | 380 int top) const { |
382 const int kPadding = 4; | 381 const int kPadding = 4; |
383 const int kGap = 6; | 382 const int kGap = 6; |
384 | 383 |
385 const int kFontHeight = 15; | 384 const int kFontHeight = 15; |
386 | 385 |
387 const int kGraphWidth = | 386 const int kGraphWidth = fps_counter->time_stamp_history_size() - 2; |
388 base::saturated_cast<int>(fps_counter->time_stamp_history_size()) - 2; | |
389 const int kGraphHeight = 40; | 387 const int kGraphHeight = 40; |
390 | 388 |
391 const int kHistogramWidth = 37; | 389 const int kHistogramWidth = 37; |
392 | 390 |
393 int width = kGraphWidth + kHistogramWidth + 4 * kPadding; | 391 int width = kGraphWidth + kHistogramWidth + 4 * kPadding; |
394 int height = kFontHeight + kGraphHeight + 4 * kPadding + 2; | 392 int height = kFontHeight + kGraphHeight + 4 * kPadding + 2; |
395 int left = bounds().width() - width - right; | 393 int left = bounds().width() - width - right; |
396 SkRect area = SkRect::MakeXYWH(left, top, width, height); | 394 SkRect area = SkRect::MakeXYWH(left, top, width, height); |
397 | 395 |
398 SkPaint paint = CreatePaint(); | 396 SkPaint paint = CreatePaint(); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 } | 618 } |
621 | 619 |
622 SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay( | 620 SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay( |
623 SkCanvas* canvas, | 621 SkCanvas* canvas, |
624 const PaintTimeCounter* paint_time_counter, | 622 const PaintTimeCounter* paint_time_counter, |
625 int right, | 623 int right, |
626 int top) const { | 624 int top) const { |
627 const int kPadding = 4; | 625 const int kPadding = 4; |
628 const int kFontHeight = 14; | 626 const int kFontHeight = 14; |
629 | 627 |
630 const int kGraphWidth = | 628 const int kGraphWidth = paint_time_counter->HistorySize(); |
631 base::saturated_cast<int>(paint_time_counter->HistorySize()); | |
632 const int kGraphHeight = 40; | 629 const int kGraphHeight = 40; |
633 | 630 |
634 SkPaint paint = CreatePaint(); | 631 SkPaint paint = CreatePaint(); |
635 | 632 |
636 const std::string title = "Compositor frame time (ms)"; | 633 const std::string title = "Compositor frame time (ms)"; |
637 int title_text_width = MeasureText(&paint, title, kFontHeight); | 634 int title_text_width = MeasureText(&paint, title, kFontHeight); |
638 int contents_width = std::max(title_text_width, kGraphWidth); | 635 int contents_width = std::max(title_text_width, kGraphWidth); |
639 | 636 |
640 const int width = contents_width + 2 * kPadding; | 637 const int width = contents_width + 2 * kPadding; |
641 const int height = | 638 const int height = |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 return "cc::HeadsUpDisplayLayerImpl"; | 861 return "cc::HeadsUpDisplayLayerImpl"; |
865 } | 862 } |
866 | 863 |
867 void HeadsUpDisplayLayerImpl::AsValueInto( | 864 void HeadsUpDisplayLayerImpl::AsValueInto( |
868 base::trace_event::TracedValue* dict) const { | 865 base::trace_event::TracedValue* dict) const { |
869 LayerImpl::AsValueInto(dict); | 866 LayerImpl::AsValueInto(dict); |
870 dict->SetString("layer_name", "Heads Up Display Layer"); | 867 dict->SetString("layer_name", "Heads Up Display Layer"); |
871 } | 868 } |
872 | 869 |
873 } // namespace cc | 870 } // namespace cc |
OLD | NEW |