Diff
Modified: trunk/Source/WebCore/ChangeLog (125891 => 125892)
--- trunk/Source/WebCore/ChangeLog 2012-08-17 13:23:51 UTC (rev 125891)
+++ trunk/Source/WebCore/ChangeLog 2012-08-17 13:48:19 UTC (rev 125892)
@@ -1,3 +1,32 @@
+2012-08-17 Ian Vollick <voll...@chromium.org>
+
+ [chromium] Add tracing for active composited animations
+ https://bugs.webkit.org/show_bug.cgi?id=84210
+
+ Reviewed by James Robinson.
+
+ This patch issues the trace events from the animations. Animations will
+ report when they start and finish on the main and impl threads (via
+ TRACE_EVENT_ASYNC*), and also issues instant trace events whenever they
+ change state.
+
+ No new tests, only changes tracing behavior.
+
+ * platform/graphics/chromium/cc/CCActiveAnimation.cpp:
+ (WebCore::CCActiveAnimation::CCActiveAnimation):
+ (WebCore::CCActiveAnimation::~CCActiveAnimation):
+ (WebCore::CCActiveAnimation::setRunState):
+ (WebCore::CCActiveAnimation::clone):
+ (WebCore):
+ (WebCore::CCActiveAnimation::cloneAndInitialize):
+ * platform/graphics/chromium/cc/CCActiveAnimation.h:
+ (WebCore::CCActiveAnimation::isControllingInstance):
+ (CCActiveAnimation):
+ * platform/graphics/chromium/cc/CCLayerAnimationController.cpp:
+ (WebCore::CCLayerAnimationController::pushNewAnimationsToImplThread):
+ (WebCore::CCLayerAnimationController::replaceImplThreadAnimations):
+ (WebCore::CCLayerAnimationController::tickAnimations):
+
2012-08-17 John J. Barton <johnjbar...@chromium.org>
Web Inspector: enhance external test-runner and add cleanup code
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCActiveAnimation.cpp (125891 => 125892)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCActiveAnimation.cpp 2012-08-17 13:23:51 UTC (rev 125891)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCActiveAnimation.cpp 2012-08-17 13:48:19 UTC (rev 125892)
@@ -26,10 +26,39 @@
#include "cc/CCActiveAnimation.h"
+#include "TraceEvent.h"
#include "cc/CCAnimationCurve.h"
+#include <wtf/Assertions.h>
+#include <wtf/StdLibExtras.h>
#include <cmath>
+namespace {
+
+// This should match the RunState enum.
+static const char* const s_runStateNames[] = {
+ "WaitingForNextTick",
+ "WaitingForTargetAvailability",
+ "WaitingForStartTime",
+ "WaitingForDeletion",
+ "Running",
+ "Paused",
+ "Finished",
+ "Aborted"
+};
+
+COMPILE_ASSERT(static_cast<int>(WebCore::CCActiveAnimation::RunStateEnumSize) == WTF_ARRAY_LENGTH(s_runStateNames), RunState_names_match_enum);
+
+// This should match the TargetProperty enum.
+static const char* const s_targetPropertyNames[] = {
+ "Transform",
+ "Opacity"
+};
+
+COMPILE_ASSERT(static_cast<int>(WebCore::CCActiveAnimation::TargetPropertyEnumSize) == WTF_ARRAY_LENGTH(s_targetPropertyNames), TargetProperty_names_match_enum);
+
+} // namespace
+
namespace WebCore {
PassOwnPtr<CCActiveAnimation> CCActiveAnimation::create(PassOwnPtr<CCAnimationCurve> curve, int animationId, int groupId, TargetProperty targetProperty)
@@ -51,11 +80,14 @@
, m_suspended(false)
, m_pauseTime(0)
, m_totalPausedTime(0)
+ , m_isControllingInstance(false)
{
}
CCActiveAnimation::~CCActiveAnimation()
{
+ if (m_runState == Running || m_runState == Paused)
+ setRunState(Aborted, 0);
}
void CCActiveAnimation::setRunState(RunState runState, double monotonicTime)
@@ -63,11 +95,35 @@
if (m_suspended)
return;
+ char nameBuffer[256];
+ snprintf(nameBuffer, sizeof(nameBuffer), "%s-%d%s", s_targetPropertyNames[m_targetProperty], m_group, m_isControllingInstance ? "(impl)" : "");
+
+ bool isWaitingToStart = m_runState == WaitingForNextTick
+ || m_runState == WaitingForTargetAvailability
+ || m_runState == WaitingForStartTime;
+
+ if (isWaitingToStart && runState == Running)
+ TRACE_EVENT_ASYNC_BEGIN1("cc", "CCActiveAnimation", this, "Name", TRACE_STR_COPY(nameBuffer));
+
+ bool wasFinished = isFinished();
+
+ const char* oldRunStateName = s_runStateNames[m_runState];
+
if (runState == Running && m_runState == Paused)
m_totalPausedTime += monotonicTime - m_pauseTime;
else if (runState == Paused)
m_pauseTime = monotonicTime;
m_runState = runState;
+
+ const char* newRunStateName = s_runStateNames[runState];
+
+ if (!wasFinished && isFinished())
+ TRACE_EVENT_ASYNC_END0("cc", "CCActiveAnimation", this);
+
+ char stateBuffer[256];
+ snprintf(stateBuffer, sizeof(stateBuffer), "%s->%s", oldRunStateName, newRunStateName);
+
+ TRACE_EVENT_INSTANT2("cc", "CCLayerAnimationController::setRunState", "Name", TRACE_STR_COPY(nameBuffer), "State", TRACE_STR_COPY(stateBuffer));
}
void CCActiveAnimation::suspend(double monotonicTime)
@@ -139,16 +195,22 @@
return trimmed;
}
-PassOwnPtr<CCActiveAnimation> CCActiveAnimation::cloneForImplThread() const
+PassOwnPtr<CCActiveAnimation> CCActiveAnimation::clone(InstanceType instanceType) const
{
+ return cloneAndInitialize(instanceType, m_runState, m_startTime);
+}
+
+PassOwnPtr<CCActiveAnimation> CCActiveAnimation::cloneAndInitialize(InstanceType instanceType, RunState initialRunState, double startTime) const
+{
OwnPtr<CCActiveAnimation> toReturn(adoptPtr(new CCActiveAnimation(m_curve->clone(), m_id, m_group, m_targetProperty)));
- toReturn->m_runState = m_runState;
+ toReturn->m_runState = initialRunState;
toReturn->m_iterations = m_iterations;
- toReturn->m_startTime = m_startTime;
+ toReturn->m_startTime = startTime;
toReturn->m_pauseTime = m_pauseTime;
toReturn->m_totalPausedTime = m_totalPausedTime;
toReturn->m_timeOffset = m_timeOffset;
toReturn->m_alternatesDirection = m_alternatesDirection;
+ toReturn->m_isControllingInstance = instanceType == ControllingInstance;
return toReturn.release();
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCActiveAnimation.h (125891 => 125892)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCActiveAnimation.h 2012-08-17 13:23:51 UTC (rev 125891)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCActiveAnimation.h 2012-08-17 13:48:19 UTC (rev 125892)
@@ -56,12 +56,16 @@
Running,
Paused,
Finished,
- Aborted
+ Aborted,
+ // This sentinel must be last.
+ RunStateEnumSize
};
enum TargetProperty {
Transform = 0,
- Opacity
+ Opacity,
+ // This sentinel must be last.
+ TargetPropertyEnumSize
};
static PassOwnPtr<CCActiveAnimation> create(PassOwnPtr<CCAnimationCurve>, int animationId, int groupId, TargetProperty);
@@ -112,8 +116,15 @@
// of iterations, returns the relative time in the current iteration.
double trimTimeToCurrentIteration(double monotonicTime) const;
- PassOwnPtr<CCActiveAnimation> cloneForImplThread() const;
+ enum InstanceType {
+ ControllingInstance = 0,
+ NonControllingInstance
+ };
+ PassOwnPtr<CCActiveAnimation> clone(InstanceType) const;
+ PassOwnPtr<CCActiveAnimation> cloneAndInitialize(InstanceType, RunState initialRunState, double startTime) const;
+ bool isControllingInstance() const { return m_isControllingInstance; }
+
void pushPropertiesTo(CCActiveAnimation*) const;
private:
@@ -154,6 +165,15 @@
// about these values.
double m_pauseTime;
double m_totalPausedTime;
+
+ // Animations lead dual lives. An active animation will be conceptually owned by
+ // two controllers, one on the impl thread and one on the main. In reality, there
+ // will be two separate CCActiveAnimation instances for the same animation. They
+ // will have the same group id and the same target property (these two values
+ // uniquely identify an animation). The instance on the impl thread is the instance
+ // that ultimately controls the values of the animating layer and so we will refer
+ // to it as the 'controlling instance'.
+ bool m_isControllingInstance;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.cpp (125891 => 125892)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.cpp 2012-08-17 13:23:51 UTC (rev 125891)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.cpp 2012-08-17 13:48:19 UTC (rev 125892)
@@ -200,11 +200,11 @@
if (!m_activeAnimations[i]->needsSynchronizedStartTime())
continue;
- OwnPtr<CCActiveAnimation> toAdd(m_activeAnimations[i]->cloneForImplThread());
+ // The new animation should be set to run as soon as possible.
+ CCActiveAnimation::RunState initialRunState = CCActiveAnimation::WaitingForTargetAvailability;
+ double startTime = 0;
+ OwnPtr<CCActiveAnimation> toAdd(m_activeAnimations[i]->cloneAndInitialize(CCActiveAnimation::ControllingInstance, initialRunState, startTime));
ASSERT(!toAdd->needsSynchronizedStartTime());
- // The new animation should be set to run as soon as possible.
- toAdd->setRunState(CCActiveAnimation::WaitingForTargetAvailability, 0);
- toAdd->setStartTime(0);
controllerImpl->addAnimation(toAdd.release());
}
}
@@ -324,7 +324,6 @@
}
}
-
void CCLayerAnimationController::markAnimationsForDeletion(double monotonicTime, CCAnimationEventsVector* events)
{
for (size_t i = 0; i < m_activeAnimations.size(); i++) {
@@ -369,13 +368,16 @@
{
controllerImpl->m_activeAnimations.clear();
for (size_t i = 0; i < m_activeAnimations.size(); ++i) {
- OwnPtr<CCActiveAnimation> toAdd(m_activeAnimations[i]->cloneForImplThread());
+ OwnPtr<CCActiveAnimation> toAdd;
if (m_activeAnimations[i]->needsSynchronizedStartTime()) {
// We haven't received an animation started notification yet, so it
// is important that we add it in a 'waiting' and not 'running' state.
- toAdd->setRunState(CCActiveAnimation::WaitingForTargetAvailability, 0);
- toAdd->setStartTime(0);
- }
+ CCActiveAnimation::RunState initialRunState = CCActiveAnimation::WaitingForTargetAvailability;
+ double startTime = 0;
+ toAdd = m_activeAnimations[i]->cloneAndInitialize(CCActiveAnimation::ControllingInstance, initialRunState, startTime);
+ } else
+ toAdd = m_activeAnimations[i]->clone(CCActiveAnimation::ControllingInstance);
+
controllerImpl->addAnimation(toAdd.release());
}
}
@@ -413,6 +415,10 @@
break;
}
+ // Do nothing for sentinel value.
+ case CCActiveAnimation::TargetPropertyEnumSize:
+ ASSERT_NOT_REACHED();
+
}
}
}
Modified: trunk/Source/WebKit/chromium/ChangeLog (125891 => 125892)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-08-17 13:23:51 UTC (rev 125891)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-08-17 13:48:19 UTC (rev 125892)
@@ -1,3 +1,18 @@
+2012-08-17 Ian Vollick <voll...@chromium.org>
+
+ [chromium] Add tracing for active composited animations
+ https://bugs.webkit.org/show_bug.cgi?id=84210
+
+ Reviewed by James Robinson.
+
+ This patch issues the trace events from the animations. Animations will
+ report when they start and finish on the main and impl threads (via
+ TRACE_EVENT_ASYNC*), and also issues instant trace events whenever they
+ change state.
+
+ * src/WebAnimationImpl.cpp:
+ (WebKit::WebAnimationImpl::cloneToCCAnimation):
+
2012-08-16 Antoine Labour <pi...@chromium.org>
[chromium] Add resource transfer functions to CCResourceProvider
Modified: trunk/Source/WebKit/chromium/src/WebAnimationImpl.cpp (125891 => 125892)
--- trunk/Source/WebKit/chromium/src/WebAnimationImpl.cpp 2012-08-17 13:23:51 UTC (rev 125891)
+++ trunk/Source/WebKit/chromium/src/WebAnimationImpl.cpp 2012-08-17 13:48:19 UTC (rev 125892)
@@ -96,7 +96,7 @@
PassOwnPtr<WebCore::CCActiveAnimation> WebAnimationImpl::cloneToCCAnimation()
{
- OwnPtr<WebCore::CCActiveAnimation> toReturn(m_animation->cloneForImplThread());
+ OwnPtr<WebCore::CCActiveAnimation> toReturn(m_animation->clone(WebCore::CCActiveAnimation::NonControllingInstance));
toReturn->setNeedsSynchronizedStartTime(true);
return toReturn.release();
}