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

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: fix review comments 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
« no previous file with comments | « 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 inverted_(false), 56 inverted_(false),
56 delegate_(NULL), 57 delegate_(NULL),
57 scale_content_(true), 58 scale_content_(true),
58 device_scale_factor_(1.0f) { 59 device_scale_factor_(1.0f) {
59 CreateWebLayer(); 60 CreateWebLayer();
60 } 61 }
61 62
62 Layer::Layer(LayerType type) 63 Layer::Layer(LayerType type)
63 : type_(type), 64 : type_(type),
64 compositor_(NULL), 65 compositor_(NULL),
65 parent_(NULL), 66 parent_(NULL),
66 visible_(true), 67 visible_(true),
68 force_render_surface_(false),
67 fills_bounds_opaquely_(true), 69 fills_bounds_opaquely_(true),
68 layer_updated_externally_(false), 70 layer_updated_externally_(false),
69 opacity_(1.0f), 71 opacity_(1.0f),
70 inverted_(false), 72 inverted_(false),
71 delegate_(NULL), 73 delegate_(NULL),
72 scale_content_(true), 74 scale_content_(true),
73 device_scale_factor_(1.0f) { 75 device_scale_factor_(1.0f) {
74 CreateWebLayer(); 76 CreateWebLayer();
75 } 77 }
76 78
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 web_layer_ = new_layer; 308 web_layer_ = new_layer;
307 web_layer_is_accelerated_ = layer_updated_externally_; 309 web_layer_is_accelerated_ = layer_updated_externally_;
308 for (size_t i = 0; i < children_.size(); ++i) { 310 for (size_t i = 0; i < children_.size(); ++i) {
309 DCHECK(!children_[i]->web_layer_.isNull()); 311 DCHECK(!children_[i]->web_layer_.isNull());
310 web_layer_.addChild(children_[i]->web_layer_); 312 web_layer_.addChild(children_[i]->web_layer_);
311 } 313 }
312 web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f)); 314 web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f));
313 web_layer_.setOpaque(fills_bounds_opaquely_); 315 web_layer_.setOpaque(fills_bounds_opaquely_);
314 web_layer_.setOpacity(visible_ ? opacity_ : 0.f); 316 web_layer_.setOpacity(visible_ ? opacity_ : 0.f);
315 web_layer_.setDebugBorderWidth(show_debug_borders_ ? 2 : 0); 317 web_layer_.setDebugBorderWidth(show_debug_borders_ ? 2 : 0);
318 web_layer_.setForceRenderSurface(force_render_surface_);
316 RecomputeTransform(); 319 RecomputeTransform();
317 RecomputeDebugBorderColor(); 320 RecomputeDebugBorderColor();
318 } 321 }
319 RecomputeDrawsContentAndUVRect(); 322 RecomputeDrawsContentAndUVRect();
320 } 323 }
321 324
322 void Layer::SetColor(SkColor color) { 325 void Layer::SetColor(SkColor color) {
323 DCHECK_EQ(type_, LAYER_SOLID_COLOR); 326 DCHECK_EQ(type_, LAYER_SOLID_COLOR);
324 // WebColor is equivalent to SkColor, per WebColor.h. 327 // WebColor is equivalent to SkColor, per WebColor.h.
325 web_layer_.to<WebKit::WebSolidColorLayer>().setBackgroundColor( 328 web_layer_.to<WebKit::WebSolidColorLayer>().setBackgroundColor(
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 if (scale_content) { 412 if (scale_content) {
410 canvas.sk_canvas()->scale(SkFloatToScalar(device_scale_factor_), 413 canvas.sk_canvas()->scale(SkFloatToScalar(device_scale_factor_),
411 SkFloatToScalar(device_scale_factor_)); 414 SkFloatToScalar(device_scale_factor_));
412 } 415 }
413 if (delegate_) 416 if (delegate_)
414 delegate_->OnPaintLayer(&canvas); 417 delegate_->OnPaintLayer(&canvas);
415 if (scale_content) 418 if (scale_content)
416 canvas.Restore(); 419 canvas.Restore();
417 } 420 }
418 421
422 void Layer::SetForceRenderSurface(bool force) {
423 if (force_render_surface_ == force)
424 return;
425
426 force_render_surface_ = force;
427 web_layer_.setForceRenderSurface(force_render_surface_);
428 }
429
419 float Layer::GetCombinedOpacity() const { 430 float Layer::GetCombinedOpacity() const {
420 float opacity = opacity_; 431 float opacity = opacity_;
421 Layer* current = this->parent_; 432 Layer* current = this->parent_;
422 while (current) { 433 while (current) {
423 opacity *= current->opacity_; 434 opacity *= current->opacity_;
424 current = current->parent_; 435 current = current->parent_;
425 } 436 }
426 return opacity; 437 return opacity;
427 } 438 }
428 439
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 return; 643 return;
633 unsigned int color = 0xFF000000; 644 unsigned int color = 0xFF000000;
634 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; 645 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000;
635 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); 646 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f);
636 if (!opaque) 647 if (!opaque)
637 color |= 0xFF; 648 color |= 0xFF;
638 web_layer_.setDebugBorderColor(color); 649 web_layer_.setDebugBorderColor(color);
639 } 650 }
640 651
641 } // namespace ui 652 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698