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

Side by Side Diff: ui/compositor/layer.cc

Issue 10444019: Aura: add a bench utility (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« ui/aura/bench/bench_main.cc ('K') | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "ui/compositor/layer.h" 5 #include "ui/compositor/layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 } // namespace 43 } // namespace
44 44
45 namespace ui { 45 namespace ui {
46 46
47 Layer::Layer() 47 Layer::Layer()
48 : type_(LAYER_TEXTURED), 48 : type_(LAYER_TEXTURED),
49 compositor_(NULL), 49 compositor_(NULL),
50 parent_(NULL), 50 parent_(NULL),
51 visible_(true), 51 visible_(true),
52 force_render_surface_(false),
52 fills_bounds_opaquely_(true), 53 fills_bounds_opaquely_(true),
53 layer_updated_externally_(false), 54 layer_updated_externally_(false),
54 opacity_(1.0f), 55 opacity_(1.0f),
55 delegate_(NULL), 56 delegate_(NULL),
56 scale_content_(true), 57 scale_content_(true),
57 device_scale_factor_(1.0f) { 58 device_scale_factor_(1.0f) {
58 CreateWebLayer(); 59 CreateWebLayer();
59 } 60 }
60 61
61 Layer::Layer(LayerType type) 62 Layer::Layer(LayerType type)
62 : type_(type), 63 : type_(type),
63 compositor_(NULL), 64 compositor_(NULL),
64 parent_(NULL), 65 parent_(NULL),
65 visible_(true), 66 visible_(true),
67 force_render_surface_(false),
66 fills_bounds_opaquely_(true), 68 fills_bounds_opaquely_(true),
67 layer_updated_externally_(false), 69 layer_updated_externally_(false),
68 opacity_(1.0f), 70 opacity_(1.0f),
69 delegate_(NULL), 71 delegate_(NULL),
70 scale_content_(true), 72 scale_content_(true),
71 device_scale_factor_(1.0f) { 73 device_scale_factor_(1.0f) {
72 CreateWebLayer(); 74 CreateWebLayer();
73 } 75 }
74 76
75 Layer::~Layer() { 77 Layer::~Layer() {
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 web_layer_ = new_layer; 291 web_layer_ = new_layer;
290 web_layer_is_accelerated_ = layer_updated_externally_; 292 web_layer_is_accelerated_ = layer_updated_externally_;
291 for (size_t i = 0; i < children_.size(); ++i) { 293 for (size_t i = 0; i < children_.size(); ++i) {
292 DCHECK(!children_[i]->web_layer_.isNull()); 294 DCHECK(!children_[i]->web_layer_.isNull());
293 web_layer_.addChild(children_[i]->web_layer_); 295 web_layer_.addChild(children_[i]->web_layer_);
294 } 296 }
295 web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f)); 297 web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f));
296 web_layer_.setOpaque(fills_bounds_opaquely_); 298 web_layer_.setOpaque(fills_bounds_opaquely_);
297 web_layer_.setOpacity(visible_ ? opacity_ : 0.f); 299 web_layer_.setOpacity(visible_ ? opacity_ : 0.f);
298 web_layer_.setDebugBorderWidth(show_debug_borders_ ? 2 : 0); 300 web_layer_.setDebugBorderWidth(show_debug_borders_ ? 2 : 0);
301 web_layer_.setForceRenderSurface(force_render_surface_);
299 RecomputeTransform(); 302 RecomputeTransform();
300 RecomputeDebugBorderColor(); 303 RecomputeDebugBorderColor();
301 } 304 }
302 RecomputeDrawsContentAndUVRect(); 305 RecomputeDrawsContentAndUVRect();
303 } 306 }
304 307
305 void Layer::SetColor(SkColor color) { 308 void Layer::SetColor(SkColor color) {
306 DCHECK_EQ(type_, LAYER_SOLID_COLOR); 309 DCHECK_EQ(type_, LAYER_SOLID_COLOR);
307 // WebColor is equivalent to SkColor, per WebColor.h. 310 // WebColor is equivalent to SkColor, per WebColor.h.
308 web_layer_.to<WebKit::WebSolidColorLayer>().setBackgroundColor( 311 web_layer_.to<WebKit::WebSolidColorLayer>().setBackgroundColor(
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 if (scale_content) { 395 if (scale_content) {
393 canvas.sk_canvas()->scale(SkFloatToScalar(device_scale_factor_), 396 canvas.sk_canvas()->scale(SkFloatToScalar(device_scale_factor_),
394 SkFloatToScalar(device_scale_factor_)); 397 SkFloatToScalar(device_scale_factor_));
395 } 398 }
396 if (delegate_) 399 if (delegate_)
397 delegate_->OnPaintLayer(&canvas); 400 delegate_->OnPaintLayer(&canvas);
398 if (scale_content) 401 if (scale_content)
399 canvas.Restore(); 402 canvas.Restore();
400 } 403 }
401 404
405 void Layer::SetForceRenderSurface(bool force) {
406 if (force_render_surface_ == force)
407 return;
408
409 force_render_surface_ = force;
410 web_layer_.setForceRenderSurface(force_render_surface_);
411 }
412
402 float Layer::GetCombinedOpacity() const { 413 float Layer::GetCombinedOpacity() const {
403 float opacity = opacity_; 414 float opacity = opacity_;
404 Layer* current = this->parent_; 415 Layer* current = this->parent_;
405 while (current) { 416 while (current) {
406 opacity *= current->opacity_; 417 opacity *= current->opacity_;
407 current = current->parent_; 418 current = current->parent_;
408 } 419 }
409 return opacity; 420 return opacity;
410 } 421 }
411 422
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 return; 626 return;
616 unsigned int color = 0xFF000000; 627 unsigned int color = 0xFF000000;
617 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; 628 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000;
618 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); 629 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f);
619 if (!opaque) 630 if (!opaque)
620 color |= 0xFF; 631 color |= 0xFF;
621 web_layer_.setDebugBorderColor(color); 632 web_layer_.setDebugBorderColor(color);
622 } 633 }
623 634
624 } // namespace ui 635 } // namespace ui
OLDNEW
« ui/aura/bench/bench_main.cc ('K') | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698