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

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

Issue 960873002: Update from https://crrev.com/318214 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 | « cc/layers/heads_up_display_layer_impl.h ('k') | cc/layers/layer.h » ('j') | 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 double HeadsUpDisplayLayerImpl::Graph::UpdateUpperBound() { 64 double HeadsUpDisplayLayerImpl::Graph::UpdateUpperBound() {
65 double target_upper_bound = std::max(max, default_upper_bound); 65 double target_upper_bound = std::max(max, default_upper_bound);
66 current_upper_bound += (target_upper_bound - current_upper_bound) * 0.5; 66 current_upper_bound += (target_upper_bound - current_upper_bound) * 0.5;
67 return current_upper_bound; 67 return current_upper_bound;
68 } 68 }
69 69
70 HeadsUpDisplayLayerImpl::HeadsUpDisplayLayerImpl(LayerTreeImpl* tree_impl, 70 HeadsUpDisplayLayerImpl::HeadsUpDisplayLayerImpl(LayerTreeImpl* tree_impl,
71 int id) 71 int id)
72 : LayerImpl(tree_impl, id), 72 : LayerImpl(tree_impl, id),
73 typeface_(skia::AdoptRef(
74 SkTypeface::CreateFromName("monospace", SkTypeface::kBold))),
73 internal_contents_scale_(1.f), 75 internal_contents_scale_(1.f),
74 fps_graph_(60.0, 80.0), 76 fps_graph_(60.0, 80.0),
75 paint_time_graph_(16.0, 48.0), 77 paint_time_graph_(16.0, 48.0),
76 fade_step_(0) { 78 fade_step_(0) {
77 } 79 }
78 80
79 HeadsUpDisplayLayerImpl::~HeadsUpDisplayLayerImpl() {} 81 HeadsUpDisplayLayerImpl::~HeadsUpDisplayLayerImpl() {}
80 82
81 scoped_ptr<LayerImpl> HeadsUpDisplayLayerImpl::CreateLayerImpl( 83 scoped_ptr<LayerImpl> HeadsUpDisplayLayerImpl::CreateLayerImpl(
82 LayerTreeImpl* tree_impl) { 84 LayerTreeImpl* tree_impl) {
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 const std::string& text, 298 const std::string& text,
297 SkPaint::Align align, 299 SkPaint::Align align,
298 int size, 300 int size,
299 int x, 301 int x,
300 int y) const { 302 int y) const {
301 const bool anti_alias = paint->isAntiAlias(); 303 const bool anti_alias = paint->isAntiAlias();
302 paint->setAntiAlias(true); 304 paint->setAntiAlias(true);
303 305
304 paint->setTextSize(size); 306 paint->setTextSize(size);
305 paint->setTextAlign(align); 307 paint->setTextAlign(align);
306 paint->setTypeface(layer_tree_impl()->settings().hud_typeface.get()); 308 paint->setTypeface(typeface_.get());
307 canvas->drawText(text.c_str(), text.length(), x, y, *paint); 309 canvas->drawText(text.c_str(), text.length(), x, y, *paint);
308 310
309 paint->setAntiAlias(anti_alias); 311 paint->setAntiAlias(anti_alias);
310 } 312 }
311 313
312 void HeadsUpDisplayLayerImpl::DrawText(SkCanvas* canvas, 314 void HeadsUpDisplayLayerImpl::DrawText(SkCanvas* canvas,
313 SkPaint* paint, 315 SkPaint* paint,
314 const std::string& text, 316 const std::string& text,
315 SkPaint::Align align, 317 SkPaint::Align align,
316 int size, 318 int size,
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 gfx::Rect clip_rect = debug_layer_rect; 705 gfx::Rect clip_rect = debug_layer_rect;
704 clip_rect.Intersect(gfx::Rect(internal_content_bounds_)); 706 clip_rect.Intersect(gfx::Rect(internal_content_bounds_));
705 SkRect sk_clip_rect = RectToSkRect(clip_rect); 707 SkRect sk_clip_rect = RectToSkRect(clip_rect);
706 708
707 canvas->save(); 709 canvas->save();
708 canvas->clipRect(sk_clip_rect); 710 canvas->clipRect(sk_clip_rect);
709 canvas->translate(sk_clip_rect.x(), sk_clip_rect.y()); 711 canvas->translate(sk_clip_rect.x(), sk_clip_rect.y());
710 712
711 SkPaint label_paint = CreatePaint(); 713 SkPaint label_paint = CreatePaint();
712 label_paint.setTextSize(kFontHeight); 714 label_paint.setTextSize(kFontHeight);
713 label_paint.setTypeface(layer_tree_impl()->settings().hud_typeface.get()); 715 label_paint.setTypeface(typeface_.get());
714 label_paint.setColor(stroke_color); 716 label_paint.setColor(stroke_color);
715 717
716 const SkScalar label_text_width = 718 const SkScalar label_text_width =
717 label_paint.measureText(label_text.c_str(), label_text.length()); 719 label_paint.measureText(label_text.c_str(), label_text.length());
718 canvas->drawRect(SkRect::MakeWH(label_text_width + 2 * kPadding, 720 canvas->drawRect(SkRect::MakeWH(label_text_width + 2 * kPadding,
719 kFontHeight + 2 * kPadding), 721 kFontHeight + 2 * kPadding),
720 label_paint); 722 label_paint);
721 723
722 label_paint.setAntiAlias(true); 724 label_paint.setAntiAlias(true);
723 label_paint.setColor(SkColorSetARGB(255, 50, 50, 50)); 725 label_paint.setColor(SkColorSetARGB(255, 50, 50, 50));
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 return "cc::HeadsUpDisplayLayerImpl"; 834 return "cc::HeadsUpDisplayLayerImpl";
833 } 835 }
834 836
835 void HeadsUpDisplayLayerImpl::AsValueInto( 837 void HeadsUpDisplayLayerImpl::AsValueInto(
836 base::trace_event::TracedValue* dict) const { 838 base::trace_event::TracedValue* dict) const {
837 LayerImpl::AsValueInto(dict); 839 LayerImpl::AsValueInto(dict);
838 dict->SetString("layer_name", "Heads Up Display Layer"); 840 dict->SetString("layer_name", "Heads Up Display Layer");
839 } 841 }
840 842
841 } // namespace cc 843 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/heads_up_display_layer_impl.h ('k') | cc/layers/layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698