Title: [104248] trunk/Source
Revision
104248
Author
[email protected]
Date
2012-01-05 17:01:33 -0800 (Thu, 05 Jan 2012)

Log Message

[chromium] Route all animate calls through CCLayerTreeHost in composited mode to simplify rate limiting logic
https://bugs.webkit.org/show_bug.cgi?id=75577

Reviewed by Darin Fisher.

Source/WebCore:

This internalizes the animation rate limiting logic to CCLayerTreeHost and removes the setters/getters for the
m_animating flag. This requires that all animation updates have to go through CCLayerTreeHost to get the right
rate limiting behavior, regardless of which proxy is being used.

* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::updateAnimations):
(WebCore::CCLayerTreeHost::layout):
(WebCore::CCLayerTreeHost::startRateLimiter):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
* platform/graphics/chromium/cc/CCThreadProxy.cpp:
(WebCore::CCThreadProxy::beginFrameAndCommit):

Source/WebKit/chromium:

Routes WebWidget-initiated animate() calls through the CCLayerTreeHost in composited mode. CCLayerTreeHost's
rate limiting logic needs to be aware of when requestAnimationFrame callbacks are run. In threaded mode, the
animate calls are driven from CCThreadProxy and so the CCLayerTreeHost can set whatever state it needs. This
makes the single-threaded mode where the animate calls are driven through the WebWidget interface outside of the
CCProxy's control.

This is a small step towards inverting the scheduling control from the WebWidget to the compositor.

* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::animate):
(WebKit::WebViewImpl::updateAnimations):
* src/WebViewImpl.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (104247 => 104248)


--- trunk/Source/WebCore/ChangeLog	2012-01-06 00:54:56 UTC (rev 104247)
+++ trunk/Source/WebCore/ChangeLog	2012-01-06 01:01:33 UTC (rev 104248)
@@ -1,3 +1,22 @@
+2012-01-04  James Robinson  <[email protected]>
+
+        [chromium] Route all animate calls through CCLayerTreeHost in composited mode to simplify rate limiting logic
+        https://bugs.webkit.org/show_bug.cgi?id=75577
+
+        Reviewed by Darin Fisher.
+
+        This internalizes the animation rate limiting logic to CCLayerTreeHost and removes the setters/getters for the
+        m_animating flag. This requires that all animation updates have to go through CCLayerTreeHost to get the right
+        rate limiting behavior, regardless of which proxy is being used.
+
+        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+        (WebCore::CCLayerTreeHost::updateAnimations):
+        (WebCore::CCLayerTreeHost::layout):
+        (WebCore::CCLayerTreeHost::startRateLimiter):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
+        (WebCore::CCThreadProxy::beginFrameAndCommit):
+
 2012-01-05  Justin Novosad  <[email protected]>
 
         [Chromium] NativeImageSkia should mark SkBitmaps as immutable

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp (104247 => 104248)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp	2012-01-06 00:54:56 UTC (rev 104247)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp	2012-01-06 01:01:33 UTC (rev 104248)
@@ -118,13 +118,18 @@
         m_contentsTextureManager->evictAndDeleteAllTextures(allocator);
 }
 
-void CCLayerTreeHost::animateAndLayout(double frameBeginTime)
+void CCLayerTreeHost::updateAnimations(double frameBeginTime)
 {
     m_animating = true;
-    m_client->animateAndLayout(frameBeginTime);
+    m_client->updateAnimations(frameBeginTime);
     m_animating = false;
 }
 
