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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 | 437 |
438 if (texture_layer_.get()) | 438 if (texture_layer_.get()) |
439 texture_layer_->WillModifyTexture(); | 439 texture_layer_->WillModifyTexture(); |
440 // TODO(piman): delegated_renderer_layer_ cleanup. | 440 // TODO(piman): delegated_renderer_layer_ cleanup. |
441 | 441 |
442 cc_layer_->RemoveAllChildren(); | 442 cc_layer_->RemoveAllChildren(); |
443 if (parent_) { | 443 if (parent_) { |
444 DCHECK(parent_->cc_layer_); | 444 DCHECK(parent_->cc_layer_); |
445 parent_->cc_layer_->ReplaceChild(cc_layer_, new_layer); | 445 parent_->cc_layer_->ReplaceChild(cc_layer_, new_layer); |
446 } | 446 } |
| 447 cc_layer_->SetLayerClient(NULL); |
447 cc_layer_->RemoveLayerAnimationEventObserver(this); | 448 cc_layer_->RemoveLayerAnimationEventObserver(this); |
448 new_layer->SetOpacity(cc_layer_->opacity()); | 449 new_layer->SetOpacity(cc_layer_->opacity()); |
449 new_layer->SetTransform(cc_layer_->transform()); | 450 new_layer->SetTransform(cc_layer_->transform()); |
450 new_layer->SetPosition(cc_layer_->position()); | 451 new_layer->SetPosition(cc_layer_->position()); |
451 | 452 |
452 cc_layer_ = new_layer.get(); | 453 cc_layer_ = new_layer.get(); |
453 content_layer_ = NULL; | 454 content_layer_ = NULL; |
454 solid_color_layer_ = NULL; | 455 solid_color_layer_ = NULL; |
455 texture_layer_ = NULL; | 456 texture_layer_ = NULL; |
456 delegated_renderer_layer_ = NULL; | 457 delegated_renderer_layer_ = NULL; |
457 | 458 |
458 cc_layer_->AddLayerAnimationEventObserver(this); | 459 cc_layer_->AddLayerAnimationEventObserver(this); |
459 for (size_t i = 0; i < children_.size(); ++i) { | 460 for (size_t i = 0; i < children_.size(); ++i) { |
460 DCHECK(children_[i]->cc_layer_); | 461 DCHECK(children_[i]->cc_layer_); |
461 cc_layer_->AddChild(children_[i]->cc_layer_); | 462 cc_layer_->AddChild(children_[i]->cc_layer_); |
462 } | 463 } |
| 464 cc_layer_->SetLayerClient(this); |
463 cc_layer_->SetAnchorPoint(gfx::PointF()); | 465 cc_layer_->SetAnchorPoint(gfx::PointF()); |
464 cc_layer_->SetContentsOpaque(fills_bounds_opaquely_); | 466 cc_layer_->SetContentsOpaque(fills_bounds_opaquely_); |
465 cc_layer_->SetForceRenderSurface(force_render_surface_); | 467 cc_layer_->SetForceRenderSurface(force_render_surface_); |
466 cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); | 468 cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); |
467 cc_layer_->SetHideLayerAndSubtree(!visible_); | 469 cc_layer_->SetHideLayerAndSubtree(!visible_); |
468 } | 470 } |
469 | 471 |
470 void Layer::SwitchCCLayerForTest() { | 472 void Layer::SwitchCCLayerForTest() { |
471 scoped_refptr<cc::ContentLayer> new_layer = cc::ContentLayer::Create(this); | 473 scoped_refptr<cc::ContentLayer> new_layer = cc::ContentLayer::Create(this); |
472 SwitchToLayer(new_layer); | 474 SwitchToLayer(new_layer); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 } | 670 } |
669 | 671 |
670 void Layer::SetForceRenderSurface(bool force) { | 672 void Layer::SetForceRenderSurface(bool force) { |
671 if (force_render_surface_ == force) | 673 if (force_render_surface_ == force) |
672 return; | 674 return; |
673 | 675 |
674 force_render_surface_ = force; | 676 force_render_surface_ = force; |
675 cc_layer_->SetForceRenderSurface(force_render_surface_); | 677 cc_layer_->SetForceRenderSurface(force_render_surface_); |
676 } | 678 } |
677 | 679 |
| 680 std::string Layer::DebugName() { |
| 681 return name_; |
| 682 } |
| 683 |
678 void Layer::OnAnimationStarted(const cc::AnimationEvent& event) { | 684 void Layer::OnAnimationStarted(const cc::AnimationEvent& event) { |
679 if (animator_.get()) | 685 if (animator_.get()) |
680 animator_->OnThreadedAnimationStarted(event); | 686 animator_->OnThreadedAnimationStarted(event); |
681 } | 687 } |
682 | 688 |
683 void Layer::StackRelativeTo(Layer* child, Layer* other, bool above) { | 689 void Layer::StackRelativeTo(Layer* child, Layer* other, bool above) { |
684 DCHECK_NE(child, other); | 690 DCHECK_NE(child, other); |
685 DCHECK_EQ(this, child->parent()); | 691 DCHECK_EQ(this, child->parent()); |
686 DCHECK_EQ(this, other->parent()); | 692 DCHECK_EQ(this, other->parent()); |
687 | 693 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 solid_color_layer_ = cc::SolidColorLayer::Create(); | 916 solid_color_layer_ = cc::SolidColorLayer::Create(); |
911 cc_layer_ = solid_color_layer_.get(); | 917 cc_layer_ = solid_color_layer_.get(); |
912 } else { | 918 } else { |
913 content_layer_ = cc::ContentLayer::Create(this); | 919 content_layer_ = cc::ContentLayer::Create(this); |
914 cc_layer_ = content_layer_.get(); | 920 cc_layer_ = content_layer_.get(); |
915 } | 921 } |
916 cc_layer_->SetAnchorPoint(gfx::PointF()); | 922 cc_layer_->SetAnchorPoint(gfx::PointF()); |
917 cc_layer_->SetContentsOpaque(true); | 923 cc_layer_->SetContentsOpaque(true); |
918 cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); | 924 cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); |
919 cc_layer_->AddLayerAnimationEventObserver(this); | 925 cc_layer_->AddLayerAnimationEventObserver(this); |
| 926 cc_layer_->SetLayerClient(this); |
920 RecomputePosition(); | 927 RecomputePosition(); |
921 } | 928 } |
922 | 929 |
923 void Layer::RecomputeCCTransformFromTransform(const gfx::Transform& transform) { | 930 void Layer::RecomputeCCTransformFromTransform(const gfx::Transform& transform) { |
924 cc_layer_->SetTransform(ConvertTransformToCCTransform(transform, | 931 cc_layer_->SetTransform(ConvertTransformToCCTransform(transform, |
925 device_scale_factor_)); | 932 device_scale_factor_)); |
926 } | 933 } |
927 | 934 |
928 gfx::Transform Layer::transform() const { | 935 gfx::Transform Layer::transform() const { |
929 gfx::Transform transform; | 936 gfx::Transform transform; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); | 971 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); |
965 } | 972 } |
966 | 973 |
967 void Layer::RecomputePosition() { | 974 void Layer::RecomputePosition() { |
968 cc_layer_->SetPosition(gfx::ScalePoint( | 975 cc_layer_->SetPosition(gfx::ScalePoint( |
969 gfx::PointF(bounds_.x(), bounds_.y()), | 976 gfx::PointF(bounds_.x(), bounds_.y()), |
970 device_scale_factor_)); | 977 device_scale_factor_)); |
971 } | 978 } |
972 | 979 |
973 } // namespace ui | 980 } // namespace ui |
OLD | NEW |