Diff
Modified: trunk/Source/WebCore/ChangeLog (111524 => 111525)
--- trunk/Source/WebCore/ChangeLog 2012-03-21 11:58:01 UTC (rev 111524)
+++ trunk/Source/WebCore/ChangeLog 2012-03-21 12:13:36 UTC (rev 111525)
@@ -1,3 +1,57 @@
+2012-03-21 Ian Vollick <[email protected]>
+
+ [chromium] Animation events should only be used for synchronizing animation start times
+ https://bugs.webkit.org/show_bug.cgi?id=81484
+
+ Reviewed by Adrienne Walker.
+
+ Tested in CCLayerTreeHostTestSynchronizeAnimationStartTimes
+
+ Eliminated animation finished events. Animations will finish naturally on the
+ main thread and the final values will be set.
+
+ Animation started events are now also used to synchronize the main thread
+ animations' start times with their impl thread equivalents, preventing skew.
+ Until main thread animations receive their synchronized start times, they will
+ apply their initial values (i.e., they will be paused at time zero). This
+ guarantees that we will not jump to the animation's final value on the main
+ thread while we wait for the synchronized start time.
+
+ * WebCore.gypi:
+ * platform/graphics/chromium/LayerChromium.cpp:
+ (WebCore::LayerChromium::notifyAnimationStarted):
+ * platform/graphics/chromium/LayerChromium.h:
+ (WebCore):
+ (LayerChromium):
+ * platform/graphics/chromium/cc/CCActiveAnimation.cpp:
+ (WebCore::CCActiveAnimation::CCActiveAnimation):
+ * platform/graphics/chromium/cc/CCActiveAnimation.h:
+ (CCActiveAnimation):
+ (WebCore::CCActiveAnimation::needsSynchronizedStartTime):
+ (WebCore::CCActiveAnimation::setNeedsSynchronizedStartTime):
+ * platform/graphics/chromium/cc/CCAnimationEvents.cpp: Removed.
+ * platform/graphics/chromium/cc/CCAnimationEvents.h:
+ (WebCore::CCAnimationStartedEvent::CCAnimationStartedEvent):
+ (CCAnimationStartedEvent):
+ (WebCore):
+ * platform/graphics/chromium/cc/CCLayerAnimationController.cpp:
+ (WebCore::CCLayerAnimationController::animate):
+ (WebCore::CCLayerAnimationController::notifyAnimationStarted):
+ (WebCore):
+ (WebCore::CCLayerAnimationController::pushNewAnimationsToImplThread):
+ (WebCore::CCLayerAnimationController::startAnimationsWaitingForNextTick):
+ (WebCore::CCLayerAnimationController::startAnimationsWaitingForStartTime):
+ (WebCore::CCLayerAnimationController::startAnimationsWaitingForTargetAvailability):
+ (WebCore::CCLayerAnimationController::purgeFinishedAnimations):
+ (WebCore::CCLayerAnimationController::tickAnimations):
+ * platform/graphics/chromium/cc/CCLayerAnimationController.h:
+ (CCLayerAnimationController):
+ * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+ (WebCore::CCLayerTreeHost::updateAnimations):
+ (WebCore::CCLayerTreeHost::setAnimationEventsRecursive):
+ * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+ (CCLayerTreeHost):
+
2012-03-21 Zeno Albisser <[email protected]>
[Qt][WK2][Mac] MiniBrowser asserts at HashTable.h:480
Modified: trunk/Source/WebCore/WebCore.gypi (111524 => 111525)
--- trunk/Source/WebCore/WebCore.gypi 2012-03-21 11:58:01 UTC (rev 111524)
+++ trunk/Source/WebCore/WebCore.gypi 2012-03-21 12:13:36 UTC (rev 111525)
@@ -3537,7 +3537,6 @@
'platform/graphics/chromium/cc/CCActiveGestureAnimation.h',
'platform/graphics/chromium/cc/CCAnimationCurve.cpp',
'platform/graphics/chromium/cc/CCAnimationCurve.h',
- 'platform/graphics/chromium/cc/CCAnimationEvents.cpp',
'platform/graphics/chromium/cc/CCAnimationEvents.h',
'platform/graphics/chromium/cc/CCDamageTracker.cpp',
'platform/graphics/chromium/cc/CCDamageTracker.h',
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp (111524 => 111525)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp 2012-03-21 11:58:01 UTC (rev 111524)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp 2012-03-21 12:13:36 UTC (rev 111525)
@@ -606,28 +606,10 @@
return m_layerAnimationController->hasActiveAnimation();
}
-void LayerChromium::setAnimationEvent(const CCAnimationEvent& event, double wallClockTime)
+void LayerChromium::notifyAnimationStarted(const CCAnimationStartedEvent& event, double wallClockTime)
{
- switch (event.type()) {
- case CCAnimationEvent::Started:
- m_layerAnimationDelegate->notifyAnimationStarted(wallClockTime);
- break;
-
- case CCAnimationEvent::FinishedFloatAnimation: {
- const CCFloatAnimationFinishedEvent* finishedEvent = event.toFloatAnimationFinishedEvent();
- ASSERT(finishedEvent->targetProperty() == CCActiveAnimation::Opacity);
- setOpacity(finishedEvent->finalValue());
- break;
- }
-
- case CCAnimationEvent::FinishedTransformAnimation: {
- const CCTransformAnimationFinishedEvent* finishedEvent = event.toTransformAnimationFinishedEvent();
- ASSERT(finishedEvent->targetProperty() == CCActiveAnimation::Transform);
- setTransform(finishedEvent->finalValue());
- break;
- }
-
- }
+ m_layerAnimationController->notifyAnimationStarted(event);
+ m_layerAnimationDelegate->notifyAnimationStarted(wallClockTime);
}
void sortLayers(Vector<RefPtr<LayerChromium> >::iterator, Vector<RefPtr<LayerChromium> >::iterator, void*)
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h (111524 => 111525)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h 2012-03-21 11:58:01 UTC (rev 111524)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h 2012-03-21 12:13:36 UTC (rev 111525)
@@ -56,7 +56,7 @@
namespace WebCore {
-class CCAnimationEvent;
+struct CCAnimationStartedEvent;
class CCLayerAnimationDelegate;
class CCLayerImpl;
class CCLayerTreeHost;
@@ -242,7 +242,7 @@
bool hasActiveAnimation() const;
- void setAnimationEvent(const CCAnimationEvent&, double wallClockTime);
+ void notifyAnimationStarted(const CCAnimationStartedEvent&, double wallClockTime);
virtual Region opaqueContentsRegion() const { return Region(); };
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCActiveAnimation.cpp (111524 => 111525)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCActiveAnimation.cpp 2012-03-21 11:58:01 UTC (rev 111524)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCActiveAnimation.cpp 2012-03-21 12:13:36 UTC (rev 111525)
@@ -45,6 +45,7 @@
, m_runState(WaitingForTargetAvailability)
, m_iterations(1)
, m_startTime(0)
+ , m_needsSynchronizedStartTime(false)
, m_pauseTime(0)
, m_totalPausedTime(0)
{
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCActiveAnimation.h (111524 => 111525)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCActiveAnimation.h 2012-03-21 11:58:01 UTC (rev 111524)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCActiveAnimation.h 2012-03-21 12:13:36 UTC (rev 111525)
@@ -92,6 +92,11 @@
CCAnimationCurve* curve() { return m_curve.get(); }
const CCAnimationCurve* curve() const { return m_curve.get(); }
+ // If this is true, even if the animation is running, it will not be tickable until
+ // it is given a start time. This is true for animations running on the main thread.
+ bool needsSynchronizedStartTime() const { return m_needsSynchronizedStartTime; }
+ void setNeedsSynchronizedStartTime(bool needsSynchronizedStartTime) { m_needsSynchronizedStartTime = needsSynchronizedStartTime; }
+
// Takes the given absolute time, and using the start time and the number
// of iterations, returns the relative time in the current iteration.
double trimTimeToCurrentIteration(double now) const;
@@ -120,6 +125,8 @@
int m_iterations;
double m_startTime;
+ bool m_needsSynchronizedStartTime;
+
// These are used in trimTimeToCurrentIteration to account for time
// spent while paused. This is not included in AnimationState since it
// there is absolutely no need for clients of this controller to know
Deleted: trunk/Source/WebCore/platform/graphics/chromium/cc/CCAnimationEvents.cpp (111524 => 111525)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCAnimationEvents.cpp 2012-03-21 11:58:01 UTC (rev 111524)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCAnimationEvents.cpp 2012-03-21 12:13:36 UTC (rev 111525)
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "cc/CCAnimationEvents.h"
-
-#include <wtf/OwnPtr.h>
-
-namespace WebCore {
-
-CCAnimationEvent::CCAnimationEvent(int layerId, CCActiveAnimation::TargetProperty targetProperty)
- : m_layerId(layerId)
- , m_targetProperty(targetProperty)
-{
-}
-
-CCAnimationEvent::~CCAnimationEvent()
-{
-}
-
-const CCAnimationStartedEvent* CCAnimationEvent::toAnimationStartedEvent() const
-{
- ASSERT(type() == Started);
- return static_cast<const CCAnimationStartedEvent*>(this);
-}
-
-const CCFloatAnimationFinishedEvent* CCAnimationEvent::toFloatAnimationFinishedEvent() const
-{
- ASSERT(type() == FinishedFloatAnimation);
- return static_cast<const CCFloatAnimationFinishedEvent*>(this);
-}
-
-const CCTransformAnimationFinishedEvent* CCAnimationEvent::toTransformAnimationFinishedEvent() const
-{
- ASSERT(type() == FinishedTransformAnimation);
- return static_cast<const CCTransformAnimationFinishedEvent*>(this);
-}
-
-PassOwnPtr<CCAnimationStartedEvent> CCAnimationStartedEvent::create(int layerId, CCActiveAnimation::TargetProperty targetProperty)
-{
- return adoptPtr(new CCAnimationStartedEvent(layerId, targetProperty));
-}
-
-CCAnimationStartedEvent::CCAnimationStartedEvent(int layerId, CCActiveAnimation::TargetProperty targetProperty)
- : CCAnimationEvent(layerId, targetProperty)
-{
-}
-
-CCAnimationStartedEvent::~CCAnimationStartedEvent()
-{
-}
-
-CCAnimationEvent::Type CCAnimationStartedEvent::type() const
-{
- return Started;
-}
-
-PassOwnPtr<CCFloatAnimationFinishedEvent> CCFloatAnimationFinishedEvent::create(int layerId, CCActiveAnimation::TargetProperty targetProperty, float finalValue)
-{
- return adoptPtr(new CCFloatAnimationFinishedEvent(layerId, targetProperty, finalValue));
-}
-
-CCFloatAnimationFinishedEvent::CCFloatAnimationFinishedEvent(int layerId, CCActiveAnimation::TargetProperty targetProperty, float finalValue)
- : CCAnimationEvent(layerId, targetProperty)
- , m_finalValue(finalValue)
-{
-}
-
-CCFloatAnimationFinishedEvent::~CCFloatAnimationFinishedEvent()
-{
-}
-
-CCAnimationEvent::Type CCFloatAnimationFinishedEvent::type() const
-{
- return FinishedFloatAnimation;
-}
-
-PassOwnPtr<CCTransformAnimationFinishedEvent> CCTransformAnimationFinishedEvent::create(int layerId, CCActiveAnimation::TargetProperty targetProperty, const TransformationMatrix& finalValue)
-{
- return adoptPtr(new CCTransformAnimationFinishedEvent(layerId, targetProperty, finalValue));
-}
-
-CCTransformAnimationFinishedEvent::CCTransformAnimationFinishedEvent(int layerId, CCActiveAnimation::TargetProperty targetProperty, const TransformationMatrix& finalValue)
- : CCAnimationEvent(layerId, targetProperty)
- , m_finalValue(finalValue)
-{
-}
-
-CCTransformAnimationFinishedEvent::~CCTransformAnimationFinishedEvent()
-{
-}
-
-CCAnimationEvent::Type CCTransformAnimationFinishedEvent::type() const
-{
- return FinishedTransformAnimation;
-}
-
-} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCAnimationEvents.h (111524 => 111525)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCAnimationEvents.h 2012-03-21 11:58:01 UTC (rev 111524)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCAnimationEvents.h 2012-03-21 12:13:36 UTC (rev 111525)
@@ -27,88 +27,27 @@
#include "cc/CCActiveAnimation.h"
-#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
-class CCAnimationStartedEvent;
-class CCFloatAnimationFinishedEvent;
-class CCTransformAnimationFinishedEvent;
+struct CCAnimationStartedEvent {
+ CCAnimationStartedEvent(int layerId, int groupId, CCActiveAnimation::TargetProperty targetProperty, double monotonicTime)
+ : layerId(layerId)
+ , groupId(groupId)
+ , targetProperty(targetProperty)
+ , monotonicTime(monotonicTime)
+ {
+ }
-class CCAnimationEvent {
-public:
- enum Type { Started, FinishedFloatAnimation, FinishedTransformAnimation };
-
- virtual ~CCAnimationEvent();
-
- virtual Type type() const = 0;
-
- int layerId() const { return m_layerId; }
-
- CCActiveAnimation::TargetProperty targetProperty() const { return m_targetProperty; }
-
- const CCAnimationStartedEvent* toAnimationStartedEvent() const;
- const CCFloatAnimationFinishedEvent* toFloatAnimationFinishedEvent() const;
- const CCTransformAnimationFinishedEvent* toTransformAnimationFinishedEvent() const;
-
-protected:
- CCAnimationEvent(int layerId, CCActiveAnimation::TargetProperty);
-
-private:
- int m_layerId;
- CCActiveAnimation::TargetProperty m_targetProperty;
+ int layerId;
+ int groupId;
+ CCActiveAnimation::TargetProperty targetProperty;
+ double monotonicTime;
};
-// Indicates that an animation has started on a particular layer.
-class CCAnimationStartedEvent : public CCAnimationEvent {
-public:
- static PassOwnPtr<CCAnimationStartedEvent> create(int layerId, CCActiveAnimation::TargetProperty);
+typedef Vector<CCAnimationStartedEvent> CCAnimationEventsVector;
- virtual ~CCAnimationStartedEvent();
-
- virtual Type type() const;
-
-private:
- CCAnimationStartedEvent(int layerId, CCActiveAnimation::TargetProperty);
-};
-
-// Indicates that a float animation has completed.
-class CCFloatAnimationFinishedEvent : public CCAnimationEvent {
-public:
- static PassOwnPtr<CCFloatAnimationFinishedEvent> create(int layerId, CCActiveAnimation::TargetProperty, float finalValue);
-
- virtual ~CCFloatAnimationFinishedEvent();
-
- virtual Type type() const;
-
- float finalValue() const { return m_finalValue; }
-
-private:
- CCFloatAnimationFinishedEvent(int layerId, CCActiveAnimation::TargetProperty, float finalValue);
-
- float m_finalValue;
-};
-
-// Indicates that a transform animation has completed.
-class CCTransformAnimationFinishedEvent : public CCAnimationEvent {
-public:
- static PassOwnPtr<CCTransformAnimationFinishedEvent> create(int layerId, CCActiveAnimation::TargetProperty, const TransformationMatrix& finalValue);
-
- virtual ~CCTransformAnimationFinishedEvent();
-
- virtual Type type() const;
-
- const TransformationMatrix& finalValue() const { return m_finalValue; }
-
-private:
- CCTransformAnimationFinishedEvent(int layerId, CCActiveAnimation::TargetProperty, const TransformationMatrix& finalValue);
-
- TransformationMatrix m_finalValue;
-};
-
-typedef Vector<OwnPtr<CCAnimationEvent> > CCAnimationEventsVector;
-
} // namespace WebCore
#endif // CCAnimationEvents_h
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.cpp (111524 => 111525)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.cpp 2012-03-21 11:58:01 UTC (rev 111524)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.cpp 2012-03-21 12:13:36 UTC (rev 111525)
@@ -96,6 +96,10 @@
anim->setIterations(iterations);
}
+ // In order to avoid skew, the main thread animation cannot tick until it has received the start time of
+ // the corresponding impl thread animation.
+ anim->setNeedsSynchronizedStartTime(true);
+
return anim.release();
}
@@ -177,7 +181,7 @@
startAnimationsWaitingForTargetAvailability(monotonicTime, events);
resolveConflicts(monotonicTime);
tickAnimations(monotonicTime);
- purgeFinishedAnimations(events);
+ purgeFinishedAnimations();
startAnimationsWaitingForTargetAvailability(monotonicTime, events);
}
@@ -212,17 +216,28 @@
return false;
}
+void CCLayerAnimationController::notifyAnimationStarted(const CCAnimationStartedEvent& event)
+{
+ for (size_t i = 0; i < m_activeAnimations.size(); ++i) {
+ if (m_activeAnimations[i]->group() == event.groupId && m_activeAnimations[i]->targetProperty() == event.targetProperty) {
+ ASSERT(m_activeAnimations[i]->needsSynchronizedStartTime());
+ m_activeAnimations[i]->setNeedsSynchronizedStartTime(false);
+ m_activeAnimations[i]->setStartTime(event.monotonicTime);
+ return;
+ }
+ }
+}
+
void CCLayerAnimationController::pushNewAnimationsToImplThread(CCLayerAnimationController* controllerImpl)
{
// Any new animations owned by the main thread's controller are cloned and adde to the impl thread's controller.
for (size_t i = 0; i < m_activeAnimations.size(); ++i) {
if (!controllerImpl->getActiveAnimation(m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty())) {
OwnPtr<CCActiveAnimation> toAdd(m_activeAnimations[i]->cloneForImplThread());
- // If the animation is already in progress -- set it to be waiting until the target is available.
- // That way, it will have a chance to start on the impl thread. Otherwise, we will never tick at the
- // very beginning of the animation.
- if (toAdd->runState() == CCActiveAnimation::Running || toAdd->runState() == CCActiveAnimation::Paused)
- toAdd->setRunState(CCActiveAnimation::WaitingForTargetAvailability, 0);
+ ASSERT(m_activeAnimations[i]->needsSynchronizedStartTime());
+ ASSERT(!toAdd->needsSynchronizedStartTime());
+ // The new animation should be set to run as soon as possible.
+ toAdd->setRunState(CCActiveAnimation::WaitingForTargetAvailability, 0);
controllerImpl->add(toAdd.release());
}
}
@@ -249,7 +264,7 @@
m_activeAnimations[i]->setRunState(CCActiveAnimation::Running, monotonicTime);
m_activeAnimations[i]->setStartTime(monotonicTime);
if (events)
- events->append(CCAnimationStartedEvent::create(m_client->id(), m_activeAnimations[i]->targetProperty()));
+ events->append(CCAnimationStartedEvent(m_client->id(), m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty(), monotonicTime));
}
}
}
@@ -260,7 +275,7 @@
if (m_activeAnimations[i]->runState() == CCActiveAnimation::WaitingForStartTime && m_activeAnimations[i]->startTime() <= monotonicTime) {
m_activeAnimations[i]->setRunState(CCActiveAnimation::Running, monotonicTime);
if (events)
- events->append(CCAnimationStartedEvent::create(m_client->id(), m_activeAnimations[i]->targetProperty()));
+ events->append(CCAnimationStartedEvent(m_client->id(), m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty(), monotonicTime));
}
}
}
@@ -298,7 +313,7 @@
m_activeAnimations[i]->setRunState(CCActiveAnimation::Running, monotonicTime);
m_activeAnimations[i]->setStartTime(monotonicTime);
if (events)
- events->append(CCAnimationStartedEvent::create(m_client->id(), m_activeAnimations[i]->targetProperty()));
+ events->append(CCAnimationStartedEvent(m_client->id(), m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty(), monotonicTime));
for (size_t j = i + 1; j < m_activeAnimations.size(); ++j) {
if (m_activeAnimations[i]->group() == m_activeAnimations[j]->group()) {
m_activeAnimations[j]->setRunState(CCActiveAnimation::Running, monotonicTime);
@@ -331,7 +346,7 @@
}
}
-void CCLayerAnimationController::purgeFinishedAnimations(CCAnimationEventsVector* events)
+void CCLayerAnimationController::purgeFinishedAnimations()
{
// Each iteration, m_activeAnimations.size() decreases or i increments,
// guaranteeing progress towards loop termination.
@@ -349,27 +364,15 @@
}
}
if (allAnimsWithSameIdAreFinished) {
- // We now need to remove all animations with the same group id as groupId
- // (and send along animation finished notifications, if necessary).
+ // We now need to remove all animations with the same group id as groupId.
// Each iteration, m_activeAnimations.size() decreases or j increments,
// guaranteeing progress towards loop termination. Also, we are guaranteed
// to remove at least one active animation.
for (size_t j = i; j < m_activeAnimations.size();) {
if (groupId != m_activeAnimations[j]->group())
j++;
- else {
- if (events) {
- switch (m_activeAnimations[j]->targetProperty()) {
- case CCActiveAnimation::Opacity:
- events->append(CCFloatAnimationFinishedEvent::create(m_client->id(), CCActiveAnimation::Opacity, m_client->opacity()));
- break;
- case CCActiveAnimation::Transform:
- events->append(CCTransformAnimationFinishedEvent::create(m_client->id(), CCActiveAnimation::Transform, m_client->transform()));
- break;
- }
- }
+ else
m_activeAnimations.remove(j);
- }
}
} else
i++;
@@ -382,6 +385,11 @@
if (m_activeAnimations[i]->runState() == CCActiveAnimation::Running) {
double trimmed = m_activeAnimations[i]->trimTimeToCurrentIteration(monotonicTime);
+ // Animation assumes its initial value until it gets the synchronized start time
+ // from the impl thread and can start ticking.
+ if (m_activeAnimations[i]->needsSynchronizedStartTime())
+ trimmed = 0;
+
switch (m_activeAnimations[i]->targetProperty()) {
case CCActiveAnimation::Transform: {
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.h (111524 => 111525)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.h 2012-03-21 11:58:01 UTC (rev 111524)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.h 2012-03-21 12:13:36 UTC (rev 111525)
@@ -86,6 +86,10 @@
// if there is an animation scheduled to animate this property in the future.
bool isAnimatingProperty(CCActiveAnimation::TargetProperty) const;
+ // This is called in response to an animation being started on the impl thread. This
+ // function updates the corresponding main thread animation's start time.
+ void notifyAnimationStarted(const CCAnimationStartedEvent&);
+
protected:
explicit CCLayerAnimationController(CCLayerAnimationControllerClient*);
@@ -99,7 +103,7 @@
void startAnimationsWaitingForStartTime(double monotonicTime, CCAnimationEventsVector*);
void startAnimationsWaitingForTargetAvailability(double monotonicTime, CCAnimationEventsVector*);
void resolveConflicts(double monotonicTime);
- void purgeFinishedAnimations(CCAnimationEventsVector*);
+ void purgeFinishedAnimations();
void tickAnimations(double monotonicTime);
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp (111524 => 111525)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2012-03-21 11:58:01 UTC (rev 111524)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2012-03-21 12:13:36 UTC (rev 111525)
@@ -179,10 +179,10 @@
m_contentsTextureManager->evictAndDeleteAllTextures(allocator);
}
-void CCLayerTreeHost::updateAnimations(double frameBeginTime)
+void CCLayerTreeHost::updateAnimations(double wallClockTime)
{
m_animating = true;
- m_client->updateAnimations(frameBeginTime);
+ m_client->updateAnimations(wallClockTime);
animateLayers(monotonicallyIncreasingTime());
m_animating = false;
}
@@ -682,8 +682,8 @@
void CCLayerTreeHost::setAnimationEventsRecursive(const CCAnimationEventsVector& events, LayerChromium* layer, double wallClockTime)
{
for (size_t eventIndex = 0; eventIndex < events.size(); ++eventIndex) {
- if (layer->id() == events[eventIndex]->layerId())
- layer->setAnimationEvent(*events[eventIndex], wallClockTime);
+ if (layer->id() == events[eventIndex].layerId)
+ layer->notifyAnimationStarted(events[eventIndex], wallClockTime);
}
for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIndex)
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h (111524 => 111525)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h 2012-03-21 11:58:01 UTC (rev 111524)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h 2012-03-21 12:13:36 UTC (rev 111525)
@@ -125,7 +125,7 @@
static bool anyLayerTreeHostInstanceExists();
// CCLayerTreeHost interface to CCProxy.
- void updateAnimations(double frameBeginTime);
+ void updateAnimations(double wallClockTime);
void layout();
void beginCommitOnImplThread(CCLayerTreeHostImpl*);
void finishCommitOnImplThread(CCLayerTreeHostImpl*);
Modified: trunk/Source/WebKit/chromium/ChangeLog (111524 => 111525)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-03-21 11:58:01 UTC (rev 111524)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-03-21 12:13:36 UTC (rev 111525)
@@ -1,3 +1,19 @@
+2012-03-21 Ian Vollick <[email protected]>
+
+ [chromium] Animation events should only be used for synchronizing animation start times
+ https://bugs.webkit.org/show_bug.cgi?id=81484
+
+ Reviewed by Adrienne Walker.
+
+ * tests/CCLayerTreeHostTest.cpp:
+ (WTF):
+ (CCLayerTreeHostTestSynchronizeAnimationStartTimes):
+ (WTF::CCLayerTreeHostTestSynchronizeAnimationStartTimes::CCLayerTreeHostTestSynchronizeAnimationStartTimes):
+ (WTF::CCLayerTreeHostTestSynchronizeAnimationStartTimes::beginTest):
+ (WTF::CCLayerTreeHostTestSynchronizeAnimationStartTimes::animateLayers):
+ (WTF::CCLayerTreeHostTestSynchronizeAnimationStartTimes::afterTest):
+ (WTF::TEST_F):
+
2012-03-21 Peter Beverloo <[email protected]>
[Chromium] Remove Android build-fix when the proper fix rolled into WebKit
Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp (111524 => 111525)
--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp 2012-03-21 11:58:01 UTC (rev 111524)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp 2012-03-21 12:13:36 UTC (rev 111525)
@@ -1006,6 +1006,49 @@
}
};
+// Ensures that main thread animations have their start times synchronized with impl thread animations.
+class CCLayerTreeHostTestSynchronizeAnimationStartTimes : public CCLayerTreeHostTestThreadOnly {
+public:
+ CCLayerTreeHostTestSynchronizeAnimationStartTimes()
+ : m_numAnimates(0)
+ {
+ }
+
+ virtual void beginTest()
+ {
+ postAddAnimationToMainThread();
+ }
+
+ virtual void animateLayers(CCLayerTreeHostImpl* layerTreeHostImpl, double monotonicTime)
+ {
+ if (!m_numAnimates) {
+ m_numAnimates++;
+ return;
+ }
+
+ CCLayerAnimationController* controllerImpl = layerTreeHostImpl->rootLayer()->layerAnimationController();
+ CCLayerAnimationController* controller = m_layerTreeHost->rootLayer()->layerAnimationController();
+ CCActiveAnimation* animationImpl = controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity);
+ CCActiveAnimation* animation = controller->getActiveAnimation(0, CCActiveAnimation::Opacity);
+
+ EXPECT_EQ(animationImpl->startTime(), animation->startTime());
+
+ endTest();
+ }
+
+ virtual void afterTest()
+ {
+ }
+
+private:
+ int m_numAnimates;
+};
+
+TEST_F(CCLayerTreeHostTestSynchronizeAnimationStartTimes, runMultiThread)
+{
+ runTestThreaded();
+}
+
TEST_F(CCLayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity, runMultiThread)
{
runTestThreaded();