Chromium Code Reviews| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 | 56 |
| 57 | 57 |
| 58 PassRefPtrWillBeRawPtr<AnimationTimeline> AnimationTimeline::create(Document* do cument, PassOwnPtrWillBeRawPtr<PlatformTiming> timing) | 58 PassRefPtrWillBeRawPtr<AnimationTimeline> AnimationTimeline::create(Document* do cument, PassOwnPtrWillBeRawPtr<PlatformTiming> timing) |
| 59 { | 59 { |
| 60 return adoptRefWillBeNoop(new AnimationTimeline(document, timing)); | 60 return adoptRefWillBeNoop(new AnimationTimeline(document, timing)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 AnimationTimeline::AnimationTimeline(Document* document, PassOwnPtrWillBeRawPtr< PlatformTiming> timing) | 63 AnimationTimeline::AnimationTimeline(Document* document, PassOwnPtrWillBeRawPtr< PlatformTiming> timing) |
| 64 : m_document(document) | 64 : m_document(document) |
| 65 , m_zeroTime(0) | 65 , m_zeroTime(0) |
| 66 , m_lastCurrentTime(0) | |
| 67 , m_lastRealTime(0) | |
| 68 , m_playbackRate(1) | |
| 66 { | 69 { |
| 67 if (!timing) | 70 if (!timing) |
| 68 m_timing = adoptPtrWillBeNoop(new AnimationTimelineTiming(this)); | 71 m_timing = adoptPtrWillBeNoop(new AnimationTimelineTiming(this)); |
| 69 else | 72 else |
| 70 m_timing = timing; | 73 m_timing = timing; |
| 71 | 74 |
| 72 ASSERT(document); | 75 ASSERT(document); |
| 73 } | 76 } |
| 74 | 77 |
| 75 AnimationTimeline::~AnimationTimeline() | 78 AnimationTimeline::~AnimationTimeline() |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 } | 163 } |
| 161 | 164 |
| 162 void AnimationTimeline::AnimationTimelineTiming::trace(Visitor* visitor) | 165 void AnimationTimeline::AnimationTimelineTiming::trace(Visitor* visitor) |
| 163 { | 166 { |
| 164 visitor->trace(m_timeline); | 167 visitor->trace(m_timeline); |
| 165 AnimationTimeline::PlatformTiming::trace(visitor); | 168 AnimationTimeline::PlatformTiming::trace(visitor); |
| 166 } | 169 } |
| 167 | 170 |
| 168 double AnimationTimeline::zeroTime() | 171 double AnimationTimeline::zeroTime() |
| 169 { | 172 { |
| 170 if (!m_zeroTime && m_document && m_document->loader()) { | 173 if (!m_zeroTime && m_document && m_document->loader()) |
|
dstockwell
2014/11/12 03:39:42
Don't reformat code.
samli
2014/11/12 20:01:13
Done.
| |
| 171 m_zeroTime = m_document->loader()->timing()->referenceMonotonicTime(); | 174 m_zeroTime = m_document->loader()->timing()->referenceMonotonicTime(); |
| 172 } | |
| 173 return m_zeroTime; | 175 return m_zeroTime; |
| 174 } | 176 } |
| 175 | 177 |
| 176 double AnimationTimeline::currentTime(bool& isNull) | 178 double AnimationTimeline::currentTime(bool& isNull) |
| 177 { | 179 { |
| 178 return currentTimeInternal(isNull) * 1000; | 180 return currentTimeInternal(isNull) * 1000; |
| 179 } | 181 } |
| 180 | 182 |
| 181 double AnimationTimeline::currentTimeInternal(bool& isNull) | 183 double AnimationTimeline::currentTimeInternal(bool& isNull) |
| 182 { | 184 { |
| 183 if (!m_document) { | 185 if (!m_document) { |
| 184 isNull = true; | 186 isNull = true; |
| 185 return std::numeric_limits<double>::quiet_NaN(); | 187 return std::numeric_limits<double>::quiet_NaN(); |
| 186 } | 188 } |
| 187 double result = m_document->animationClock().currentTime() - zeroTime(); | 189 double result = m_lastCurrentTime + (m_document->animationClock().currentTim e() - m_lastRealTime - zeroTime()) * playbackRateForInspector(); |
| 188 isNull = std::isnan(result); | 190 isNull = std::isnan(result); |
| 189 return result; | 191 return result; |
| 190 } | 192 } |
| 191 | 193 |
| 192 double AnimationTimeline::currentTime() | 194 double AnimationTimeline::currentTime() |
| 193 { | 195 { |
| 194 return currentTimeInternal() * 1000; | 196 return currentTimeInternal() * 1000; |
| 195 } | 197 } |
| 196 | 198 |
| 197 double AnimationTimeline::currentTimeInternal() | 199 double AnimationTimeline::currentTimeInternal() |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 223 } | 225 } |
| 224 | 226 |
| 225 void AnimationTimeline::setOutdatedAnimationPlayer(AnimationPlayer* player) | 227 void AnimationTimeline::setOutdatedAnimationPlayer(AnimationPlayer* player) |
| 226 { | 228 { |
| 227 ASSERT(player->outdated()); | 229 ASSERT(player->outdated()); |
| 228 m_playersNeedingUpdate.add(player); | 230 m_playersNeedingUpdate.add(player); |
| 229 if (m_document && m_document->page() && !m_document->page()->animator().isSe rvicingAnimations()) | 231 if (m_document && m_document->page() && !m_document->page()->animator().isSe rvicingAnimations()) |
| 230 m_timing->serviceOnNextFrame(); | 232 m_timing->serviceOnNextFrame(); |
| 231 } | 233 } |
| 232 | 234 |
| 235 void AnimationTimeline::setPlaybackRateForInspector(double playbackRate) | |
|
dstockwell
2014/11/12 03:39:42
Add a fixme, needs to invalidate compositor animat
samli
2014/11/12 20:01:13
Done.
| |
| 236 { | |
| 237 m_lastCurrentTime = currentTimeInternal(); | |
|
dstockwell
2014/11/12 03:39:42
I'm not sure you need both lastCurrentTime and las
samli
2014/11/12 20:01:13
(m_document->animationClock().currentTime() + m_de
dstockwell
2014/11/12 22:49:44
Can we just special case playback rate 0, like in
| |
| 238 m_lastRealTime = m_document->animationClock().currentTime() - zeroTime(); | |
| 239 m_playbackRate = playbackRate; | |
| 240 } | |
| 241 | |
| 242 double AnimationTimeline::playbackRateForInspector() const | |
| 243 { | |
| 244 return m_playbackRate; | |
| 245 } | |
| 246 | |
| 233 #if !ENABLE(OILPAN) | 247 #if !ENABLE(OILPAN) |
| 234 void AnimationTimeline::detachFromDocument() | 248 void AnimationTimeline::detachFromDocument() |
| 235 { | 249 { |
| 236 // FIXME: AnimationTimeline should keep Document alive. | 250 // FIXME: AnimationTimeline should keep Document alive. |
| 237 m_document = nullptr; | 251 m_document = nullptr; |
| 238 } | 252 } |
| 239 #endif | 253 #endif |
| 240 | 254 |
| 241 void AnimationTimeline::trace(Visitor* visitor) | 255 void AnimationTimeline::trace(Visitor* visitor) |
| 242 { | 256 { |
| 243 #if ENABLE(OILPAN) | 257 #if ENABLE(OILPAN) |
| 244 visitor->trace(m_document); | 258 visitor->trace(m_document); |
| 245 visitor->trace(m_timing); | 259 visitor->trace(m_timing); |
| 246 visitor->trace(m_playersNeedingUpdate); | 260 visitor->trace(m_playersNeedingUpdate); |
| 247 visitor->trace(m_players); | 261 visitor->trace(m_players); |
| 248 #endif | 262 #endif |
| 249 } | 263 } |
| 250 | 264 |
| 251 } // namespace | 265 } // namespace |
| OLD | NEW |