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

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

Issue 900063002: Fixes for two different HUD issues related to win32k lockdown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: better adoptref 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
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 double HeadsUpDisplayLayerImpl::Graph::UpdateUpperBound() { 63 double HeadsUpDisplayLayerImpl::Graph::UpdateUpperBound() {
64 double target_upper_bound = std::max(max, default_upper_bound); 64 double target_upper_bound = std::max(max, default_upper_bound);
65 current_upper_bound += (target_upper_bound - current_upper_bound) * 0.5; 65 current_upper_bound += (target_upper_bound - current_upper_bound) * 0.5;
66 return current_upper_bound; 66 return current_upper_bound;
67 } 67 }
68 68
69 HeadsUpDisplayLayerImpl::HeadsUpDisplayLayerImpl(LayerTreeImpl* tree_impl, 69 HeadsUpDisplayLayerImpl::HeadsUpDisplayLayerImpl(LayerTreeImpl* tree_impl,
70 int id) 70 int id)
71 : LayerImpl(tree_impl, id), 71 : LayerImpl(tree_impl, id),
72 typeface_(skia::AdoptRef(
73 SkTypeface::CreateFromName("monospace", SkTypeface::kBold))),
74 fps_graph_(60.0, 80.0), 72 fps_graph_(60.0, 80.0),
75 paint_time_graph_(16.0, 48.0), 73 paint_time_graph_(16.0, 48.0),
76 fade_step_(0) {} 74 fade_step_(0) {
75 }
77 76
78 HeadsUpDisplayLayerImpl::~HeadsUpDisplayLayerImpl() {} 77 HeadsUpDisplayLayerImpl::~HeadsUpDisplayLayerImpl() {}
79 78
80 scoped_ptr<LayerImpl> HeadsUpDisplayLayerImpl::CreateLayerImpl( 79 scoped_ptr<LayerImpl> HeadsUpDisplayLayerImpl::CreateLayerImpl(
81 LayerTreeImpl* tree_impl) { 80 LayerTreeImpl* tree_impl) {
82 return HeadsUpDisplayLayerImpl::Create(tree_impl, id()); 81 return HeadsUpDisplayLayerImpl::Create(tree_impl, id());
83 } 82 }
84 83
85 void HeadsUpDisplayLayerImpl::AcquireResource( 84 void HeadsUpDisplayLayerImpl::AcquireResource(
86 ResourceProvider* resource_provider) { 85 ResourceProvider* resource_provider) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 nearest_neighbor); 165 nearest_neighbor);
167 } 166 }
168 167
169 void HeadsUpDisplayLayerImpl::UpdateHudTexture( 168 void HeadsUpDisplayLayerImpl::UpdateHudTexture(
170 DrawMode draw_mode, 169 DrawMode draw_mode,
171 ResourceProvider* resource_provider) { 170 ResourceProvider* resource_provider) {
172 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE || !resources_.back()->id()) 171 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE || !resources_.back()->id())
173 return; 172 return;
174 173
175 SkISize canvas_size; 174 SkISize canvas_size;
176 if (hud_canvas_) 175 if (hud_surface_)
177 canvas_size = hud_canvas_->getDeviceSize(); 176 canvas_size = hud_surface_->getCanvas()->getDeviceSize();
178 else 177 else
179 canvas_size.set(0, 0); 178 canvas_size.set(0, 0);
180 179
181 if (canvas_size.width() != content_bounds().width() || 180 if (canvas_size.width() != content_bounds().width() ||
182 canvas_size.height() != content_bounds().height() || !hud_canvas_) { 181 canvas_size.height() != content_bounds().height() || !hud_surface_) {
183 TRACE_EVENT0("cc", "ResizeHudCanvas"); 182 TRACE_EVENT0("cc", "ResizeHudCanvas");
184 bool opaque = false; 183
185 hud_canvas_ = make_scoped_ptr(skia::CreateBitmapCanvas( 184 hud_surface_ = skia::AdoptRef(SkSurface::NewRasterN32Premul(
186 content_bounds().width(), content_bounds().height(), opaque)); 185 content_bounds().width(), content_bounds().height()));
187 } 186 }
188 187
189 UpdateHudContents(); 188 UpdateHudContents();
190 189
191 { 190 {
192 TRACE_EVENT0("cc", "DrawHudContents"); 191 TRACE_EVENT0("cc", "DrawHudContents");
193 hud_canvas_->clear(SkColorSetARGB(0, 0, 0, 0)); 192 hud_surface_->getCanvas()->clear(SkColorSetARGB(0, 0, 0, 0));
194 hud_canvas_->save(); 193 hud_surface_->getCanvas()->save();
195 hud_canvas_->scale(contents_scale_x(), contents_scale_y()); 194 hud_surface_->getCanvas()->scale(contents_scale_x(), contents_scale_y());
196 195
197 DrawHudContents(hud_canvas_.get()); 196 DrawHudContents(hud_surface_->getCanvas());
198 197
199 hud_canvas_->restore(); 198 hud_surface_->getCanvas()->restore();
200 } 199 }
201 200
202 TRACE_EVENT0("cc", "UploadHudTexture"); 201 TRACE_EVENT0("cc", "UploadHudTexture");
203 SkImageInfo info; 202 SkImageInfo info;
204 size_t row_bytes = 0; 203 size_t row_bytes = 0;
205 const void* pixels = hud_canvas_->peekPixels(&info, &row_bytes); 204 const void* pixels = hud_surface_->getCanvas()->peekPixels(&info, &row_bytes);
206 DCHECK(pixels); 205 DCHECK(pixels);
207 gfx::Rect content_rect(content_bounds()); 206 gfx::Rect content_rect(content_bounds());
208 DCHECK(info.colorType() == kN32_SkColorType); 207 DCHECK(info.colorType() == kN32_SkColorType);
209 resource_provider->SetPixels(resources_.back()->id(), 208 resource_provider->SetPixels(resources_.back()->id(),
210 static_cast<const uint8_t*>(pixels), 209 static_cast<const uint8_t*>(pixels),
211 content_rect, 210 content_rect,
212 content_rect, 211 content_rect,
213 gfx::Vector2d()); 212 gfx::Vector2d());
214 } 213 }
215 214
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 const std::string& text, 292 const std::string& text,
294 SkPaint::Align align, 293 SkPaint::Align align,
295 int size, 294 int size,
296 int x, 295 int x,
297 int y) const { 296 int y) const {
298 const bool anti_alias = paint->isAntiAlias(); 297 const bool anti_alias = paint->isAntiAlias();
299 paint->setAntiAlias(true); 298 paint->setAntiAlias(true);
300 299
301 paint->setTextSize(size); 300 paint->setTextSize(size);
302 paint->setTextAlign(align); 301 paint->setTextAlign(align);
303 paint->setTypeface(typeface_.get()); 302 paint->setTypeface(layer_tree_impl()->settings().hud_typeface.get());
304 canvas->drawText(text.c_str(), text.length(), x, y, *paint); 303 canvas->drawText(text.c_str(), text.length(), x, y, *paint);
305 304
306 paint->setAntiAlias(anti_alias); 305 paint->setAntiAlias(anti_alias);
307 } 306 }
308 307
309 void HeadsUpDisplayLayerImpl::DrawText(SkCanvas* canvas, 308 void HeadsUpDisplayLayerImpl::DrawText(SkCanvas* canvas,
310 SkPaint* paint, 309 SkPaint* paint,
311 const std::string& text, 310 const std::string& text,
312 SkPaint::Align align, 311 SkPaint::Align align,
313 int size, 312 int size,
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 gfx::Rect clip_rect = debug_layer_rect; 698 gfx::Rect clip_rect = debug_layer_rect;
700 clip_rect.Intersect(gfx::Rect(content_bounds())); 699 clip_rect.Intersect(gfx::Rect(content_bounds()));
701 SkRect sk_clip_rect = RectToSkRect(clip_rect); 700 SkRect sk_clip_rect = RectToSkRect(clip_rect);
702 701
703 canvas->save(); 702 canvas->save();
704 canvas->clipRect(sk_clip_rect); 703 canvas->clipRect(sk_clip_rect);
705 canvas->translate(sk_clip_rect.x(), sk_clip_rect.y()); 704 canvas->translate(sk_clip_rect.x(), sk_clip_rect.y());
706 705
707 SkPaint label_paint = CreatePaint(); 706 SkPaint label_paint = CreatePaint();
708 label_paint.setTextSize(kFontHeight); 707 label_paint.setTextSize(kFontHeight);
709 label_paint.setTypeface(typeface_.get()); 708 label_paint.setTypeface(layer_tree_impl()->settings().hud_typeface.get());
710 label_paint.setColor(stroke_color); 709 label_paint.setColor(stroke_color);
711 710
712 const SkScalar label_text_width = 711 const SkScalar label_text_width =
713 label_paint.measureText(label_text.c_str(), label_text.length()); 712 label_paint.measureText(label_text.c_str(), label_text.length());
714 canvas->drawRect(SkRect::MakeWH(label_text_width + 2 * kPadding, 713 canvas->drawRect(SkRect::MakeWH(label_text_width + 2 * kPadding,
715 kFontHeight + 2 * kPadding), 714 kFontHeight + 2 * kPadding),
716 label_paint); 715 label_paint);
717 716
718 label_paint.setAntiAlias(true); 717 label_paint.setAntiAlias(true);
719 label_paint.setColor(SkColorSetARGB(255, 50, 50, 50)); 718 label_paint.setColor(SkColorSetARGB(255, 50, 50, 50));
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 return "cc::HeadsUpDisplayLayerImpl"; 837 return "cc::HeadsUpDisplayLayerImpl";
839 } 838 }
840 839
841 void HeadsUpDisplayLayerImpl::AsValueInto( 840 void HeadsUpDisplayLayerImpl::AsValueInto(
842 base::debug::TracedValue* dict) const { 841 base::debug::TracedValue* dict) const {
843 LayerImpl::AsValueInto(dict); 842 LayerImpl::AsValueInto(dict);
844 dict->SetString("layer_name", "Heads Up Display Layer"); 843 dict->SetString("layer_name", "Heads Up Display Layer");
845 } 844 }
846 845
847 } // namespace cc 846 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698