| OLD | NEW |
| 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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 if (fills_bounds_opaquely_ == fills_bounds_opaquely) | 402 if (fills_bounds_opaquely_ == fills_bounds_opaquely) |
| 403 return; | 403 return; |
| 404 | 404 |
| 405 fills_bounds_opaquely_ = fills_bounds_opaquely; | 405 fills_bounds_opaquely_ = fills_bounds_opaquely; |
| 406 | 406 |
| 407 cc_layer_->setContentsOpaque(fills_bounds_opaquely); | 407 cc_layer_->setContentsOpaque(fills_bounds_opaquely); |
| 408 } | 408 } |
| 409 | 409 |
| 410 void Layer::SetExternalTexture(Texture* texture) { | 410 void Layer::SetExternalTexture(Texture* texture) { |
| 411 DCHECK_EQ(type_, LAYER_TEXTURED); | 411 DCHECK_EQ(type_, LAYER_TEXTURED); |
| 412 DCHECK(!solid_color_layer_); |
| 412 layer_updated_externally_ = !!texture; | 413 layer_updated_externally_ = !!texture; |
| 413 texture_ = texture; | 414 texture_ = texture; |
| 414 if (cc_layer_is_accelerated_ != layer_updated_externally_) { | 415 if (cc_layer_is_accelerated_ != layer_updated_externally_) { |
| 415 // Switch to a different type of layer. | 416 // Switch to a different type of layer. |
| 416 cc_layer_->removeAllChildren(); | 417 cc_layer_->removeAllChildren(); |
| 417 scoped_refptr<cc::ContentLayer> old_content_layer( | 418 |
| 418 content_layer_.release()); | 419 scoped_refptr<cc::ContentLayer> old_content_layer; |
| 419 scoped_refptr<cc::SolidColorLayer> old_solid_layer( | 420 old_content_layer.swap(content_layer_); |
| 420 solid_color_layer_.release()); | 421 scoped_refptr<cc::TextureLayer> old_texture_layer; |
| 421 scoped_refptr<cc::TextureLayer> old_texture_layer( | 422 old_texture_layer.swap(texture_layer_); |
| 422 texture_layer_.release()); | 423 |
| 423 cc::Layer* new_layer = NULL; | 424 cc::Layer* new_layer = NULL; |
| 424 if (layer_updated_externally_) { | 425 if (layer_updated_externally_) { |
| 425 texture_layer_ = cc::TextureLayer::create(this); | 426 texture_layer_ = cc::TextureLayer::create(this); |
| 426 texture_layer_->setFlipped(texture_->flipped()); | 427 texture_layer_->setFlipped(texture_->flipped()); |
| 427 new_layer = texture_layer_.get(); | 428 new_layer = texture_layer_.get(); |
| 428 } else { | 429 } else { |
| 429 old_texture_layer->willModifyTexture(); | 430 old_texture_layer->willModifyTexture(); |
| 430 content_layer_ = cc::ContentLayer::create(this); | 431 content_layer_ = cc::ContentLayer::create(this); |
| 431 new_layer = content_layer_.get(); | 432 new_layer = content_layer_.get(); |
| 432 } | 433 } |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 0, | 794 0, |
| 794 static_cast<float>(size.width())/texture_size.width(), | 795 static_cast<float>(size.width())/texture_size.width(), |
| 795 static_cast<float>(size.height())/texture_size.height()); | 796 static_cast<float>(size.height())/texture_size.height()); |
| 796 texture_layer_->setUVRect(rect); | 797 texture_layer_->setUVRect(rect); |
| 797 | 798 |
| 798 cc_layer_->setBounds(ConvertSizeToPixel(this, size)); | 799 cc_layer_->setBounds(ConvertSizeToPixel(this, size)); |
| 799 } | 800 } |
| 800 } | 801 } |
| 801 | 802 |
| 802 } // namespace ui | 803 } // namespace ui |
| OLD | NEW |