Skip to content
Permalink
Browse files
[Qt] requestAnimationFrame should only trigger when a new frame can b…
…e 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:

Canonical link: https://commits.webkit.org/110222@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@123786 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Zeno Albisser committed Jul 26, 2012
1 parent fb572c4 commit dce7267d03841c1c2a1335ee2554c114418e6244
Showing 11 changed files with 146 additions and 1 deletion.
@@ -1,3 +1,16 @@
2012-07-26 Zeno Albisser <zeno@webkit.org>

[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 <yurys@chromium.org>

Unreviewed. Revert r123740 as it breaks AppleMac compilation.
@@ -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

@@ -1,3 +1,35 @@
2012-07-26 Zeno Albisser <zeno@webkit.org>

[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 <kaustubh@motorola.com>

[DRT] LTC:: pageNumberForElementById() could be moved to Internals
@@ -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,6 +651,17 @@ void ChromeClientQt::setCursor(const Cursor& cursor)
#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)
@@ -49,6 +49,7 @@ class FileChooser;
class FileIconLoader;
class FloatRect;
class Page;
class RefreshAnimation;
struct FrameLoadRequest;
class QtAbstractWebPopup;
struct ViewportArguments;
@@ -176,6 +177,9 @@ class ChromeClientQt : public ChromeClient {
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 @@ class ChromeClientQt : public ChromeClient {
bool statusBarVisible;
bool menuBarVisible;
QEventLoop* m_eventLoop;
OwnPtr<RefreshAnimation> m_refreshAnimation;

#if ENABLE(VIDEO) && (USE(GSTREAMER) || USE(QT_MULTIMEDIA) || USE(QTKIT))
FullScreenVideoQt* m_fullScreenVideo;
@@ -1,3 +1,28 @@
2012-07-26 Zeno Albisser <zeno@webkit.org>

[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 <jer.noble@apple.com>

Add a ChromeClient method to send diagnostic logging messages from WebCore to the client.
@@ -635,6 +635,15 @@ void WebChromeClient::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
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();
@@ -162,6 +162,9 @@ class WebChromeClient : public WebCore::ChromeClient {

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.
@@ -356,6 +356,10 @@ void LayerTreeCoordinator::performScheduledLayerFlush()
{
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 @@ void LayerTreeCoordinator::setVisibleContentsRect(const IntRect& rect, float sca
m_shouldSendScrollPositionUpdate = true;
}

void LayerTreeCoordinator::scheduleAnimation()
{
scheduleLayerFlush();
}

void LayerTreeCoordinator::renderNextFrame()
{
m_waitingForUIProcess = false;
@@ -86,6 +86,7 @@ class LayerTreeCoordinator : public LayerTreeHost, WebCore::GraphicsLayerClient
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*);
@@ -105,6 +105,10 @@ class LayerTreeHost : public RefCounted<LayerTreeHost> {
virtual WebCore::GraphicsDeviceAdapter* graphicsDeviceAdapter() const { return 0; }
#endif

#if USE(UI_SIDE_COMPOSITING)
virtual void scheduleAnimation() = 0;
#endif

protected:
explicit LayerTreeHost(WebPage*);

0 comments on commit dce7267

Please sign in to comment.