| 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 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 return true; | 216 return true; |
| 217 } | 217 } |
| 218 return false; | 218 return false; |
| 219 } | 219 } |
| 220 | 220 |
| 221 void Layer::SetAnimator(LayerAnimator* animator) { | 221 void Layer::SetAnimator(LayerAnimator* animator) { |
| 222 Compositor* compositor = GetCompositor(); | 222 Compositor* compositor = GetCompositor(); |
| 223 | 223 |
| 224 if (animator_) { | 224 if (animator_) { |
| 225 if (compositor) | 225 if (compositor) |
| 226 animator_->ResetCompositor(compositor); | 226 animator_->DetachLayerAndTimeline(compositor); |
| 227 animator_->SetDelegate(nullptr); | 227 animator_->SetDelegate(nullptr); |
| 228 } | 228 } |
| 229 | 229 |
| 230 animator_ = animator; | 230 animator_ = animator; |
| 231 | 231 |
| 232 if (animator_) { | 232 if (animator_) { |
| 233 animator_->SetDelegate(this); | 233 animator_->SetDelegate(this); |
| 234 if (compositor) | 234 if (compositor) |
| 235 animator_->SetCompositor(compositor); | 235 animator_->AttachLayerAndTimeline(compositor); |
| 236 } | 236 } |
| 237 } | 237 } |
| 238 | 238 |
| 239 LayerAnimator* Layer::GetAnimator() { | 239 LayerAnimator* Layer::GetAnimator() { |
| 240 if (!animator_.get()) | 240 if (!animator_.get()) |
| 241 SetAnimator(LayerAnimator::CreateDefaultAnimator()); | 241 SetAnimator(LayerAnimator::CreateDefaultAnimator()); |
| 242 return animator_.get(); | 242 return animator_.get(); |
| 243 } | 243 } |
| 244 | 244 |
| 245 void Layer::SetTransform(const gfx::Transform& transform) { | 245 void Layer::SetTransform(const gfx::Transform& transform) { |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 subpixel_position_offset_); | 1049 subpixel_position_offset_); |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 void Layer::SetCompositorForAnimatorsInTree(Compositor* compositor) { | 1052 void Layer::SetCompositorForAnimatorsInTree(Compositor* compositor) { |
| 1053 DCHECK(compositor); | 1053 DCHECK(compositor); |
| 1054 LayerAnimatorCollection* collection = compositor->layer_animator_collection(); | 1054 LayerAnimatorCollection* collection = compositor->layer_animator_collection(); |
| 1055 | 1055 |
| 1056 if (animator_) { | 1056 if (animator_) { |
| 1057 if (animator_->is_animating()) | 1057 if (animator_->is_animating()) |
| 1058 animator_->AddToCollection(collection); | 1058 animator_->AddToCollection(collection); |
| 1059 animator_->SetCompositor(compositor); | 1059 animator_->AttachLayerAndTimeline(compositor); |
| 1060 } | 1060 } |
| 1061 | 1061 |
| 1062 for (auto* child : children_) | 1062 for (auto* child : children_) |
| 1063 child->SetCompositorForAnimatorsInTree(compositor); | 1063 child->SetCompositorForAnimatorsInTree(compositor); |
| 1064 } | 1064 } |
| 1065 | 1065 |
| 1066 void Layer::ResetCompositorForAnimatorsInTree(Compositor* compositor) { | 1066 void Layer::ResetCompositorForAnimatorsInTree(Compositor* compositor) { |
| 1067 DCHECK(compositor); | 1067 DCHECK(compositor); |
| 1068 LayerAnimatorCollection* collection = compositor->layer_animator_collection(); | 1068 LayerAnimatorCollection* collection = compositor->layer_animator_collection(); |
| 1069 | 1069 |
| 1070 if (animator_) { | 1070 if (animator_) { |
| 1071 animator_->ResetCompositor(compositor); | 1071 animator_->DetachLayerAndTimeline(compositor); |
| 1072 animator_->RemoveFromCollection(collection); | 1072 animator_->RemoveFromCollection(collection); |
| 1073 } | 1073 } |
| 1074 | 1074 |
| 1075 for (auto* child : children_) | 1075 for (auto* child : children_) |
| 1076 child->ResetCompositorForAnimatorsInTree(compositor); | 1076 child->ResetCompositorForAnimatorsInTree(compositor); |
| 1077 } | 1077 } |
| 1078 | 1078 |
| 1079 } // namespace ui | 1079 } // namespace ui |
| OLD | NEW |