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

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

Issue 1027393004: Fix text clipping in CompositorFrameTime Display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 SkCanvas* canvas, 605 SkCanvas* canvas,
606 const PaintTimeCounter* paint_time_counter, 606 const PaintTimeCounter* paint_time_counter,
607 int right, 607 int right,
608 int top) const { 608 int top) const {
609 const int kPadding = 4; 609 const int kPadding = 4;
610 const int kFontHeight = 14; 610 const int kFontHeight = 14;
611 611
612 const int kGraphWidth = paint_time_counter->HistorySize(); 612 const int kGraphWidth = paint_time_counter->HistorySize();
613 const int kGraphHeight = 40; 613 const int kGraphHeight = 40;
614 614
615 const int width = kGraphWidth + 2 * kPadding; 615 SkPaint paint = CreatePaint();
616 paint.setTextSize(kFontHeight);
danakj 2015/03/26 22:53:20 Can you add a MeasureText that sits beside DrawTex
617 paint.setTypeface(typeface_.get());
618
619 const std::string title = "Compositor frame time (ms)";
620 int title_text_width =
621 SkScalarCeilToInt(paint.measureText(title.c_str(), title.length()));
622 int contentsWidth = std::max(title_text_width, kGraphWidth);
danakj 2015/03/26 22:53:20 contents_width
623
624 const int width = contentsWidth + 2 * kPadding;
616 const int height = 625 const int height =
617 kFontHeight + kGraphHeight + 4 * kPadding + 2 + kFontHeight + kPadding; 626 kFontHeight + kGraphHeight + 4 * kPadding + 2 + kFontHeight + kPadding;
618 const int left = bounds().width() - width - right; 627 const int left = bounds().width() - width - right;
619 628
620 const SkRect area = SkRect::MakeXYWH(left, top, width, height); 629 const SkRect area = SkRect::MakeXYWH(left, top, width, height);
621 630
622 SkPaint paint = CreatePaint();
623 DrawGraphBackground(canvas, &paint, area); 631 DrawGraphBackground(canvas, &paint, area);
624 632
625 SkRect text_bounds = SkRect::MakeXYWH( 633 SkRect text_bounds = SkRect::MakeXYWH(left + kPadding, top + kPadding,
626 left + kPadding, top + kPadding, kGraphWidth, kFontHeight); 634 contentsWidth, kFontHeight);
627 SkRect text_bounds2 = SkRect::MakeXYWH(left + kPadding, 635 SkRect text_bounds2 =
628 text_bounds.bottom() + kPadding, 636 SkRect::MakeXYWH(left + kPadding, text_bounds.bottom() + kPadding,
629 kGraphWidth, 637 contentsWidth, kFontHeight);
630 kFontHeight); 638 SkRect graph_bounds = SkRect::MakeXYWH(left + (width - kGraphWidth) / 2,
631 SkRect graph_bounds = SkRect::MakeXYWH(left + kPadding,
632 text_bounds2.bottom() + 2 * kPadding, 639 text_bounds2.bottom() + 2 * kPadding,
633 kGraphWidth, 640 kGraphWidth, kGraphHeight);
634 kGraphHeight);
635 641
636 const std::string value_text = 642 const std::string value_text =
637 base::StringPrintf("%.1f", paint_time_graph_.value); 643 base::StringPrintf("%.1f", paint_time_graph_.value);
638 const std::string min_max_text = base::StringPrintf( 644 const std::string min_max_text = base::StringPrintf(
639 "%.1f-%.1f", paint_time_graph_.min, paint_time_graph_.max); 645 "%.1f-%.1f", paint_time_graph_.min, paint_time_graph_.max);
640 646
641 paint.setColor(DebugColors::PaintTimeDisplayTextAndGraphColor()); 647 paint.setColor(DebugColors::PaintTimeDisplayTextAndGraphColor());
642 DrawText(canvas, &paint, "Compositor frame time(ms)", SkPaint::kLeft_Align, 648 DrawText(canvas, &paint, title, SkPaint::kLeft_Align, kFontHeight,
643 kFontHeight, text_bounds.left(), text_bounds.bottom()); 649 text_bounds.left(), text_bounds.bottom());
644 DrawText(canvas, 650 DrawText(canvas,
645 &paint, 651 &paint,
646 value_text, 652 value_text,
647 SkPaint::kLeft_Align, 653 SkPaint::kLeft_Align,
648 kFontHeight, 654 kFontHeight,
649 text_bounds2.left(), 655 text_bounds2.left(),
650 text_bounds2.bottom()); 656 text_bounds2.bottom());
651 DrawText(canvas, 657 DrawText(canvas,
652 &paint, 658 &paint,
653 min_max_text, 659 min_max_text,
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 return "cc::HeadsUpDisplayLayerImpl"; 848 return "cc::HeadsUpDisplayLayerImpl";
843 } 849 }
844 850
845 void HeadsUpDisplayLayerImpl::AsValueInto( 851 void HeadsUpDisplayLayerImpl::AsValueInto(
846 base::trace_event::TracedValue* dict) const { 852 base::trace_event::TracedValue* dict) const {
847 LayerImpl::AsValueInto(dict); 853 LayerImpl::AsValueInto(dict);
848 dict->SetString("layer_name", "Heads Up Display Layer"); 854 dict->SetString("layer_name", "Heads Up Display Layer");
849 } 855 }
850 856
851 } // namespace cc 857 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698