OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gfx/compositor/layer.h" | 5 #include "ui/gfx/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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 258 |
259 void Layer::SetExternalTexture(ui::Texture* texture) { | 259 void Layer::SetExternalTexture(ui::Texture* texture) { |
260 layer_updated_externally_ = !!texture; | 260 layer_updated_externally_ = !!texture; |
261 texture_ = texture; | 261 texture_ = texture; |
262 #if defined(USE_WEBKIT_COMPOSITOR) | 262 #if defined(USE_WEBKIT_COMPOSITOR) |
263 if (web_layer_is_accelerated_ != layer_updated_externally_) { | 263 if (web_layer_is_accelerated_ != layer_updated_externally_) { |
264 // Switch to a different type of layer. | 264 // Switch to a different type of layer. |
265 web_layer_.removeAllChildren(); | 265 web_layer_.removeAllChildren(); |
266 WebKit::WebLayer new_layer; | 266 WebKit::WebLayer new_layer; |
267 if (layer_updated_externally_) | 267 if (layer_updated_externally_) |
268 new_layer = WebKit::WebExternalTextureLayer::create(this); | 268 new_layer = WebKit::WebExternalTextureLayer::create(); |
269 else | 269 else |
270 new_layer = WebKit::WebContentLayer::create(this, this); | 270 new_layer = WebKit::WebContentLayer::create(this); |
271 if (parent_) { | 271 if (parent_) { |
272 DCHECK(!parent_->web_layer_.isNull()); | 272 DCHECK(!parent_->web_layer_.isNull()); |
273 parent_->web_layer_.replaceChild(web_layer_, new_layer); | 273 parent_->web_layer_.replaceChild(web_layer_, new_layer); |
274 } | 274 } |
275 web_layer_ = new_layer; | 275 web_layer_ = new_layer; |
276 web_layer_is_accelerated_ = layer_updated_externally_; | 276 web_layer_is_accelerated_ = layer_updated_externally_; |
277 for (size_t i = 0; i < children_.size(); ++i) { | 277 for (size_t i = 0; i < children_.size(); ++i) { |
278 DCHECK(!children_[i]->web_layer_.isNull()); | 278 DCHECK(!children_[i]->web_layer_.isNull()); |
279 web_layer_.addChild(children_[i]->web_layer_); | 279 web_layer_.addChild(children_[i]->web_layer_); |
280 } | 280 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 #else | 390 #else |
391 if (!visible_) | 391 if (!visible_) |
392 return; | 392 return; |
393 | 393 |
394 Draw(); | 394 Draw(); |
395 for (size_t i = 0; i < children_.size(); ++i) | 395 for (size_t i = 0; i < children_.size(); ++i) |
396 children_.at(i)->DrawTree(); | 396 children_.at(i)->DrawTree(); |
397 #endif | 397 #endif |
398 } | 398 } |
399 | 399 |
400 void Layer::notifyNeedsComposite() { | |
401 #if defined(USE_WEBKIT_COMPOSITOR) | |
402 ScheduleDraw(); | |
403 #else | |
404 NOTREACHED(); | |
405 #endif | |
406 } | |
407 | |
408 void Layer::paintContents(WebKit::WebCanvas* web_canvas, | 400 void Layer::paintContents(WebKit::WebCanvas* web_canvas, |
409 const WebKit::WebRect& clip) { | 401 const WebKit::WebRect& clip) { |
410 TRACE_EVENT0("ui", "Layer::paintContents"); | 402 TRACE_EVENT0("ui", "Layer::paintContents"); |
411 #if defined(USE_WEBKIT_COMPOSITOR) | 403 #if defined(USE_WEBKIT_COMPOSITOR) |
412 gfx::CanvasSkia canvas(web_canvas); | 404 gfx::CanvasSkia canvas(web_canvas); |
413 delegate_->OnPaintLayer(&canvas); | 405 delegate_->OnPaintLayer(&canvas); |
414 #else | 406 #else |
415 NOTREACHED(); | 407 NOTREACHED(); |
416 #endif | 408 #endif |
417 } | 409 } |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 const Transform& Layer::GetTransformForAnimation() const { | 715 const Transform& Layer::GetTransformForAnimation() const { |
724 return transform(); | 716 return transform(); |
725 } | 717 } |
726 | 718 |
727 float Layer::GetOpacityForAnimation() const { | 719 float Layer::GetOpacityForAnimation() const { |
728 return opacity(); | 720 return opacity(); |
729 } | 721 } |
730 | 722 |
731 #if defined(USE_WEBKIT_COMPOSITOR) | 723 #if defined(USE_WEBKIT_COMPOSITOR) |
732 void Layer::CreateWebLayer() { | 724 void Layer::CreateWebLayer() { |
733 web_layer_ = WebKit::WebContentLayer::create(this, this); | 725 web_layer_ = WebKit::WebContentLayer::create(this); |
734 web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f)); | 726 web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f)); |
735 web_layer_.setOpaque(true); | 727 web_layer_.setOpaque(true); |
736 web_layer_is_accelerated_ = false; | 728 web_layer_is_accelerated_ = false; |
737 show_debug_borders_ = CommandLine::ForCurrentProcess()->HasSwitch( | 729 show_debug_borders_ = CommandLine::ForCurrentProcess()->HasSwitch( |
738 switches::kUIShowLayerBorders); | 730 switches::kUIShowLayerBorders); |
739 web_layer_.setDebugBorderWidth(show_debug_borders_ ? 2 : 0); | 731 web_layer_.setDebugBorderWidth(show_debug_borders_ ? 2 : 0); |
740 RecomputeDrawsContentAndUVRect(); | 732 RecomputeDrawsContentAndUVRect(); |
741 RecomputeDebugBorderColor(); | 733 RecomputeDebugBorderColor(); |
742 } | 734 } |
743 | 735 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 unsigned int color = 0xFF000000; | 771 unsigned int color = 0xFF000000; |
780 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; | 772 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; |
781 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); | 773 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); |
782 if (!opaque) | 774 if (!opaque) |
783 color |= 0xFF; | 775 color |= 0xFF; |
784 web_layer_.setDebugBorderColor(color); | 776 web_layer_.setDebugBorderColor(color); |
785 } | 777 } |
786 #endif | 778 #endif |
787 | 779 |
788 } // namespace ui | 780 } // namespace ui |
OLD | NEW |