Title: [150071] trunk/Source
Revision
150071
Author
commit-qu...@webkit.org
Date
2013-05-14 09:17:09 -0700 (Tue, 14 May 2013)

Log Message

[BlackBerry] Use requestAnimationFrame for animations
https://bugs.webkit.org/show_bug.cgi?id=115896

Patch by Carlos Garcia Campos <cgar...@igalia.com> on 2013-05-14
Reviewed by Rob Buis.

Source/WebKit/blackberry:

Make WebPagePrivate a
BlackBerry::Platform::AnimationFrameRateClient and use it to
schedule animations.

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::WebPagePrivate):
(BlackBerry::WebKit::WebPagePrivate::~WebPagePrivate):
(WebKit):
(BlackBerry::WebKit::WebPagePrivate::animationFrameChanged):
(BlackBerry::WebKit::WebPagePrivate::scheduleAnimation):
(BlackBerry::WebKit::WebPagePrivate::startRefreshAnimationClient):
(BlackBerry::WebKit::WebPagePrivate::stopRefreshAnimationClient):
(BlackBerry::WebKit::WebPagePrivate::handleServiceScriptedAnimationsOnMainThread):
* Api/WebPage_p.h:
(WebPagePrivate):
* WebCoreSupport/ChromeClientBlackBerry.cpp:
(WebCore):
(WebCore::ChromeClientBlackBerry::scheduleAnimation):
* WebCoreSupport/ChromeClientBlackBerry.h:
(ChromeClientBlackBerry):

Source/WTF:

* wtf/Platform.h: Disable REQUEST_ANIMATION_FRAME_TIMER and
WTF_USE_REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR for BlackBerry
port.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (150070 => 150071)


--- trunk/Source/WTF/ChangeLog	2013-05-14 15:59:14 UTC (rev 150070)
+++ trunk/Source/WTF/ChangeLog	2013-05-14 16:17:09 UTC (rev 150071)
@@ -1,5 +1,16 @@
 2013-05-14  Carlos Garcia Campos  <cgar...@igalia.com>
 
+        [BlackBerry] Use requestAnimationFrame for animations
+        https://bugs.webkit.org/show_bug.cgi?id=115896
+
+        Reviewed by Rob Buis.
+
+        * wtf/Platform.h: Disable REQUEST_ANIMATION_FRAME_TIMER and
+        WTF_USE_REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR for BlackBerry
+        port.
+
+2013-05-14  Carlos Garcia Campos  <cgar...@igalia.com>
+
         [BlackBerry] Implement platform strategies
         https://bugs.webkit.org/show_bug.cgi?id=112162
 

Modified: trunk/Source/WTF/wtf/Platform.h (150070 => 150071)


--- trunk/Source/WTF/wtf/Platform.h	2013-05-14 15:59:14 UTC (rev 150070)
+++ trunk/Source/WTF/wtf/Platform.h	2013-05-14 16:17:09 UTC (rev 150071)
@@ -975,11 +975,11 @@
 #define HAVE_MEDIA_ACCESSIBILITY_FRAMEWORK 1
 #endif
 
-#if PLATFORM(MAC) || PLATFORM(GTK) || (PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(WIN_CAIRO)) || PLATFORM(BLACKBERRY)
+#if PLATFORM(MAC) || PLATFORM(GTK) || (PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(WIN_CAIRO))
 #define WTF_USE_REQUEST_ANIMATION_FRAME_TIMER 1
 #endif
 
-#if PLATFORM(MAC) || PLATFORM(BLACKBERRY)
+#if PLATFORM(MAC)
 #define WTF_USE_REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR 1
 #endif
 

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (150070 => 150071)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2013-05-14 15:59:14 UTC (rev 150070)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2013-05-14 16:17:09 UTC (rev 150071)
@@ -429,6 +429,10 @@
 #endif
     , m_didStartAnimations(false)
     , m_animationStartTime(0)
+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
+    , m_isRunningRefreshAnimationClient(false)
+    , m_animationScheduled(false)
+#endif
 {
     static bool isInitialized = false;
     if (!isInitialized) {
@@ -455,6 +459,11 @@
     if (BackingStorePrivate::currentBackingStoreOwner() == m_webPage)
         BackingStorePrivate::setCurrentBackingStoreOwner(0);
 
+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
+    stopRefreshAnimationClient();
+    cancelCallOnMainThread(handleServiceScriptedAnimationsOnMainThread, this);
+#endif
+
     delete m_webSettings;
     m_webSettings = 0;
 
@@ -6307,5 +6316,54 @@
     return ScriptController::processingUserGesture();
 }
 
+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
+void WebPagePrivate::animationFrameChanged()
+{
+    if (!m_animationMutex.tryLock())
+        return;
+
+    if (!m_animationScheduled) {
+        stopRefreshAnimationClient();
+        m_animationMutex.unlock();
+        return;
+    }
+
+    m_animationScheduled = false;
+    callOnMainThread(handleServiceScriptedAnimationsOnMainThread, this);
+    m_animationMutex.unlock();
 }
+
+void WebPagePrivate::scheduleAnimation()
+{
+    if (m_animationScheduled)
+        return;
+    MutexLocker lock(m_animationMutex);
+    m_animationScheduled = true;
+    startRefreshAnimationClient();
 }
+
+void WebPagePrivate::startRefreshAnimationClient()
+{
+    if (m_isRunningRefreshAnimationClient)
+        return;
+    m_isRunningRefreshAnimationClient = true;
+    BlackBerry::Platform::AnimationFrameRateController::instance()->addClient(this);
+}
+
+void WebPagePrivate::stopRefreshAnimationClient()
+{
+    if (!m_isRunningRefreshAnimationClient)
+        return;
+    m_isRunningRefreshAnimationClient = false;
+    BlackBerry::Platform::AnimationFrameRateController::instance()->removeClient(this);
+}
+
+void WebPagePrivate::handleServiceScriptedAnimationsOnMainThread(void* data)
+{
+    WebPagePrivate* webPagePrivate = static_cast<WebPagePrivate*>(data);
+    webPagePrivate->m_mainFrame->view()->serviceScriptedAnimations(currentTime());
+}
+#endif
+
+}
+}

Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (150070 => 150071)


--- trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2013-05-14 15:59:14 UTC (rev 150070)
+++ trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2013-05-14 16:17:09 UTC (rev 150071)
@@ -100,6 +100,9 @@
 #if USE(ACCELERATED_COMPOSITING)
     , public WebCore::GraphicsLayerClient
 #endif
+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
+    , public BlackBerry::Platform::AnimationFrameRateClient
+#endif
     , public Platform::GuardedPointerBase {
 public:
     enum ViewMode { Desktop, FixedDesktop };
@@ -454,6 +457,15 @@
     void updateBackgroundColor(const WebCore::Color& backgroundColor);
     WebCore::Color documentBackgroundColor() const;
 
+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
+    // BlackBerry::Platform::AnimationFrameRateClient.
+    virtual void animationFrameChanged();
+    void scheduleAnimation();
+    void startRefreshAnimationClient();
+    void stopRefreshAnimationClient();
+    static void handleServiceScriptedAnimationsOnMainThread(void*);
+#endif
+
     WebPage* m_webPage;
     WebPageClient* m_client;
     WebCore::InspectorClientBlackBerry* m_inspectorClient;
@@ -640,6 +652,12 @@
     bool m_didStartAnimations;
     double m_animationStartTime;
 
+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
+    Mutex m_animationMutex;
+    bool m_isRunningRefreshAnimationClient;
+    bool m_animationScheduled;
+#endif
+
 protected:
     virtual ~WebPagePrivate();
 };

Modified: trunk/Source/WebKit/blackberry/ChangeLog (150070 => 150071)


--- trunk/Source/WebKit/blackberry/ChangeLog	2013-05-14 15:59:14 UTC (rev 150070)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2013-05-14 16:17:09 UTC (rev 150071)
@@ -1,5 +1,33 @@
 2013-05-14  Carlos Garcia Campos  <cgar...@igalia.com>
 
+        [BlackBerry] Use requestAnimationFrame for animations
+        https://bugs.webkit.org/show_bug.cgi?id=115896
+
+        Reviewed by Rob Buis.
+
+        Make WebPagePrivate a
+        BlackBerry::Platform::AnimationFrameRateClient and use it to
+        schedule animations.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::WebPagePrivate):
+        (BlackBerry::WebKit::WebPagePrivate::~WebPagePrivate):
+        (WebKit):
+        (BlackBerry::WebKit::WebPagePrivate::animationFrameChanged):
+        (BlackBerry::WebKit::WebPagePrivate::scheduleAnimation):
+        (BlackBerry::WebKit::WebPagePrivate::startRefreshAnimationClient):
+        (BlackBerry::WebKit::WebPagePrivate::stopRefreshAnimationClient):
+        (BlackBerry::WebKit::WebPagePrivate::handleServiceScriptedAnimationsOnMainThread):
+        * Api/WebPage_p.h:
+        (WebPagePrivate):
+        * WebCoreSupport/ChromeClientBlackBerry.cpp:
+        (WebCore):
+        (WebCore::ChromeClientBlackBerry::scheduleAnimation):
+        * WebCoreSupport/ChromeClientBlackBerry.h:
+        (ChromeClientBlackBerry):
+
+2013-05-14  Carlos Garcia Campos  <cgar...@igalia.com>
+
         [BlackBerry] Implement platform strategies
         https://bugs.webkit.org/show_bug.cgi?id=112162
 

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp (150070 => 150071)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp	2013-05-14 15:59:14 UTC (rev 150070)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp	2013-05-14 16:17:09 UTC (rev 150071)
@@ -824,4 +824,11 @@
     return nullptr;
 }
 
+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
+void ChromeClientBlackBerry::scheduleAnimation()
+{
+    m_webPagePrivate->scheduleAnimation();
+}
+#endif
+
 } // namespace WebCore

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.h (150070 => 150071)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.h	2013-05-14 15:59:14 UTC (rev 150070)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.h	2013-05-14 16:17:09 UTC (rev 150071)
@@ -151,6 +151,10 @@
     virtual bool allowsAcceleratedCompositing() const;
 #endif
 
+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
+    virtual void scheduleAnimation();
+#endif
+
     BlackBerry::WebKit::WebPagePrivate* webPagePrivate() const { return m_webPagePrivate; }
 
 private:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to