Changeset 117171 in webkit


Ignore:
Timestamp:
May 15, 2012 3:51:01 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-15
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/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:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r117170 r117171  
     12012-05-15  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/CCLayerTreeHost.cpp:
     17        (WebCore::CCLayerTreeHost::finishCommitOnImplThread):
     18        (WebCore::CCLayerTreeHost::didAddAnimation):
     19        (WebCore):
     20        (WebCore::CCLayerTreeHost::didBecomeInvisibleOnImplThread):
     21        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
     22        (CCLayerTreeHost):
     23        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
     24        (WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
     25        * platform/graphics/chromium/cc/CCProxy.h:
     26        (CCProxy):
     27        * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
     28        (CCSingleThreadProxyAnimationTimer):
     29        (WebCore::CCSingleThreadProxyAnimationTimer::create):
     30        (WebCore::CCSingleThreadProxyAnimationTimer::CCSingleThreadProxyAnimationTimer):
     31        (WebCore):
     32        (WebCore::CCSingleThreadProxy::CCSingleThreadProxy):
     33        (WebCore::CCSingleThreadProxy::didAddAnimation):
     34        (WebCore::CCSingleThreadProxy::doComposite):
     35        * platform/graphics/chromium/cc/CCSingleThreadProxy.h:
     36        (WebCore):
     37        * platform/graphics/chromium/cc/CCThreadProxy.h:
     38
    1392012-05-15  Alexandre Elias  <aelias@google.com>
    240
  • trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp

    r116786 r117171  
    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/CCLayerTreeHost.cpp

    r116714 r117171  
    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

    r116722 r117171  
    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

    r116779 r117171  
    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

    r116979 r117171  
    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

    r116979 r117171  
    3333#include "cc/CCLayerTreeHost.h"
    3434#include "cc/CCTextureUpdater.h"
     35#include "cc/CCTimer.h"
    3536#include <wtf/CurrentTime.h>
    3637
     
    3839
    3940namespace WebCore {
     41
     42class CCSingleThreadProxyAnimationTimer : public CCTimer, CCTimerClient {
     43public:
     44    static PassOwnPtr<CCSingleThreadProxyAnimationTimer> create(CCSingleThreadProxy* proxy) { return adoptPtr(new CCSingleThreadProxyAnimationTimer(proxy)); }
     45
     46    virtual void onTimerFired() OVERRIDE
     47    {
     48        m_proxy->compositeImmediately();
     49    }
     50
     51private:
     52    explicit CCSingleThreadProxyAnimationTimer(CCSingleThreadProxy* proxy)
     53        : CCTimer(CCProxy::mainThread(), this)
     54        , m_proxy(proxy)
     55    {
     56    }
     57
     58    CCSingleThreadProxy* m_proxy;
     59};
     60
     61// Measured in seconds.
     62static const double animationTimerDelay = 1 / 60.0;
    4063
    4164PassOwnPtr<CCProxy> CCSingleThreadProxy::create(CCLayerTreeHost* layerTreeHost)
     
    4871    , m_contextLost(false)
    4972    , m_compositorIdentifier(-1)
     73    , m_animationTimer(CCSingleThreadProxyAnimationTimer::create(this))
    5074    , m_layerRendererInitialized(false)
    5175    , m_nextFrameIsNewlyCommittedFrame(false)
     
    261285}
    262286
     287void CCSingleThreadProxy::didAddAnimation()
     288{
     289    m_animationTimer->startOneShot(animationTimerDelay);
     290}
     291
    263292void CCSingleThreadProxy::stop()
    264293{
     
    332361    ASSERT(!m_contextLost);
    333362    {
    334       DebugScopedSetImplThread impl;
    335       double monotonicTime = monotonicallyIncreasingTime();
    336       double wallClockTime = currentTime();
    337       m_layerTreeHostImpl->animate(monotonicTime, wallClockTime);
    338 
    339       // We guard prepareToDraw() with canDraw() because it always returns a valid frame, so can only
    340       // be used when such a frame is possible. Since drawLayers() depends on the result of
    341       // prepareToDraw(), it is guarded on canDraw() as well.
    342       if (!m_layerTreeHostImpl->canDraw())
    343           return false;
    344 
    345       CCLayerTreeHostImpl::FrameData frame;
    346       m_layerTreeHostImpl->prepareToDraw(frame);
    347       m_layerTreeHostImpl->drawLayers(frame);
    348       m_layerTreeHostImpl->didDrawAllLayers(frame);
     363        DebugScopedSetImplThread impl;
     364        double monotonicTime = monotonicallyIncreasingTime();
     365        double wallClockTime = currentTime();
     366
     367        m_layerTreeHostImpl->animate(monotonicTime, wallClockTime);
     368
     369        // We guard prepareToDraw() with canDraw() because it always returns a valid frame, so can only
     370        // be used when such a frame is possible. Since drawLayers() depends on the result of
     371        // prepareToDraw(), it is guarded on canDraw() as well.
     372        if (!m_layerTreeHostImpl->canDraw())
     373            return false;
     374
     375        CCLayerTreeHostImpl::FrameData frame;
     376        m_layerTreeHostImpl->prepareToDraw(frame);
     377        m_layerTreeHostImpl->drawLayers(frame);
     378        m_layerTreeHostImpl->didDrawAllLayers(frame);
    349379    }
    350380
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h

    r116714 r117171  
    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

    r116714 r117171  
    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

    r117170 r117171  
     12012-05-15  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-15  Alexandre Elias  <aelias@google.com>
    213
  • trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp

    r116714 r117171  
    11411141    virtual void animateLayers(CCLayerTreeHostImpl* layerTreeHostImpl, double monotonicTime)
    11421142    {
    1143         if (!m_numAnimates) {
    1144             // We have a long animation running. It should continue to tick even if we are not visible.
    1145             postSetVisibleToMainThread(false);
     1143        if (m_numAnimates < 2) {
     1144            if (!m_numAnimates) {
     1145                // We have a long animation running. It should continue to tick even if we are not visible.
     1146                postSetVisibleToMainThread(false);
     1147            }
    11461148            m_numAnimates++;
    11471149            return;
     
    11581160};
    11591161
    1160 #if OS(WINDOWS)
    1161 // http://webkit.org/b/74623
    1162 TEST_F(CCLayerTreeHostTestTickAnimationWhileBackgrounded, FLAKY_runMultiThread)
    1163 #else
    1164 TEST_F(CCLayerTreeHostTestTickAnimationWhileBackgrounded, runMultiThread)
    1165 #endif
    1166 {
    1167     runTestThreaded();
    1168 }
     1162SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestTickAnimationWhileBackgrounded)
    11691163
    11701164// Ensures that animations continue to be ticked when we are backgrounded.
     
    12011195};
    12021196
    1203 #if OS(WINDOWS)
    1204 // http://webkit.org/b/74623
    1205 TEST_F(CCLayerTreeHostTestAddAnimationWithTimingFunction, FLAKY_runMultiThread)
    1206 #else
    1207 TEST_F(CCLayerTreeHostTestAddAnimationWithTimingFunction, runMultiThread)
    1208 #endif
    1209 {
    1210     runTestThreaded();
    1211 }
     1197SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestAddAnimationWithTimingFunction)
    12121198
    12131199// Ensures that when opacity is being animated, this value does not cause the subtree to be skipped.
     
    12911277};
    12921278
    1293 TEST_F(CCLayerTreeHostTestSynchronizeAnimationStartTimes, runMultiThread)
    1294 {
    1295     runTestThreaded();
    1296 }
     1279SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestSynchronizeAnimationStartTimes)
    12971280
    12981281// Ensures that main thread animations have their start times synchronized with impl thread animations.
     
    13201303};
    13211304
    1322 TEST_F(CCLayerTreeHostTestAnimationFinishedEvents, runMultiThread)
    1323 {
    1324     runTestThreaded();
    1325 }
     1305SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestAnimationFinishedEvents)
    13261306
    13271307class CCLayerTreeHostTestScrollSimple : public CCLayerTreeHostTestThreadOnly {
Note: See TracChangeset for help on using the changeset viewer.