Title: [123786] trunk/Source
Revision
123786
Author
[email protected]
Date
2012-07-26 13:15:53 -0700 (Thu, 26 Jul 2012)

Log Message

[Qt] requestAnimationFrame should only trigger when a new frame can be displayed.
https://bugs.webkit.org/show_bug.cgi?id=88638

Source/WebKit/qt:

Disable REQUEST_ANIMATION_FRAME_TIMER for the Qt port and tie
the servicing of scripted animations to the renderNextFrame call for WK2.
For WK1 we rely on the RefreshAnimation that is based on QAbstractAnimation.

Reviewed by Jocelyn Turcotte.

* WebCoreSupport/ChromeClientQt.cpp:
(RefreshAnimation):
    Add a RefreshAnimation that is based on QAbstractAnimation
    and drives the servicing of the scripted animations for WK1.
(WebCore::RefreshAnimation::RefreshAnimation):
(WebCore::RefreshAnimation::duration):
(WebCore::RefreshAnimation::scheduleAnimation):
    Set m_animationScheduled to true and start the animation
    timer in case it is not running yet.
(WebCore::RefreshAnimation::updateCurrentTime):
    Call serviceScriptedAnimations if m_animationScheduled is true.
    If this is not the case, the animation timer can be stopped,
    because no animation needs to be scheduled anymore.
(WebCore):
(WebCore::ChromeClientQt::scheduleAnimation):
    Create and start the RefreshAnimation instance with the
    first call to scheduleAnimation.
* WebCoreSupport/ChromeClientQt.h:
(WebCore):
(ChromeClientQt):

Source/WebKit2:

Disable REQUEST_ANIMATION_FRAME_TIMER for the Qt port and tie
the servicing of scripted animations to layer syncing for WK2.
For WK1 we rely on the RefreshAnimation that is based on QAbstractAnimation.

Reviewed by Jocelyn Turcotte.

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit):
(WebKit::WebChromeClient::scheduleAnimation):
* WebProcess/WebCoreSupport/WebChromeClient.h:
(WebChromeClient):
* WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp:
(WebKit::LayerTreeCoordinator::performScheduledLayerFlush):
(WebKit::LayerTreeCoordinator::scheduleAnimation):
(WebKit):
* WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h:
(LayerTreeCoordinator):
* WebProcess/WebPage/LayerTreeHost.h:
(LayerTreeHost):

Source/WTF:

Disable REQUEST_ANIMATION_FRAME_TIMER for the Qt port and tie
the servicing of scripted animations to layer syncing for WK2.
For WK1 we rely on the RefreshAnimation that is based on QAbstractAnimation.

Reviewed by Jocelyn Turcotte.

* wtf/Platform.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (123785 => 123786)


--- trunk/Source/WTF/ChangeLog	2012-07-26 20:10:26 UTC (rev 123785)
+++ trunk/Source/WTF/ChangeLog	2012-07-26 20:15:53 UTC (rev 123786)
@@ -1,3 +1,16 @@
+2012-07-26  Zeno Albisser  <[email protected]>
+
+        [Qt] requestAnimationFrame should only trigger when a new frame can be displayed.
+        https://bugs.webkit.org/show_bug.cgi?id=88638
+
+        Disable REQUEST_ANIMATION_FRAME_TIMER for the Qt port and tie
+        the servicing of scripted animations to layer syncing for WK2.
+        For WK1 we rely on the RefreshAnimation that is based on QAbstractAnimation.
+
+        Reviewed by Jocelyn Turcotte.
+
+        * wtf/Platform.h:
+
 2012-07-26  Yury Semikhatsky  <[email protected]>
 
         Unreviewed. Revert r123740 as it breaks AppleMac compilation.

Modified: trunk/Source/WTF/wtf/Platform.h (123785 => 123786)


--- trunk/Source/WTF/wtf/Platform.h	2012-07-26 20:10:26 UTC (rev 123785)
+++ trunk/Source/WTF/wtf/Platform.h	2012-07-26 20:15:53 UTC (rev 123786)
@@ -1105,7 +1105,7 @@
 #define WTF_USE_COREMEDIA 1
 #endif
 
-#if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(EFL) || (PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(WIN_CAIRO)) || PLATFORM(QT) || PLATFORM(BLACKBERRY)
+#if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(EFL) || (PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(WIN_CAIRO)) || PLATFORM(BLACKBERRY)
 #define WTF_USE_REQUEST_ANIMATION_FRAME_TIMER 1
 #endif
 

Modified: trunk/Source/WebKit/qt/ChangeLog (123785 => 123786)