+void CCLayerTreeHost::layout()
+{
+    m_client->layout();
+}
+
 void CCLayerTreeHost::beginCommitOnImplThread(CCLayerTreeHostImpl* hostImpl)
 {
     ASSERT(CCProxy::isImplThread());
@@ -500,7 +505,7 @@
 
 void CCLayerTreeHost::startRateLimiter(GraphicsContext3D* context)
 {
-    if (animating())
+    if (m_animating)
         return;
     ASSERT(context);
     RateLimiterMap::iterator it = m_rateLimiters.find(context);

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h (104247 => 104248)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2012-01-06 00:54:56 UTC (rev 104247)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2012-01-06 01:01:33 UTC (rev 104248)
@@ -53,7 +53,8 @@
 
 class CCLayerTreeHostClient {
 public:
-    virtual void animateAndLayout(double frameBeginTime) = 0;
+    virtual void updateAnimations(double frameBeginTime) = 0;
+    virtual void layout() = 0;
     virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) = 0;
     virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() = 0;
     virtual void didRecreateGraphicsContext(bool success) = 0;
@@ -121,7 +122,8 @@
     static bool anyLayerTreeHostInstanceExists();
 
     // CCLayerTreeHost interface to CCProxy.
-    void animateAndLayout(double frameBeginTime);
+    void updateAnimations(double frameBeginTime);
+    void layout();
     void beginCommitOnImplThread(CCLayerTreeHostImpl*);
     void finishCommitOnImplThread(CCLayerTreeHostImpl*);
     void commitComplete();
@@ -133,10 +135,6 @@
     void didCompleteSwapBuffers() { m_client->didCompleteSwapBuffers(); }
     void deleteContentsTexturesOnImplThread(TextureAllocator*);
 
-    // CCLayerTreeHost interface to WebView.
-    bool animating() const { return m_animating; }
-    void setAnimating(bool animating) { m_animating = animating; } // Can be removed when non-threaded scheduling moves inside.
-
     CCLayerTreeHostClient* client() { return m_client; }
 
     int compositorIdentifier() const { return m_compositorIdentifier; }

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp (104247 => 104248)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp	2012-01-06 00:54:56 UTC (rev 104247)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp	2012-01-06 01:01:33 UTC (rev 104248)
@@ -363,15 +363,13 @@
     // Re-do the commit flow so that we don't send the scrollInfo on the BFAC message.
     m_layerTreeHost->applyScrollAndScale(*scrollInfo);
 
-    // FIXME: recreate the context if it was requested by the impl thread
-    {
-        TRACE_EVENT("CCLayerTreeHost::animateAndLayout", this, 0);
-        m_layerTreeHost->animateAndLayout(frameBeginTime);
-    }
+    // FIXME: recreate the context if it was requested by the impl thread.
+    m_layerTreeHost->updateAnimations(frameBeginTime);
+    m_layerTreeHost->layout();
 
     ASSERT(m_lastExecutedBeginFrameAndCommitSequenceNumber == sequenceNumber);
 
-    // Clear the commit flag after animateAndLayout here --- objects that only
+    // Clear the commit flag after updating animations and layout here --- objects that only
     // layout when painted will trigger another setNeedsCommit inside
     // updateLayers.
     m_commitRequested = false;

Modified: trunk/Source/WebKit/chromium/ChangeLog (104247 => 104248)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-01-06 00:54:56 UTC (rev 104247)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-01-06 01:01:33 UTC (rev 104248)
@@ -1,3 +1,23 @@
+2012-01-04  James Robinson  <[email protected]>
+
+        [chromium] Route all animate calls through CCLayerTreeHost in composited mode to simplify rate limiting logic
+        https://bugs.webkit.org/show_bug.cgi?id=75577
+
+        Reviewed by Darin Fisher.
+
+        Routes WebWidget-initiated animate() calls through the CCLayerTreeHost in composited mode. CCLayerTreeHost's
+        rate limiting logic needs to be aware of when requestAnimationFrame callbacks are run. In threaded mode, the
+        animate calls are driven from CCThreadProxy and so the CCLayerTreeHost can set whatever state it needs. This
+        makes the single-threaded mode where the animate calls are driven through the WebWidget interface outside of the
+        CCProxy's control.
+
+        This is a small step towards inverting the scheduling control from the WebWidget to the compositor.
+
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::animate):
+        (WebKit::WebViewImpl::updateAnimations):
+        * src/WebViewImpl.h:
+
 2012-01-05  David Levin  <[email protected]>
 
         [chromium] Resize requests at the view level should be ignored when in autoresize mode.

Modified: trunk/Source/WebKit/chromium/public/platform/WebLayerTreeViewClient.h (104247 => 104248)


--- trunk/Source/WebKit/chromium/public/platform/WebLayerTreeViewClient.h	2012-01-06 00:54:56 UTC (rev 104247)
+++ trunk/Source/WebKit/chromium/public/platform/WebLayerTreeViewClient.h	2012-01-06 01:01:33 UTC (rev 104248)
@@ -33,9 +33,10 @@
 
 class WebLayerTreeViewClient {
 public:
-    // Updates animation and layout. This is called before the compositing pass
-    // so that layers can be updated at the given frame time.
-    virtual void animateAndLayout(double frameBeginTime) = 0;
+    // Updates animation and layout. These are called before the compositing
+    // pass so that layers can be updated at the given frame time.
+    virtual void updateAnimations(double frameBeginTime) = 0;
+    virtual void layout() = 0;
 
     // Applies a scroll delta to the root layer, which is bundled with a page
     // scale factor that may apply a CSS transform on the whole document (used

Modified: trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp (104247 => 104248)


--- trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp	2012-01-06 00:54:56 UTC (rev 104247)
+++ trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp	2012-01-06 01:01:33 UTC (rev 104248)
@@ -60,12 +60,18 @@
 {
 }
 
-void WebLayerTreeViewImpl::animateAndLayout(double frameBeginTime)
+void WebLayerTreeViewImpl::updateAnimations(double frameBeginTime)
 {
     if (m_client)
-        m_client->animateAndLayout(frameBeginTime);
+        m_client->updateAnimations(frameBeginTime);
 }
 
+void WebLayerTreeViewImpl::layout()
+{
+    if (m_client)
+        m_client->layout();
+}
+
 void WebLayerTreeViewImpl::applyScrollAndScale(const WebCore::IntSize& scrollDelta, float pageScale)
 {
     if (m_client)

Modified: trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.h (104247 => 104248)


--- trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.h	2012-01-06 00:54:56 UTC (rev 104247)
+++ trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.h	2012-01-06 01:01:33 UTC (rev 104248)
@@ -41,7 +41,8 @@
 private:
     WebLayerTreeViewImpl(WebLayerTreeViewClient*, const WebLayerTreeView::Settings&);
     virtual ~WebLayerTreeViewImpl();
-    virtual void animateAndLayout(double frameBeginTime);
+    virtual void updateAnimations(double frameBeginTime);
+    virtual void layout();
     virtual void applyScrollAndScale(const WebCore::IntSize& scrollDelta, float pageScale);
     virtual PassRefPtr<WebCore::GraphicsContext3D> createLayerTreeHostContext3D();
     virtual void didRecreateGraphicsContext(bool success);

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (104247 => 104248)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-01-06 00:54:56 UTC (rev 104247)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-01-06 01:01:33 UTC (rev 104248)
@@ -1127,24 +1127,34 @@
 void WebViewImpl::animate(double frameBeginTime)
 {
 #if ENABLE(REQUEST_ANIMATION_FRAME)
-    TRACE_EVENT("WebViewImpl::animate", this, 0);
     // FIXME: remove this zero-check once render_widget has been modified to
     // pass in a frameBeginTime.
     if (!frameBeginTime)
         frameBeginTime = currentTime();
-    WebFrameImpl* webframe = mainFrameImpl();
-    if (webframe) {
-        FrameView* view = webframe->frameView();
-        if (view) {
-            if (!CCProxy::hasImplThread() && m_layerTreeHost)
-                m_layerTreeHost->setAnimating(true);
 
-            view->serviceScriptedAnimations(convertSecondsToDOMTimeStamp(frameBeginTime));
+#if USE(ACCELERATED_COMPOSITING)
+    // In composited mode, we always go through the compositor so it can apply
+    // appropriate flow-control mechanisms.
+    if (isAcceleratedCompositingActive())
+        m_layerTreeHost->updateAnimations(frameBeginTime);
+    else
+#endif
+        updateAnimations(frameBeginTime);
+#endif
+}
 
-            if (!CCProxy::hasImplThread() && m_layerTreeHost)
-                m_layerTreeHost->setAnimating(false);
-        }
-    }
+void WebViewImpl::updateAnimations(double frameBeginTime)
+{
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+    TRACE_EVENT("WebViewImpl::updateAnimations", this, 0);
+
+    WebFrameImpl* webframe = mainFrameImpl();
+    if (!webframe)
+        return;
+    FrameView* view = webframe->frameView();
+    if (!view)
+        return;
+    view->serviceScriptedAnimations(convertSecondsToDOMTimeStamp(frameBeginTime));
 #endif
 }
 
@@ -3003,12 +3013,6 @@
     return context;
 }
 
-void WebViewImpl::animateAndLayout(double frameBeginTime)
-{
-    animate(frameBeginTime);
-    layout();
-}
-
 void WebViewImpl::applyScrollAndScale(const IntSize& scrollDelta, float pageScaleDelta)
 {
     if (!mainFrameImpl() || !mainFrameImpl()->frameView())

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.h (104247 => 104248)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.h	2012-01-06 00:54:56 UTC (rev 104247)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.h	2012-01-06 01:01:33 UTC (rev 104248)
@@ -109,7 +109,7 @@
     virtual void willExitFullScreen();
     virtual void didExitFullScreen();
     virtual void animate(double frameBeginTime);
-    virtual void layout();
+    virtual void layout(); // Also implements CCLayerTreeHostClient::layout()
     virtual void paint(WebCanvas*, const WebRect&);
     virtual void themeChanged();
     virtual void composite(bool finish);
@@ -238,7 +238,7 @@
     virtual void removePageOverlay(WebPageOverlay*);
 
     // CCLayerTreeHostClient
-    virtual void animateAndLayout(double frameBeginTime);
+    virtual void updateAnimations(double frameBeginTime);
     virtual void applyScrollAndScale(const WebCore::IntSize&, float);
     virtual PassRefPtr<WebCore::GraphicsContext3D> createLayerTreeHostContext3D();
     virtual void didCommitAndDrawFrame();

Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp (104247 => 104248)


--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp	2012-01-06 00:54:56 UTC (rev 104247)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp	2012-01-06 01:01:33 UTC (rev 104248)
@@ -59,7 +59,8 @@
     virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*) { }
     virtual void drawLayersOnCCThread(CCLayerTreeHostImpl*) { }
     virtual void applyScrollAndScale(const IntSize&, float) { }
-    virtual void animateAndLayout(double frameBeginTime) { }
+    virtual void updateAnimations(double frameBeginTime) { }
+    virtual void layout() { }
 };
 
 // Adapts CCLayerTreeHostImpl for test. Runs real code, then invokes test hooks.
@@ -137,11 +138,16 @@
         return adoptPtr(new MockLayerTreeHostClient(testHooks));
     }
 
-    virtual void animateAndLayout(double frameBeginTime)
+    virtual void updateAnimations(double frameBeginTime)
     {
-        m_testHooks->animateAndLayout(frameBeginTime);
+        m_testHooks->updateAnimations(frameBeginTime);
     }
 
+    virtual void layout()
+    {
+        m_testHooks->layout();
+    }
+
     virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale)
     {
         m_testHooks->applyScrollAndScale(scrollDelta, scale);
@@ -696,7 +702,7 @@
         postSetNeedsAnimateToMainThread();
     }
 
-    virtual void animateAndLayout(double)
+    virtual void updateAnimations(double)
     {
         if (!m_numAnimates) {
             m_layerTreeHost->setNeedsAnimate();
@@ -736,7 +742,7 @@
         postSetNeedsCommitToMainThread();
     }
 
-    virtual void animateAndLayout(double frameBeginTime)
+    virtual void layout()
     {
         LayerChromium* root = m_layerTreeHost->rootLayer();
         if (!m_layerTreeHost->frameNumber())

Modified: trunk/Source/WebKit/chromium/tests/LayerChromiumTest.cpp (104247 => 104248)


--- trunk/Source/WebKit/chromium/tests/LayerChromiumTest.cpp	2012-01-06 00:54:56 UTC (rev 104247)
+++ trunk/Source/WebKit/chromium/tests/LayerChromiumTest.cpp	2012-01-06 01:01:33 UTC (rev 104248)
@@ -52,7 +52,8 @@
 
 class FakeCCLayerTreeHostClient : public CCLayerTreeHostClient {
 public:
-    virtual void animateAndLayout(double frameBeginTime) { }
+    virtual void updateAnimations(double frameBeginTime) { }
+    virtual void layout() { }
     virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) { }
     virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() { return 0; }
     virtual void didRecreateGraphicsContext(bool success) { }

Modified: trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp (104247 => 104248)


--- trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp	2012-01-06 00:54:56 UTC (rev 104247)
+++ trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp	2012-01-06 01:01:33 UTC (rev 104248)
@@ -52,7 +52,8 @@
 public:
     MOCK_METHOD0(scheduleComposite, void());
 
-    virtual void animateAndLayout(double frameBeginTime) { }
+    virtual void updateAnimations(double frameBeginTime) { }
+    virtual void layout() { }
     virtual void applyScrollAndScale(const WebSize& scrollDelta, float scaleFactor) { }
     virtual WebGraphicsContext3D* createContext3D() { return CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes()).leakPtr(); }
     virtual void didRebindGraphicsContext(bool success) { }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to