diff options
author | jianli <jianli@chromium.org> | 2015-03-30 16:40:27 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-30 23:41:14 +0000 |
commit | 05ec069bfb1e10e8f344937793a21b3715549170 (patch) | |
tree | 711d23c733cdfde2867a16886401a6c1d4ee9c71 /cc | |
parent | 170e7fbfa745726d13a84aa5d8edc4720f7ca0d4 (diff) | |
download | chromium_src-05ec069bfb1e10e8f344937793a21b3715549170.zip chromium_src-05ec069bfb1e10e8f344937793a21b3715549170.tar.gz chromium_src-05ec069bfb1e10e8f344937793a21b3715549170.tar.bz2 |
Revert of Revert of Fix text clipping in CompositorFrameTime Display (patchset #1 id:1 of https://codereview.chromium.org/1047013002/)
Reason for revert:
Not a culprit. Bring it back.
Original issue's description:
> Revert of Fix text clipping in CompositorFrameTime Display (patchset #2 id:20001 of https://codereview.chromium.org/1027393004/)
>
> Reason for revert:
> Speculative revert for Blink layout test failures in WebKit Mac10.8 (retina):
> https://build.chromium.org/p/chromium.webkit/builders/WebKit%20Mac10.8%20%28retina%29/builds/27696
>
> Original issue's description:
> > Fix text clipping in CompositorFrameTime Display
> >
> > Because different OS have different fonts for HUD.
> > Set the width of CompositorFrameTime Display to be maximum
> > of graph width and text width to prevent text clipping.
> >
> > BUG=445877
> >
> > Committed: https://crrev.com/88b4cf8d33b499f972e1c447e741230170beeb8d
> > Cr-Commit-Position: refs/heads/master@{#322807}
>
> TBR=danakj@chromium.org,behara.ms@samsung.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=445877
>
> Committed: https://crrev.com/933b39f06e409d623eb4dbc4da692ae41460372e
> Cr-Commit-Position: refs/heads/master@{#322858}
TBR=danakj@chromium.org,behara.ms@samsung.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=445877
Review URL: https://codereview.chromium.org/1043023002
Cr-Commit-Position: refs/heads/master@{#322908}
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layers/heads_up_display_layer_impl.cc | 40 | ||||
-rw-r--r-- | cc/layers/heads_up_display_layer_impl.h | 1 |
2 files changed, 28 insertions, 13 deletions
diff --git a/cc/layers/heads_up_display_layer_impl.cc b/cc/layers/heads_up_display_layer_impl.cc index d2558c1..379ae69 100644 --- a/cc/layers/heads_up_display_layer_impl.cc +++ b/cc/layers/heads_up_display_layer_impl.cc @@ -297,7 +297,18 @@ void HeadsUpDisplayLayerImpl::DrawHudContents(SkCanvas* canvas) { if (debug_state.ShowMemoryStats()) DrawMemoryDisplay(canvas, 0, area.bottom(), SkMaxScalar(area.width(), 150)); } +int HeadsUpDisplayLayerImpl::MeasureText(SkPaint* paint, + const std::string& text, + int size) const { + const bool anti_alias = paint->isAntiAlias(); + paint->setAntiAlias(true); + paint->setTextSize(size); + paint->setTypeface(typeface_.get()); + SkScalar text_width = paint->measureText(text.c_str(), text.length()); + paint->setAntiAlias(anti_alias); + return SkScalarCeilToInt(text_width); +} void HeadsUpDisplayLayerImpl::DrawText(SkCanvas* canvas, SkPaint* paint, const std::string& text, @@ -612,26 +623,29 @@ SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay( const int kGraphWidth = paint_time_counter->HistorySize(); const int kGraphHeight = 40; - const int width = kGraphWidth + 2 * kPadding; + SkPaint paint = CreatePaint(); + + const std::string title = "Compositor frame time (ms)"; + int title_text_width = MeasureText(&paint, title, kFontHeight); + int contents_width = std::max(title_text_width, kGraphWidth); + + const int width = contents_width + 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, + contents_width, kFontHeight); + SkRect text_bounds2 = + SkRect::MakeXYWH(left + kPadding, text_bounds.bottom() + kPadding, + contents_width, 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 +653,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, diff --git a/cc/layers/heads_up_display_layer_impl.h b/cc/layers/heads_up_display_layer_impl.h index 750d991..299d91e 100644 --- a/cc/layers/heads_up_display_layer_impl.h +++ b/cc/layers/heads_up_display_layer_impl.h @@ -77,6 +77,7 @@ class CC_EXPORT HeadsUpDisplayLayerImpl : public LayerImpl { void UpdateHudContents(); void DrawHudContents(SkCanvas* canvas); + int MeasureText(SkPaint* paint, const std::string& text, int size) const; void DrawText(SkCanvas* canvas, SkPaint* paint, const std::string& text, |