Changeset 150071 in webkit


Ignore:
Timestamp:
May 14, 2013 9:17:09 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Carlos Garcia Campos <cgarcia@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.

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r150062 r150071  
     12013-05-14  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [BlackBerry] Use requestAnimationFrame for animations
     4        https://bugs.webkit.org/show_bug.cgi?id=115896
     5
     6        Reviewed by Rob Buis.
     7
     8        * wtf/Platform.h: Disable REQUEST_ANIMATION_FRAME_TIMER and
     9        WTF_USE_REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR for BlackBerry
     10        port.
     11
    1122013-05-14  Carlos Garcia Campos  <cgarcia@igalia.com>
    213
  • trunk/Source/WTF/wtf/Platform.h

    r150062 r150071  
    976976#endif
    977977
    978 #if PLATFORM(MAC) || PLATFORM(GTK) || (PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(WIN_CAIRO)) || PLATFORM(BLACKBERRY)
     978#if PLATFORM(MAC) || PLATFORM(GTK) || (PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(WIN_CAIRO))
    979979#define WTF_USE_REQUEST_ANIMATION_FRAME_TIMER 1
    980980#endif
    981981
    982 #if PLATFORM(MAC) || PLATFORM(BLACKBERRY)
     982#if PLATFORM(MAC)
    983983#define WTF_USE_REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR 1
    984984#endif
  • trunk/Source/WebKit/blackberry/Api/WebPage.cpp

    r150060 r150071  
    430430    , m_didStartAnimations(false)
    431431    , m_animationStartTime(0)
     432#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
     433    , m_isRunningRefreshAnimationClient(false)
     434    , m_animationScheduled(false)
     435#endif
    432436{
    433437    static bool isInitialized = false;
     
    455459    if (BackingStorePrivate::currentBackingStoreOwner() == m_webPage)
    456460        BackingStorePrivate::setCurrentBackingStoreOwner(0);
     461
     462#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
     463    stopRefreshAnimationClient();
     464    cancelCallOnMainThread(handleServiceScriptedAnimationsOnMainThread, this);
     465#endif
    457466
    458467    delete m_webSettings;
     
    63086317}
    63096318
    6310 }
    6311 }
     6319#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
     6320void WebPagePrivate::animationFrameChanged()
     6321{
     6322    if (!m_animationMutex.tryLock())
     6323        return;
     6324
     6325    if (!m_animationScheduled) {
     6326        stopRefreshAnimationClient();
     6327        m_animationMutex.unlock();
     6328        return;
     6329    }
     6330
     6331    m_animationScheduled = false;
     6332    callOnMainThread(handleServiceScriptedAnimationsOnMainThread, this);
     6333    m_animationMutex.unlock();
     6334}
     6335
     6336void WebPagePrivate::scheduleAnimation()
     6337{
     6338    if (m_animationScheduled)
     6339        return;
     6340    MutexLocker lock(m_animationMutex);
     6341    m_animationScheduled = true;
     6342    startRefreshAnimationClient();
     6343}
     6344
     6345void WebPagePrivate::startRefreshAnimationClient()
     6346{
     6347    if (m_isRunningRefreshAnimationClient)
     6348        return;
     6349    m_isRunningRefreshAnimationClient = true;
     6350    BlackBerry::Platform::AnimationFrameRateController::instance()->addClient(this);
     6351}
     6352
     6353void WebPagePrivate::stopRefreshAnimationClient()
     6354{
     6355    if (!m_isRunningRefreshAnimationClient)
     6356        return;
     6357    m_isRunningRefreshAnimationClient = false;
     6358    BlackBerry::Platform::AnimationFrameRateController::instance()->removeClient(this);
     6359}
     6360
     6361void WebPagePrivate::handleServiceScriptedAnimationsOnMainThread(void* data)
     6362{
     6363    WebPagePrivate* webPagePrivate = static_cast<WebPagePrivate*>(data);
     6364    webPagePrivate->m_mainFrame->view()->serviceScriptedAnimations(currentTime());
     6365}
     6366#endif
     6367
     6368}
     6369}
  • trunk/Source/WebKit/blackberry/Api/WebPage_p.h

    r150060 r150071  
    100100#if USE(ACCELERATED_COMPOSITING)
    101101    , public WebCore::GraphicsLayerClient
     102#endif
     103#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
     104    , public BlackBerry::Platform::AnimationFrameRateClient
    102105#endif
    103106    , public Platform::GuardedPointerBase {
     
    455458    WebCore::Color documentBackgroundColor() const;
    456459
     460#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
     461    // BlackBerry::Platform::AnimationFrameRateClient.
     462    virtual void animationFrameChanged();
     463    void scheduleAnimation();
     464    void startRefreshAnimationClient();
     465    void stopRefreshAnimationClient();
     466    static void handleServiceScriptedAnimationsOnMainThread(void*);
     467#endif
     468
    457469    WebPage* m_webPage;
    458470    WebPageClient* m_client;
     
    641653    double m_animationStartTime;
    642654
     655#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
     656    Mutex m_animationMutex;
     657    bool m_isRunningRefreshAnimationClient;
     658    bool m_animationScheduled;
     659#endif
     660
    643661protected:
    644662    virtual ~WebPagePrivate();
  • trunk/Source/WebKit/blackberry/ChangeLog

    r150062 r150071  
     12013-05-14  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [BlackBerry] Use requestAnimationFrame for animations
     4        https://bugs.webkit.org/show_bug.cgi?id=115896
     5
     6        Reviewed by Rob Buis.
     7
     8        Make WebPagePrivate a
     9        BlackBerry::Platform::AnimationFrameRateClient and use it to
     10        schedule animations.
     11
     12        * Api/WebPage.cpp:
     13        (BlackBerry::WebKit::WebPagePrivate::WebPagePrivate):
     14        (BlackBerry::WebKit::WebPagePrivate::~WebPagePrivate):
     15        (WebKit):
     16        (BlackBerry::WebKit::WebPagePrivate::animationFrameChanged):
     17        (BlackBerry::WebKit::WebPagePrivate::scheduleAnimation):
     18        (BlackBerry::WebKit::WebPagePrivate::startRefreshAnimationClient):
     19        (BlackBerry::WebKit::WebPagePrivate::stopRefreshAnimationClient):
     20        (BlackBerry::WebKit::WebPagePrivate::handleServiceScriptedAnimationsOnMainThread):
     21        * Api/WebPage_p.h:
     22        (WebPagePrivate):
     23        * WebCoreSupport/ChromeClientBlackBerry.cpp:
     24        (WebCore):
     25        (WebCore::ChromeClientBlackBerry::scheduleAnimation):
     26        * WebCoreSupport/ChromeClientBlackBerry.h:
     27        (ChromeClientBlackBerry):
     28
    1292013-05-14  Carlos Garcia Campos  <cgarcia@igalia.com>
    230
  • trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp

    r149125 r150071  
    825825}
    826826
     827#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
     828void ChromeClientBlackBerry::scheduleAnimation()
     829{
     830    m_webPagePrivate->scheduleAnimation();
     831}
     832#endif
     833
    827834} // namespace WebCore
  • trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.h

    r149818 r150071  
    152152#endif
    153153
     154#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
     155    virtual void scheduleAnimation();
     156#endif
     157
    154158    BlackBerry::WebKit::WebPagePrivate* webPagePrivate() const { return m_webPagePrivate; }
    155159
Note: See TracChangeset for help on using the changeset viewer.