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 22 matching lines...) Expand all Loading... | |
| 33 | 33 |
| 34 #include "core/animation/Animation.h" | 34 #include "core/animation/Animation.h" |
| 35 #include "core/animation/AnimationTimeline.h" | 35 #include "core/animation/AnimationTimeline.h" |
| 36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
| 37 #include "core/dom/ExceptionCode.h" | 37 #include "core/dom/ExceptionCode.h" |
| 38 #include "core/events/AnimationPlayerEvent.h" | 38 #include "core/events/AnimationPlayerEvent.h" |
| 39 #include "core/frame/UseCounter.h" | 39 #include "core/frame/UseCounter.h" |
| 40 #include "core/inspector/InspectorInstrumentation.h" | 40 #include "core/inspector/InspectorInstrumentation.h" |
| 41 #include "core/inspector/InspectorTraceEvents.h" | 41 #include "core/inspector/InspectorTraceEvents.h" |
| 42 #include "platform/TraceEvent.h" | 42 #include "platform/TraceEvent.h" |
| 43 #include "public/platform/Platform.h" | |
| 44 #include "public/platform/WebCompositorAnimationPlayer.h" | |
| 45 #include "public/platform/WebCompositorSupport.h" | |
| 43 #include "wtf/MathExtras.h" | 46 #include "wtf/MathExtras.h" |
| 44 | 47 |
| 45 namespace blink { | 48 namespace blink { |
| 46 | 49 |
| 47 namespace { | 50 namespace { |
| 48 | 51 |
| 49 static unsigned nextSequenceNumber() | 52 static unsigned nextSequenceNumber() |
| 50 { | 53 { |
| 51 static unsigned next = 0; | 54 static unsigned next = 0; |
| 52 return ++next; | 55 return ++next; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 , m_held(true) | 87 , m_held(true) |
| 85 , m_isPausedForTesting(false) | 88 , m_isPausedForTesting(false) |
| 86 , m_outdated(false) | 89 , m_outdated(false) |
| 87 , m_finished(true) | 90 , m_finished(true) |
| 88 , m_compositorState(nullptr) | 91 , m_compositorState(nullptr) |
| 89 , m_compositorPending(false) | 92 , m_compositorPending(false) |
| 90 , m_compositorGroup(0) | 93 , m_compositorGroup(0) |
| 91 , m_currentTimePending(false) | 94 , m_currentTimePending(false) |
| 92 , m_stateIsBeingUpdated(false) | 95 , m_stateIsBeingUpdated(false) |
| 93 { | 96 { |
| 97 createCompositorPlayer(); | |
|
dstockwell
2015/02/26 00:07:12
Why do we always create a compositor player? Seems
loyso (OOO)
2015/02/26 03:24:57
Because draft. In reality we must know beforehand,
| |
| 98 | |
| 94 if (m_content) { | 99 if (m_content) { |
| 95 if (m_content->player()) { | 100 if (m_content->player()) { |
| 96 m_content->player()->cancel(); | 101 m_content->player()->cancel(); |
| 97 m_content->player()->setSource(0); | 102 m_content->player()->setSource(0); |
| 98 } | 103 } |
| 99 m_content->attach(this); | 104 m_content->attach(this); |
| 100 } | 105 } |
| 101 } | 106 } |
| 102 | 107 |
| 103 AnimationPlayer::~AnimationPlayer() | 108 AnimationPlayer::~AnimationPlayer() |
| 104 { | 109 { |
| 105 #if !ENABLE(OILPAN) | 110 #if !ENABLE(OILPAN) |
| 106 if (m_content) | 111 if (m_content) |
| 107 m_content->detach(); | 112 m_content->detach(); |
| 108 if (m_timeline) | 113 if (m_timeline) |
| 109 m_timeline->playerDestroyed(this); | 114 m_timeline->playerDestroyed(this); |
| 110 #endif | 115 #endif |
| 116 | |
| 117 destroyCompositorPlayer(); | |
| 111 } | 118 } |
| 112 | 119 |
| 113 double AnimationPlayer::sourceEnd() const | 120 double AnimationPlayer::sourceEnd() const |
| 114 { | 121 { |
| 115 return m_content ? m_content->endTimeInternal() : 0; | 122 return m_content ? m_content->endTimeInternal() : 0; |
| 116 } | 123 } |
| 117 | 124 |
| 118 bool AnimationPlayer::limited(double currentTime) const | 125 bool AnimationPlayer::limited(double currentTime) const |
| 119 { | 126 { |
| 120 return (m_playbackRate < 0 && currentTime <= 0) || (m_playbackRate > 0 && cu rrentTime >= sourceEnd()); | 127 return (m_playbackRate < 0 && currentTime <= 0) || (m_playbackRate > 0 && cu rrentTime >= sourceEnd()); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 | 353 |
| 347 bool AnimationPlayer::affects(const Element& element, CSSPropertyID property) co nst | 354 bool AnimationPlayer::affects(const Element& element, CSSPropertyID property) co nst |
| 348 { | 355 { |
| 349 if (!m_content || !m_content->isAnimation()) | 356 if (!m_content || !m_content->isAnimation()) |
| 350 return false; | 357 return false; |
| 351 | 358 |
| 352 const Animation* animation = toAnimation(m_content.get()); | 359 const Animation* animation = toAnimation(m_content.get()); |
| 353 return (animation->target() == &element) && animation->affects(property); | 360 return (animation->target() == &element) && animation->affects(property); |
| 354 } | 361 } |
| 355 | 362 |
| 363 void AnimationPlayer::notifyAnimationStarted(double monotonicTime, int group) | |
| 364 { | |
| 365 timeline()->document()->compositorPendingAnimations().notifyCompositorAnimat ionStarted(monotonicTime, group); | |
| 366 } | |
| 367 | |
| 368 void AnimationPlayer::notifyAnimationFinished(double monotonicTime, int group) | |
| 369 { | |
| 370 } | |
| 371 | |
| 372 void AnimationPlayer::createCompositorPlayer() | |
| 373 { | |
| 374 if (Platform::current()->compositorSupport()) { | |
| 375 m_compositorPlayer = adoptPtr(Platform::current()->compositorSupport()-> createAnimationPlayer()); | |
| 376 m_compositorPlayer->setAnimationDelegate(this); | |
| 377 } | |
| 378 } | |
| 379 | |
| 380 void AnimationPlayer::destroyCompositorPlayer() | |
| 381 { | |
| 382 if (m_compositorPlayer) | |
| 383 m_compositorPlayer->setAnimationDelegate(nullptr); | |
| 384 m_compositorPlayer.clear(); | |
| 385 } | |
| 386 | |
| 356 double AnimationPlayer::calculateStartTime(double currentTime) const | 387 double AnimationPlayer::calculateStartTime(double currentTime) const |
| 357 { | 388 { |
| 358 return m_timeline->effectiveTime() - currentTime / m_playbackRate; | 389 return m_timeline->effectiveTime() - currentTime / m_playbackRate; |
| 359 } | 390 } |
| 360 | 391 |
| 361 double AnimationPlayer::calculateCurrentTime() const | 392 double AnimationPlayer::calculateCurrentTime() const |
| 362 { | 393 { |
| 363 if (isNull(m_startTime) || !m_timeline) | 394 if (isNull(m_startTime) || !m_timeline) |
| 364 return 0; | 395 return 0; |
| 365 return (m_timeline->effectiveTime() - m_startTime) * m_playbackRate; | 396 return (m_timeline->effectiveTime() - m_startTime) * m_playbackRate; |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 930 visitor->trace(m_content); | 961 visitor->trace(m_content); |
| 931 visitor->trace(m_timeline); | 962 visitor->trace(m_timeline); |
| 932 visitor->trace(m_pendingFinishedEvent); | 963 visitor->trace(m_pendingFinishedEvent); |
| 933 visitor->trace(m_finishedPromise); | 964 visitor->trace(m_finishedPromise); |
| 934 visitor->trace(m_readyPromise); | 965 visitor->trace(m_readyPromise); |
| 935 EventTargetWithInlineData::trace(visitor); | 966 EventTargetWithInlineData::trace(visitor); |
| 936 ActiveDOMObject::trace(visitor); | 967 ActiveDOMObject::trace(visitor); |
| 937 } | 968 } |
| 938 | 969 |
| 939 } // namespace | 970 } // namespace |
| OLD | NEW |