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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 cc_layer_->SetIsDrawable(IsDrawn()); | 480 cc_layer_->SetIsDrawable(IsDrawn()); |
481 } | 481 } |
482 | 482 |
483 void Layer::SwitchCCLayerForTest() { | 483 void Layer::SwitchCCLayerForTest() { |
484 scoped_refptr<cc::ContentLayer> new_layer = cc::ContentLayer::Create(this); | 484 scoped_refptr<cc::ContentLayer> new_layer = cc::ContentLayer::Create(this); |
485 SwitchToLayer(new_layer); | 485 SwitchToLayer(new_layer); |
486 content_layer_ = new_layer; | 486 content_layer_ = new_layer; |
487 } | 487 } |
488 | 488 |
489 void Layer::SetExternalTexture(Texture* texture) { | 489 void Layer::SetExternalTexture(Texture* texture) { |
| 490 // Hold a ref to the old |Texture| until we have updated all |
| 491 // compositor references to the texture id that it holds. |
| 492 scoped_refptr<ui::Texture> old_texture = texture_; |
| 493 |
490 DCHECK_EQ(type_, LAYER_TEXTURED); | 494 DCHECK_EQ(type_, LAYER_TEXTURED); |
491 DCHECK(!solid_color_layer_); | 495 DCHECK(!solid_color_layer_); |
492 bool has_texture = !!texture; | 496 bool has_texture = !!texture; |
493 layer_updated_externally_ = has_texture; | 497 layer_updated_externally_ = has_texture; |
494 texture_ = texture; | 498 texture_ = texture; |
495 if (!!texture_layer_ != has_texture) { | 499 if (!!texture_layer_ != has_texture) { |
496 // Switch to a different type of layer. | 500 // Switch to a different type of layer. |
497 if (has_texture) { | 501 if (has_texture) { |
498 scoped_refptr<cc::TextureLayer> new_layer = | 502 scoped_refptr<cc::TextureLayer> new_layer = |
499 cc::TextureLayer::Create(this); | 503 cc::TextureLayer::Create(this); |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); | 939 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); |
936 } | 940 } |
937 | 941 |
938 void Layer::RecomputePosition() { | 942 void Layer::RecomputePosition() { |
939 cc_layer_->SetPosition(gfx::ScalePoint( | 943 cc_layer_->SetPosition(gfx::ScalePoint( |
940 gfx::PointF(bounds_.x(), bounds_.y()), | 944 gfx::PointF(bounds_.x(), bounds_.y()), |
941 device_scale_factor_)); | 945 device_scale_factor_)); |
942 } | 946 } |
943 | 947 |
944 } // namespace ui | 948 } // namespace ui |
OLD | NEW |