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/animation_host.h" | 5 #include "cc/animation/animation_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 scroll_offset_animation_player_->DetachLayer(); | 132 scroll_offset_animation_player_->DetachLayer(); |
133 if (element_id) | 133 if (element_id) |
134 scroll_offset_animation_player_->AttachLayer(element_id); | 134 scroll_offset_animation_player_->AttachLayer(element_id); |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 AnimationHost* animation_host_; | 138 AnimationHost* animation_host_; |
139 scoped_refptr<AnimationTimeline> scroll_offset_timeline_; | 139 scoped_refptr<AnimationTimeline> scroll_offset_timeline_; |
140 | 140 |
141 // We have just one player for impl-only scroll offset animations. | 141 // We have just one player for impl-only scroll offset animations. |
142 // I.e. only one layer can have an impl-only scroll offset animation at | 142 // I.e. only one element can have an impl-only scroll offset animation at |
143 // any given time. | 143 // any given time. |
144 scoped_refptr<AnimationPlayer> scroll_offset_animation_player_; | 144 scoped_refptr<AnimationPlayer> scroll_offset_animation_player_; |
145 | 145 |
146 DISALLOW_COPY_AND_ASSIGN(ScrollOffsetAnimations); | 146 DISALLOW_COPY_AND_ASSIGN(ScrollOffsetAnimations); |
147 }; | 147 }; |
148 | 148 |
149 std::unique_ptr<AnimationHost> AnimationHost::Create( | 149 std::unique_ptr<AnimationHost> AnimationHost::Create( |
150 ThreadInstance thread_instance) { | 150 ThreadInstance thread_instance) { |
151 return base::WrapUnique(new AnimationHost(thread_instance)); | 151 return base::WrapUnique(new AnimationHost(thread_instance)); |
152 } | 152 } |
153 | 153 |
154 AnimationHost::AnimationHost(ThreadInstance thread_instance) | 154 AnimationHost::AnimationHost(ThreadInstance thread_instance) |
155 : mutator_host_client_(nullptr), | 155 : mutator_host_client_(nullptr), |
156 thread_instance_(thread_instance), | 156 thread_instance_(thread_instance), |
157 supports_scroll_animations_(false), | 157 supports_scroll_animations_(false), |
158 animation_waiting_for_deletion_(false) { | 158 animation_waiting_for_deletion_(false) { |
159 if (thread_instance_ == ThreadInstance::IMPL) | 159 if (thread_instance_ == ThreadInstance::IMPL) |
160 scroll_offset_animations_ = | 160 scroll_offset_animations_ = |
161 base::WrapUnique(new ScrollOffsetAnimations(this)); | 161 base::WrapUnique(new ScrollOffsetAnimations(this)); |
162 } | 162 } |
163 | 163 |
164 AnimationHost::~AnimationHost() { | 164 AnimationHost::~AnimationHost() { |
165 scroll_offset_animations_ = nullptr; | 165 scroll_offset_animations_ = nullptr; |
166 | 166 |
167 ClearTimelines(); | 167 ClearTimelines(); |
168 DCHECK(!mutator_host_client()); | 168 DCHECK(!mutator_host_client()); |
169 DCHECK(layer_to_element_animations_map_.empty()); | 169 DCHECK(element_to_animations_map_.empty()); |
170 } | 170 } |
171 | 171 |
172 AnimationTimeline* AnimationHost::GetTimelineById(int timeline_id) const { | 172 AnimationTimeline* AnimationHost::GetTimelineById(int timeline_id) const { |
173 auto f = id_to_timeline_map_.find(timeline_id); | 173 auto f = id_to_timeline_map_.find(timeline_id); |
174 return f == id_to_timeline_map_.end() ? nullptr : f->second.get(); | 174 return f == id_to_timeline_map_.end() ? nullptr : f->second.get(); |
175 } | 175 } |
176 | 176 |
177 void AnimationHost::ClearTimelines() { | 177 void AnimationHost::ClearTimelines() { |
178 for (auto& kv : id_to_timeline_map_) | 178 for (auto& kv : id_to_timeline_map_) |
179 EraseTimeline(kv.second); | 179 EraseTimeline(kv.second); |
(...skipping 13 matching lines...) Expand all Loading... |
193 std::make_pair(timeline->id(), std::move(timeline))); | 193 std::make_pair(timeline->id(), std::move(timeline))); |
194 } | 194 } |
195 | 195 |
196 void AnimationHost::RemoveAnimationTimeline( | 196 void AnimationHost::RemoveAnimationTimeline( |
197 scoped_refptr<AnimationTimeline> timeline) { | 197 scoped_refptr<AnimationTimeline> timeline) { |
198 DCHECK(timeline->id()); | 198 DCHECK(timeline->id()); |
199 EraseTimeline(timeline); | 199 EraseTimeline(timeline); |
200 id_to_timeline_map_.erase(timeline->id()); | 200 id_to_timeline_map_.erase(timeline->id()); |
201 } | 201 } |
202 | 202 |
203 void AnimationHost::RegisterLayer(ElementId element_id, | 203 void AnimationHost::RegisterElement(ElementId element_id, |
204 LayerTreeType tree_type) { | 204 ElementListType list_type) { |
205 scoped_refptr<ElementAnimations> element_animations = | 205 scoped_refptr<ElementAnimations> element_animations = |
206 GetElementAnimationsForLayerId(element_id); | 206 GetElementAnimationsForElementId(element_id); |
207 if (element_animations) | 207 if (element_animations) |
208 element_animations->LayerRegistered(element_id, tree_type); | 208 element_animations->ElementRegistered(element_id, list_type); |
209 } | 209 } |
210 | 210 |
211 void AnimationHost::UnregisterLayer(ElementId element_id, | 211 void AnimationHost::UnregisterElement(ElementId element_id, |
212 LayerTreeType tree_type) { | 212 ElementListType list_type) { |
213 scoped_refptr<ElementAnimations> element_animations = | 213 scoped_refptr<ElementAnimations> element_animations = |
214 GetElementAnimationsForLayerId(element_id); | 214 GetElementAnimationsForElementId(element_id); |
215 if (element_animations) | 215 if (element_animations) |
216 element_animations->LayerUnregistered(element_id, tree_type); | 216 element_animations->ElementUnregistered(element_id, list_type); |
217 } | 217 } |
218 | 218 |
219 void AnimationHost::RegisterPlayerForLayer(ElementId element_id, | 219 void AnimationHost::RegisterPlayerForElement(ElementId element_id, |
220 AnimationPlayer* player) { | 220 AnimationPlayer* player) { |
221 DCHECK(element_id); | 221 DCHECK(element_id); |
222 DCHECK(player); | 222 DCHECK(player); |
223 | 223 |
224 scoped_refptr<ElementAnimations> element_animations = | 224 scoped_refptr<ElementAnimations> element_animations = |
225 GetElementAnimationsForLayerId(element_id); | 225 GetElementAnimationsForElementId(element_id); |
226 if (!element_animations) { | 226 if (!element_animations) { |
227 element_animations = ElementAnimations::Create(); | 227 element_animations = ElementAnimations::Create(); |
228 element_animations->SetElementId(element_id); | 228 element_animations->SetElementId(element_id); |
229 RegisterElementAnimations(element_animations.get()); | 229 RegisterElementAnimations(element_animations.get()); |
230 } | 230 } |
231 | 231 |
232 if (element_animations->animation_host() != this) { | 232 if (element_animations->animation_host() != this) { |
233 element_animations->SetAnimationHost(this); | 233 element_animations->SetAnimationHost(this); |
234 element_animations->InitAffectedElementTypes(); | 234 element_animations->InitAffectedElementTypes(); |
235 } | 235 } |
236 | 236 |
237 element_animations->AddPlayer(player); | 237 element_animations->AddPlayer(player); |
238 } | 238 } |
239 | 239 |
240 void AnimationHost::UnregisterPlayerForLayer(ElementId element_id, | 240 void AnimationHost::UnregisterPlayerForElement(ElementId element_id, |
241 AnimationPlayer* player) { | 241 AnimationPlayer* player) { |
242 DCHECK(element_id); | 242 DCHECK(element_id); |
243 DCHECK(player); | 243 DCHECK(player); |
244 | 244 |
245 scoped_refptr<ElementAnimations> element_animations = | 245 scoped_refptr<ElementAnimations> element_animations = |
246 GetElementAnimationsForLayerId(element_id); | 246 GetElementAnimationsForElementId(element_id); |
247 DCHECK(element_animations); | 247 DCHECK(element_animations); |
248 element_animations->RemovePlayer(player); | 248 element_animations->RemovePlayer(player); |
249 | 249 |
250 if (element_animations->IsEmpty()) { | 250 if (element_animations->IsEmpty()) { |
251 element_animations->ClearAffectedElementTypes(); | 251 element_animations->ClearAffectedElementTypes(); |
252 UnregisterElementAnimations(element_animations.get()); | 252 UnregisterElementAnimations(element_animations.get()); |
253 element_animations->SetAnimationHost(nullptr); | 253 element_animations->SetAnimationHost(nullptr); |
254 } | 254 } |
255 } | 255 } |
256 | 256 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 // Firstly, sync all players with impl thread to create ElementAnimations. | 311 // Firstly, sync all players with impl thread to create ElementAnimations. |
312 for (auto& kv : id_to_timeline_map_) { | 312 for (auto& kv : id_to_timeline_map_) { |
313 AnimationTimeline* timeline = kv.second.get(); | 313 AnimationTimeline* timeline = kv.second.get(); |
314 AnimationTimeline* timeline_impl = | 314 AnimationTimeline* timeline_impl = |
315 host_impl->GetTimelineById(timeline->id()); | 315 host_impl->GetTimelineById(timeline->id()); |
316 if (timeline_impl) | 316 if (timeline_impl) |
317 timeline->PushPropertiesTo(timeline_impl); | 317 timeline->PushPropertiesTo(timeline_impl); |
318 } | 318 } |
319 | 319 |
320 // Secondly, sync properties for created ElementAnimations. | 320 // Secondly, sync properties for created ElementAnimations. |
321 for (auto& kv : layer_to_element_animations_map_) { | 321 for (auto& kv : element_to_animations_map_) { |
322 const auto& element_animations = kv.second; | 322 const auto& element_animations = kv.second; |
323 auto element_animations_impl = | 323 auto element_animations_impl = |
324 host_impl->GetElementAnimationsForLayerId(kv.first); | 324 host_impl->GetElementAnimationsForElementId(kv.first); |
325 if (element_animations_impl) | 325 if (element_animations_impl) |
326 element_animations->PushPropertiesTo(std::move(element_animations_impl)); | 326 element_animations->PushPropertiesTo(std::move(element_animations_impl)); |
327 } | 327 } |
328 } | 328 } |
329 | 329 |
330 scoped_refptr<ElementAnimations> AnimationHost::GetElementAnimationsForLayerId( | 330 scoped_refptr<ElementAnimations> |
331 ElementId element_id) const { | 331 AnimationHost::GetElementAnimationsForElementId(ElementId element_id) const { |
332 DCHECK(element_id); | 332 DCHECK(element_id); |
333 auto iter = layer_to_element_animations_map_.find(element_id); | 333 auto iter = element_to_animations_map_.find(element_id); |
334 return iter == layer_to_element_animations_map_.end() ? nullptr | 334 return iter == element_to_animations_map_.end() ? nullptr : iter->second; |
335 : iter->second; | |
336 } | 335 } |
337 | 336 |
338 void AnimationHost::SetSupportsScrollAnimations( | 337 void AnimationHost::SetSupportsScrollAnimations( |
339 bool supports_scroll_animations) { | 338 bool supports_scroll_animations) { |
340 supports_scroll_animations_ = supports_scroll_animations; | 339 supports_scroll_animations_ = supports_scroll_animations; |
341 } | 340 } |
342 | 341 |
343 bool AnimationHost::SupportsScrollAnimations() const { | 342 bool AnimationHost::SupportsScrollAnimations() const { |
344 return supports_scroll_animations_; | 343 return supports_scroll_animations_; |
345 } | 344 } |
346 | 345 |
347 bool AnimationHost::NeedsAnimateLayers() const { | 346 bool AnimationHost::NeedsAnimateLayers() const { |
348 return !active_element_animations_map_.empty(); | 347 return !active_element_to_animations_map_.empty(); |
349 } | 348 } |
350 | 349 |
351 bool AnimationHost::ActivateAnimations() { | 350 bool AnimationHost::ActivateAnimations() { |
352 if (!NeedsAnimateLayers()) | 351 if (!NeedsAnimateLayers()) |
353 return false; | 352 return false; |
354 | 353 |
355 TRACE_EVENT0("cc", "AnimationHost::ActivateAnimations"); | 354 TRACE_EVENT0("cc", "AnimationHost::ActivateAnimations"); |
356 LayerToElementAnimationsMap active_element_animations_map_copy = | 355 ElementToAnimationsMap active_element_animations_map_copy = |
357 active_element_animations_map_; | 356 active_element_to_animations_map_; |
358 for (auto& it : active_element_animations_map_copy) | 357 for (auto& it : active_element_animations_map_copy) |
359 it.second->ActivateAnimations(); | 358 it.second->ActivateAnimations(); |
360 | 359 |
361 return true; | 360 return true; |
362 } | 361 } |
363 | 362 |
364 bool AnimationHost::AnimateLayers(base::TimeTicks monotonic_time) { | 363 bool AnimationHost::AnimateLayers(base::TimeTicks monotonic_time) { |
365 if (!NeedsAnimateLayers()) | 364 if (!NeedsAnimateLayers()) |
366 return false; | 365 return false; |
367 | 366 |
368 TRACE_EVENT0("cc", "AnimationHost::AnimateLayers"); | 367 TRACE_EVENT0("cc", "AnimationHost::AnimateLayers"); |
369 LayerToElementAnimationsMap active_element_animations_map_copy = | 368 ElementToAnimationsMap active_element_animations_map_copy = |
370 active_element_animations_map_; | 369 active_element_to_animations_map_; |
371 for (auto& it : active_element_animations_map_copy) | 370 for (auto& it : active_element_animations_map_copy) |
372 it.second->Animate(monotonic_time); | 371 it.second->Animate(monotonic_time); |
373 | 372 |
374 return true; | 373 return true; |
375 } | 374 } |
376 | 375 |
377 bool AnimationHost::UpdateAnimationState(bool start_ready_animations, | 376 bool AnimationHost::UpdateAnimationState(bool start_ready_animations, |
378 AnimationEvents* events) { | 377 AnimationEvents* events) { |
379 if (!NeedsAnimateLayers()) | 378 if (!NeedsAnimateLayers()) |
380 return false; | 379 return false; |
381 | 380 |
382 TRACE_EVENT0("cc", "AnimationHost::UpdateAnimationState"); | 381 TRACE_EVENT0("cc", "AnimationHost::UpdateAnimationState"); |
383 LayerToElementAnimationsMap active_element_animations_map_copy = | 382 ElementToAnimationsMap active_element_animations_map_copy = |
384 active_element_animations_map_; | 383 active_element_to_animations_map_; |
385 for (auto& it : active_element_animations_map_copy) | 384 for (auto& it : active_element_animations_map_copy) |
386 it.second->UpdateState(start_ready_animations, events); | 385 it.second->UpdateState(start_ready_animations, events); |
387 | 386 |
388 return true; | 387 return true; |
389 } | 388 } |
390 | 389 |
391 std::unique_ptr<AnimationEvents> AnimationHost::CreateEvents() { | 390 std::unique_ptr<AnimationEvents> AnimationHost::CreateEvents() { |
392 return base::WrapUnique(new AnimationEvents()); | 391 return base::WrapUnique(new AnimationEvents()); |
393 } | 392 } |
394 | 393 |
395 void AnimationHost::SetAnimationEvents( | 394 void AnimationHost::SetAnimationEvents( |
396 std::unique_ptr<AnimationEvents> events) { | 395 std::unique_ptr<AnimationEvents> events) { |
397 for (size_t event_index = 0; event_index < events->events_.size(); | 396 for (size_t event_index = 0; event_index < events->events_.size(); |
398 ++event_index) { | 397 ++event_index) { |
399 int event_layer_id = events->events_[event_index].element_id; | 398 int event_layer_id = events->events_[event_index].element_id; |
400 | 399 |
401 // Use the map of all ElementAnimations, not just active ones, since | 400 // Use the map of all ElementAnimations, not just active ones, since |
402 // non-active ElementAnimations may still receive events for impl-only | 401 // non-active ElementAnimations may still receive events for impl-only |
403 // animations. | 402 // animations. |
404 const LayerToElementAnimationsMap& all_element_animations = | 403 const ElementToAnimationsMap& all_element_animations = |
405 layer_to_element_animations_map_; | 404 element_to_animations_map_; |
406 auto iter = all_element_animations.find(event_layer_id); | 405 auto iter = all_element_animations.find(event_layer_id); |
407 if (iter != all_element_animations.end()) { | 406 if (iter != all_element_animations.end()) { |
408 switch (events->events_[event_index].type) { | 407 switch (events->events_[event_index].type) { |
409 case AnimationEvent::STARTED: | 408 case AnimationEvent::STARTED: |
410 (*iter).second->NotifyAnimationStarted(events->events_[event_index]); | 409 (*iter).second->NotifyAnimationStarted(events->events_[event_index]); |
411 break; | 410 break; |
412 | 411 |
413 case AnimationEvent::FINISHED: | 412 case AnimationEvent::FINISHED: |
414 (*iter).second->NotifyAnimationFinished(events->events_[event_index]); | 413 (*iter).second->NotifyAnimationFinished(events->events_[event_index]); |
415 break; | 414 break; |
(...skipping 10 matching lines...) Expand all Loading... |
426 case AnimationEvent::TAKEOVER: | 425 case AnimationEvent::TAKEOVER: |
427 (*iter).second->NotifyAnimationTakeover(events->events_[event_index]); | 426 (*iter).second->NotifyAnimationTakeover(events->events_[event_index]); |
428 break; | 427 break; |
429 } | 428 } |
430 } | 429 } |
431 } | 430 } |
432 } | 431 } |
433 | 432 |
434 bool AnimationHost::ScrollOffsetAnimationWasInterrupted( | 433 bool AnimationHost::ScrollOffsetAnimationWasInterrupted( |
435 ElementId element_id) const { | 434 ElementId element_id) const { |
436 auto element_animations = GetElementAnimationsForLayerId(element_id); | 435 auto element_animations = GetElementAnimationsForElementId(element_id); |
437 return element_animations | 436 return element_animations |
438 ? element_animations->scroll_offset_animation_was_interrupted() | 437 ? element_animations->scroll_offset_animation_was_interrupted() |
439 : false; | 438 : false; |
440 } | 439 } |
441 | 440 |
442 bool AnimationHost::IsAnimatingFilterProperty(ElementId element_id, | 441 bool AnimationHost::IsAnimatingFilterProperty(ElementId element_id, |
443 LayerTreeType tree_type) const { | 442 ElementListType list_type) const { |
444 auto element_animations = GetElementAnimationsForLayerId(element_id); | 443 auto element_animations = GetElementAnimationsForElementId(element_id); |
445 return element_animations | 444 return element_animations |
446 ? element_animations->IsCurrentlyAnimatingProperty( | 445 ? element_animations->IsCurrentlyAnimatingProperty( |
447 TargetProperty::FILTER, tree_type) | 446 TargetProperty::FILTER, list_type) |
448 : false; | 447 : false; |
449 } | 448 } |
450 | 449 |
451 bool AnimationHost::IsAnimatingOpacityProperty(ElementId element_id, | 450 bool AnimationHost::IsAnimatingOpacityProperty( |
452 LayerTreeType tree_type) const { | 451 ElementId element_id, |
453 auto element_animations = GetElementAnimationsForLayerId(element_id); | 452 ElementListType list_type) const { |
| 453 auto element_animations = GetElementAnimationsForElementId(element_id); |
454 return element_animations | 454 return element_animations |
455 ? element_animations->IsCurrentlyAnimatingProperty( | 455 ? element_animations->IsCurrentlyAnimatingProperty( |
456 TargetProperty::OPACITY, tree_type) | 456 TargetProperty::OPACITY, list_type) |
457 : false; | 457 : false; |
458 } | 458 } |
459 | 459 |
460 bool AnimationHost::IsAnimatingTransformProperty( | 460 bool AnimationHost::IsAnimatingTransformProperty( |
461 ElementId element_id, | 461 ElementId element_id, |
462 LayerTreeType tree_type) const { | 462 ElementListType list_type) const { |
463 auto element_animations = GetElementAnimationsForLayerId(element_id); | 463 auto element_animations = GetElementAnimationsForElementId(element_id); |
464 return element_animations | 464 return element_animations |
465 ? element_animations->IsCurrentlyAnimatingProperty( | 465 ? element_animations->IsCurrentlyAnimatingProperty( |
466 TargetProperty::TRANSFORM, tree_type) | 466 TargetProperty::TRANSFORM, list_type) |
467 : false; | 467 : false; |
468 } | 468 } |
469 | 469 |
470 bool AnimationHost::HasPotentiallyRunningFilterAnimation( | 470 bool AnimationHost::HasPotentiallyRunningFilterAnimation( |
471 ElementId element_id, | 471 ElementId element_id, |
472 LayerTreeType tree_type) const { | 472 ElementListType list_type) const { |
473 auto element_animations = GetElementAnimationsForLayerId(element_id); | 473 auto element_animations = GetElementAnimationsForElementId(element_id); |
474 return element_animations | 474 return element_animations |
475 ? element_animations->IsPotentiallyAnimatingProperty( | 475 ? element_animations->IsPotentiallyAnimatingProperty( |
476 TargetProperty::FILTER, tree_type) | 476 TargetProperty::FILTER, list_type) |
477 : false; | 477 : false; |
478 } | 478 } |
479 | 479 |
480 bool AnimationHost::HasPotentiallyRunningOpacityAnimation( | 480 bool AnimationHost::HasPotentiallyRunningOpacityAnimation( |
481 ElementId element_id, | 481 ElementId element_id, |
482 LayerTreeType tree_type) const { | 482 ElementListType list_type) const { |
483 auto element_animations = GetElementAnimationsForLayerId(element_id); | 483 auto element_animations = GetElementAnimationsForElementId(element_id); |
484 return element_animations | 484 return element_animations |
485 ? element_animations->IsPotentiallyAnimatingProperty( | 485 ? element_animations->IsPotentiallyAnimatingProperty( |
486 TargetProperty::OPACITY, tree_type) | 486 TargetProperty::OPACITY, list_type) |
487 : false; | 487 : false; |
488 } | 488 } |
489 | 489 |
490 bool AnimationHost::HasPotentiallyRunningTransformAnimation( | 490 bool AnimationHost::HasPotentiallyRunningTransformAnimation( |
491 ElementId element_id, | 491 ElementId element_id, |
492 LayerTreeType tree_type) const { | 492 ElementListType list_type) const { |
493 auto element_animations = GetElementAnimationsForLayerId(element_id); | 493 auto element_animations = GetElementAnimationsForElementId(element_id); |
494 return element_animations | 494 return element_animations |
495 ? element_animations->IsPotentiallyAnimatingProperty( | 495 ? element_animations->IsPotentiallyAnimatingProperty( |
496 TargetProperty::TRANSFORM, tree_type) | 496 TargetProperty::TRANSFORM, list_type) |
497 : false; | 497 : false; |
498 } | 498 } |
499 | 499 |
500 bool AnimationHost::HasAnyAnimationTargetingProperty( | 500 bool AnimationHost::HasAnyAnimationTargetingProperty( |
501 ElementId element_id, | 501 ElementId element_id, |
502 TargetProperty::Type property) const { | 502 TargetProperty::Type property) const { |
503 auto element_animations = GetElementAnimationsForLayerId(element_id); | 503 auto element_animations = GetElementAnimationsForElementId(element_id); |
504 if (!element_animations) | 504 if (!element_animations) |
505 return false; | 505 return false; |
506 | 506 |
507 return !!element_animations->GetAnimation(property); | 507 return !!element_animations->GetAnimation(property); |
508 } | 508 } |
509 | 509 |
510 bool AnimationHost::FilterIsAnimatingOnImplOnly(ElementId element_id) const { | 510 bool AnimationHost::FilterIsAnimatingOnImplOnly(ElementId element_id) const { |
511 auto element_animations = GetElementAnimationsForLayerId(element_id); | 511 auto element_animations = GetElementAnimationsForElementId(element_id); |
512 if (!element_animations) | 512 if (!element_animations) |
513 return false; | 513 return false; |
514 | 514 |
515 Animation* animation = | 515 Animation* animation = |
516 element_animations->GetAnimation(TargetProperty::FILTER); | 516 element_animations->GetAnimation(TargetProperty::FILTER); |
517 return animation && animation->is_impl_only(); | 517 return animation && animation->is_impl_only(); |
518 } | 518 } |
519 | 519 |
520 bool AnimationHost::OpacityIsAnimatingOnImplOnly(ElementId element_id) const { | 520 bool AnimationHost::OpacityIsAnimatingOnImplOnly(ElementId element_id) const { |
521 auto element_animations = GetElementAnimationsForLayerId(element_id); | 521 auto element_animations = GetElementAnimationsForElementId(element_id); |
522 if (!element_animations) | 522 if (!element_animations) |
523 return false; | 523 return false; |
524 | 524 |
525 Animation* animation = | 525 Animation* animation = |
526 element_animations->GetAnimation(TargetProperty::OPACITY); | 526 element_animations->GetAnimation(TargetProperty::OPACITY); |
527 return animation && animation->is_impl_only(); | 527 return animation && animation->is_impl_only(); |
528 } | 528 } |
529 | 529 |
530 bool AnimationHost::ScrollOffsetIsAnimatingOnImplOnly( | 530 bool AnimationHost::ScrollOffsetIsAnimatingOnImplOnly( |
531 ElementId element_id) const { | 531 ElementId element_id) const { |
532 auto element_animations = GetElementAnimationsForLayerId(element_id); | 532 auto element_animations = GetElementAnimationsForElementId(element_id); |
533 if (!element_animations) | 533 if (!element_animations) |
534 return false; | 534 return false; |
535 | 535 |
536 Animation* animation = | 536 Animation* animation = |
537 element_animations->GetAnimation(TargetProperty::SCROLL_OFFSET); | 537 element_animations->GetAnimation(TargetProperty::SCROLL_OFFSET); |
538 return animation && animation->is_impl_only(); | 538 return animation && animation->is_impl_only(); |
539 } | 539 } |
540 | 540 |
541 bool AnimationHost::TransformIsAnimatingOnImplOnly(ElementId element_id) const { | 541 bool AnimationHost::TransformIsAnimatingOnImplOnly(ElementId element_id) const { |
542 auto element_animations = GetElementAnimationsForLayerId(element_id); | 542 auto element_animations = GetElementAnimationsForElementId(element_id); |
543 if (!element_animations) | 543 if (!element_animations) |
544 return false; | 544 return false; |
545 | 545 |
546 Animation* animation = | 546 Animation* animation = |
547 element_animations->GetAnimation(TargetProperty::TRANSFORM); | 547 element_animations->GetAnimation(TargetProperty::TRANSFORM); |
548 return animation && animation->is_impl_only(); | 548 return animation && animation->is_impl_only(); |
549 } | 549 } |
550 | 550 |
551 bool AnimationHost::HasFilterAnimationThatInflatesBounds( | 551 bool AnimationHost::HasFilterAnimationThatInflatesBounds( |
552 ElementId element_id) const { | 552 ElementId element_id) const { |
553 auto element_animations = GetElementAnimationsForLayerId(element_id); | 553 auto element_animations = GetElementAnimationsForElementId(element_id); |
554 return element_animations | 554 return element_animations |
555 ? element_animations->HasFilterAnimationThatInflatesBounds() | 555 ? element_animations->HasFilterAnimationThatInflatesBounds() |
556 : false; | 556 : false; |
557 } | 557 } |
558 | 558 |
559 bool AnimationHost::HasTransformAnimationThatInflatesBounds( | 559 bool AnimationHost::HasTransformAnimationThatInflatesBounds( |
560 ElementId element_id) const { | 560 ElementId element_id) const { |
561 auto element_animations = GetElementAnimationsForLayerId(element_id); | 561 auto element_animations = GetElementAnimationsForElementId(element_id); |
562 return element_animations | 562 return element_animations |
563 ? element_animations->HasTransformAnimationThatInflatesBounds() | 563 ? element_animations->HasTransformAnimationThatInflatesBounds() |
564 : false; | 564 : false; |
565 } | 565 } |
566 | 566 |
567 bool AnimationHost::HasAnimationThatInflatesBounds(ElementId element_id) const { | 567 bool AnimationHost::HasAnimationThatInflatesBounds(ElementId element_id) const { |
568 auto element_animations = GetElementAnimationsForLayerId(element_id); | 568 auto element_animations = GetElementAnimationsForElementId(element_id); |
569 return element_animations | 569 return element_animations |
570 ? element_animations->HasAnimationThatInflatesBounds() | 570 ? element_animations->HasAnimationThatInflatesBounds() |
571 : false; | 571 : false; |
572 } | 572 } |
573 | 573 |
574 bool AnimationHost::FilterAnimationBoundsForBox(ElementId element_id, | 574 bool AnimationHost::FilterAnimationBoundsForBox(ElementId element_id, |
575 const gfx::BoxF& box, | 575 const gfx::BoxF& box, |
576 gfx::BoxF* bounds) const { | 576 gfx::BoxF* bounds) const { |
577 auto element_animations = GetElementAnimationsForLayerId(element_id); | 577 auto element_animations = GetElementAnimationsForElementId(element_id); |
578 return element_animations | 578 return element_animations |
579 ? element_animations->FilterAnimationBoundsForBox(box, bounds) | 579 ? element_animations->FilterAnimationBoundsForBox(box, bounds) |
580 : false; | 580 : false; |
581 } | 581 } |
582 | 582 |
583 bool AnimationHost::TransformAnimationBoundsForBox(ElementId element_id, | 583 bool AnimationHost::TransformAnimationBoundsForBox(ElementId element_id, |
584 const gfx::BoxF& box, | 584 const gfx::BoxF& box, |
585 gfx::BoxF* bounds) const { | 585 gfx::BoxF* bounds) const { |
586 *bounds = gfx::BoxF(); | 586 *bounds = gfx::BoxF(); |
587 auto element_animations = GetElementAnimationsForLayerId(element_id); | 587 auto element_animations = GetElementAnimationsForElementId(element_id); |
588 return element_animations | 588 return element_animations |
589 ? element_animations->TransformAnimationBoundsForBox(box, bounds) | 589 ? element_animations->TransformAnimationBoundsForBox(box, bounds) |
590 : true; | 590 : true; |
591 } | 591 } |
592 | 592 |
593 bool AnimationHost::HasOnlyTranslationTransforms( | 593 bool AnimationHost::HasOnlyTranslationTransforms( |
594 ElementId element_id, | 594 ElementId element_id, |
595 LayerTreeType tree_type) const { | 595 ElementListType list_type) const { |
596 auto element_animations = GetElementAnimationsForLayerId(element_id); | 596 auto element_animations = GetElementAnimationsForElementId(element_id); |
597 return element_animations | 597 return element_animations |
598 ? element_animations->HasOnlyTranslationTransforms(tree_type) | 598 ? element_animations->HasOnlyTranslationTransforms(list_type) |
599 : true; | 599 : true; |
600 } | 600 } |
601 | 601 |
602 bool AnimationHost::AnimationsPreserveAxisAlignment( | 602 bool AnimationHost::AnimationsPreserveAxisAlignment( |
603 ElementId element_id) const { | 603 ElementId element_id) const { |
604 auto element_animations = GetElementAnimationsForLayerId(element_id); | 604 auto element_animations = GetElementAnimationsForElementId(element_id); |
605 return element_animations | 605 return element_animations |
606 ? element_animations->AnimationsPreserveAxisAlignment() | 606 ? element_animations->AnimationsPreserveAxisAlignment() |
607 : true; | 607 : true; |
608 } | 608 } |
609 | 609 |
610 bool AnimationHost::MaximumTargetScale(ElementId element_id, | 610 bool AnimationHost::MaximumTargetScale(ElementId element_id, |
611 LayerTreeType tree_type, | 611 ElementListType list_type, |
612 float* max_scale) const { | 612 float* max_scale) const { |
613 *max_scale = 0.f; | 613 *max_scale = 0.f; |
614 auto element_animations = GetElementAnimationsForLayerId(element_id); | 614 auto element_animations = GetElementAnimationsForElementId(element_id); |
615 return element_animations | 615 return element_animations |
616 ? element_animations->MaximumTargetScale(tree_type, max_scale) | 616 ? element_animations->MaximumTargetScale(list_type, max_scale) |
617 : true; | 617 : true; |
618 } | 618 } |
619 | 619 |
620 bool AnimationHost::AnimationStartScale(ElementId element_id, | 620 bool AnimationHost::AnimationStartScale(ElementId element_id, |
621 LayerTreeType tree_type, | 621 ElementListType list_type, |
622 float* start_scale) const { | 622 float* start_scale) const { |
623 *start_scale = 0.f; | 623 *start_scale = 0.f; |
624 auto element_animations = GetElementAnimationsForLayerId(element_id); | 624 auto element_animations = GetElementAnimationsForElementId(element_id); |
625 return element_animations | 625 return element_animations |
626 ? element_animations->AnimationStartScale(tree_type, start_scale) | 626 ? element_animations->AnimationStartScale(list_type, start_scale) |
627 : true; | 627 : true; |
628 } | 628 } |
629 | 629 |
630 bool AnimationHost::HasAnyAnimation(ElementId element_id) const { | 630 bool AnimationHost::HasAnyAnimation(ElementId element_id) const { |
631 auto element_animations = GetElementAnimationsForLayerId(element_id); | 631 auto element_animations = GetElementAnimationsForElementId(element_id); |
632 return element_animations ? element_animations->has_any_animation() : false; | 632 return element_animations ? element_animations->has_any_animation() : false; |
633 } | 633 } |
634 | 634 |
635 bool AnimationHost::HasActiveAnimationForTesting(ElementId element_id) const { | 635 bool AnimationHost::HasActiveAnimationForTesting(ElementId element_id) const { |
636 auto element_animations = GetElementAnimationsForLayerId(element_id); | 636 auto element_animations = GetElementAnimationsForElementId(element_id); |
637 return element_animations ? element_animations->HasActiveAnimation() : false; | 637 return element_animations ? element_animations->HasActiveAnimation() : false; |
638 } | 638 } |
639 | 639 |
640 void AnimationHost::ImplOnlyScrollAnimationCreate( | 640 void AnimationHost::ImplOnlyScrollAnimationCreate( |
641 ElementId element_id, | 641 ElementId element_id, |
642 const gfx::ScrollOffset& target_offset, | 642 const gfx::ScrollOffset& target_offset, |
643 const gfx::ScrollOffset& current_offset) { | 643 const gfx::ScrollOffset& current_offset) { |
644 DCHECK(scroll_offset_animations_); | 644 DCHECK(scroll_offset_animations_); |
645 scroll_offset_animations_->ScrollAnimationCreate(element_id, target_offset, | 645 scroll_offset_animations_->ScrollAnimationCreate(element_id, target_offset, |
646 current_offset); | 646 current_offset); |
(...skipping 10 matching lines...) Expand all Loading... |
657 } | 657 } |
658 | 658 |
659 void AnimationHost::ScrollAnimationAbort(bool needs_completion) { | 659 void AnimationHost::ScrollAnimationAbort(bool needs_completion) { |
660 DCHECK(scroll_offset_animations_); | 660 DCHECK(scroll_offset_animations_); |
661 return scroll_offset_animations_->ScrollAnimationAbort(needs_completion); | 661 return scroll_offset_animations_->ScrollAnimationAbort(needs_completion); |
662 } | 662 } |
663 | 663 |
664 void AnimationHost::DidActivateElementAnimations( | 664 void AnimationHost::DidActivateElementAnimations( |
665 ElementAnimations* element_animations) { | 665 ElementAnimations* element_animations) { |
666 DCHECK(element_animations->element_id()); | 666 DCHECK(element_animations->element_id()); |
667 active_element_animations_map_[element_animations->element_id()] = | 667 active_element_to_animations_map_[element_animations->element_id()] = |
668 element_animations; | 668 element_animations; |
669 } | 669 } |
670 | 670 |
671 void AnimationHost::DidDeactivateElementAnimations( | 671 void AnimationHost::DidDeactivateElementAnimations( |
672 ElementAnimations* element_animations) { | 672 ElementAnimations* element_animations) { |
673 DCHECK(element_animations->element_id()); | 673 DCHECK(element_animations->element_id()); |
674 active_element_animations_map_.erase(element_animations->element_id()); | 674 active_element_to_animations_map_.erase(element_animations->element_id()); |
675 } | 675 } |
676 | 676 |
677 void AnimationHost::RegisterElementAnimations( | 677 void AnimationHost::RegisterElementAnimations( |
678 ElementAnimations* element_animations) { | 678 ElementAnimations* element_animations) { |
679 DCHECK(element_animations->element_id()); | 679 DCHECK(element_animations->element_id()); |
680 layer_to_element_animations_map_[element_animations->element_id()] = | 680 element_to_animations_map_[element_animations->element_id()] = |
681 element_animations; | 681 element_animations; |
682 } | 682 } |
683 | 683 |
684 void AnimationHost::UnregisterElementAnimations( | 684 void AnimationHost::UnregisterElementAnimations( |
685 ElementAnimations* element_animations) { | 685 ElementAnimations* element_animations) { |
686 DCHECK(element_animations->element_id()); | 686 DCHECK(element_animations->element_id()); |
687 layer_to_element_animations_map_.erase(element_animations->element_id()); | 687 element_to_animations_map_.erase(element_animations->element_id()); |
688 DidDeactivateElementAnimations(element_animations); | 688 DidDeactivateElementAnimations(element_animations); |
689 } | 689 } |
690 | 690 |
691 const AnimationHost::LayerToElementAnimationsMap& | 691 const AnimationHost::ElementToAnimationsMap& |
692 AnimationHost::active_element_animations_for_testing() const { | 692 AnimationHost::active_element_animations_for_testing() const { |
693 return active_element_animations_map_; | 693 return active_element_to_animations_map_; |
694 } | 694 } |
695 | 695 |
696 const AnimationHost::LayerToElementAnimationsMap& | 696 const AnimationHost::ElementToAnimationsMap& |
697 AnimationHost::all_element_animations_for_testing() const { | 697 AnimationHost::all_element_animations_for_testing() const { |
698 return layer_to_element_animations_map_; | 698 return element_to_animations_map_; |
699 } | 699 } |
700 | 700 |
701 void AnimationHost::OnAnimationWaitingForDeletion() { | 701 void AnimationHost::OnAnimationWaitingForDeletion() { |
702 animation_waiting_for_deletion_ = true; | 702 animation_waiting_for_deletion_ = true; |
703 } | 703 } |
704 | 704 |
705 } // namespace cc | 705 } // namespace cc |
OLD | NEW |