Changeset 125892 in webkit
- Timestamp:
- Aug 17, 2012 6:48:19 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r125889 r125892 1 2012-08-17 Ian Vollick <vollick@chromium.org> 2 3 [chromium] Add tracing for active composited animations 4 https://bugs.webkit.org/show_bug.cgi?id=84210 5 6 Reviewed by James Robinson. 7 8 This patch issues the trace events from the animations. Animations will 9 report when they start and finish on the main and impl threads (via 10 TRACE_EVENT_ASYNC*), and also issues instant trace events whenever they 11 change state. 12 13 No new tests, only changes tracing behavior. 14 15 * platform/graphics/chromium/cc/CCActiveAnimation.cpp: 16 (WebCore::CCActiveAnimation::CCActiveAnimation): 17 (WebCore::CCActiveAnimation::~CCActiveAnimation): 18 (WebCore::CCActiveAnimation::setRunState): 19 (WebCore::CCActiveAnimation::clone): 20 (WebCore): 21 (WebCore::CCActiveAnimation::cloneAndInitialize): 22 * platform/graphics/chromium/cc/CCActiveAnimation.h: 23 (WebCore::CCActiveAnimation::isControllingInstance): 24 (CCActiveAnimation): 25 * platform/graphics/chromium/cc/CCLayerAnimationController.cpp: 26 (WebCore::CCLayerAnimationController::pushNewAnimationsToImplThread): 27 (WebCore::CCLayerAnimationController::replaceImplThreadAnimations): 28 (WebCore::CCLayerAnimationController::tickAnimations): 29 1 30 2012-08-17 John J. Barton <johnjbarton@chromium.org> 2 31 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCActiveAnimation.cpp
r120326 r125892 27 27 #include "cc/CCActiveAnimation.h" 28 28 29 #include "TraceEvent.h" 29 30 #include "cc/CCAnimationCurve.h" 31 #include <wtf/Assertions.h> 32 #include <wtf/StdLibExtras.h> 30 33 31 34 #include <cmath> 35 36 namespace { 37 38 // This should match the RunState enum. 39 static const char* const s_runStateNames[] = { 40 "WaitingForNextTick", 41 "WaitingForTargetAvailability", 42 "WaitingForStartTime", 43 "WaitingForDeletion", 44 "Running", 45 "Paused", 46 "Finished", 47 "Aborted" 48 }; 49 50 COMPILE_ASSERT(static_cast<int>(WebCore::CCActiveAnimation::RunStateEnumSize) == WTF_ARRAY_LENGTH(s_runStateNames), RunState_names_match_enum); 51 52 // This should match the TargetProperty enum. 53 static const char* const s_targetPropertyNames[] = { 54 "Transform", 55 "Opacity" 56 }; 57 58 COMPILE_ASSERT(static_cast<int>(WebCore::CCActiveAnimation::TargetPropertyEnumSize) == WTF_ARRAY_LENGTH(s_targetPropertyNames), TargetProperty_names_match_enum); 59 60 } // namespace 32 61 33 62 namespace WebCore { … … 52 81 , m_pauseTime(0) 53 82 , m_totalPausedTime(0) 83 , m_isControllingInstance(false) 54 84 { 55 85 } … … 57 87 CCActiveAnimation::~CCActiveAnimation() 58 88 { 89 if (m_runState == Running || m_runState == Paused) 90 setRunState(Aborted, 0); 59 91 } 60 92 … … 63 95 if (m_suspended) 64 96 return; 97 98 char nameBuffer[256]; 99 snprintf(nameBuffer, sizeof(nameBuffer), "%s-%d%s", s_targetPropertyNames[m_targetProperty], m_group, m_isControllingInstance ? "(impl)" : ""); 100 101 bool isWaitingToStart = m_runState == WaitingForNextTick 102 || m_runState == WaitingForTargetAvailability 103 || m_runState == WaitingForStartTime; 104 105 if (isWaitingToStart && runState == Running) 106 TRACE_EVENT_ASYNC_BEGIN1("cc", "CCActiveAnimation", this, "Name", TRACE_STR_COPY(nameBuffer)); 107 108 bool wasFinished = isFinished(); 109 110 const char* oldRunStateName = s_runStateNames[m_runState]; 65 111 66 112 if (runState == Running && m_runState == Paused) … … 69 115 m_pauseTime = monotonicTime; 70 116 m_runState = runState; 117 118 const char* newRunStateName = s_runStateNames[runState]; 119 120 if (!wasFinished && isFinished()) 121 TRACE_EVENT_ASYNC_END0("cc", "CCActiveAnimation", this); 122 123 char stateBuffer[256]; 124 snprintf(stateBuffer, sizeof(stateBuffer), "%s->%s", oldRunStateName, newRunStateName); 125 126 TRACE_EVENT_INSTANT2("cc", "CCLayerAnimationController::setRunState", "Name", TRACE_STR_COPY(nameBuffer), "State", TRACE_STR_COPY(stateBuffer)); 71 127 } 72 128 … … 140 196 } 141 197 142 PassOwnPtr<CCActiveAnimation> CCActiveAnimation::cloneForImplThread() const 198 PassOwnPtr<CCActiveAnimation> CCActiveAnimation::clone(InstanceType instanceType) const 199 { 200 return cloneAndInitialize(instanceType, m_runState, m_startTime); 201 } 202 203 PassOwnPtr<CCActiveAnimation> CCActiveAnimation::cloneAndInitialize(InstanceType instanceType, RunState initialRunState, double startTime) const 143 204 { 144 205 OwnPtr<CCActiveAnimation> toReturn(adoptPtr(new CCActiveAnimation(m_curve->clone(), m_id, m_group, m_targetProperty))); 145 toReturn->m_runState = m_runState;206 toReturn->m_runState = initialRunState; 146 207 toReturn->m_iterations = m_iterations; 147 toReturn->m_startTime = m_startTime;208 toReturn->m_startTime = startTime; 148 209 toReturn->m_pauseTime = m_pauseTime; 149 210 toReturn->m_totalPausedTime = m_totalPausedTime; 150 211 toReturn->m_timeOffset = m_timeOffset; 151 212 toReturn->m_alternatesDirection = m_alternatesDirection; 213 toReturn->m_isControllingInstance = instanceType == ControllingInstance; 152 214 return toReturn.release(); 153 215 } -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCActiveAnimation.h
r124239 r125892 57 57 Paused, 58 58 Finished, 59 Aborted 59 Aborted, 60 // This sentinel must be last. 61 RunStateEnumSize 60 62 }; 61 63 62 64 enum TargetProperty { 63 65 Transform = 0, 64 Opacity 66 Opacity, 67 // This sentinel must be last. 68 TargetPropertyEnumSize 65 69 }; 66 70 … … 113 117 double trimTimeToCurrentIteration(double monotonicTime) const; 114 118 115 PassOwnPtr<CCActiveAnimation> cloneForImplThread() const; 119 enum InstanceType { 120 ControllingInstance = 0, 121 NonControllingInstance 122 }; 123 124 PassOwnPtr<CCActiveAnimation> clone(InstanceType) const; 125 PassOwnPtr<CCActiveAnimation> cloneAndInitialize(InstanceType, RunState initialRunState, double startTime) const; 126 bool isControllingInstance() const { return m_isControllingInstance; } 116 127 117 128 void pushPropertiesTo(CCActiveAnimation*) const; … … 155 166 double m_pauseTime; 156 167 double m_totalPausedTime; 168 169 // Animations lead dual lives. An active animation will be conceptually owned by 170 // two controllers, one on the impl thread and one on the main. In reality, there 171 // will be two separate CCActiveAnimation instances for the same animation. They 172 // will have the same group id and the same target property (these two values 173 // uniquely identify an animation). The instance on the impl thread is the instance 174 // that ultimately controls the values of the animating layer and so we will refer 175 // to it as the 'controlling instance'. 176 bool m_isControllingInstance; 157 177 }; 158 178 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.cpp
r121378 r125892 201 201 continue; 202 202 203 OwnPtr<CCActiveAnimation> toAdd(m_activeAnimations[i]->cloneForImplThread()); 203 // The new animation should be set to run as soon as possible. 204 CCActiveAnimation::RunState initialRunState = CCActiveAnimation::WaitingForTargetAvailability; 205 double startTime = 0; 206 OwnPtr<CCActiveAnimation> toAdd(m_activeAnimations[i]->cloneAndInitialize(CCActiveAnimation::ControllingInstance, initialRunState, startTime)); 204 207 ASSERT(!toAdd->needsSynchronizedStartTime()); 205 // The new animation should be set to run as soon as possible.206 toAdd->setRunState(CCActiveAnimation::WaitingForTargetAvailability, 0);207 toAdd->setStartTime(0);208 208 controllerImpl->addAnimation(toAdd.release()); 209 209 } … … 325 325 } 326 326 327 328 327 void CCLayerAnimationController::markAnimationsForDeletion(double monotonicTime, CCAnimationEventsVector* events) 329 328 { … … 370 369 controllerImpl->m_activeAnimations.clear(); 371 370 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { 372 OwnPtr<CCActiveAnimation> toAdd (m_activeAnimations[i]->cloneForImplThread());371 OwnPtr<CCActiveAnimation> toAdd; 373 372 if (m_activeAnimations[i]->needsSynchronizedStartTime()) { 374 373 // We haven't received an animation started notification yet, so it 375 374 // is important that we add it in a 'waiting' and not 'running' state. 376 toAdd->setRunState(CCActiveAnimation::WaitingForTargetAvailability, 0); 377 toAdd->setStartTime(0); 378 } 375 CCActiveAnimation::RunState initialRunState = CCActiveAnimation::WaitingForTargetAvailability; 376 double startTime = 0; 377 toAdd = m_activeAnimations[i]->cloneAndInitialize(CCActiveAnimation::ControllingInstance, initialRunState, startTime); 378 } else 379 toAdd = m_activeAnimations[i]->clone(CCActiveAnimation::ControllingInstance); 380 379 381 controllerImpl->addAnimation(toAdd.release()); 380 382 } … … 414 416 } 415 417 418 // Do nothing for sentinel value. 419 case CCActiveAnimation::TargetPropertyEnumSize: 420 ASSERT_NOT_REACHED(); 421 416 422 } 417 423 } -
trunk/Source/WebKit/chromium/ChangeLog
r125851 r125892 1 2012-08-17 Ian Vollick <vollick@chromium.org> 2 3 [chromium] Add tracing for active composited animations 4 https://bugs.webkit.org/show_bug.cgi?id=84210 5 6 Reviewed by James Robinson. 7 8 This patch issues the trace events from the animations. Animations will 9 report when they start and finish on the main and impl threads (via 10 TRACE_EVENT_ASYNC*), and also issues instant trace events whenever they 11 change state. 12 13 * src/WebAnimationImpl.cpp: 14 (WebKit::WebAnimationImpl::cloneToCCAnimation): 15 1 16 2012-08-16 Antoine Labour <piman@chromium.org> 2 17 -
trunk/Source/WebKit/chromium/src/WebAnimationImpl.cpp
r125469 r125892 97 97 PassOwnPtr<WebCore::CCActiveAnimation> WebAnimationImpl::cloneToCCAnimation() 98 98 { 99 OwnPtr<WebCore::CCActiveAnimation> toReturn(m_animation->clone ForImplThread());99 OwnPtr<WebCore::CCActiveAnimation> toReturn(m_animation->clone(WebCore::CCActiveAnimation::NonControllingInstance)); 100 100 toReturn->setNeedsSynchronizedStartTime(true); 101 101 return toReturn.release();
Note: See TracChangeset
for help on using the changeset viewer.