| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/animation/AnimationTimeline.h" | 32 #include "core/animation/AnimationTimeline.h" |
| 33 | 33 |
| 34 #include "core/animation/AnimationClock.h" | 34 #include "core/animation/AnimationClock.h" |
| 35 #include "core/animation/ElementAnimations.h" | 35 #include "core/animation/ElementAnimations.h" |
| 36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
| 37 #include "core/frame/FrameView.h" | 37 #include "core/frame/FrameView.h" |
| 38 #include "core/loader/DocumentLoader.h" | 38 #include "core/loader/DocumentLoader.h" |
| 39 #include "core/page/Page.h" | 39 #include "core/page/Page.h" |
| 40 #include "platform/RuntimeEnabledFeatures.h" |
| 40 #include "platform/TraceEvent.h" | 41 #include "platform/TraceEvent.h" |
| 42 #include "public/platform/Platform.h" |
| 43 #include "public/platform/WebCompositorAnimationTimeline.h" |
| 44 #include "public/platform/WebCompositorSupport.h" |
| 41 | 45 |
| 42 namespace blink { | 46 namespace blink { |
| 43 | 47 |
| 44 namespace { | 48 namespace { |
| 45 | 49 |
| 46 bool compareAnimationPlayers(const RefPtrWillBeMember<blink::AnimationPlayer>& l
eft, const RefPtrWillBeMember<blink::AnimationPlayer>& right) | 50 bool compareAnimationPlayers(const RefPtrWillBeMember<blink::AnimationPlayer>& l
eft, const RefPtrWillBeMember<blink::AnimationPlayer>& right) |
| 47 { | 51 { |
| 48 return AnimationPlayer::hasLowerPriority(left.get(), right.get()); | 52 return AnimationPlayer::hasLowerPriority(left.get(), right.get()); |
| 49 } | 53 } |
| 50 | 54 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 65 , m_zeroTime(0) // 0 is used by unit tests which cannot initialize from the
loader | 69 , m_zeroTime(0) // 0 is used by unit tests which cannot initialize from the
loader |
| 66 , m_zeroTimeInitialized(false) | 70 , m_zeroTimeInitialized(false) |
| 67 , m_playbackRate(1) | 71 , m_playbackRate(1) |
| 68 , m_lastCurrentTimeInternal(0) | 72 , m_lastCurrentTimeInternal(0) |
| 69 { | 73 { |
| 70 if (!timing) | 74 if (!timing) |
| 71 m_timing = adoptPtrWillBeNoop(new AnimationTimelineTiming(this)); | 75 m_timing = adoptPtrWillBeNoop(new AnimationTimelineTiming(this)); |
| 72 else | 76 else |
| 73 m_timing = timing; | 77 m_timing = timing; |
| 74 | 78 |
| 79 if (Platform::current()->compositorSupport() && RuntimeEnabledFeatures::comp
ositorAnimationTimelinesEnabled()) |
| 80 m_compositorTimeline = adoptPtr(Platform::current()->compositorSupport()
->createAnimationTimeline()); |
| 81 |
| 75 ASSERT(document); | 82 ASSERT(document); |
| 76 } | 83 } |
| 77 | 84 |
| 78 AnimationTimeline::~AnimationTimeline() | 85 AnimationTimeline::~AnimationTimeline() |
| 79 { | 86 { |
| 80 #if !ENABLE(OILPAN) | 87 #if !ENABLE(OILPAN) |
| 81 for (const auto& player : m_players) | 88 for (const auto& player : m_players) |
| 82 player->timelineDestroyed(); | 89 player->timelineDestroyed(); |
| 83 #endif | 90 #endif |
| 84 } | 91 } |
| 85 | 92 |
| 86 void AnimationTimeline::playerAttached(AnimationPlayer& player) | 93 void AnimationTimeline::playerAttached(AnimationPlayer& player) |
| 87 { | 94 { |
| 88 ASSERT(player.timeline() == this); | 95 ASSERT(player.timeline() == this); |
| 89 ASSERT(!m_players.contains(&player)); | 96 ASSERT(!m_players.contains(&player)); |
| 90 m_players.add(&player); | 97 m_players.add(&player); |
| 98 |
| 99 if (m_compositorTimeline) |
| 100 m_compositorTimeline->playerAttached(player); |
| 91 } | 101 } |
| 92 | 102 |
| 93 AnimationPlayer* AnimationTimeline::play(AnimationNode* child) | 103 AnimationPlayer* AnimationTimeline::play(AnimationNode* child) |
| 94 { | 104 { |
| 95 if (!m_document) | 105 if (!m_document) |
| 96 return nullptr; | 106 return nullptr; |
| 97 | 107 |
| 98 RefPtrWillBeRawPtr<AnimationPlayer> player = AnimationPlayer::create(child,
this); | 108 RefPtrWillBeRawPtr<AnimationPlayer> player = AnimationPlayer::create(child,
this); |
| 99 ASSERT(m_players.contains(player.get())); | 109 ASSERT(m_players.contains(player.get())); |
| 100 | 110 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 timeToNextEffect = std::min(timeToNextEffect, player->timeToEffectChange
()); | 162 timeToNextEffect = std::min(timeToNextEffect, player->timeToEffectChange
()); |
| 153 } | 163 } |
| 154 | 164 |
| 155 if (timeToNextEffect < s_minimumDelay) { | 165 if (timeToNextEffect < s_minimumDelay) { |
| 156 m_timing->serviceOnNextFrame(); | 166 m_timing->serviceOnNextFrame(); |
| 157 } else if (timeToNextEffect != std::numeric_limits<double>::infinity()) { | 167 } else if (timeToNextEffect != std::numeric_limits<double>::infinity()) { |
| 158 m_timing->wakeAfter(timeToNextEffect - s_minimumDelay); | 168 m_timing->wakeAfter(timeToNextEffect - s_minimumDelay); |
| 159 } | 169 } |
| 160 } | 170 } |
| 161 | 171 |
| 172 void AnimationTimeline::updateCompositorPlayerToElementAttachments() |
| 173 { |
| 174 for (AnimationPlayer* player : m_players) |
| 175 player->updateCompositorPlayerToElementAttachment(); |
| 176 } |
| 177 |
| 162 void AnimationTimeline::AnimationTimelineTiming::wakeAfter(double duration) | 178 void AnimationTimeline::AnimationTimelineTiming::wakeAfter(double duration) |
| 163 { | 179 { |
| 164 m_timer.startOneShot(duration, FROM_HERE); | 180 m_timer.startOneShot(duration, FROM_HERE); |
| 165 } | 181 } |
| 166 | 182 |
| 167 void AnimationTimeline::AnimationTimelineTiming::cancelWake() | 183 void AnimationTimeline::AnimationTimelineTiming::cancelWake() |
| 168 { | 184 { |
| 169 m_timer.stop(); | 185 m_timer.stop(); |
| 170 } | 186 } |
| 171 | 187 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 { | 328 { |
| 313 #if ENABLE(OILPAN) | 329 #if ENABLE(OILPAN) |
| 314 visitor->trace(m_document); | 330 visitor->trace(m_document); |
| 315 visitor->trace(m_timing); | 331 visitor->trace(m_timing); |
| 316 visitor->trace(m_playersNeedingUpdate); | 332 visitor->trace(m_playersNeedingUpdate); |
| 317 visitor->trace(m_players); | 333 visitor->trace(m_players); |
| 318 #endif | 334 #endif |
| 319 } | 335 } |
| 320 | 336 |
| 321 } // namespace | 337 } // namespace |
| OLD | NEW |