--- trunk/Source/WebKit/qt/ChangeLog	2012-07-26 20:10:26 UTC (rev 123785)
+++ trunk/Source/WebKit/qt/ChangeLog	2012-07-26 20:15:53 UTC (rev 123786)
@@ -1,3 +1,35 @@
+2012-07-26  Zeno Albisser  <[email protected]>
+
+        [Qt] requestAnimationFrame should only trigger when a new frame can be displayed.
+        https://bugs.webkit.org/show_bug.cgi?id=88638
+
+        Disable REQUEST_ANIMATION_FRAME_TIMER for the Qt port and tie
+        the servicing of scripted animations to the renderNextFrame call for WK2.
+        For WK1 we rely on the RefreshAnimation that is based on QAbstractAnimation.
+
+        Reviewed by Jocelyn Turcotte.
+
+        * WebCoreSupport/ChromeClientQt.cpp:
+        (RefreshAnimation):
+            Add a RefreshAnimation that is based on QAbstractAnimation
+            and drives the servicing of the scripted animations for WK1.
+        (WebCore::RefreshAnimation::RefreshAnimation):
+        (WebCore::RefreshAnimation::duration):
+        (WebCore::RefreshAnimation::scheduleAnimation):
+            Set m_animationScheduled to true and start the animation
+            timer in case it is not running yet.
+        (WebCore::RefreshAnimation::updateCurrentTime):
+            Call serviceScriptedAnimations if m_animationScheduled is true.
+            If this is not the case, the animation timer can be stopped,
+            because no animation needs to be scheduled anymore.
+        (WebCore):
+        (WebCore::ChromeClientQt::scheduleAnimation):
+            Create and start the RefreshAnimation instance with the
+            first call to scheduleAnimation.
+        * WebCoreSupport/ChromeClientQt.h:
+        (WebCore):
+        (ChromeClientQt):
+
 2012-07-26  Kaustubh Atrawalkar  <[email protected]>
 
         [DRT] LTC:: pageNumberForElementById() could be moved to Internals

Modified: trunk/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp (123785 => 123786)


--- trunk/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp	2012-07-26 20:10:26 UTC (rev 123785)
+++ trunk/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp	2012-07-26 20:15:53 UTC (rev 123786)
@@ -70,6 +70,7 @@
 #include "qwebsecurityorigin.h"
 #include "qwebsecurityorigin_p.h"
 #include "qwebview.h"
+#include <qabstractanimation.h>
 #include <qdebug.h>
 #include <qeventloop.h>
 #include <qtooltip.h>
@@ -88,6 +89,38 @@
 
 namespace WebCore {
 
+class RefreshAnimation : public QAbstractAnimation {
+public:
+    RefreshAnimation(ChromeClientQt* chromeClient)
+        : QAbstractAnimation()
+        , m_chromeClient(chromeClient)
+        , m_animationScheduled(false)
+    { }
+
+    virtual int duration() const { return -1; }
+
+    void scheduleAnimation()
+    {
+        m_animationScheduled = true;
+        if (state() != QAbstractAnimation::Running)
+            start();
+    }
+
+protected:
+    virtual void updateCurrentTime(int currentTime)
+    {
+        UNUSED_PARAM(currentTime);
+        if (m_animationScheduled) {
+            m_animationScheduled = false;
+            m_chromeClient->serviceScriptedAnimations();
+        } else
+            stop();
+    }
+private:
+    ChromeClientQt* m_chromeClient;
+    bool m_animationScheduled;
+};
+
 bool ChromeClientQt::dumpVisitedLinksCallbacks = false;
 
 ChromeClientQt::ChromeClientQt(QWebPage* webPage)
@@ -618,7 +651,18 @@
 #endif
 }
 
+void ChromeClientQt::scheduleAnimation()
+{
+    if (!m_refreshAnimation)
+        m_refreshAnimation = adoptPtr(new RefreshAnimation(this));
+    m_refreshAnimation->scheduleAnimation();
+}
 
