Diff
Modified: branches/chromium/1132/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp (117499 => 117500)
--- branches/chromium/1132/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp 2012-05-17 21:41:37 UTC (rev 117499)
+++ branches/chromium/1132/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp 2012-05-17 21:46:02 UTC (rev 117500)
@@ -595,8 +595,10 @@
return false;
bool addedAnimation = m_layerAnimationController->addAnimation(values, boxSize, animation, animationId, groupId, timeOffset);
- if (addedAnimation)
+ if (addedAnimation) {
+ m_layerTreeHost->didAddAnimation();
setNeedsCommit();
+ }
return addedAnimation;
}
Modified: branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp (117499 => 117500)
--- branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2012-05-17 21:41:37 UTC (rev 117499)
+++ branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2012-05-17 21:46:02 UTC (rev 117500)
@@ -233,10 +233,8 @@
// We may have added an animation during the tree sync. This will cause both layer tree hosts
// to visit their controllers.
- if (rootLayer()) {
+ if (rootLayer() && m_needsAnimateLayers)
hostImpl->setNeedsAnimateLayers();
- m_needsAnimateLayers = true;
- }
hostImpl->setSourceFrameNumber(frameNumber());
hostImpl->setViewportSize(viewportSize());
@@ -339,6 +337,12 @@
setAnimationEventsRecursive(*events, m_rootLayer.get(), wallClockTime);
}
+void CCLayerTreeHost::didAddAnimation()
+{
+ m_needsAnimateLayers = true;
+ m_proxy->didAddAnimation();
+}
+
void CCLayerTreeHost::setRootLayer(PassRefPtr<LayerChromium> rootLayer)
{
if (m_rootLayer == rootLayer)
@@ -407,10 +411,8 @@
// We may have added an animation during the tree sync. This will cause both layer tree hosts
// to visit their controllers.
- if (rootLayer()) {
+ if (rootLayer() && m_needsAnimateLayers)
hostImpl->setNeedsAnimateLayers();
- m_needsAnimateLayers = true;
- }
}
void CCLayerTreeHost::setContentsMemoryAllocationLimitBytes(size_t bytes)
Modified: branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h (117499 => 117500)
--- branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h 2012-05-17 21:41:37 UTC (rev 117499)
+++ branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h 2012-05-17 21:46:02 UTC (rev 117500)
@@ -198,6 +198,7 @@
bool commitRequested() const;
void setAnimationEvents(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime);
+ void didAddAnimation();
LayerChromium* rootLayer() { return m_rootLayer.get(); }
const LayerChromium* rootLayer() const { return m_rootLayer.get(); }
Modified: branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp (117499 => 117500)
--- branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp 2012-05-17 21:41:37 UTC (rev 117499)
+++ branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp 2012-05-17 21:46:02 UTC (rev 117500)
@@ -119,7 +119,7 @@
, m_maxPageScale(0)
, m_needsAnimateLayers(false)
, m_pinchGestureActive(false)
- , m_timeSourceClientAdapter(CCLayerTreeHostImplTimeSourceAdapter::create(this, CCDelayBasedTimeSource::create(lowFrequencyAnimationInterval * 1000.0, CCProxy::currentThread())))
+ , m_timeSourceClientAdapter(CCLayerTreeHostImplTimeSourceAdapter::create(this, CCDelayBasedTimeSource::create(lowFrequencyAnimationInterval, CCProxy::currentThread())))
, m_fpsCounter(CCFrameRateCounter::create())
, m_debugRectHistory(CCDebugRectHistory::create())
{
Modified: branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h (117499 => 117500)
--- branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h 2012-05-17 21:41:37 UTC (rev 117499)
+++ branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h 2012-05-17 21:46:02 UTC (rev 117500)
@@ -86,6 +86,8 @@
virtual void setNeedsRedraw() = 0;
virtual void setVisible(bool) = 0;
+ virtual void didAddAnimation() = 0;
+
virtual bool commitRequested() const = 0;
virtual void start() = 0; // Must be called before using the proxy.
Modified: branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp (117499 => 117500)
--- branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp 2012-05-17 21:41:37 UTC (rev 117499)
+++ branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp 2012-05-17 21:46:02 UTC (rev 117500)
@@ -32,6 +32,7 @@
#include "cc/CCFontAtlas.h"
#include "cc/CCLayerTreeHost.h"
#include "cc/CCTextureUpdater.h"
+#include "cc/CCTimer.h"
#include <wtf/CurrentTime.h>
using namespace std;
@@ -39,6 +40,28 @@
namespace WebCore {
+class CCSingleThreadProxyAnimationTimer : public CCTimer, CCTimerClient {
+public:
+ static PassOwnPtr<CCSingleThreadProxyAnimationTimer> create(CCSingleThreadProxy* proxy) { return adoptPtr(new CCSingleThreadProxyAnimationTimer(proxy)); }
+
+ virtual void onTimerFired() OVERRIDE
+ {
+ m_proxy->compositeImmediately();
+ }
+
+private:
+ explicit CCSingleThreadProxyAnimationTimer(CCSingleThreadProxy* proxy)
+ : CCTimer(CCProxy::mainThread(), this)
+ , m_proxy(proxy)
+ {
+ }
+
+ CCSingleThreadProxy* m_proxy;
+};
+
+// Measured in seconds.
+static const double animationTimerDelay = 1 / 60.0;
+
PassOwnPtr<CCProxy> CCSingleThreadProxy::create(CCLayerTreeHost* layerTreeHost)
{
return adoptPtr(new CCSingleThreadProxy(layerTreeHost));
@@ -48,6 +71,7 @@
: m_layerTreeHost(layerTreeHost)
, m_contextLost(false)
, m_compositorIdentifier(-1)
+ , m_animationTimer(CCSingleThreadProxyAnimationTimer::create(this))
, m_layerRendererInitialized(false)
, m_nextFrameIsNewlyCommittedFrame(false)
{
@@ -253,6 +277,11 @@
setNeedsCommit();
}
+void CCSingleThreadProxy::didAddAnimation()
+{
+ m_animationTimer->startOneShot(animationTimerDelay);
+}
+
void CCSingleThreadProxy::stop()
{
TRACE_EVENT("CCSingleThreadProxy::stop", this, 0);
@@ -322,21 +351,22 @@
{
ASSERT(!m_contextLost);
{
- DebugScopedSetImplThread impl;
- double monotonicTime = monotonicallyIncreasingTime();
- double wallClockTime = currentTime();
- m_layerTreeHostImpl->animate(monotonicTime, wallClockTime);
+ DebugScopedSetImplThread impl;
+ double monotonicTime = monotonicallyIncreasingTime();
+ double wallClockTime = currentTime();
- // We guard prepareToDraw() with canDraw() because it always returns a valid frame, so can only
- // be used when such a frame is possible. Since drawLayers() depends on the result of
- // prepareToDraw(), it is guarded on canDraw() as well.
- if (!m_layerTreeHostImpl->canDraw())
- return false;
+ m_layerTreeHostImpl->animate(monotonicTime, wallClockTime);
- CCLayerTreeHostImpl::FrameData frame;
- m_layerTreeHostImpl->prepareToDraw(frame);
- m_layerTreeHostImpl->drawLayers(frame);
- m_layerTreeHostImpl->didDrawAllLayers(frame);
+ // We guard prepareToDraw() with canDraw() because it always returns a valid frame, so can only
+ // be used when such a frame is possible. Since drawLayers() depends on the result of
+ // prepareToDraw(), it is guarded on canDraw() as well.
+ if (!m_layerTreeHostImpl->canDraw())
+ return false;
+
+ CCLayerTreeHostImpl::FrameData frame;
+ m_layerTreeHostImpl->prepareToDraw(frame);
+ m_layerTreeHostImpl->drawLayers(frame);
+ m_layerTreeHostImpl->didDrawAllLayers(frame);
}
if (m_layerTreeHostImpl->isContextLost()) {
Modified: branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h (117499 => 117500)
--- branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h 2012-05-17 21:41:37 UTC (rev 117499)
+++ branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h 2012-05-17 21:46:02 UTC (rev 117500)
@@ -35,6 +35,7 @@
namespace WebCore {
class CCLayerTreeHost;
+class CCSingleThreadProxyAnimationTimer;
class CCSingleThreadProxy : public CCProxy, CCLayerTreeHostImplClient {
public:
@@ -59,6 +60,7 @@
virtual void setNeedsRedraw() OVERRIDE;
virtual bool commitRequested() const OVERRIDE;
virtual void setVisible(bool) OVERRIDE;
+ virtual void didAddAnimation() OVERRIDE;
virtual void start() OVERRIDE;
virtual void stop() OVERRIDE;
virtual size_t maxPartialTextureUpdates() const OVERRIDE { return std::numeric_limits<size_t>::max(); }
@@ -94,6 +96,8 @@
// be used for anything else.
RefPtr<GraphicsContext3D> m_contextBeforeInitialization;
+ OwnPtr<CCSingleThreadProxyAnimationTimer> m_animationTimer;
+
// Used on the CCThread, but checked on main thread during initialization/shutdown.
OwnPtr<CCLayerTreeHostImpl> m_layerTreeHostImpl;
bool m_layerRendererInitialized;
Modified: branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h (117499 => 117500)
--- branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h 2012-05-17 21:41:37 UTC (rev 117499)
+++ branches/chromium/1132/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h 2012-05-17 21:46:02 UTC (rev 117500)
@@ -68,6 +68,7 @@
virtual void setNeedsRedraw() OVERRIDE;
virtual bool commitRequested() const OVERRIDE;
virtual void setVisible(bool) OVERRIDE;
+ virtual void didAddAnimation() OVERRIDE { }
virtual void start() OVERRIDE;
virtual void stop() OVERRIDE;
virtual size_t maxPartialTextureUpdates() const OVERRIDE;
Modified: branches/chromium/1132/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp (117499 => 117500)
--- branches/chromium/1132/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp 2012-05-17 21:41:37 UTC (rev 117499)
+++ branches/chromium/1132/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp 2012-05-17 21:46:02 UTC (rev 117500)
@@ -1135,9 +1135,11 @@
virtual void animateLayers(CCLayerTreeHostImpl* layerTreeHostImpl, double monotonicTime)
{
- if (!m_numAnimates) {
- // We have a long animation running. It should continue to tick even if we are not visible.
- postSetVisibleToMainThread(false);
+ if (m_numAnimates < 2) {
+ if (!m_numAnimates) {
+ // We have a long animation running. It should continue to tick even if we are not visible.
+ postSetVisibleToMainThread(false);
+ }
m_numAnimates++;
return;
}
@@ -1270,10 +1272,7 @@
CCLayerTreeHostImpl* m_layerTreeHostImpl;
};
-TEST_F(CCLayerTreeHostTestSynchronizeAnimationStartTimes, runMultiThread)
-{
- runTestThreaded();
-}
+SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestSynchronizeAnimationStartTimes)
// Ensures that main thread animations have their start times synchronized with impl thread animations.
class CCLayerTreeHostTestAnimationFinishedEvents : public CCLayerTreeHostTestThreadOnly {
@@ -1299,10 +1298,7 @@
private:
};
-TEST_F(CCLayerTreeHostTestAnimationFinishedEvents, runMultiThread)
-{
- runTestThreaded();
-}
+SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestAnimationFinishedEvents)
class CCLayerTreeHostTestScrollSimple : public CCLayerTreeHostTestThreadOnly {
public: