| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 m_timeline(&timeline), | 92 m_timeline(&timeline), |
| 93 m_paused(false), | 93 m_paused(false), |
| 94 m_held(false), | 94 m_held(false), |
| 95 m_isPausedForTesting(false), | 95 m_isPausedForTesting(false), |
| 96 m_isCompositedAnimationDisabledForTesting(false), | 96 m_isCompositedAnimationDisabledForTesting(false), |
| 97 m_outdated(false), | 97 m_outdated(false), |
| 98 m_finished(true), | 98 m_finished(true), |
| 99 m_compositorState(nullptr), | 99 m_compositorState(nullptr), |
| 100 m_compositorPending(false), | 100 m_compositorPending(false), |
| 101 m_compositorGroup(0), | 101 m_compositorGroup(0), |
| 102 m_preFinalizerRegistered(false), | |
| 103 m_currentTimePending(false), | 102 m_currentTimePending(false), |
| 104 m_stateIsBeingUpdated(false), | 103 m_stateIsBeingUpdated(false), |
| 105 m_effectSuppressed(false) { | 104 m_effectSuppressed(false) { |
| 106 if (m_content) { | 105 if (m_content) { |
| 107 if (m_content->animation()) { | 106 if (m_content->animation()) { |
| 108 m_content->animation()->cancel(); | 107 m_content->animation()->cancel(); |
| 109 m_content->animation()->setEffect(0); | 108 m_content->animation()->setEffect(0); |
| 110 } | 109 } |
| 111 m_content->attach(this); | 110 m_content->attach(this); |
| 112 } | 111 } |
| 113 InspectorInstrumentation::didCreateAnimation(m_timeline->document(), | 112 InspectorInstrumentation::didCreateAnimation(m_timeline->document(), |
| 114 m_sequenceNumber); | 113 m_sequenceNumber); |
| 115 } | 114 } |
| 116 | 115 |
| 117 Animation::~Animation() { | 116 Animation::~Animation() { |
| 118 destroyCompositorPlayer(); | 117 // Verify that m_compositorPlayer has been disposed of. |
| 118 DCHECK(!m_compositorPlayer); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void Animation::dispose() { | 121 void Animation::dispose() { |
| 122 destroyCompositorPlayer(); | 122 destroyCompositorPlayer(); |
| 123 // If the AnimationTimeline and its Animation objects are | 123 // If the AnimationTimeline and its Animation objects are |
| 124 // finalized by the same GC, we have to eagerly clear out | 124 // finalized by the same GC, we have to eagerly clear out |
| 125 // this Animation object's compositor player registration. | 125 // this Animation object's compositor player registration. |
| 126 DCHECK(!m_compositorPlayer); | 126 DCHECK(!m_compositorPlayer); |
| 127 } | 127 } |
| 128 | 128 |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 } | 903 } |
| 904 | 904 |
| 905 void Animation::endUpdatingState() { | 905 void Animation::endUpdatingState() { |
| 906 DCHECK(m_stateIsBeingUpdated); | 906 DCHECK(m_stateIsBeingUpdated); |
| 907 m_stateIsBeingUpdated = false; | 907 m_stateIsBeingUpdated = false; |
| 908 } | 908 } |
| 909 | 909 |
| 910 void Animation::createCompositorPlayer() { | 910 void Animation::createCompositorPlayer() { |
| 911 if (Platform::current()->isThreadedAnimationEnabled() && | 911 if (Platform::current()->isThreadedAnimationEnabled() && |
| 912 !m_compositorPlayer) { | 912 !m_compositorPlayer) { |
| 913 // We only need to pre-finalize if we are running animations on the | |
| 914 // compositor. | |
| 915 if (!m_preFinalizerRegistered) { | |
| 916 ThreadState::current()->registerPreFinalizer(this); | |
| 917 m_preFinalizerRegistered = true; | |
| 918 } | |
| 919 | |
| 920 DCHECK(Platform::current()->compositorSupport()); | 913 DCHECK(Platform::current()->compositorSupport()); |
| 921 m_compositorPlayer = CompositorAnimationPlayer::create(); | 914 m_compositorPlayer = CompositorAnimationPlayerHolder::create(this); |
| 922 DCHECK(m_compositorPlayer); | 915 DCHECK(m_compositorPlayer); |
| 923 m_compositorPlayer->setAnimationDelegate(this); | |
| 924 attachCompositorTimeline(); | 916 attachCompositorTimeline(); |
| 925 } | 917 } |
| 926 | 918 |
| 927 attachCompositedLayers(); | 919 attachCompositedLayers(); |
| 928 } | 920 } |
| 929 | 921 |
| 930 void Animation::destroyCompositorPlayer() { | 922 void Animation::destroyCompositorPlayer() { |
| 931 detachCompositedLayers(); | 923 detachCompositedLayers(); |
| 932 | 924 |
| 933 if (m_compositorPlayer) { | 925 if (m_compositorPlayer) { |
| 934 detachCompositorTimeline(); | 926 detachCompositorTimeline(); |
| 935 m_compositorPlayer->setAnimationDelegate(nullptr); | 927 m_compositorPlayer->detach(); |
| 936 m_compositorPlayer.reset(); | 928 m_compositorPlayer = nullptr; |
| 937 } | 929 } |
| 938 } | 930 } |
| 939 | 931 |
| 940 void Animation::attachCompositorTimeline() { | 932 void Animation::attachCompositorTimeline() { |
| 941 if (m_compositorPlayer) { | 933 if (m_compositorPlayer) { |
| 942 CompositorAnimationTimeline* timeline = | 934 CompositorAnimationTimeline* timeline = |
| 943 m_timeline ? m_timeline->compositorTimeline() : nullptr; | 935 m_timeline ? m_timeline->compositorTimeline() : nullptr; |
| 944 if (timeline) | 936 if (timeline) |
| 945 timeline->playerAttached(*this); | 937 timeline->playerAttached(*this); |
| 946 } | 938 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 959 if (!m_compositorPlayer) | 951 if (!m_compositorPlayer) |
| 960 return; | 952 return; |
| 961 | 953 |
| 962 DCHECK(m_content); | 954 DCHECK(m_content); |
| 963 DCHECK(m_content->isKeyframeEffectReadOnly()); | 955 DCHECK(m_content->isKeyframeEffectReadOnly()); |
| 964 | 956 |
| 965 toKeyframeEffectReadOnly(m_content.get())->attachCompositedLayers(); | 957 toKeyframeEffectReadOnly(m_content.get())->attachCompositedLayers(); |
| 966 } | 958 } |
| 967 | 959 |
| 968 void Animation::detachCompositedLayers() { | 960 void Animation::detachCompositedLayers() { |
| 969 if (m_compositorPlayer && m_compositorPlayer->isElementAttached()) | 961 if (m_compositorPlayer && m_compositorPlayer->player()->isElementAttached()) |
| 970 m_compositorPlayer->detachElement(); | 962 m_compositorPlayer->player()->detachElement(); |
| 971 } | 963 } |
| 972 | 964 |
| 973 void Animation::notifyAnimationStarted(double monotonicTime, int group) { | 965 void Animation::notifyAnimationStarted(double monotonicTime, int group) { |
| 974 timeline() | 966 timeline() |
| 975 ->document() | 967 ->document() |
| 976 ->compositorPendingAnimations() | 968 ->compositorPendingAnimations() |
| 977 .notifyCompositorAnimationStarted(monotonicTime, group); | 969 .notifyCompositorAnimationStarted(monotonicTime, group); |
| 978 } | 970 } |
| 979 | 971 |
| 980 Animation::PlayStateUpdateScope::PlayStateUpdateScope( | 972 Animation::PlayStateUpdateScope::PlayStateUpdateScope( |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 StyleChangeReason::StyleSheetChange)); | 1111 StyleChangeReason::StyleSheetChange)); |
| 1120 } | 1112 } |
| 1121 | 1113 |
| 1122 DEFINE_TRACE(Animation) { | 1114 DEFINE_TRACE(Animation) { |
| 1123 visitor->trace(m_content); | 1115 visitor->trace(m_content); |
| 1124 visitor->trace(m_timeline); | 1116 visitor->trace(m_timeline); |
| 1125 visitor->trace(m_pendingFinishedEvent); | 1117 visitor->trace(m_pendingFinishedEvent); |
| 1126 visitor->trace(m_pendingCancelledEvent); | 1118 visitor->trace(m_pendingCancelledEvent); |
| 1127 visitor->trace(m_finishedPromise); | 1119 visitor->trace(m_finishedPromise); |
| 1128 visitor->trace(m_readyPromise); | 1120 visitor->trace(m_readyPromise); |
| 1121 visitor->trace(m_compositorPlayer); |
| 1129 EventTargetWithInlineData::trace(visitor); | 1122 EventTargetWithInlineData::trace(visitor); |
| 1130 SuspendableObject::trace(visitor); | 1123 SuspendableObject::trace(visitor); |
| 1131 } | 1124 } |
| 1132 | 1125 |
| 1126 Animation::CompositorAnimationPlayerHolder* |
| 1127 Animation::CompositorAnimationPlayerHolder::create(Animation* animation) { |
| 1128 return new CompositorAnimationPlayerHolder(animation); |
| 1129 } |
| 1130 |
| 1131 Animation::CompositorAnimationPlayerHolder::CompositorAnimationPlayerHolder( |
| 1132 Animation* animation) |
| 1133 : m_animation(animation) { |
| 1134 ThreadState::current()->registerPreFinalizer(this); |
| 1135 m_compositorPlayer = CompositorAnimationPlayer::create(); |
| 1136 m_compositorPlayer->setAnimationDelegate(m_animation); |
| 1137 } |
| 1138 |
| 1139 void Animation::CompositorAnimationPlayerHolder::dispose() { |
| 1140 if (!m_animation) |
| 1141 return; |
| 1142 m_animation->dispose(); |
| 1143 DCHECK(!m_animation); |
| 1144 DCHECK(!m_compositorPlayer); |
| 1145 } |
| 1146 |
| 1147 void Animation::CompositorAnimationPlayerHolder::detach() { |
| 1148 DCHECK(m_compositorPlayer); |
| 1149 m_compositorPlayer->setAnimationDelegate(nullptr); |
| 1150 m_animation = nullptr; |
| 1151 m_compositorPlayer.reset(); |
| 1152 } |
| 1133 } // namespace blink | 1153 } // namespace blink |
| OLD | NEW |