Changeset 116594 in webkit


Ignore:
Timestamp:
May 9, 2012 6:52:56 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Ensure animations get ticked at least once when added.
https://bugs.webkit.org/show_bug.cgi?id=86013

Patch by Ian Vollick <vollick@chromium.org> on 2012-05-09
Reviewed by James Robinson.

Source/WebCore:

Tested in

CCLayerTreeHostTestTickAnimationWhileBackgrounded.runSingleThreaded
CCLayerTreeHostTestAddAnimationWithTimingFunction.runSingleThreaded
CCLayerTreeHostTestSynchronizeAnimationStartTimes.runSingleThreaded
CCLayerTreeHostTestAnimationFinishedEvents.runSingleThreaded

  • platform/graphics/chromium/LayerChromium.cpp:

(WebCore::LayerChromium::addAnimation):

  • platform/graphics/chromium/cc/CCLayerAnimationController.cpp:

(WebCore::CCLayerAnimationController::pushNewAnimationsToImplThread):

  • platform/graphics/chromium/cc/CCLayerTreeHost.cpp:

(WebCore::CCLayerTreeHost::finishCommitOnImplThread):
(WebCore::CCLayerTreeHost::didAddAnimation):
(WebCore):
(WebCore::CCLayerTreeHost::didBecomeInvisibleOnImplThread):

  • platform/graphics/chromium/cc/CCLayerTreeHost.h:

(CCLayerTreeHost):

  • platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:

(WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):

  • platform/graphics/chromium/cc/CCProxy.h:

(CCProxy):

  • platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:

(CCSingleThreadProxyAnimationTimer):
(WebCore::CCSingleThreadProxyAnimationTimer::create):
(WebCore::CCSingleThreadProxyAnimationTimer::CCSingleThreadProxyAnimationTimer):
(WebCore):
(WebCore::CCSingleThreadProxy::CCSingleThreadProxy):
(WebCore::CCSingleThreadProxy::didAddAnimation):
(WebCore::CCSingleThreadProxy::doComposite):

  • platform/graphics/chromium/cc/CCSingleThreadProxy.h:

(WebCore):

  • platform/graphics/chromium/cc/CCThreadProxy.h:

Source/WebKit/chromium:

  • tests/CCLayerTreeHostTest.cpp:

(WTF::CCLayerTreeHostTestTickAnimationWhileBackgrounded::animateLayers):
(WTF):

