OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/element_animations.h" | 5 #include "cc/animation/element_animations.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 } | 25 } |
26 | 26 |
27 ElementAnimations::ElementAnimations() | 27 ElementAnimations::ElementAnimations() |
28 : players_list_(new PlayersList()), | 28 : players_list_(new PlayersList()), |
29 animation_host_(), | 29 animation_host_(), |
30 element_id_(), | 30 element_id_(), |
31 is_active_(false), | 31 is_active_(false), |
32 has_element_in_active_list_(false), | 32 has_element_in_active_list_(false), |
33 has_element_in_pending_list_(false), | 33 has_element_in_pending_list_(false), |
34 scroll_offset_animation_was_interrupted_(false), | 34 scroll_offset_animation_was_interrupted_(false), |
35 needs_push_properties_(false) { | 35 needs_push_properties_(false), |
36 ClearNeedsUpdateImplClientState(); | 36 needs_update_impl_client_state_(false) {} |
37 } | |
38 | 37 |
39 ElementAnimations::~ElementAnimations() {} | 38 ElementAnimations::~ElementAnimations() {} |
40 | 39 |
41 void ElementAnimations::SetAnimationHost(AnimationHost* host) { | 40 void ElementAnimations::SetAnimationHost(AnimationHost* host) { |
42 animation_host_ = host; | 41 animation_host_ = host; |
43 } | 42 } |
44 | 43 |
45 void ElementAnimations::SetElementId(ElementId element_id) { | 44 void ElementAnimations::SetElementId(ElementId element_id) { |
46 element_id_ = element_id; | 45 element_id_ = element_id; |
47 } | 46 } |
48 | 47 |
49 void ElementAnimations::InitAffectedElementTypes() { | 48 void ElementAnimations::InitAffectedElementTypes() { |
50 DCHECK(element_id_); | 49 DCHECK(element_id_); |
51 DCHECK(animation_host_); | 50 DCHECK(animation_host_); |
52 | 51 |
53 UpdateActivation(ActivationType::FORCE); | 52 UpdateActivation(ActivationType::FORCE); |
54 | 53 |
55 DCHECK(animation_host_->mutator_host_client()); | 54 DCHECK(animation_host_->mutator_host_client()); |
56 if (animation_host_->mutator_host_client()->IsElementInList( | 55 if (animation_host_->mutator_host_client()->IsElementInList( |
57 element_id_, ElementListType::ACTIVE)) { | 56 element_id_, ElementListType::ACTIVE)) { |
58 set_has_element_in_active_list(true); | 57 set_has_element_in_active_list(true); |
59 } | 58 } |
60 if (animation_host_->mutator_host_client()->IsElementInList( | 59 if (animation_host_->mutator_host_client()->IsElementInList( |
61 element_id_, ElementListType::PENDING)) { | 60 element_id_, ElementListType::PENDING)) { |
62 set_has_element_in_pending_list(true); | 61 set_has_element_in_pending_list(true); |
63 } | 62 } |
64 } | 63 } |
65 | 64 |
| 65 TargetProperties ElementAnimations::GetPropertiesMaskForAnimationState() { |
| 66 TargetProperties properties; |
| 67 properties[TargetProperty::TRANSFORM] = true; |
| 68 properties[TargetProperty::OPACITY] = true; |
| 69 properties[TargetProperty::FILTER] = true; |
| 70 return properties; |
| 71 } |
| 72 |
66 void ElementAnimations::ClearAffectedElementTypes() { | 73 void ElementAnimations::ClearAffectedElementTypes() { |
67 DCHECK(animation_host_); | 74 DCHECK(animation_host_); |
68 | 75 |
| 76 TargetProperties disable_properties = GetPropertiesMaskForAnimationState(); |
| 77 PropertyAnimationState disabled_state_mask, disabled_state; |
| 78 disabled_state_mask.currently_running = disable_properties; |
| 79 disabled_state_mask.potentially_animating = disable_properties; |
| 80 |
69 if (has_element_in_active_list()) { | 81 if (has_element_in_active_list()) { |
70 IsAnimatingChanged(ElementListType::ACTIVE, TargetProperty::TRANSFORM, | 82 animation_host()->mutator_host_client()->ElementIsAnimatingChanged( |
71 AnimationChangeType::BOTH, false); | 83 element_id(), ElementListType::ACTIVE, disabled_state_mask, |
72 IsAnimatingChanged(ElementListType::ACTIVE, TargetProperty::OPACITY, | 84 disabled_state); |
73 AnimationChangeType::BOTH, false); | |
74 } | 85 } |
75 set_has_element_in_active_list(false); | 86 set_has_element_in_active_list(false); |
76 | 87 |
77 if (has_element_in_pending_list()) { | 88 if (has_element_in_pending_list()) { |
78 IsAnimatingChanged(ElementListType::PENDING, TargetProperty::TRANSFORM, | 89 animation_host()->mutator_host_client()->ElementIsAnimatingChanged( |
79 AnimationChangeType::BOTH, false); | 90 element_id(), ElementListType::PENDING, disabled_state_mask, |
80 IsAnimatingChanged(ElementListType::PENDING, TargetProperty::OPACITY, | 91 disabled_state); |
81 AnimationChangeType::BOTH, false); | |
82 } | 92 } |
83 set_has_element_in_pending_list(false); | 93 set_has_element_in_pending_list(false); |
84 | 94 |
85 animation_host_->DidDeactivateElementAnimations(this); | 95 animation_host_->DidDeactivateElementAnimations(this); |
86 UpdateActivation(ActivationType::FORCE); | 96 UpdateActivation(ActivationType::FORCE); |
87 } | 97 } |
88 | 98 |
89 void ElementAnimations::ElementRegistered(ElementId element_id, | 99 void ElementAnimations::ElementRegistered(ElementId element_id, |
90 ElementListType list_type) { | 100 ElementListType list_type) { |
91 DCHECK_EQ(element_id_, element_id); | 101 DCHECK_EQ(element_id_, element_id); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 143 |
134 if (!needs_push_properties_) | 144 if (!needs_push_properties_) |
135 return; | 145 return; |
136 needs_push_properties_ = false; | 146 needs_push_properties_ = false; |
137 | 147 |
138 element_animations_impl->scroll_offset_animation_was_interrupted_ = | 148 element_animations_impl->scroll_offset_animation_was_interrupted_ = |
139 scroll_offset_animation_was_interrupted_; | 149 scroll_offset_animation_was_interrupted_; |
140 scroll_offset_animation_was_interrupted_ = false; | 150 scroll_offset_animation_was_interrupted_ = false; |
141 | 151 |
142 // Update impl client state. | 152 // Update impl client state. |
143 element_animations_impl->UpdateClientAnimationState( | 153 if (needs_update_impl_client_state_) |
144 needs_update_impl_client_state_transform_, | 154 element_animations_impl->UpdateClientAnimationState(); |
145 needs_update_impl_client_state_opacity_, | 155 needs_update_impl_client_state_ = false; |
146 needs_update_impl_client_state_filter_); | |
147 ClearNeedsUpdateImplClientState(); | |
148 | 156 |
149 element_animations_impl->UpdateActivation(ActivationType::NORMAL); | 157 element_animations_impl->UpdateActivation(ActivationType::NORMAL); |
150 UpdateActivation(ActivationType::NORMAL); | 158 UpdateActivation(ActivationType::NORMAL); |
151 } | 159 } |
152 | 160 |
153 void ElementAnimations::UpdateClientAnimationState( | |
154 TargetProperty::Type target_property) { | |
155 switch (target_property) { | |
156 case TargetProperty::TRANSFORM: | |
157 case TargetProperty::OPACITY: | |
158 case TargetProperty::FILTER: | |
159 UpdateClientAnimationStateInternal(target_property); | |
160 break; | |
161 default: | |
162 // Do not update for other properties. | |
163 break; | |
164 } | |
165 } | |
166 | |
167 void ElementAnimations::UpdateClientAnimationState(bool transform, | |
168 bool opacity, | |
169 bool filter) { | |
170 if (transform) | |
171 UpdateClientAnimationStateInternal(TargetProperty::TRANSFORM); | |
172 if (opacity) | |
173 UpdateClientAnimationStateInternal(TargetProperty::OPACITY); | |
174 if (filter) | |
175 UpdateClientAnimationStateInternal(TargetProperty::FILTER); | |
176 } | |
177 | |
178 void ElementAnimations::AddAnimation(std::unique_ptr<Animation> animation) { | 161 void ElementAnimations::AddAnimation(std::unique_ptr<Animation> animation) { |
179 // TODO(loyso): Erase this. Rewrite element_animations_unittest to use | 162 // TODO(loyso): Erase this. Rewrite element_animations_unittest to use |
180 // AnimationPlayer::AddAnimation. | 163 // AnimationPlayer::AddAnimation. |
181 | 164 |
182 // Add animation to the first player. | 165 // Add animation to the first player. |
183 DCHECK(players_list_->might_have_observers()); | 166 DCHECK(players_list_->might_have_observers()); |
184 ElementAnimations::PlayersList::Iterator it(players_list_.get()); | 167 ElementAnimations::PlayersList::Iterator it(players_list_.get()); |
185 AnimationPlayer* player = it.GetNext(); | 168 AnimationPlayer* player = it.GetNext(); |
186 DCHECK(player); | 169 DCHECK(player); |
187 player->AddAnimation(std::move(animation)); | 170 player->AddAnimation(std::move(animation)); |
(...skipping 14 matching lines...) Expand all Loading... |
202 player->StartAnimations(monotonic_time); | 185 player->StartAnimations(monotonic_time); |
203 } | 186 } |
204 } | 187 } |
205 { | 188 { |
206 ElementAnimations::PlayersList::Iterator it(players_list_.get()); | 189 ElementAnimations::PlayersList::Iterator it(players_list_.get()); |
207 AnimationPlayer* player; | 190 AnimationPlayer* player; |
208 while ((player = it.GetNext()) != nullptr) | 191 while ((player = it.GetNext()) != nullptr) |
209 player->TickAnimations(monotonic_time); | 192 player->TickAnimations(monotonic_time); |
210 } | 193 } |
211 last_tick_time_ = monotonic_time; | 194 last_tick_time_ = monotonic_time; |
212 | 195 UpdateClientAnimationState(); |
213 UpdateClientAnimationStateInternal(TargetProperty::OPACITY); | |
214 UpdateClientAnimationStateInternal(TargetProperty::TRANSFORM); | |
215 UpdateClientAnimationStateInternal(TargetProperty::FILTER); | |
216 } | 196 } |
217 | 197 |
218 void ElementAnimations::UpdateState(bool start_ready_animations, | 198 void ElementAnimations::UpdateState(bool start_ready_animations, |
219 AnimationEvents* events) { | 199 AnimationEvents* events) { |
220 if (!has_element_in_active_list()) | 200 if (!has_element_in_active_list()) |
221 return; | 201 return; |
222 | 202 |
223 // Animate hasn't been called, this happens if an element has been added | 203 // Animate hasn't been called, this happens if an element has been added |
224 // between the Commit and Draw phases. | 204 // between the Commit and Draw phases. |
225 if (last_tick_time_ == base::TimeTicks()) | 205 if (last_tick_time_ == base::TimeTicks()) |
(...skipping 27 matching lines...) Expand all Loading... |
253 player->StartAnimations(last_tick_time_); | 233 player->StartAnimations(last_tick_time_); |
254 player->PromoteStartedAnimations(last_tick_time_, events); | 234 player->PromoteStartedAnimations(last_tick_time_, events); |
255 } | 235 } |
256 } | 236 } |
257 } | 237 } |
258 | 238 |
259 UpdateActivation(ActivationType::NORMAL); | 239 UpdateActivation(ActivationType::NORMAL); |
260 } | 240 } |
261 | 241 |
262 void ElementAnimations::ActivateAnimations() { | 242 void ElementAnimations::ActivateAnimations() { |
263 bool changed_transform_animation = false; | |
264 bool changed_opacity_animation = false; | |
265 bool changed_filter_animation = false; | |
266 | |
267 ElementAnimations::PlayersList::Iterator it(players_list_.get()); | 243 ElementAnimations::PlayersList::Iterator it(players_list_.get()); |
268 AnimationPlayer* player; | 244 AnimationPlayer* player; |
269 while ((player = it.GetNext()) != nullptr) { | 245 while ((player = it.GetNext()) != nullptr) |
270 player->ActivateAnimations(&changed_transform_animation, | 246 player->ActivateAnimations(); |
271 &changed_opacity_animation, | |
272 &changed_filter_animation); | |
273 } | |
274 | 247 |
275 scroll_offset_animation_was_interrupted_ = false; | 248 scroll_offset_animation_was_interrupted_ = false; |
276 UpdateActivation(ActivationType::NORMAL); | 249 UpdateActivation(ActivationType::NORMAL); |
277 UpdateClientAnimationState(changed_transform_animation, | |
278 changed_opacity_animation, | |
279 changed_filter_animation); | |
280 } | 250 } |
281 | 251 |
282 void ElementAnimations::NotifyAnimationStarted(const AnimationEvent& event) { | 252 void ElementAnimations::NotifyAnimationStarted(const AnimationEvent& event) { |
283 DCHECK(!event.is_impl_only); | 253 DCHECK(!event.is_impl_only); |
284 ElementAnimations::PlayersList::Iterator it(players_list_.get()); | 254 ElementAnimations::PlayersList::Iterator it(players_list_.get()); |
285 AnimationPlayer* player; | 255 AnimationPlayer* player; |
286 while ((player = it.GetNext()) != nullptr) { | 256 while ((player = it.GetNext()) != nullptr) { |
287 if (player->NotifyAnimationStarted(event)) | 257 if (player->NotifyAnimationStarted(event)) |
288 break; | 258 break; |
289 } | 259 } |
(...skipping 22 matching lines...) Expand all Loading... |
312 void ElementAnimations::NotifyAnimationAborted(const AnimationEvent& event) { | 282 void ElementAnimations::NotifyAnimationAborted(const AnimationEvent& event) { |
313 DCHECK(!event.is_impl_only); | 283 DCHECK(!event.is_impl_only); |
314 | 284 |
315 ElementAnimations::PlayersList::Iterator it(players_list_.get()); | 285 ElementAnimations::PlayersList::Iterator it(players_list_.get()); |
316 AnimationPlayer* player; | 286 AnimationPlayer* player; |
317 while ((player = it.GetNext()) != nullptr) { | 287 while ((player = it.GetNext()) != nullptr) { |
318 if (player->NotifyAnimationAborted(event)) | 288 if (player->NotifyAnimationAborted(event)) |
319 break; | 289 break; |
320 } | 290 } |
321 | 291 |
322 UpdateClientAnimationState(event.target_property); | 292 UpdateClientAnimationState(); |
323 } | 293 } |
324 | 294 |
325 void ElementAnimations::NotifyAnimationPropertyUpdate( | 295 void ElementAnimations::NotifyAnimationPropertyUpdate( |
326 const AnimationEvent& event) { | 296 const AnimationEvent& event) { |
327 DCHECK(!event.is_impl_only); | 297 DCHECK(!event.is_impl_only); |
328 bool notify_active_elements = true; | 298 bool notify_active_elements = true; |
329 bool notify_pending_elements = true; | 299 bool notify_pending_elements = true; |
330 switch (event.target_property) { | 300 switch (event.target_property) { |
331 case TargetProperty::OPACITY: | 301 case TargetProperty::OPACITY: |
332 NotifyClientOpacityAnimated(event.opacity, notify_active_elements, | 302 NotifyClientOpacityAnimated(event.opacity, notify_active_elements, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 bool success = player->MaximumTargetScale(list_type, &player_max_scale); | 404 bool success = player->MaximumTargetScale(list_type, &player_max_scale); |
435 if (!success) | 405 if (!success) |
436 return false; | 406 return false; |
437 // Union: a maximum. | 407 // Union: a maximum. |
438 *max_scale = std::max(*max_scale, player_max_scale); | 408 *max_scale = std::max(*max_scale, player_max_scale); |
439 } | 409 } |
440 | 410 |
441 return true; | 411 return true; |
442 } | 412 } |
443 | 413 |
444 void ElementAnimations::SetNeedsUpdateImplClientState(bool transform, | 414 void ElementAnimations::SetNeedsUpdateImplClientState() { |
445 bool opacity, | 415 needs_update_impl_client_state_ = true; |
446 bool filter) { | 416 SetNeedsPushProperties(); |
447 if (transform) | |
448 needs_update_impl_client_state_transform_ = true; | |
449 if (opacity) | |
450 needs_update_impl_client_state_opacity_ = true; | |
451 if (filter) | |
452 needs_update_impl_client_state_filter_ = true; | |
453 | |
454 if (needs_update_impl_client_state_transform_ || | |
455 needs_update_impl_client_state_opacity_ || | |
456 needs_update_impl_client_state_filter_) | |
457 SetNeedsPushProperties(); | |
458 } | |
459 | |
460 void ElementAnimations::ClearNeedsUpdateImplClientState() { | |
461 needs_update_impl_client_state_transform_ = false; | |
462 needs_update_impl_client_state_opacity_ = false; | |
463 needs_update_impl_client_state_filter_ = false; | |
464 } | 417 } |
465 | 418 |
466 void ElementAnimations::UpdateActivation(ActivationType type) { | 419 void ElementAnimations::UpdateActivation(ActivationType type) { |
467 bool force = type == ActivationType::FORCE; | 420 bool force = type == ActivationType::FORCE; |
468 if (animation_host_) { | 421 if (animation_host_) { |
469 bool was_active = is_active_; | 422 bool was_active = is_active_; |
470 is_active_ = false; | 423 is_active_ = false; |
471 | 424 |
472 ElementAnimations::PlayersList::Iterator it(players_list_.get()); | 425 ElementAnimations::PlayersList::Iterator it(players_list_.get()); |
473 AnimationPlayer* player; | 426 AnimationPlayer* player; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 void ElementAnimations::NotifyClientScrollOffsetAnimated( | 479 void ElementAnimations::NotifyClientScrollOffsetAnimated( |
527 const gfx::ScrollOffset& scroll_offset, | 480 const gfx::ScrollOffset& scroll_offset, |
528 bool notify_active_elements, | 481 bool notify_active_elements, |
529 bool notify_pending_elements) { | 482 bool notify_pending_elements) { |
530 if (notify_active_elements && has_element_in_active_list()) | 483 if (notify_active_elements && has_element_in_active_list()) |
531 OnScrollOffsetAnimated(ElementListType::ACTIVE, scroll_offset); | 484 OnScrollOffsetAnimated(ElementListType::ACTIVE, scroll_offset); |
532 if (notify_pending_elements && has_element_in_pending_list()) | 485 if (notify_pending_elements && has_element_in_pending_list()) |
533 OnScrollOffsetAnimated(ElementListType::PENDING, scroll_offset); | 486 OnScrollOffsetAnimated(ElementListType::PENDING, scroll_offset); |
534 } | 487 } |
535 | 488 |
536 void ElementAnimations::NotifyClientAnimationChanged( | 489 void ElementAnimations::UpdateClientAnimationState() { |
537 TargetProperty::Type property, | 490 if (!element_id()) |
538 ElementListType list_type, | 491 return; |
539 bool notify_elements_about_potential_animation, | 492 DCHECK(animation_host()); |
540 bool notify_elements_about_running_animation) { | 493 if (!animation_host()->mutator_host_client()) |
541 PropertyAnimationState* animation_state = nullptr; | 494 return; |
542 switch (property) { | |
543 case TargetProperty::OPACITY: | |
544 animation_state = &opacity_animation_state_; | |
545 break; | |
546 case TargetProperty::TRANSFORM: | |
547 animation_state = &transform_animation_state_; | |
548 break; | |
549 case TargetProperty::FILTER: | |
550 animation_state = &filter_animation_state_; | |
551 break; | |
552 default: | |
553 NOTREACHED(); | |
554 break; | |
555 } | |
556 | 495 |
557 bool notify_elements_about_potential_and_running_animation = | 496 PropertyAnimationState prev_pending = pending_state_; |
558 notify_elements_about_potential_animation && | 497 PropertyAnimationState prev_active = active_state_; |
559 notify_elements_about_running_animation; | |
560 bool active = list_type == ElementListType::ACTIVE; | |
561 if (notify_elements_about_potential_and_running_animation) { | |
562 bool potentially_animating = | |
563 active ? animation_state->potentially_animating_for_active_elements | |
564 : animation_state->potentially_animating_for_pending_elements; | |
565 bool currently_animating = | |
566 active ? animation_state->currently_running_for_active_elements | |
567 : animation_state->currently_running_for_pending_elements; | |
568 DCHECK_EQ(potentially_animating, currently_animating); | |
569 IsAnimatingChanged(list_type, property, AnimationChangeType::BOTH, | |
570 potentially_animating); | |
571 } else if (notify_elements_about_potential_animation) { | |
572 bool potentially_animating = | |
573 active ? animation_state->potentially_animating_for_active_elements | |
574 : animation_state->potentially_animating_for_pending_elements; | |
575 IsAnimatingChanged(list_type, property, AnimationChangeType::POTENTIAL, | |
576 potentially_animating); | |
577 } else if (notify_elements_about_running_animation) { | |
578 bool currently_animating = | |
579 active ? animation_state->currently_running_for_active_elements | |
580 : animation_state->currently_running_for_pending_elements; | |
581 IsAnimatingChanged(list_type, property, AnimationChangeType::RUNNING, | |
582 currently_animating); | |
583 } | |
584 } | |
585 | 498 |
586 void ElementAnimations::UpdateClientAnimationStateInternal( | 499 pending_state_.Clear(); |
587 TargetProperty::Type property) { | 500 active_state_.Clear(); |
588 PropertyAnimationState* animation_state = nullptr; | |
589 switch (property) { | |
590 case TargetProperty::OPACITY: | |
591 animation_state = &opacity_animation_state_; | |
592 break; | |
593 case TargetProperty::TRANSFORM: | |
594 animation_state = &transform_animation_state_; | |
595 break; | |
596 case TargetProperty::FILTER: | |
597 animation_state = &filter_animation_state_; | |
598 break; | |
599 default: | |
600 NOTREACHED(); | |
601 break; | |
602 } | |
603 | |
604 PropertyAnimationState previous_state = *animation_state; | |
605 animation_state->Clear(); | |
606 DCHECK(previous_state.IsValid()); | |
607 | 501 |
608 ElementAnimations::PlayersList::Iterator it(players_list_.get()); | 502 ElementAnimations::PlayersList::Iterator it(players_list_.get()); |
609 AnimationPlayer* player; | 503 AnimationPlayer* player; |
610 while ((player = it.GetNext()) != nullptr) { | 504 while ((player = it.GetNext()) != nullptr) { |
611 PropertyAnimationState player_state; | 505 PropertyAnimationState player_pending_state, player_active_state; |
612 player->GetPropertyAnimationStateFor(property, &player_state); | 506 player->GetPropertyAnimationState(&player_pending_state, |
613 *animation_state |= player_state; | 507 &player_active_state); |
| 508 pending_state_ |= player_pending_state; |
| 509 active_state_ |= player_active_state; |
614 } | 510 } |
615 | 511 |
616 if (*animation_state == previous_state) | 512 TargetProperties allowed_properties = GetPropertiesMaskForAnimationState(); |
617 return; | 513 PropertyAnimationState allowed_state; |
| 514 allowed_state.currently_running = allowed_properties; |
| 515 allowed_state.potentially_animating = allowed_properties; |
618 | 516 |
619 PropertyAnimationState diff_state = previous_state ^ *animation_state; | 517 pending_state_ &= allowed_state; |
| 518 active_state_ &= allowed_state; |
620 | 519 |
621 if (has_element_in_active_list()) | 520 DCHECK(pending_state_.IsValid()); |
622 NotifyClientAnimationChanged( | 521 DCHECK(active_state_.IsValid()); |
623 property, ElementListType::ACTIVE, | 522 |
624 diff_state.potentially_animating_for_active_elements, | 523 if (has_element_in_active_list() && prev_active != active_state_) { |
625 diff_state.currently_running_for_active_elements); | 524 PropertyAnimationState diff_active = prev_active ^ active_state_; |
626 if (has_element_in_pending_list()) | 525 animation_host()->mutator_host_client()->ElementIsAnimatingChanged( |
627 NotifyClientAnimationChanged( | 526 element_id(), ElementListType::ACTIVE, diff_active, active_state_); |
628 property, ElementListType::PENDING, | 527 } |
629 diff_state.potentially_animating_for_pending_elements, | 528 if (has_element_in_pending_list() && prev_pending != pending_state_) { |
630 diff_state.currently_running_for_pending_elements); | 529 PropertyAnimationState diff_pending = prev_pending ^ pending_state_; |
| 530 animation_host()->mutator_host_client()->ElementIsAnimatingChanged( |
| 531 element_id(), ElementListType::PENDING, diff_pending, pending_state_); |
| 532 } |
631 } | 533 } |
632 | 534 |
633 bool ElementAnimations::HasActiveAnimation() const { | 535 bool ElementAnimations::HasActiveAnimation() const { |
634 ElementAnimations::PlayersList::Iterator it(players_list_.get()); | 536 ElementAnimations::PlayersList::Iterator it(players_list_.get()); |
635 AnimationPlayer* player; | 537 AnimationPlayer* player; |
636 while ((player = it.GetNext()) != nullptr) { | 538 while ((player = it.GetNext()) != nullptr) { |
637 if (player->HasActiveAnimation()) | 539 if (player->HasActiveAnimation()) |
638 return true; | 540 return true; |
639 } | 541 } |
640 | 542 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 void ElementAnimations::OnScrollOffsetAnimated( | 676 void ElementAnimations::OnScrollOffsetAnimated( |
775 ElementListType list_type, | 677 ElementListType list_type, |
776 const gfx::ScrollOffset& scroll_offset) { | 678 const gfx::ScrollOffset& scroll_offset) { |
777 DCHECK(element_id()); | 679 DCHECK(element_id()); |
778 DCHECK(animation_host()); | 680 DCHECK(animation_host()); |
779 DCHECK(animation_host()->mutator_host_client()); | 681 DCHECK(animation_host()->mutator_host_client()); |
780 animation_host()->mutator_host_client()->SetElementScrollOffsetMutated( | 682 animation_host()->mutator_host_client()->SetElementScrollOffsetMutated( |
781 element_id(), list_type, scroll_offset); | 683 element_id(), list_type, scroll_offset); |
782 } | 684 } |
783 | 685 |
784 void ElementAnimations::IsAnimatingChanged(ElementListType list_type, | |
785 TargetProperty::Type property, | |
786 AnimationChangeType change_type, | |
787 bool is_animating) { | |
788 if (!element_id()) | |
789 return; | |
790 DCHECK(animation_host()); | |
791 if (animation_host()->mutator_host_client()) { | |
792 switch (property) { | |
793 case TargetProperty::OPACITY: | |
794 animation_host() | |
795 ->mutator_host_client() | |
796 ->ElementOpacityIsAnimatingChanged(element_id(), list_type, | |
797 change_type, is_animating); | |
798 break; | |
799 case TargetProperty::TRANSFORM: | |
800 animation_host() | |
801 ->mutator_host_client() | |
802 ->ElementTransformIsAnimatingChanged(element_id(), list_type, | |
803 change_type, is_animating); | |
804 break; | |
805 case TargetProperty::FILTER: | |
806 animation_host() | |
807 ->mutator_host_client() | |
808 ->ElementFilterIsAnimatingChanged(element_id(), list_type, | |
809 change_type, is_animating); | |
810 break; | |
811 default: | |
812 NOTREACHED(); | |
813 break; | |
814 } | |
815 } | |
816 } | |
817 | |
818 gfx::ScrollOffset ElementAnimations::ScrollOffsetForAnimation() const { | 686 gfx::ScrollOffset ElementAnimations::ScrollOffsetForAnimation() const { |
819 if (animation_host()) { | 687 if (animation_host()) { |
820 DCHECK(animation_host()->mutator_host_client()); | 688 DCHECK(animation_host()->mutator_host_client()); |
821 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( | 689 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( |
822 element_id()); | 690 element_id()); |
823 } | 691 } |
824 | 692 |
825 return gfx::ScrollOffset(); | 693 return gfx::ScrollOffset(); |
826 } | 694 } |
827 | 695 |
828 } // namespace cc | 696 } // namespace cc |
OLD | NEW |