Title: [117960] trunk/Source
Revision
117960
Author
[email protected]
Date
2012-05-22 06:03:33 -0700 (Tue, 22 May 2012)

Log Message

[chromium] Speed up CCLayerTreeHostTestTickAnimationWhileBackgrounded
https://bugs.webkit.org/show_bug.cgi?id=86871

Patch by Ian Vollick <[email protected]> on 2012-05-22
Reviewed by James Robinson.

Source/WebCore:

With this patch, the background animation timer is lazily created,
allowing for different time intervals to be used. In particular, a
very short interval for unit tests.

Unit tests: CCLayerTreeHostTestTickAnimationWhileBackgrounded.runSingleThread
            CCLayerTreeHostTestTickAnimationWhileBackgrounded.runMultiThread

* platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
(WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
(WebCore::CCLayerTreeHostImpl::setBackgroundTickingEnabled):
(WebCore):
(WebCore::CCLayerTreeHostImpl::setVisible):
(WebCore::CCLayerTreeHostImpl::animateLayers):
(WebCore::CCLayerTreeHostImpl::lowFrequencyAnimationInterval):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
(CCLayerTreeHostImpl):
* platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
(WebCore::CCSingleThreadProxy::setVisible):

Source/WebKit/chromium:

Use a shorter time interval for background animation ticking so that
unit tests can run faster.

* tests/CCLayerTreeHostTest.cpp:
(WTF::MockLayerTreeHostImpl::lowFrequencyAnimationInterval):
(MockLayerTreeHostImpl):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (117959 => 117960)


--- trunk/Source/WebCore/ChangeLog	2012-05-22 12:35:18 UTC (rev 117959)
+++ trunk/Source/WebCore/ChangeLog	2012-05-22 13:03:33 UTC (rev 117960)
@@ -1,3 +1,29 @@
+2012-05-22  Ian Vollick  <[email protected]>
+
+        [chromium] Speed up CCLayerTreeHostTestTickAnimationWhileBackgrounded
+        https://bugs.webkit.org/show_bug.cgi?id=86871
+
+        Reviewed by James Robinson.
+
+        With this patch, the background animation timer is lazily created,
+        allowing for different time intervals to be used. In particular, a
+        very short interval for unit tests.
+
+        Unit tests: CCLayerTreeHostTestTickAnimationWhileBackgrounded.runSingleThread
+                    CCLayerTreeHostTestTickAnimationWhileBackgrounded.runMultiThread
+
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
+        (WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
+        (WebCore::CCLayerTreeHostImpl::setBackgroundTickingEnabled):
+        (WebCore):
+        (WebCore::CCLayerTreeHostImpl::setVisible):
+        (WebCore::CCLayerTreeHostImpl::animateLayers):
+        (WebCore::CCLayerTreeHostImpl::lowFrequencyAnimationInterval):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
+        (CCLayerTreeHostImpl):
+        * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
+        (WebCore::CCSingleThreadProxy::setVisible):
+
 2012-05-22  Alexander Pavlov  <[email protected]>
 
         Web Inspector: [Styles] Odd synthetic shorthands may appear in the style

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp (117959 => 117960)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2012-05-22 12:35:18 UTC (rev 117959)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2012-05-22 13:03:33 UTC (rev 117960)
@@ -43,11 +43,11 @@
 #include "cc/CCLayerTreeHostCommon.h"
 #include "cc/CCPageScaleAnimation.h"
 #include "cc/CCRenderSurfaceDrawQuad.h"
+#include "cc/CCSingleThreadProxy.h"
 #include "cc/CCThreadTask.h"
 #include <wtf/CurrentTime.h>
 
 namespace {
-const double lowFrequencyAnimationInterval = 1;
 
 void didVisibilityChange(WebCore::CCLayerTreeHostImpl* id, bool visible)
 {
@@ -78,6 +78,11 @@
 
     virtual void onTimerTick() OVERRIDE
     {
+        // FIXME: We require that animate be called on the impl thread. This
+        // avoids asserts in single threaded mode. Ideally background ticking
+        // would be handled by the proxy/scheduler and this could be removed.
+        DebugScopedSetImplThread impl;
+
         m_layerTreeHostImpl->animate(monotonicallyIncreasingTime(), currentTime());
     }
 
@@ -119,7 +124,6 @@
     , m_maxPageScale(0)
     , m_needsAnimateLayers(false)
     , m_pinchGestureActive(false)
-    , m_timeSourceClientAdapter(CCLayerTreeHostImplTimeSourceAdapter::create(this, CCDelayBasedTimeSource::create(lowFrequencyAnimationInterval, CCProxy::currentThread())))
     , m_fpsCounter(CCFrameRateCounter::create())
     , m_debugRectHistory(CCDebugRectHistory::create())
 {
@@ -370,6 +374,15 @@
     needsAnimateLayers = subtreeNeedsAnimateLayers;
 }
 
+void CCLayerTreeHostImpl::setBackgroundTickingEnabled(bool enabled)
+{
+    // Lazily create the timeSource adapter so that we can vary the interval for testing.
+    if (!m_timeSourceClientAdapter)
+        m_timeSourceClientAdapter = CCLayerTreeHostImplTimeSourceAdapter::create(this, CCDelayBasedTimeSource::create(lowFrequencyAnimationInterval(), CCProxy::currentThread()));
+
+    m_timeSourceClientAdapter->setActive(enabled);
+}
+
 IntSize CCLayerTreeHostImpl::contentSize() const
 {
     // TODO(aelias): Hardcoding the first child here is weird. Think of
@@ -514,6 +527,8 @@
 
 void CCLayerTreeHostImpl::setVisible(bool visible)
 {
+    ASSERT(CCProxy::isImplThread());
+
     if (m_visible == visible)
         return;
     m_visible = visible;
@@ -524,8 +539,7 @@
 
     m_layerRenderer->setVisible(visible);
 
-    const bool shouldTickInBackground = !visible && m_needsAnimateLayers;
-    m_timeSourceClientAdapter->setActive(shouldTickInBackground);
+    setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers);
 }
 
 bool CCLayerTreeHostImpl::initializeLayerRenderer(PassRefPtr<GraphicsContext3D> context, TextureUploaderOption textureUploader)
@@ -863,10 +877,14 @@
     if (didAnimate)
         m_client->setNeedsRedrawOnImplThread();
 
-    const bool shouldTickInBackground = m_needsAnimateLayers && !m_visible;
-    m_timeSourceClientAdapter->setActive(shouldTickInBackground);
+    setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers);
 }
 
+double CCLayerTreeHostImpl::lowFrequencyAnimationInterval() const
+{
+    return 1;
+}
+
 void CCLayerTreeHostImpl::sendDidLoseContextRecursive(CCLayerImpl* current)
 {
     ASSERT(current);

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h (117959 => 117960)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h	2012-05-22 12:35:18 UTC (rev 117959)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h	2012-05-22 13:03:33 UTC (rev 117960)
@@ -177,6 +177,9 @@
     // Virtual for testing.
     virtual void animateLayers(double monotonicTime, double wallClockTime);
 
+    // Virtual for testing. Measured in seconds.
+    virtual double lowFrequencyAnimationInterval() const;
+
     CCLayerTreeHostImplClient* m_client;
     int m_sourceFrameNumber;
     int m_frameNumber;
@@ -197,6 +200,7 @@
     // if this helper function is called.
     bool calculateRenderPasses(CCRenderPassList&, CCLayerList& renderSurfaceLayerList);
     void animateLayersRecursive(CCLayerImpl*, double monotonicTime, double wallClockTime, CCAnimationEventsVector*, bool& didAnimate, bool& needsAnimateLayers);
+    void setBackgroundTickingEnabled(bool);
     IntSize contentSize() const;
     void sendDidLoseContextRecursive(CCLayerImpl*);
     void clearRenderSurfacesOnCCLayerImplRecursive(CCLayerImpl*);

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp (117959 => 117960)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp	2012-05-22 12:35:18 UTC (rev 117959)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp	2012-05-22 13:03:33 UTC (rev 117960)
@@ -273,15 +273,19 @@
 
 void CCSingleThreadProxy::setVisible(bool visible)
 {
+    DebugScopedSetImplThread impl;
     m_layerTreeHostImpl->setVisible(visible);
 
     if (!visible) {
-        DebugScopedSetImplThread impl;
+
         m_layerTreeHost->didBecomeInvisibleOnImplThread(m_layerTreeHostImpl.get());
         return;
     }
 
-    setNeedsCommit();
+    {
+        DebugScopedSetMainThread main;
+        setNeedsCommit();
+    }
 }
 
 void CCSingleThreadProxy::didAddAnimation()

Modified: trunk/Source/WebKit/chromium/ChangeLog (117959 => 117960)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-05-22 12:35:18 UTC (rev 117959)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-05-22 13:03:33 UTC (rev 117960)
@@ -1,3 +1,17 @@
+2012-05-22  Ian Vollick  <[email protected]>
+
+        [chromium] Speed up CCLayerTreeHostTestTickAnimationWhileBackgrounded
+        https://bugs.webkit.org/show_bug.cgi?id=86871
+
+        Reviewed by James Robinson.
+
+        Use a shorter time interval for background animation ticking so that
+        unit tests can run faster.
+
+        * tests/CCLayerTreeHostTest.cpp:
+        (WTF::MockLayerTreeHostImpl::lowFrequencyAnimationInterval):
+        (MockLayerTreeHostImpl):
+
 2012-05-21  Alexandre Elias  <[email protected]>
 
         [chromium] Simplify RTL root layer adjustment

Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp (117959 => 117960)


--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp	2012-05-22 12:35:18 UTC (rev 117959)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp	2012-05-22 13:03:33 UTC (rev 117960)
@@ -135,6 +135,11 @@
         m_testHooks->animateLayers(this, monotonicTime);
     }
 
+    virtual double lowFrequencyAnimationInterval() const
+    {
+        return 1.0 / 60;
+    }
+
 private:
     MockLayerTreeHostImpl(TestHooks* testHooks, const CCSettings& settings, CCLayerTreeHostImplClient* client)
         : CCLayerTreeHostImpl(settings, client)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to