Location:
trunk/Source
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r116592 r116594  
     12012-05-09  Ian Vollick  <vollick@chromium.org>
     2
     3        [chromium] Ensure animations get ticked at least once when added.
     4        https://bugs.webkit.org/show_bug.cgi?id=86013
     5
     6        Reviewed by James Robinson.
     7
     8        Tested in
     9          CCLayerTreeHostTestTickAnimationWhileBackgrounded.runSingleThreaded
     10          CCLayerTreeHostTestAddAnimationWithTimingFunction.runSingleThreaded
     11          CCLayerTreeHostTestSynchronizeAnimationStartTimes.runSingleThreaded
     12          CCLayerTreeHostTestAnimationFinishedEvents.runSingleThreaded
     13
     14        * platform/graphics/chromium/LayerChromium.cpp:
     15        (WebCore::LayerChromium::addAnimation):
     16        * platform/graphics/chromium/cc/CCLayerAnimationController.cpp:
     17        (WebCore::CCLayerAnimationController::pushNewAnimationsToImplThread):
     18        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
     19        (WebCore::CCLayerTreeHost::finishCommitOnImplThread):
     20        (WebCore::CCLayerTreeHost::didAddAnimation):
     21        (WebCore):
     22        (WebCore::CCLayerTreeHost::didBecomeInvisibleOnImplThread):
     23        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
     24        (CCLayerTreeHost):
     25        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
     26        (WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
     27        * platform/graphics/chromium/cc/CCProxy.h:
     28        (CCProxy):
     29        * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
     30        (CCSingleThreadProxyAnimationTimer):
     31        (WebCore::CCSingleThreadProxyAnimationTimer::create):
     32        (WebCore::CCSingleThreadProxyAnimationTimer::CCSingleThreadProxyAnimationTimer):
     33        (WebCore):
     34        (WebCore::CCSingleThreadProxy::CCSingleThreadProxy):
     35        (WebCore::CCSingleThreadProxy::didAddAnimation):
     36        (WebCore::CCSingleThreadProxy::doComposite):
     37        * platform/graphics/chromium/cc/CCSingleThreadProxy.h:
     38        (WebCore):
     39        * platform/graphics/chromium/cc/CCThreadProxy.h:
     40
    1412012-05-09  Adam Barth  <abarth@webkit.org>
    242
  • trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp

    r116195 r116594  
    601601
    602602    bool addedAnimation = m_layerAnimationController->addAnimation(values, boxSize, animation, animationId, groupId, timeOffset);
    603     if (addedAnimation)
     603    if (addedAnimation) {
     604        m_layerTreeHost->didAddAnimation();
    604605        setNeedsCommit();
     606    }
    605607    return addedAnimation;
    606608}
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.cpp

    r116554 r116594  
    282282        // The new animation should be set to run as soon as possible.
    283283        toAdd->setRunState(CCActiveAnimation::WaitingForTargetAvailability, 0);
     284        toAdd->setStartTime(0);
    284285        controllerImpl->add(toAdd.release());
    285286    }
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp

    r116316 r116594  
    234234    // We may have added an animation during the tree sync. This will cause both layer tree hosts
    235235    // to visit their controllers.
    236     if (rootLayer()) {
     236    if (rootLayer() && m_needsAnimateLayers)
    237237        hostImpl->setNeedsAnimateLayers();
    238         m_needsAnimateLayers = true;
    239     }
    240238
    241239    hostImpl->setSourceFrameNumber(frameNumber());
     
    338336    ASSERT(CCThreadProxy::isMainThread());
    339337    setAnimationEventsRecursive(*events, m_rootLayer.get(), wallClockTime);
     338}
     339
     340void CCLayerTreeHost::didAddAnimation()
     341{
     342    m_needsAnimateLayers = true;
     343    m_proxy->didAddAnimation();
    340344}
    341345
     
    408412    // We may have added an animation during the tree sync. This will cause both layer tree hosts
    409413    // to visit their controllers.
    410     if (rootLayer()) {
     414    if (rootLayer() && m_needsAnimateLayers)
    411415        hostImpl->setNeedsAnimateLayers();
    412         m_needsAnimateLayers = true;
    413     }
    414416}
    415417
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h

    r115881 r116594  
    199199
    200200    void setAnimationEvents(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime);
     201    void didAddAnimation();
    201202
    202203    LayerChromium* rootLayer() { return m_rootLayer.get(); }
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp

    r116587 r116594  
    120120    , m_needsAnimateLayers(false)
    121121    , m_pinchGestureActive(false)
    122     , m_timeSourceClientAdapter(CCLayerTreeHostImplTimeSourceAdapter::create(this, CCDelayBasedTimeSource::create(lowFrequencyAnimationInterval * 1000.0, CCProxy::currentThread())))
     122    , m_timeSourceClientAdapter(CCLayerTreeHostImplTimeSourceAdapter::create(this, CCDelayBasedTimeSource::create(lowFrequencyAnimationInterval, CCProxy::currentThread())))
    123123    , m_fpsCounter(CCFrameRateCounter::create())
    124124    , m_debugRectHistory(CCDebugRectHistory::create())
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h

    r115355 r116594  
    8787    virtual void setVisible(bool) = 0;
    8888
     89    virtual void didAddAnimation() = 0;
     90
    8991    virtual bool commitRequested() const = 0;
    9092
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp

    r116587 r116594  
    3333#include "cc/CCLayerTreeHost.h"
    3434#include "cc/CCTextureUpdater.h"
     35#include "cc/CCTimer.h"
    3536#include <wtf/CurrentTime.h>
    3637
     
    5758};
    5859
     60class CCSingleThreadProxyAnimationTimer : public CCTimer, CCTimerClient {
     61public:
     62    static PassOwnPtr<CCSingleThreadProxyAnimationTimer> create(CCSingleThreadProxy* proxy) { return adoptPtr(new CCSingleThreadProxyAnimationTimer(proxy)); }
     63
     64    virtual void onTimerFired() OVERRIDE
     65    {
     66        m_proxy->compositeImmediately();
     67    }
     68
     69private:
     70    explicit CCSingleThreadProxyAnimationTimer(CCSingleThreadProxy* proxy)
     71        : CCTimer(CCProxy::mainThread(), this)
     72        , m_proxy(proxy)
     73    {
     74    }
     75
     76    CCSingleThreadProxy* m_proxy;
     77};
     78
     79// Measured in seconds.
     80static const double animationTimerDelay = 1 / 60.0;
     81
    5982PassOwnPtr<CCProxy> CCSingleThreadProxy::create(CCLayerTreeHost* layerTreeHost)
    6083{
     
    6689    , m_contextLost(false)
    6790    , m_compositorIdentifier(-1)
     91    , m_animationTimer(CCSingleThreadProxyAnimationTimer::create(this))
    6892    , m_layerRendererInitialized(false)
    6993    , m_nextFrameIsNewlyCommittedFrame(false)
     
    277301}
    278302
     303void CCSingleThreadProxy::didAddAnimation()
     304{
     305    m_animationTimer->startOneShot(animationTimerDelay);
     306}
     307
    279308void CCSingleThreadProxy::stop()
    280309{
     
    346375    ASSERT(!m_contextLost);
    347376    {
    348       DebugScopedSetImplThread impl;
    349       double monotonicTime = monotonicallyIncreasingTime();
    350       double wallClockTime = currentTime();
    351       m_layerTreeHostImpl->animate(monotonicTime, wallClockTime);
    352 
    353       // We guard prepareToDraw() with canDraw() because it always returns a valid frame, so can only
    354       // be used when such a frame is possible. Since drawLayers() depends on the result of
    355       // prepareToDraw(), it is guarded on canDraw() as well.
    356       if (!m_layerTreeHostImpl->canDraw())
    357           return false;
    358 
    359       CCLayerTreeHostImpl::FrameData frame;
    360       m_layerTreeHostImpl->prepareToDraw(frame);
    361       m_layerTreeHostImpl->drawLayers(frame);
    362       m_layerTreeHostImpl->didDrawAllLayers(frame);
     377        DebugScopedSetImplThread impl;
     378        double monotonicTime = monotonicallyIncreasingTime();
     379        double wallClockTime = currentTime();
     380
     381        m_layerTreeHostImpl->animate(monotonicTime, wallClockTime);
     382
     383        // We guard prepareToDraw() with canDraw() because it always returns a valid frame, so can only
     384        // be used when such a frame is possible. Since drawLayers() depends on the result of
     385        // prepareToDraw(), it is guarded on canDraw() as well.
     386        if (!m_layerTreeHostImpl->canDraw() || !m_layerTreeHostImpl->visible())
     387            return false;
     388
     389        CCLayerTreeHostImpl::FrameData frame;
     390        m_layerTreeHostImpl->prepareToDraw(frame);
     391        m_layerTreeHostImpl->drawLayers(frame);
     392        m_layerTreeHostImpl->didDrawAllLayers(frame);
    363393    }
    364394
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h

    r115881 r116594  
    3636
    3737class CCLayerTreeHost;
     38class CCSingleThreadProxyAnimationTimer;
    3839
    3940class CCSingleThreadProxy : public CCProxy, CCLayerTreeHostImplClient {
     
    6061    virtual bool commitRequested() const OVERRIDE;
    6162    virtual void setVisible(bool) OVERRIDE;
     63    virtual void didAddAnimation() OVERRIDE;
    6264    virtual void start() OVERRIDE;
    6365    virtual void stop() OVERRIDE;
     
    9496    // be used for anything else.
    9597    RefPtr<GraphicsContext3D> m_contextBeforeInitialization;
     98
     99    OwnPtr<CCSingleThreadProxyAnimationTimer> m_animationTimer;
    96100
    97101    // Used on the CCThread, but checked on main thread during initialization/shutdown.
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h

    r115881 r116594  
    6969    virtual bool commitRequested() const OVERRIDE;
    7070    virtual void setVisible(bool) OVERRIDE;
     71    virtual void didAddAnimation() OVERRIDE { }
    7172    virtual void start() OVERRIDE;
    7273    virtual void stop() OVERRIDE;
  • trunk/Source/WebKit/chromium/ChangeLog

    r116592 r116594  
     12012-05-09  Ian Vollick  <vollick@chromium.org>
     2
     3        [chromium] Ensure animations get ticked at least once when added.
     4        https://bugs.webkit.org/show_bug.cgi?id=86013
     5
     6        Reviewed by James Robinson.
     7
     8        * tests/CCLayerTreeHostTest.cpp:
     9        (WTF::CCLayerTreeHostTestTickAnimationWhileBackgrounded::animateLayers):
     10        (WTF):
     11
    1122012-05-09  Adam Barth  <abarth@webkit.org>
    213
  • trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp

    r116587 r116594  
    11361136    virtual void animateLayers(CCLayerTreeHostImpl* layerTreeHostImpl, double monotonicTime)
    11371137    {
    1138         if (!m_numAnimates) {
    1139             // We have a long animation running. It should continue to tick even if we are not visible.
    1140             postSetVisibleToMainThread(false);
     1138        if (m_numAnimates < 2) {
     1139            if (!m_numAnimates) {
     1140                // We have a long animation running. It should continue to tick even if we are not visible.
     1141                postSetVisibleToMainThread(false);
     1142            }
    11411143            m_numAnimates++;
    11421144            return;
     
    11531155};
    11541156
    1155 #if OS(WINDOWS)
    1156 // http://webkit.org/b/74623
    1157 TEST_F(CCLayerTreeHostTestTickAnimationWhileBackgrounded, FLAKY_runMultiThread)
    1158 #else
    1159 TEST_F(CCLayerTreeHostTestTickAnimationWhileBackgrounded, runMultiThread)
    1160 #endif
    1161 {
    1162     runTestThreaded();
    1163 }
     1157SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestTickAnimationWhileBackgrounded)
    11641158
    11651159// Ensures that animations continue to be ticked when we are backgrounded.
     
    11961190};
    11971191
    1198 #if OS(WINDOWS)
    1199 // http://webkit.org/b/74623
    1200 TEST_F(CCLayerTreeHostTestAddAnimationWithTimingFunction, FLAKY_runMultiThread)
    1201 #else
    1202 TEST_F(CCLayerTreeHostTestAddAnimationWithTimingFunction, runMultiThread)
    1203 #endif
    1204 {
    1205     runTestThreaded();
    1206 }
     1192SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestAddAnimationWithTimingFunction)
    12071193
    12081194// Ensures that when opacity is being animated, this value does not cause the subtree to be skipped.
     
    12811267};
    12821268
    1283 TEST_F(CCLayerTreeHostTestSynchronizeAnimationStartTimes, runMultiThread)
    1284 {
    1285     runTestThreaded();
    1286 }
     1269SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestSynchronizeAnimationStartTimes)
    12871270
    12881271// Ensures that main thread animations have their start times synchronized with impl thread animations.
     
    13101293};
    13111294
    1312 TEST_F(CCLayerTreeHostTestAnimationFinishedEvents, runMultiThread)
    1313 {
    1314     runTestThreaded();
    1315 }
     1295SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestAnimationFinishedEvents)
    13161296
    13171297class CCLayerTreeHostTestScrollSimple : public CCLayerTreeHostTestThreadOnly {
Note: See TracChangeset for help on using the changeset viewer.