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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/heads_up_display_layer_impl.cc
diff --git a/cc/layers/heads_up_display_layer_impl.cc b/cc/layers/heads_up_display_layer_impl.cc
index d2558c144a8c0d51a26c7382c97434dedff782b3..435dab2ddcbf4f90d9fab061a3116876e3f20812 100644
--- a/cc/layers/heads_up_display_layer_impl.cc
+++ b/cc/layers/heads_up_display_layer_impl.cc
@@ -612,26 +612,32 @@ SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay(
const int kGraphWidth = paint_time_counter->HistorySize();
const int kGraphHeight = 40;
- const int width = kGraphWidth + 2 * kPadding;
+ SkPaint paint = CreatePaint();
+ paint.setTextSize(kFontHeight);
danakj 2015/03/26 22:53:20 Can you add a MeasureText that sits beside DrawTex
+ paint.setTypeface(typeface_.get());
+
+ const std::string title = "Compositor frame time (ms)";
+ int title_text_width =
+ SkScalarCeilToInt(paint.measureText(title.c_str(), title.length()));
+ int contentsWidth = std::max(title_text_width, kGraphWidth);
danakj 2015/03/26 22:53:20 contents_width
+
+ const int width = contentsWidth + 2 * kPadding;
const int height =
kFontHeight + kGraphHeight + 4 * kPadding + 2 + kFontHeight + kPadding;
const int left = bounds().width() - width - right;
const SkRect area = SkRect::MakeXYWH(left, top, width, height);
- SkPaint paint = CreatePaint();
DrawGraphBackground(canvas, &paint, area);
- SkRect text_bounds = SkRect::MakeXYWH(
- left + kPadding, top + kPadding, kGraphWidth, kFontHeight);
- SkRect text_bounds2 = SkRect::MakeXYWH(left + kPadding,
- text_bounds.bottom() + kPadding,
- kGraphWidth,
- kFontHeight);
- SkRect graph_bounds = SkRect::MakeXYWH(left + kPadding,
+ SkRect text_bounds = SkRect::MakeXYWH(left + kPadding, top + kPadding,
+ contentsWidth, kFontHeight);
+ SkRect text_bounds2 =
+ SkRect::MakeXYWH(left + kPadding, text_bounds.bottom() + kPadding,
+ contentsWidth, kFontHeight);
+ SkRect graph_bounds = SkRect::MakeXYWH(left + (width - kGraphWidth) / 2,
text_bounds2.bottom() + 2 * kPadding,
- kGraphWidth,
- kGraphHeight);
+ kGraphWidth, kGraphHeight);
const std::string value_text =
base::StringPrintf("%.1f", paint_time_graph_.value);
@@ -639,8 +645,8 @@ SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay(
"%.1f-%.1f", paint_time_graph_.min, paint_time_graph_.max);
paint.setColor(DebugColors::PaintTimeDisplayTextAndGraphColor());
- DrawText(canvas, &paint, "Compositor frame time(ms)", SkPaint::kLeft_Align,
- kFontHeight, text_bounds.left(), text_bounds.bottom());
+ DrawText(canvas, &paint, title, SkPaint::kLeft_Align, kFontHeight,
+ text_bounds.left(), text_bounds.bottom());
DrawText(canvas,
&paint,
value_text,
« 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