| 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 24 matching lines...) Expand all Loading... |
| 35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
| 36 #include "core/frame/FrameView.h" | 36 #include "core/frame/FrameView.h" |
| 37 #include "core/page/Page.h" | 37 #include "core/page/Page.h" |
| 38 #include "platform/tracing/TraceEvent.h" | 38 #include "platform/tracing/TraceEvent.h" |
| 39 | 39 |
| 40 namespace blink { | 40 namespace blink { |
| 41 | 41 |
| 42 void CompositorPendingAnimations::add(Animation* animation) { | 42 void CompositorPendingAnimations::add(Animation* animation) { |
| 43 DCHECK(animation); | 43 DCHECK(animation); |
| 44 DCHECK_EQ(m_pending.find(animation), kNotFound); | 44 DCHECK_EQ(m_pending.find(animation), kNotFound); |
| 45 m_pending.append(animation); | 45 m_pending.push_back(animation); |
| 46 | 46 |
| 47 Document* document = animation->timeline()->document(); | 47 Document* document = animation->timeline()->document(); |
| 48 if (document->view()) | 48 if (document->view()) |
| 49 document->view()->scheduleAnimation(); | 49 document->view()->scheduleAnimation(); |
| 50 | 50 |
| 51 bool visible = document->page() && document->page()->isPageVisible(); | 51 bool visible = document->page() && document->page()->isPageVisible(); |
| 52 if (!visible && !m_timer.isActive()) { | 52 if (!visible && !m_timer.isActive()) { |
| 53 m_timer.startOneShot(0, BLINK_FROM_HERE); | 53 m_timer.startOneShot(0, BLINK_FROM_HERE); |
| 54 } | 54 } |
| 55 } | 55 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 75 // grouping. | 75 // grouping. |
| 76 if (animation->preCommit(animation->hasStartTime() ? 1 : compositorGroup, | 76 if (animation->preCommit(animation->hasStartTime() ? 1 : compositorGroup, |
| 77 startOnCompositor)) { | 77 startOnCompositor)) { |
| 78 if (animation->hasActiveAnimationsOnCompositor() && | 78 if (animation->hasActiveAnimationsOnCompositor() && |
| 79 !hadCompositorAnimation) { | 79 !hadCompositorAnimation) { |
| 80 startedSynchronizedOnCompositor = true; | 80 startedSynchronizedOnCompositor = true; |
| 81 } | 81 } |
| 82 | 82 |
| 83 if (animation->playing() && !animation->hasStartTime() && | 83 if (animation->playing() && !animation->hasStartTime() && |
| 84 animation->timeline() && animation->timeline()->isActive()) { | 84 animation->timeline() && animation->timeline()->isActive()) { |
| 85 waitingForStartTime.append(animation.get()); | 85 waitingForStartTime.push_back(animation.get()); |
| 86 } | 86 } |
| 87 } else { | 87 } else { |
| 88 deferred.append(animation); | 88 deferred.push_back(animation); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 // If any synchronized animations were started on the compositor, all | 92 // If any synchronized animations were started on the compositor, all |
| 93 // remaning synchronized animations need to wait for the synchronized | 93 // remaning synchronized animations need to wait for the synchronized |
| 94 // start time. Otherwise they may start immediately. | 94 // start time. Otherwise they may start immediately. |
| 95 if (startedSynchronizedOnCompositor) { | 95 if (startedSynchronizedOnCompositor) { |
| 96 for (auto& animation : waitingForStartTime) { | 96 for (auto& animation : waitingForStartTime) { |
| 97 if (!animation->hasStartTime()) { | 97 if (!animation->hasStartTime()) { |
| 98 m_waitingForCompositorAnimationStart.append(animation); | 98 m_waitingForCompositorAnimationStart.push_back(animation); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 } else { | 101 } else { |
| 102 for (auto& animation : waitingForStartTime) { | 102 for (auto& animation : waitingForStartTime) { |
| 103 if (!animation->hasStartTime()) { | 103 if (!animation->hasStartTime()) { |
| 104 animation->notifyCompositorStartTime( | 104 animation->notifyCompositorStartTime( |
| 105 animation->timeline()->currentTimeInternal()); | 105 animation->timeline()->currentTimeInternal()); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 } | 108 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 for (auto animation : animations) { | 147 for (auto animation : animations) { |
| 148 if (animation->hasStartTime() || | 148 if (animation->hasStartTime() || |
| 149 animation->playStateInternal() != Animation::Pending || | 149 animation->playStateInternal() != Animation::Pending || |
| 150 !animation->timeline() || !animation->timeline()->isActive()) { | 150 !animation->timeline() || !animation->timeline()->isActive()) { |
| 151 // Already started or no longer relevant. | 151 // Already started or no longer relevant. |
| 152 continue; | 152 continue; |
| 153 } | 153 } |
| 154 if (compositorGroup && animation->compositorGroup() != compositorGroup) { | 154 if (compositorGroup && animation->compositorGroup() != compositorGroup) { |
| 155 // Still waiting. | 155 // Still waiting. |
| 156 m_waitingForCompositorAnimationStart.append(animation); | 156 m_waitingForCompositorAnimationStart.push_back(animation); |
| 157 continue; | 157 continue; |
| 158 } | 158 } |
| 159 animation->notifyCompositorStartTime(monotonicAnimationStartTime - | 159 animation->notifyCompositorStartTime(monotonicAnimationStartTime - |
| 160 animation->timeline()->zeroTime()); | 160 animation->timeline()->zeroTime()); |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 | 163 |
| 164 DEFINE_TRACE(CompositorPendingAnimations) { | 164 DEFINE_TRACE(CompositorPendingAnimations) { |
| 165 visitor->trace(m_pending); | 165 visitor->trace(m_pending); |
| 166 visitor->trace(m_waitingForCompositorAnimationStart); | 166 visitor->trace(m_waitingForCompositorAnimationStart); |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace blink | 169 } // namespace blink |
| OLD | NEW |