Chromium Code Reviews| 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, |