+void ChromeClientQt::serviceScriptedAnimations()
+{
+    m_webPage->mainFrame()->d->frame->view()->serviceScriptedAnimations(convertSecondsToDOMTimeStamp(currentTime()));
+}
+
 #if USE(ACCELERATED_COMPOSITING)
 void ChromeClientQt::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
 {

Modified: trunk/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h (123785 => 123786)


--- trunk/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h	2012-07-26 20:10:26 UTC (rev 123785)
+++ trunk/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h	2012-07-26 20:15:53 UTC (rev 123786)
@@ -49,6 +49,7 @@
 class FileIconLoader;
 class FloatRect;
 class Page;
+class RefreshAnimation;
 struct FrameLoadRequest;
 class QtAbstractWebPopup;
 struct ViewportArguments;
@@ -176,6 +177,9 @@
     virtual void setCursor(const Cursor&);
     virtual void setCursorHiddenUntilMouseMoves(bool) { }
 
+    virtual void scheduleAnimation();
+    virtual void serviceScriptedAnimations();
+
     virtual void scrollRectIntoView(const LayoutRect) const { }
 
     virtual bool selectItemWritingDirectionIsNatural();
@@ -201,6 +205,7 @@
     bool statusBarVisible;
     bool menuBarVisible;
     QEventLoop* m_eventLoop;
+    OwnPtr<RefreshAnimation> m_refreshAnimation;
 
 #if ENABLE(VIDEO) && (USE(GSTREAMER) || USE(QT_MULTIMEDIA) || USE(QTKIT))
     FullScreenVideoQt* m_fullScreenVideo;

Modified: trunk/Source/WebKit2/ChangeLog (123785 => 123786)


--- trunk/Source/WebKit2/ChangeLog	2012-07-26 20:10:26 UTC (rev 123785)
+++ trunk/Source/WebKit2/ChangeLog	2012-07-26 20:15:53 UTC (rev 123786)
@@ -1,3 +1,28 @@
+2012-07-26  Zeno Albisser  <[email protected]>
+
+        [Qt] requestAnimationFrame should only trigger when a new frame can be displayed.
+        https://bugs.webkit.org/show_bug.cgi?id=88638
+
+        Disable REQUEST_ANIMATION_FRAME_TIMER for the Qt port and tie
+        the servicing of scripted animations to layer syncing for WK2.
+        For WK1 we rely on the RefreshAnimation that is based on QAbstractAnimation.
+
+        Reviewed by Jocelyn Turcotte.
+
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit):
+        (WebKit::WebChromeClient::scheduleAnimation):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        (WebChromeClient):
+        * WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp:
+        (WebKit::LayerTreeCoordinator::performScheduledLayerFlush):
+        (WebKit::LayerTreeCoordinator::scheduleAnimation):
+        (WebKit):
+        * WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h:
+        (LayerTreeCoordinator):
+        * WebProcess/WebPage/LayerTreeHost.h:
+        (LayerTreeHost):
+
 2012-07-26  Jer Noble  <[email protected]>
 
         Add a ChromeClient method to send diagnostic logging messages from WebCore to the client.

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (123785 => 123786)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp	2012-07-26 20:10:26 UTC (rev 123785)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp	2012-07-26 20:15:53 UTC (rev 123786)
@@ -635,6 +635,15 @@
     m_page->send(Messages::WebPageProxy::SetCursorHiddenUntilMouseMoves(hiddenUntilMouseMoves));
 }
 
+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
+void WebChromeClient::scheduleAnimation()
+{
+#if USE(UI_SIDE_COMPOSITING)
+    m_page->drawingArea()->layerTreeHost()->scheduleAnimation();
+#endif
+}
+#endif
+
 void WebChromeClient::formStateDidChange(const Node*)
 {
     notImplemented();

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h (123785 => 123786)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h	2012-07-26 20:10:26 UTC (rev 123785)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h	2012-07-26 20:15:53 UTC (rev 123786)
@@ -162,6 +162,9 @@
 
     virtual void setCursor(const WebCore::Cursor&) OVERRIDE;
     virtual void setCursorHiddenUntilMouseMoves(bool) OVERRIDE;
+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
+    virtual void scheduleAnimation() OVERRIDE;
+#endif
 
     // Notification that the given form element has changed. This function
     // will be called frequently, so handling should be very fast.

Modified: trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp (123785 => 123786)


--- trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp	2012-07-26 20:10:26 UTC (rev 123785)
+++ trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp	2012-07-26 20:15:53 UTC (rev 123786)
@@ -356,6 +356,10 @@
 {
     if (m_isSuspended || m_waitingForUIProcess)
         return;
+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER) && !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
+    // Make sure that any previously registered animation callbacks are being executed before we flush the layers.
+    m_webPage->corePage()->mainFrame()->view()->serviceScriptedAnimations(convertSecondsToDOMTimeStamp(currentTime()));
+#endif
 
     m_webPage->layoutIfNeeded();
 
@@ -544,6 +548,11 @@
         m_shouldSendScrollPositionUpdate = true;
 }
 
+void LayerTreeCoordinator::scheduleAnimation()
+{
+    scheduleLayerFlush();
+}
+
 void LayerTreeCoordinator::renderNextFrame()
 {
     m_waitingForUIProcess = false;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h (123785 => 123786)


--- trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h	2012-07-26 20:10:26 UTC (rev 123785)
+++ trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h	2012-07-26 20:15:53 UTC (rev 123786)
@@ -86,6 +86,7 @@
     virtual void syncFixedLayers();
 
     virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, ShareableSurface::Handle&, WebCore::IntPoint&);
+    virtual void scheduleAnimation() OVERRIDE;
 
 protected:
     explicit LayerTreeCoordinator(WebPage*);

Modified: trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h (123785 => 123786)


--- trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h	2012-07-26 20:10:26 UTC (rev 123785)
+++ trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h	2012-07-26 20:15:53 UTC (rev 123786)
@@ -105,6 +105,10 @@
     virtual WebCore::GraphicsDeviceAdapter* graphicsDeviceAdapter() const { return 0; }
 #endif
 
+#if USE(UI_SIDE_COMPOSITING)
+    virtual void scheduleAnimation() = 0;
+#endif
+
 protected:
     explicit LayerTreeHost(WebPage*);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to