Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(534)

Side by Side Diff: cc/animation/layer_animation_controller.cc

Issue 1881373002: CC Animation: Erase AnimationRegistrar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@private
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "cc/animation/layer_animation_controller.h" 5 #include "cc/animation/layer_animation_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
11 11
12 #include "cc/animation/animation.h" 12 #include "cc/animation/animation.h"
13 #include "cc/animation/animation_curve.h" 13 #include "cc/animation/animation_curve.h"
14 #include "cc/animation/animation_delegate.h" 14 #include "cc/animation/animation_delegate.h"
15 #include "cc/animation/animation_events.h" 15 #include "cc/animation/animation_events.h"
16 #include "cc/animation/animation_registrar.h" 16 #include "cc/animation/animation_host.h"
17 #include "cc/animation/keyframed_animation_curve.h" 17 #include "cc/animation/keyframed_animation_curve.h"
18 #include "cc/animation/layer_animation_value_observer.h" 18 #include "cc/animation/layer_animation_value_observer.h"
19 #include "cc/animation/layer_animation_value_provider.h" 19 #include "cc/animation/layer_animation_value_provider.h"
20 #include "cc/animation/scroll_offset_animation_curve.h" 20 #include "cc/animation/scroll_offset_animation_curve.h"
21 #include "cc/output/filter_operations.h" 21 #include "cc/output/filter_operations.h"
22 #include "ui/gfx/geometry/box_f.h" 22 #include "ui/gfx/geometry/box_f.h"
23 #include "ui/gfx/transform.h" 23 #include "ui/gfx/transform.h"
24 24
25 namespace cc { 25 namespace cc {
26 26
27 LayerAnimationController::LayerAnimationController(int id) 27 LayerAnimationController::LayerAnimationController(int id)
28 : registrar_(0), 28 : host_(0),
29 id_(id), 29 id_(id),
30 is_active_(false), 30 is_active_(false),
31 value_provider_(nullptr), 31 value_provider_(nullptr),
32 layer_animation_delegate_(nullptr), 32 layer_animation_delegate_(nullptr),
33 needs_to_start_animations_(false), 33 needs_to_start_animations_(false),
34 scroll_offset_animation_was_interrupted_(false), 34 scroll_offset_animation_was_interrupted_(false),
35 potentially_animating_transform_for_active_observers_(false), 35 potentially_animating_transform_for_active_observers_(false),
36 potentially_animating_transform_for_pending_observers_(false) {} 36 potentially_animating_transform_for_pending_observers_(false) {}
37 37
38 LayerAnimationController::~LayerAnimationController() { 38 LayerAnimationController::~LayerAnimationController() {
39 if (registrar_) 39 if (host_)
40 registrar_->UnregisterAnimationController(this); 40 host_->UnregisterAnimationController(this);
41 } 41 }
42 42
43 scoped_refptr<LayerAnimationController> LayerAnimationController::Create( 43 scoped_refptr<LayerAnimationController> LayerAnimationController::Create(
44 int id) { 44 int id) {
45 return make_scoped_refptr(new LayerAnimationController(id)); 45 return make_scoped_refptr(new LayerAnimationController(id));
46 } 46 }
47 47
48 void LayerAnimationController::PauseAnimation(int animation_id, 48 void LayerAnimationController::PauseAnimation(int animation_id,
49 base::TimeDelta time_offset) { 49 base::TimeDelta time_offset) {
50 for (size_t i = 0; i < animations_.size(); ++i) { 50 for (size_t i = 0; i < animations_.size(); ++i) {
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 if ((observer_type == ObserverType::ACTIVE && 363 if ((observer_type == ObserverType::ACTIVE &&
364 animations_[i]->affects_active_observers()) || 364 animations_[i]->affects_active_observers()) ||
365 (observer_type == ObserverType::PENDING && 365 (observer_type == ObserverType::PENDING &&
366 animations_[i]->affects_pending_observers())) 366 animations_[i]->affects_pending_observers()))
367 return true; 367 return true;
368 } 368 }
369 } 369 }
370 return false; 370 return false;
371 } 371 }
372 372
373 void LayerAnimationController::SetAnimationRegistrar( 373 void LayerAnimationController::SetAnimationHost(AnimationHost* host) {
374 AnimationRegistrar* registrar) { 374 if (host_ == host)
375 if (registrar_ == registrar)
376 return; 375 return;
377 376
378 if (registrar_) 377 if (host_)
379 registrar_->UnregisterAnimationController(this); 378 host_->UnregisterAnimationController(this);
380 379
381 registrar_ = registrar; 380 host_ = host;
382 if (registrar_) 381 if (host_)
383 registrar_->RegisterAnimationController(this); 382 host_->RegisterAnimationController(this);
384 383
385 UpdateActivation(FORCE_ACTIVATION); 384 UpdateActivation(FORCE_ACTIVATION);
386 } 385 }
387 386
388 void LayerAnimationController::NotifyAnimationStarted( 387 void LayerAnimationController::NotifyAnimationStarted(
389 const AnimationEvent& event) { 388 const AnimationEvent& event) {
390 if (event.is_impl_only) { 389 if (event.is_impl_only) {
391 FOR_EACH_OBSERVER(LayerAnimationEventObserver, event_observers_, 390 FOR_EACH_OBSERVER(LayerAnimationEventObserver, event_observers_,
392 OnAnimationStarted(event)); 391 OnAnimationStarted(event));
393 if (layer_animation_delegate_) 392 if (layer_animation_delegate_)
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 animations_[i]->affects_pending_observers()); 1154 animations_[i]->affects_pending_observers());
1156 break; 1155 break;
1157 } 1156 }
1158 } 1157 }
1159 } 1158 }
1160 } 1159 }
1161 } 1160 }
1162 1161
1163 void LayerAnimationController::UpdateActivation(UpdateActivationType type) { 1162 void LayerAnimationController::UpdateActivation(UpdateActivationType type) {
1164 bool force = type == FORCE_ACTIVATION; 1163 bool force = type == FORCE_ACTIVATION;
1165 if (registrar_) { 1164 if (host_) {
1166 bool was_active = is_active_; 1165 bool was_active = is_active_;
1167 is_active_ = false; 1166 is_active_ = false;
1168 for (size_t i = 0; i < animations_.size(); ++i) { 1167 for (size_t i = 0; i < animations_.size(); ++i) {
1169 if (animations_[i]->run_state() != Animation::WAITING_FOR_DELETION) { 1168 if (animations_[i]->run_state() != Animation::WAITING_FOR_DELETION) {
1170 is_active_ = true; 1169 is_active_ = true;
1171 break; 1170 break;
1172 } 1171 }
1173 } 1172 }
1174 1173
1175 if (is_active_ && (!was_active || force)) 1174 if (is_active_ && (!was_active || force))
1176 registrar_->DidActivateAnimationController(this); 1175 host_->DidActivateAnimationController(this);
1177 else if (!is_active_ && (was_active || force)) 1176 else if (!is_active_ && (was_active || force))
1178 registrar_->DidDeactivateAnimationController(this); 1177 host_->DidDeactivateAnimationController(this);
1179 } 1178 }
1180 } 1179 }
1181 1180
1182 void LayerAnimationController::NotifyObserversOpacityAnimated( 1181 void LayerAnimationController::NotifyObserversOpacityAnimated(
1183 float opacity, 1182 float opacity,
1184 bool notify_active_observers, 1183 bool notify_active_observers,
1185 bool notify_pending_observers) { 1184 bool notify_pending_observers) {
1186 if (value_observers_.might_have_observers()) { 1185 if (value_observers_.might_have_observers()) {
1187 base::ObserverListBase<LayerAnimationValueObserver>::Iterator it( 1186 base::ObserverListBase<LayerAnimationValueObserver>::Iterator it(
1188 &value_observers_); 1187 &value_observers_);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 &value_observers_); 1286 &value_observers_);
1288 LayerAnimationValueObserver* obs; 1287 LayerAnimationValueObserver* obs;
1289 while ((obs = it.GetNext()) != nullptr) 1288 while ((obs = it.GetNext()) != nullptr)
1290 if (obs->IsActive()) 1289 if (obs->IsActive())
1291 return true; 1290 return true;
1292 } 1291 }
1293 return false; 1292 return false;
1294 } 1293 }
1295 1294
1296 } // namespace cc 1295 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/layer_animation_controller.h ('k') | cc/animation/layer_animation_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698