Changeset 125892 in webkit


Ignore:
Timestamp:
Aug 17, 2012 6:48:19 AM (12 years ago)
Author:
vollick@chromium.org
Message:

[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.

Source/WebCore:

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):

Source/WebKit/chromium:

  • src/WebAnimationImpl.cpp:

(WebKit::WebAnimationImpl::cloneToCCAnimation):

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r125889 r125892  
     12012-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
    1302012-08-17  John J. Barton  <johnjbarton@chromium.org>
    231
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCActiveAnimation.cpp

    r120326 r125892  
    2727#include "cc/CCActiveAnimation.h"
    2828
     29#include "TraceEvent.h"
    2930#include "cc/CCAnimationCurve.h"
     31#include <wtf/Assertions.h>
     32#include <wtf/StdLibExtras.h>
    3033
    3134#include <cmath>
     35
     36namespace {
     37
     38// This should match the RunState enum.
     39static const char* const s_runStateNames[] = {
     40    "WaitingForNextTick",
     41    "WaitingForTargetAvailability",
     42    "WaitingForStartTime",
     43    "WaitingForDeletion",
     44    "Running",
     45    "Paused",
     46    "Finished",
     47    "Aborted"
     48};
     49
     50COMPILE_ASSERT(static_cast<int>(WebCore::CCActiveAnimation::RunStateEnumSize) == WTF_ARRAY_LENGTH(s_runStateNames), RunState_names_match_enum);
     51
     52// This should match the TargetProperty enum.
     53static const char* const s_targetPropertyNames[] = {
     54    "Transform",
     55    "Opacity"
     56};
     57
     58COMPILE_ASSERT(static_cast<int>(WebCore::CCActiveAnimation::TargetPropertyEnumSize) == WTF_ARRAY_LENGTH(s_targetPropertyNames), TargetProperty_names_match_enum);
     59
     60} // namespace
    3261
    3362namespace WebCore {
     
    5281    , m_pauseTime(0)
    5382    , m_totalPausedTime(0)
     83    , m_isControllingInstance(false)
    5484{
    5585}
     
    5787CCActiveAnimation::~CCActiveAnimation()
    5888{
     89    if (m_runState == Running || m_runState == Paused)
     90        setRunState(Aborted, 0);
    5991}
    6092
     
    6395    if (m_suspended)
    6496        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];
    65111
    66112    if (runState == Running && m_runState == Paused)
     
    69115        m_pauseTime = monotonicTime;
    70116    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));
    71127}
    72128
     
    140196}
    141197
    142 PassOwnPtr<CCActiveAnimation> CCActiveAnimation::cloneForImplThread() const
     198PassOwnPtr<CCActiveAnimation> CCActiveAnimation::clone(InstanceType instanceType) const
     199{
     200    return cloneAndInitialize(instanceType, m_runState, m_startTime);
     201}
     202
     203PassOwnPtr<CCActiveAnimation> CCActiveAnimation::cloneAndInitialize(InstanceType instanceType, RunState initialRunState, double startTime) const
    143204{
    144205    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;
    146207    toReturn->m_iterations = m_iterations;
    147     toReturn->m_startTime = m_startTime;
     208    toReturn->m_startTime = startTime;
    148209    toReturn->m_pauseTime = m_pauseTime;
    149210    toReturn->m_totalPausedTime = m_totalPausedTime;
    150211    toReturn->m_timeOffset = m_timeOffset;
    151212    toReturn->m_alternatesDirection = m_alternatesDirection;
     213    toReturn->m_isControllingInstance = instanceType == ControllingInstance;
    152214    return toReturn.release();
    153215}
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCActiveAnimation.h

    r124239 r125892  
    5757        Paused,
    5858        Finished,
    59         Aborted
     59        Aborted,
     60        // This sentinel must be last.
     61        RunStateEnumSize
    6062    };
    6163
    6264    enum TargetProperty {
    6365        Transform = 0,
    64         Opacity
     66        Opacity,
     67        // This sentinel must be last.
     68        TargetPropertyEnumSize
    6569    };
    6670
     
    113117    double trimTimeToCurrentIteration(double monotonicTime) const;
    114118
    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; }
    116127
    117128    void pushPropertiesTo(CCActiveAnimation*) const;
     
    155166    double m_pauseTime;
    156167    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;
    157177};
    158178
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.cpp

    r121378 r125892  
    201201            continue;
    202202
    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));
    204207        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);
    208208        controllerImpl->addAnimation(toAdd.release());
    209209    }
     
    325325}
    326326
    327 
    328327void CCLayerAnimationController::markAnimationsForDeletion(double monotonicTime, CCAnimationEventsVector* events)
    329328{
     
    370369    controllerImpl->m_activeAnimations.clear();
    371370    for (size_t i = 0; i < m_activeAnimations.size(); ++i) {
    372         OwnPtr<CCActiveAnimation> toAdd(m_activeAnimations[i]->cloneForImplThread());
     371        OwnPtr<CCActiveAnimation> toAdd;
    373372        if (m_activeAnimations[i]->needsSynchronizedStartTime()) {
    374373            // We haven't received an animation started notification yet, so it
    375374            // 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
    379381        controllerImpl->addAnimation(toAdd.release());
    380382    }
     
    414416            }
    415417
     418            // Do nothing for sentinel value.
     419            case CCActiveAnimation::TargetPropertyEnumSize:
     420                ASSERT_NOT_REACHED();
     421
    416422            }
    417423        }
  • trunk/Source/WebKit/chromium/ChangeLog

    r125851 r125892  
     12012-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
    1162012-08-16  Antoine Labour  <piman@chromium.org>
    217
  • trunk/Source/WebKit/chromium/src/WebAnimationImpl.cpp

    r125469 r125892  
    9797PassOwnPtr<WebCore::CCActiveAnimation> WebAnimationImpl::cloneToCCAnimation()
    9898{
    99     OwnPtr<WebCore::CCActiveAnimation> toReturn(m_animation->cloneForImplThread());
     99    OwnPtr<WebCore::CCActiveAnimation> toReturn(m_animation->clone(WebCore::CCActiveAnimation::NonControllingInstance));
    100100    toReturn->setNeedsSynchronizedStartTime(true);
    101101    return toReturn.release();
Note: See TracChangeset for help on using the changeset viewer.