REGRESSION (iOS WebKit2): requestAnimationFrame fires more than once between layer...
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 May 2014 02:17:59 +0000 (02:17 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 May 2014 02:17:59 +0000 (02:17 +0000)
commitd875d8c4a6fde4bc090eb8efbf80f4e7a4682fe4
tree6da73c8a28367d7113ac2499910cd99440985f8f
parent8d69fe3cde3b1c7eb03beb0d6d3d4e1f5084042a
REGRESSION (iOS WebKit2): requestAnimationFrame fires more than once between layer tree commits
https://bugs.webkit.org/show_bug.cgi?id=132794
<rdar://problem/16877909>

Reviewed by Simon Fraser.

Virtualize DisplayRefreshMonitor so that WebKit2 can implement its own DisplayRefreshMonitor for UI-side compositing views.
This allows the synchronization of requestAnimationFrame callbacks with UI-side compositing painting.

* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:

* page/ChromeClient.h:
(WebCore::ChromeClient::graphicsLayerFactory):
(WebCore::ChromeClient::createDisplayRefreshMonitor):
* platform/graphics/DisplayRefreshMonitorFactory.h: Added.
* platform/graphics/GraphicsLayerUpdater.cpp:
(WebCore::GraphicsLayerUpdater::createDisplayRefreshMonitor):
* platform/graphics/GraphicsLayerUpdater.h:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::createDisplayRefreshMonitor):
* rendering/RenderLayerCompositor.h:
Give the ChromeClient a chance to provide us with a custom DisplayRefreshMonitor.
If it does not, we'll fall back to making a DisplayRefreshMonitorMac or
DisplayRefreshMonitorIOS depending on the platform.

* dom/ScriptedAnimationController.cpp:
* dom/ScriptedAnimationController.h:
* platform/graphics/DisplayRefreshMonitor.cpp:
* platform/graphics/DisplayRefreshMonitor.h:
* platform/graphics/DisplayRefreshMonitorClient.cpp: Added.
* platform/graphics/DisplayRefreshMonitorClient.h: Added.
* platform/graphics/DisplayRefreshMonitorManager.cpp: Added.
* platform/graphics/DisplayRefreshMonitorManager.h: Added.
Split DisplayRefreshMonitor.cpp into one file per class.
Use references in a few places.
Remove some useless comments.

* platform/graphics/DisplayRefreshMonitor.cpp:
(WebCore::DisplayRefreshMonitor::displayDidRefresh):
Use takeAny() and remove a FIXME about it not existing.

* platform/graphics/DisplayRefreshMonitorClient.cpp: Added.
(WebCore::DisplayRefreshMonitorClient::fireDisplayRefreshIfNeeded):
Use an early return instead of having the whole function body in an if().

* platform/graphics/ios/DisplayRefreshMonitorIOS.h: Added.
* platform/graphics/ios/DisplayRefreshMonitorIOS.mm:
* platform/graphics/mac/DisplayRefreshMonitorMac.cpp:
* platform/graphics/mac/DisplayRefreshMonitorMac.h: Added.
Virtualize DisplayRefreshMonitorIOS and DisplayRefreshMonitorMac,
and move things specific to each of them out of DisplayRefreshMonitor itself.

* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::createDisplayRefreshMonitor):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::graphicsLayerFactory):
(WebKit::DrawingArea::createDisplayRefreshMonitor):
Plumb the DisplayRefreshMonitor request through to the DrawingArea.
RemoteLayerTreeDrawingArea will implement and return a RemoteLayerTreeDisplayRefreshMonitor.

* WebProcess/WebPage/Cocoa/RemoteLayerTreeDisplayRefreshMonitor.h: Added.
(WebKit::RemoteLayerTreeDisplayRefreshMonitor::create):
* WebProcess/WebPage/Cocoa/RemoteLayerTreeDisplayRefreshMonitor.mm: Added.
(WebKit::RemoteLayerTreeDisplayRefreshMonitor::RemoteLayerTreeDisplayRefreshMonitor):
(WebKit::RemoteLayerTreeDisplayRefreshMonitor::~RemoteLayerTreeDisplayRefreshMonitor):
(WebKit::RemoteLayerTreeDisplayRefreshMonitor::requestRefreshCallback):
When requesting a display refresh callback, schedule a layer commit.
It may end up being empty, but will still call us back with a didUpdate,
upon which we'll fire the callback.

(WebKit::RemoteLayerTreeDisplayRefreshMonitor::didUpdateLayers):

* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::createDisplayRefreshMonitor):
(WebKit::RemoteLayerTreeDrawingArea::willDestroyDisplayRefreshMonitor):
Keep track of the set of DisplayRefreshMonitors.

(WebKit::RemoteLayerTreeDrawingArea::didUpdate):
Fire requestAnimationFrame callbacks once the UI process commits the new layer tree.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169299 268f45cc-cd09-0410-ab3c-d52691b4dbfc
30 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/ScriptedAnimationController.cpp
Source/WebCore/dom/ScriptedAnimationController.h
Source/WebCore/page/ChromeClient.h
Source/WebCore/platform/graphics/DisplayRefreshMonitor.cpp
Source/WebCore/platform/graphics/DisplayRefreshMonitor.h
Source/WebCore/platform/graphics/DisplayRefreshMonitorClient.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/DisplayRefreshMonitorClient.h [new file with mode: 0644]
Source/WebCore/platform/graphics/DisplayRefreshMonitorManager.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/DisplayRefreshMonitorManager.h [new file with mode: 0644]
Source/WebCore/platform/graphics/GraphicsLayerUpdater.cpp
Source/WebCore/platform/graphics/GraphicsLayerUpdater.h
Source/WebCore/platform/graphics/ios/DisplayRefreshMonitorIOS.h [new file with mode: 0644]
Source/WebCore/platform/graphics/ios/DisplayRefreshMonitorIOS.mm
Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.cpp
Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.h [new file with mode: 0644]
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
Source/WebKit2/WebProcess/WebPage/Cocoa/RemoteLayerTreeDisplayRefreshMonitor.h [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/Cocoa/RemoteLayerTreeDisplayRefreshMonitor.mm [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp
Source/WebKit2/WebProcess/WebPage/DrawingArea.h
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm