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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 void Layer::SetFillsBoundsOpaquely(bool fills_bounds_opaquely) { | 424 void Layer::SetFillsBoundsOpaquely(bool fills_bounds_opaquely) { |
425 if (fills_bounds_opaquely_ == fills_bounds_opaquely) | 425 if (fills_bounds_opaquely_ == fills_bounds_opaquely) |
426 return; | 426 return; |
427 | 427 |
428 fills_bounds_opaquely_ = fills_bounds_opaquely; | 428 fills_bounds_opaquely_ = fills_bounds_opaquely; |
429 | 429 |
430 cc_layer_->SetContentsOpaque(fills_bounds_opaquely); | 430 cc_layer_->SetContentsOpaque(fills_bounds_opaquely); |
431 } | 431 } |
432 | 432 |
433 void Layer::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) { | 433 void Layer::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) { |
| 434 // Finish animations being handled by cc_layer_. |
| 435 if (animator_) { |
| 436 animator_->StopAnimatingProperty(LayerAnimationElement::TRANSFORM); |
| 437 animator_->StopAnimatingProperty(LayerAnimationElement::OPACITY); |
| 438 } |
| 439 |
434 if (texture_layer_.get()) | 440 if (texture_layer_.get()) |
435 texture_layer_->WillModifyTexture(); | 441 texture_layer_->WillModifyTexture(); |
436 // TODO(piman): delegated_renderer_layer_ cleanup. | 442 // TODO(piman): delegated_renderer_layer_ cleanup. |
437 | 443 |
438 cc_layer_->RemoveAllChildren(); | 444 cc_layer_->RemoveAllChildren(); |
439 if (parent_) { | 445 if (parent_) { |
440 DCHECK(parent_->cc_layer_); | 446 DCHECK(parent_->cc_layer_); |
441 parent_->cc_layer_->ReplaceChild(cc_layer_, new_layer); | 447 parent_->cc_layer_->ReplaceChild(cc_layer_, new_layer); |
442 } | 448 } |
443 cc_layer_->RemoveLayerAnimationEventObserver(this); | 449 cc_layer_->RemoveLayerAnimationEventObserver(this); |
(...skipping 10 matching lines...) Expand all Loading... |
454 for (size_t i = 0; i < children_.size(); ++i) { | 460 for (size_t i = 0; i < children_.size(); ++i) { |
455 DCHECK(children_[i]->cc_layer_); | 461 DCHECK(children_[i]->cc_layer_); |
456 cc_layer_->AddChild(children_[i]->cc_layer_); | 462 cc_layer_->AddChild(children_[i]->cc_layer_); |
457 } | 463 } |
458 cc_layer_->SetAnchorPoint(gfx::PointF()); | 464 cc_layer_->SetAnchorPoint(gfx::PointF()); |
459 cc_layer_->SetContentsOpaque(fills_bounds_opaquely_); | 465 cc_layer_->SetContentsOpaque(fills_bounds_opaquely_); |
460 cc_layer_->SetForceRenderSurface(force_render_surface_); | 466 cc_layer_->SetForceRenderSurface(force_render_surface_); |
461 cc_layer_->SetIsDrawable(IsDrawn()); | 467 cc_layer_->SetIsDrawable(IsDrawn()); |
462 } | 468 } |
463 | 469 |
| 470 void Layer::SwitchCCLayerForTest() { |
| 471 scoped_refptr<cc::ContentLayer> new_layer = cc::ContentLayer::Create(this); |
| 472 SwitchToLayer(new_layer); |
| 473 content_layer_ = new_layer; |
| 474 } |
| 475 |
464 void Layer::SetExternalTexture(Texture* texture) { | 476 void Layer::SetExternalTexture(Texture* texture) { |
465 DCHECK_EQ(type_, LAYER_TEXTURED); | 477 DCHECK_EQ(type_, LAYER_TEXTURED); |
466 DCHECK(!solid_color_layer_); | 478 DCHECK(!solid_color_layer_); |
467 bool has_texture = !!texture; | 479 bool has_texture = !!texture; |
468 layer_updated_externally_ = has_texture; | 480 layer_updated_externally_ = has_texture; |
469 texture_ = texture; | 481 texture_ = texture; |
470 if (!!texture_layer_ != has_texture) { | 482 if (!!texture_layer_ != has_texture) { |
471 // Switch to a different type of layer. | 483 // Switch to a different type of layer. |
472 if (has_texture) { | 484 if (has_texture) { |
473 scoped_refptr<cc::TextureLayer> new_layer = | 485 scoped_refptr<cc::TextureLayer> new_layer = |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 texture_layer_->SetUV(uv_top_left, uv_bottom_right); | 928 texture_layer_->SetUV(uv_top_left, uv_bottom_right); |
917 } else if (delegated_renderer_layer_.get()) { | 929 } else if (delegated_renderer_layer_.get()) { |
918 delegated_renderer_layer_->SetDisplaySize( | 930 delegated_renderer_layer_->SetDisplaySize( |
919 ConvertSizeToPixel(this, delegated_frame_size_in_dip_)); | 931 ConvertSizeToPixel(this, delegated_frame_size_in_dip_)); |
920 size.ClampToMax(delegated_frame_size_in_dip_); | 932 size.ClampToMax(delegated_frame_size_in_dip_); |
921 } | 933 } |
922 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); | 934 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); |
923 } | 935 } |
924 | 936 |
925 } // namespace ui | 937 } // namespace ui |
OLD | NEW |