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/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
| 16 #include "cc/animation/animation_id_provider.h" |
| 17 #include "cc/animation/animation_player.h" |
| 18 #include "cc/animation/animation_timeline.h" |
16 #include "cc/base/scoped_ptr_algorithm.h" | 19 #include "cc/base/scoped_ptr_algorithm.h" |
17 #include "cc/layers/content_layer.h" | 20 #include "cc/layers/content_layer.h" |
18 #include "cc/layers/delegated_renderer_layer.h" | 21 #include "cc/layers/delegated_renderer_layer.h" |
19 #include "cc/layers/nine_patch_layer.h" | 22 #include "cc/layers/nine_patch_layer.h" |
20 #include "cc/layers/picture_layer.h" | 23 #include "cc/layers/picture_layer.h" |
21 #include "cc/layers/solid_color_layer.h" | 24 #include "cc/layers/solid_color_layer.h" |
22 #include "cc/layers/surface_layer.h" | 25 #include "cc/layers/surface_layer.h" |
23 #include "cc/layers/texture_layer.h" | 26 #include "cc/layers/texture_layer.h" |
24 #include "cc/output/copy_output_request.h" | 27 #include "cc/output/copy_output_request.h" |
25 #include "cc/output/delegated_frame_data.h" | 28 #include "cc/output/delegated_frame_data.h" |
26 #include "cc/output/filter_operation.h" | 29 #include "cc/output/filter_operation.h" |
27 #include "cc/output/filter_operations.h" | 30 #include "cc/output/filter_operations.h" |
28 #include "cc/resources/transferable_resource.h" | 31 #include "cc/resources/transferable_resource.h" |
| 32 #include "cc/trees/layer_tree_host.h" |
29 #include "ui/compositor/compositor_switches.h" | 33 #include "ui/compositor/compositor_switches.h" |
30 #include "ui/compositor/dip_util.h" | 34 #include "ui/compositor/dip_util.h" |
31 #include "ui/compositor/layer_animator.h" | 35 #include "ui/compositor/layer_animator.h" |
32 #include "ui/gfx/animation/animation.h" | 36 #include "ui/gfx/animation/animation.h" |
33 #include "ui/gfx/canvas.h" | 37 #include "ui/gfx/canvas.h" |
34 #include "ui/gfx/display.h" | 38 #include "ui/gfx/display.h" |
35 #include "ui/gfx/geometry/point3_f.h" | 39 #include "ui/gfx/geometry/point3_f.h" |
36 #include "ui/gfx/geometry/point_conversions.h" | 40 #include "ui/gfx/geometry/point_conversions.h" |
37 #include "ui/gfx/geometry/size_conversions.h" | 41 #include "ui/gfx/geometry/size_conversions.h" |
38 #include "ui/gfx/interpolated_transform.h" | 42 #include "ui/gfx/interpolated_transform.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 if (compositor_) | 122 if (compositor_) |
119 compositor_->SetRootLayer(NULL); | 123 compositor_->SetRootLayer(NULL); |
120 if (parent_) | 124 if (parent_) |
121 parent_->Remove(this); | 125 parent_->Remove(this); |
122 if (layer_mask_) | 126 if (layer_mask_) |
123 SetMaskLayer(NULL); | 127 SetMaskLayer(NULL); |
124 if (layer_mask_back_link_) | 128 if (layer_mask_back_link_) |
125 layer_mask_back_link_->SetMaskLayer(NULL); | 129 layer_mask_back_link_->SetMaskLayer(NULL); |
126 for (size_t i = 0; i < children_.size(); ++i) | 130 for (size_t i = 0; i < children_.size(); ++i) |
127 children_[i]->parent_ = NULL; | 131 children_[i]->parent_ = NULL; |
128 cc_layer_->RemoveLayerAnimationEventObserver(this); | 132 |
| 133 if (compositor_) |
| 134 DetachLayer(); |
| 135 |
129 cc_layer_->RemoveFromParent(); | 136 cc_layer_->RemoveFromParent(); |
130 } | 137 } |
131 | 138 |
132 // static | 139 // static |
133 bool Layer::UsingPictureLayer() { | 140 bool Layer::UsingPictureLayer() { |
134 return g_ui_impl_side_painting_status.Get().enabled; | 141 return g_ui_impl_side_painting_status.Get().enabled; |
135 } | 142 } |
136 | 143 |
137 const Compositor* Layer::GetCompositor() const { | 144 const Compositor* Layer::GetCompositor() const { |
138 return GetRoot(this)->compositor_; | 145 return GetRoot(this)->compositor_; |
139 } | 146 } |
140 | 147 |
141 float Layer::opacity() const { | 148 float Layer::opacity() const { |
142 return cc_layer_->opacity(); | 149 return cc_layer_->opacity(); |
143 } | 150 } |
144 | 151 |
145 void Layer::SetCompositor(Compositor* compositor) { | 152 void Layer::SetCompositor(Compositor* compositor) { |
| 153 if (compositor) |
| 154 RegisterForAnimations(compositor); |
| 155 |
146 // This function must only be called to set the compositor on the root layer, | 156 // This function must only be called to set the compositor on the root layer, |
147 // or to reset it. | 157 // or to reset it. |
148 DCHECK(!compositor || !compositor_); | 158 DCHECK(!compositor || !compositor_); |
149 DCHECK(!compositor || compositor->root_layer() == this); | 159 DCHECK(!compositor || compositor->root_layer() == this); |
150 DCHECK(!parent_); | 160 DCHECK(!parent_); |
151 if (compositor_) { | 161 if (compositor_) { |
| 162 DetachLayer(); |
| 163 DetachAnimationPlayer(); |
| 164 |
152 RemoveAnimatorsInTreeFromCollection( | 165 RemoveAnimatorsInTreeFromCollection( |
153 compositor_->layer_animator_collection()); | 166 compositor_->layer_animator_collection()); |
154 } | 167 } |
155 compositor_ = compositor; | 168 compositor_ = compositor; |
156 if (compositor) { | 169 if (compositor) { |
| 170 AttachAnimationPlayer(); |
| 171 AttachLayer(); |
| 172 |
157 OnDeviceScaleFactorChanged(compositor->device_scale_factor()); | 173 OnDeviceScaleFactorChanged(compositor->device_scale_factor()); |
158 SendPendingThreadedAnimations(); | 174 SendPendingThreadedAnimations(); |
159 AddAnimatorsInTreeToCollection(compositor_->layer_animator_collection()); | 175 AddAnimatorsInTreeToCollection(compositor_->layer_animator_collection()); |
160 } | 176 } |
161 } | 177 } |
162 | 178 |
163 void Layer::Add(Layer* child) { | 179 void Layer::Add(Layer* child) { |
164 DCHECK(!child->compositor_); | 180 DCHECK(!child->compositor_); |
165 if (child->parent_) | 181 if (child->parent_) |
166 child->parent_->Remove(child); | 182 child->parent_->Remove(child); |
167 child->parent_ = this; | 183 child->parent_ = this; |
168 children_.push_back(child); | 184 children_.push_back(child); |
169 cc_layer_->AddChild(child->cc_layer_); | 185 cc_layer_->AddChild(child->cc_layer_); |
170 child->OnDeviceScaleFactorChanged(device_scale_factor_); | 186 child->OnDeviceScaleFactorChanged(device_scale_factor_); |
171 if (GetCompositor()) | 187 Compositor* compositor = GetCompositor(); |
| 188 if (compositor) { |
| 189 child->RegisterForAnimations(compositor); |
| 190 child->AttachAnimationPlayer(); |
| 191 child->AttachLayer(); |
| 192 |
172 child->SendPendingThreadedAnimations(); | 193 child->SendPendingThreadedAnimations(); |
| 194 } |
173 LayerAnimatorCollection* collection = GetLayerAnimatorCollection(); | 195 LayerAnimatorCollection* collection = GetLayerAnimatorCollection(); |
174 if (collection) | 196 if (collection) |
175 child->AddAnimatorsInTreeToCollection(collection); | 197 child->AddAnimatorsInTreeToCollection(collection); |
176 } | 198 } |
177 | 199 |
178 void Layer::Remove(Layer* child) { | 200 void Layer::Remove(Layer* child) { |
179 // Current bounds are used to calculate offsets when layers are reparented. | 201 // Current bounds are used to calculate offsets when layers are reparented. |
180 // Stop (and complete) an ongoing animation to update the bounds immediately. | 202 // Stop (and complete) an ongoing animation to update the bounds immediately. |
181 LayerAnimator* child_animator = child->animator_.get(); | 203 LayerAnimator* child_animator = child->animator_.get(); |
182 if (child_animator) | 204 if (child_animator) |
183 child_animator->StopAnimatingProperty(ui::LayerAnimationElement::BOUNDS); | 205 child_animator->StopAnimatingProperty(ui::LayerAnimationElement::BOUNDS); |
184 LayerAnimatorCollection* collection = GetLayerAnimatorCollection(); | 206 LayerAnimatorCollection* collection = GetLayerAnimatorCollection(); |
185 if (collection) | 207 if (collection) |
186 child->RemoveAnimatorsInTreeFromCollection(collection); | 208 child->RemoveAnimatorsInTreeFromCollection(collection); |
187 | 209 |
| 210 Compositor* compositor = GetCompositor(); |
| 211 if (compositor) { |
| 212 child->DetachLayer(); |
| 213 child->DetachAnimationPlayer(); |
| 214 } |
| 215 |
188 std::vector<Layer*>::iterator i = | 216 std::vector<Layer*>::iterator i = |
189 std::find(children_.begin(), children_.end(), child); | 217 std::find(children_.begin(), children_.end(), child); |
190 DCHECK(i != children_.end()); | 218 DCHECK(i != children_.end()); |
191 children_.erase(i); | 219 children_.erase(i); |
192 child->parent_ = NULL; | 220 child->parent_ = NULL; |
193 child->cc_layer_->RemoveFromParent(); | 221 child->cc_layer_->RemoveFromParent(); |
194 } | 222 } |
195 | 223 |
196 void Layer::StackAtTop(Layer* child) { | 224 void Layer::StackAtTop(Layer* child) { |
197 if (children_.size() <= 1 || child == children_.back()) | 225 if (children_.size() <= 1 || child == children_.back()) |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 | 512 |
485 if (texture_layer_.get()) | 513 if (texture_layer_.get()) |
486 texture_layer_->ClearClient(); | 514 texture_layer_->ClearClient(); |
487 // TODO(piman): delegated_renderer_layer_ cleanup. | 515 // TODO(piman): delegated_renderer_layer_ cleanup. |
488 | 516 |
489 cc_layer_->RemoveAllChildren(); | 517 cc_layer_->RemoveAllChildren(); |
490 if (cc_layer_->parent()) { | 518 if (cc_layer_->parent()) { |
491 cc_layer_->parent()->ReplaceChild(cc_layer_, new_layer); | 519 cc_layer_->parent()->ReplaceChild(cc_layer_, new_layer); |
492 } | 520 } |
493 cc_layer_->SetLayerClient(NULL); | 521 cc_layer_->SetLayerClient(NULL); |
494 cc_layer_->RemoveLayerAnimationEventObserver(this); | 522 |
| 523 DetachLayer(); |
| 524 |
495 new_layer->SetOpacity(cc_layer_->opacity()); | 525 new_layer->SetOpacity(cc_layer_->opacity()); |
496 new_layer->SetTransform(cc_layer_->transform()); | 526 new_layer->SetTransform(cc_layer_->transform()); |
497 new_layer->SetPosition(cc_layer_->position()); | 527 new_layer->SetPosition(cc_layer_->position()); |
498 new_layer->SetBackgroundColor(cc_layer_->background_color()); | 528 new_layer->SetBackgroundColor(cc_layer_->background_color()); |
499 | 529 |
500 cc_layer_ = new_layer.get(); | 530 cc_layer_ = new_layer.get(); |
501 content_layer_ = NULL; | 531 content_layer_ = NULL; |
502 solid_color_layer_ = NULL; | 532 solid_color_layer_ = NULL; |
503 texture_layer_ = NULL; | 533 texture_layer_ = NULL; |
504 delegated_renderer_layer_ = NULL; | 534 delegated_renderer_layer_ = NULL; |
505 surface_layer_ = NULL; | 535 surface_layer_ = NULL; |
506 | 536 |
507 cc_layer_->AddLayerAnimationEventObserver(this); | 537 AttachLayer(); |
| 538 |
508 for (size_t i = 0; i < children_.size(); ++i) { | 539 for (size_t i = 0; i < children_.size(); ++i) { |
509 DCHECK(children_[i]->cc_layer_); | 540 DCHECK(children_[i]->cc_layer_); |
510 cc_layer_->AddChild(children_[i]->cc_layer_); | 541 cc_layer_->AddChild(children_[i]->cc_layer_); |
511 } | 542 } |
512 cc_layer_->SetLayerClient(this); | 543 cc_layer_->SetLayerClient(this); |
513 cc_layer_->SetTransformOrigin(gfx::Point3F()); | 544 cc_layer_->SetTransformOrigin(gfx::Point3F()); |
514 cc_layer_->SetContentsOpaque(fills_bounds_opaquely_); | 545 cc_layer_->SetContentsOpaque(fills_bounds_opaquely_); |
515 cc_layer_->SetForceRenderSurface(force_render_surface_); | 546 cc_layer_->SetForceRenderSurface(force_render_surface_); |
516 cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); | 547 cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); |
517 cc_layer_->SetHideLayerAndSubtree(!visible_); | 548 cc_layer_->SetHideLayerAndSubtree(!visible_); |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 } | 992 } |
962 | 993 |
963 float Layer::GetDeviceScaleFactor() const { | 994 float Layer::GetDeviceScaleFactor() const { |
964 return device_scale_factor_; | 995 return device_scale_factor_; |
965 } | 996 } |
966 | 997 |
967 void Layer::AddThreadedAnimation(scoped_ptr<cc::Animation> animation) { | 998 void Layer::AddThreadedAnimation(scoped_ptr<cc::Animation> animation) { |
968 DCHECK(cc_layer_); | 999 DCHECK(cc_layer_); |
969 // Until this layer has a compositor (and hence cc_layer_ has a | 1000 // Until this layer has a compositor (and hence cc_layer_ has a |
970 // LayerTreeHost), addAnimation will fail. | 1001 // LayerTreeHost), addAnimation will fail. |
971 if (GetCompositor()) | 1002 if (GetCompositor()) { |
972 cc_layer_->AddAnimation(animation.Pass()); | 1003 animation_player_ ? animation_player_->AddAnimation(animation.Pass()) |
973 else | 1004 : (void)cc_layer_->AddAnimation(animation.Pass()); |
| 1005 } else |
974 pending_threaded_animations_.push_back(animation.Pass()); | 1006 pending_threaded_animations_.push_back(animation.Pass()); |
975 } | 1007 } |
976 | 1008 |
977 namespace{ | 1009 namespace{ |
978 | 1010 |
979 struct HasAnimationId { | 1011 struct HasAnimationId { |
980 HasAnimationId(int id): id_(id) { | 1012 HasAnimationId(int id): id_(id) { |
981 } | 1013 } |
982 | 1014 |
983 bool operator()(cc::Animation* animation) const { | 1015 bool operator()(cc::Animation* animation) const { |
984 return animation->id() == id_; | 1016 return animation->id() == id_; |
985 } | 1017 } |
986 | 1018 |
987 private: | 1019 private: |
988 int id_; | 1020 int id_; |
989 }; | 1021 }; |
990 | 1022 |
991 } | 1023 } |
992 | 1024 |
993 void Layer::RemoveThreadedAnimation(int animation_id) { | 1025 void Layer::RemoveThreadedAnimation(int animation_id) { |
994 DCHECK(cc_layer_); | 1026 DCHECK(cc_layer_); |
995 if (pending_threaded_animations_.size() == 0) { | 1027 if (pending_threaded_animations_.size() == 0) { |
996 cc_layer_->RemoveAnimation(animation_id); | 1028 animation_player_ ? animation_player_->RemoveAnimation(animation_id) |
| 1029 : cc_layer_->RemoveAnimation(animation_id); |
997 return; | 1030 return; |
998 } | 1031 } |
999 | 1032 |
1000 pending_threaded_animations_.erase( | 1033 pending_threaded_animations_.erase( |
1001 cc::remove_if(&pending_threaded_animations_, | 1034 cc::remove_if(&pending_threaded_animations_, |
1002 pending_threaded_animations_.begin(), | 1035 pending_threaded_animations_.begin(), |
1003 pending_threaded_animations_.end(), | 1036 pending_threaded_animations_.end(), |
1004 HasAnimationId(animation_id)), | 1037 HasAnimationId(animation_id)), |
1005 pending_threaded_animations_.end()); | 1038 pending_threaded_animations_.end()); |
1006 } | 1039 } |
1007 | 1040 |
1008 LayerAnimatorCollection* Layer::GetLayerAnimatorCollection() { | 1041 LayerAnimatorCollection* Layer::GetLayerAnimatorCollection() { |
1009 Compositor* compositor = GetCompositor(); | 1042 Compositor* compositor = GetCompositor(); |
1010 return compositor ? compositor->layer_animator_collection() : NULL; | 1043 return compositor ? compositor->layer_animator_collection() : NULL; |
1011 } | 1044 } |
1012 | 1045 |
1013 void Layer::SendPendingThreadedAnimations() { | 1046 void Layer::SendPendingThreadedAnimations() { |
1014 for (cc::ScopedPtrVector<cc::Animation>::iterator it = | 1047 for (cc::ScopedPtrVector<cc::Animation>::iterator it = |
1015 pending_threaded_animations_.begin(); | 1048 pending_threaded_animations_.begin(); |
1016 it != pending_threaded_animations_.end(); | 1049 it != pending_threaded_animations_.end(); ++it) { |
1017 ++it) | 1050 animation_player_ |
1018 cc_layer_->AddAnimation(pending_threaded_animations_.take(it)); | 1051 ? animation_player_->AddAnimation(pending_threaded_animations_.take(it)) |
| 1052 : (void)cc_layer_->AddAnimation(pending_threaded_animations_.take(it)); |
| 1053 } |
1019 | 1054 |
1020 pending_threaded_animations_.clear(); | 1055 pending_threaded_animations_.clear(); |
1021 | 1056 |
1022 for (size_t i = 0; i < children_.size(); ++i) | 1057 for (size_t i = 0; i < children_.size(); ++i) |
1023 children_[i]->SendPendingThreadedAnimations(); | 1058 children_[i]->SendPendingThreadedAnimations(); |
1024 } | 1059 } |
1025 | 1060 |
1026 void Layer::CreateCcLayer() { | 1061 void Layer::CreateCcLayer() { |
1027 if (type_ == LAYER_SOLID_COLOR) { | 1062 if (type_ == LAYER_SOLID_COLOR) { |
1028 solid_color_layer_ = cc::SolidColorLayer::Create(); | 1063 solid_color_layer_ = cc::SolidColorLayer::Create(); |
1029 cc_layer_ = solid_color_layer_.get(); | 1064 cc_layer_ = solid_color_layer_.get(); |
1030 } else if (type_ == LAYER_NINE_PATCH) { | 1065 } else if (type_ == LAYER_NINE_PATCH) { |
1031 nine_patch_layer_ = cc::NinePatchLayer::Create(); | 1066 nine_patch_layer_ = cc::NinePatchLayer::Create(); |
1032 cc_layer_ = nine_patch_layer_.get(); | 1067 cc_layer_ = nine_patch_layer_.get(); |
1033 } else { | 1068 } else { |
1034 if (Layer::UsingPictureLayer()) | 1069 if (Layer::UsingPictureLayer()) |
1035 content_layer_ = cc::PictureLayer::Create(this); | 1070 content_layer_ = cc::PictureLayer::Create(this); |
1036 else | 1071 else |
1037 content_layer_ = cc::ContentLayer::Create(this); | 1072 content_layer_ = cc::ContentLayer::Create(this); |
1038 cc_layer_ = content_layer_.get(); | 1073 cc_layer_ = content_layer_.get(); |
1039 } | 1074 } |
1040 cc_layer_->SetTransformOrigin(gfx::Point3F()); | 1075 cc_layer_->SetTransformOrigin(gfx::Point3F()); |
1041 cc_layer_->SetContentsOpaque(true); | 1076 cc_layer_->SetContentsOpaque(true); |
1042 cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); | 1077 cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); |
1043 cc_layer_->AddLayerAnimationEventObserver(this); | |
1044 cc_layer_->SetLayerClient(this); | 1078 cc_layer_->SetLayerClient(this); |
1045 RecomputePosition(); | 1079 RecomputePosition(); |
1046 } | 1080 } |
1047 | 1081 |
| 1082 void Layer::RegisterForAnimations(Compositor* compositor) { |
| 1083 DCHECK(compositor); |
| 1084 const cc::LayerTreeHost& host = compositor->GetLayerTreeHost(); |
| 1085 cc_layer_->RegisterForAnimations(host.animation_registrar(), host.settings()); |
| 1086 |
| 1087 if (host.settings().use_compositor_animation_timelines) { |
| 1088 if (!animation_player_) { |
| 1089 animation_player_ = |
| 1090 cc::AnimationPlayer::Create(cc::AnimationIdProvider::NextPlayerId()); |
| 1091 } |
| 1092 } |
| 1093 |
| 1094 for (size_t i = 0; i < children_.size(); ++i) |
| 1095 children_[i]->RegisterForAnimations(compositor); |
| 1096 } |
| 1097 |
| 1098 void Layer::AttachLayer() { |
| 1099 DCHECK(cc_layer_); |
| 1100 |
| 1101 if (animation_player_) { |
| 1102 animation_player_->AttachLayer(cc_layer_->id()); |
| 1103 DCHECK(animation_player_->layer_animation_controller()); |
| 1104 animation_player_->layer_animation_controller()->AddEventObserver(this); |
| 1105 } else { |
| 1106 cc_layer_->AddLayerAnimationEventObserver(this); |
| 1107 } |
| 1108 |
| 1109 for (size_t i = 0; i < children_.size(); ++i) |
| 1110 children_[i]->AttachLayer(); |
| 1111 } |
| 1112 |
| 1113 void Layer::DetachLayer() { |
| 1114 if (animation_player_) { |
| 1115 DCHECK(animation_player_->layer_animation_controller()); |
| 1116 animation_player_->layer_animation_controller()->RemoveEventObserver(this); |
| 1117 animation_player_->DetachLayer(); |
| 1118 } else { |
| 1119 cc_layer_->RemoveLayerAnimationEventObserver(this); |
| 1120 } |
| 1121 |
| 1122 for (size_t i = 0; i < children_.size(); ++i) |
| 1123 children_[i]->DetachLayer(); |
| 1124 } |
| 1125 |
| 1126 void Layer::AttachAnimationPlayer() { |
| 1127 Compositor* compositor = GetCompositor(); |
| 1128 DCHECK(compositor); |
| 1129 |
| 1130 if (animation_player_) |
| 1131 compositor->GetAnimationTimeline()->AttachPlayer(animation_player_.get()); |
| 1132 |
| 1133 for (size_t i = 0; i < children_.size(); ++i) |
| 1134 children_[i]->AttachAnimationPlayer(); |
| 1135 } |
| 1136 |
| 1137 void Layer::DetachAnimationPlayer() { |
| 1138 Compositor* compositor = GetCompositor(); |
| 1139 DCHECK(compositor); |
| 1140 |
| 1141 if (animation_player_) |
| 1142 compositor->GetAnimationTimeline()->DetachPlayer(animation_player_.get()); |
| 1143 |
| 1144 for (size_t i = 0; i < children_.size(); ++i) |
| 1145 children_[i]->DetachAnimationPlayer(); |
| 1146 } |
| 1147 |
1048 gfx::Transform Layer::transform() const { | 1148 gfx::Transform Layer::transform() const { |
1049 return cc_layer_->transform(); | 1149 return cc_layer_->transform(); |
1050 } | 1150 } |
1051 | 1151 |
1052 void Layer::RecomputeDrawsContentAndUVRect() { | 1152 void Layer::RecomputeDrawsContentAndUVRect() { |
1053 DCHECK(cc_layer_); | 1153 DCHECK(cc_layer_); |
1054 gfx::Size size(bounds_.size()); | 1154 gfx::Size size(bounds_.size()); |
1055 if (texture_layer_.get()) { | 1155 if (texture_layer_.get()) { |
1056 size.SetToMin(frame_size_in_dip_); | 1156 size.SetToMin(frame_size_in_dip_); |
1057 gfx::PointF uv_top_left(0.f, 0.f); | 1157 gfx::PointF uv_top_left(0.f, 0.f); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 children_.end(), | 1191 children_.end(), |
1092 std::bind2nd(std::mem_fun(&Layer::RemoveAnimatorsInTreeFromCollection), | 1192 std::bind2nd(std::mem_fun(&Layer::RemoveAnimatorsInTreeFromCollection), |
1093 collection)); | 1193 collection)); |
1094 } | 1194 } |
1095 | 1195 |
1096 bool Layer::IsAnimating() const { | 1196 bool Layer::IsAnimating() const { |
1097 return animator_.get() && animator_->is_animating(); | 1197 return animator_.get() && animator_->is_animating(); |
1098 } | 1198 } |
1099 | 1199 |
1100 } // namespace ui | 1200 } // namespace ui |
OLD | NEW |