Schedule rendering at regular interval (60fps)
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Apr 2013 15:28:19 +0000 (15:28 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Apr 2013 15:28:19 +0000 (15:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=114617

Patch by Seulgi Kim <seulgikim@company100.net> on 2013-04-15
Reviewed by Martin Robinson.

Schedule rendering reguarly regardless of the time taken to render a
frame. Otherwise, next flush delayed by the amount of the rendering
time.

* WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
(WebKit::LayerTreeHostGtk::LayerTreeHostGtk):
(WebKit::LayerTreeHostGtk::layerFlushTimerFired):
(WebKit::LayerTreeHostGtk::flushAndRenderLayers):
* WebProcess/WebPage/gtk/LayerTreeHostGtk.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@148439 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp
Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h

index aa77d61..69b90ef 100644 (file)
@@ -1,3 +1,20 @@
+2013-04-15  Seulgi Kim  <seulgikim@company100.net>
+
+        Schedule rendering at regular interval (60fps)
+        https://bugs.webkit.org/show_bug.cgi?id=114617
+
+        Reviewed by Martin Robinson.
+
+        Schedule rendering reguarly regardless of the time taken to render a
+        frame. Otherwise, next flush delayed by the amount of the rendering
+        time.
+
+        * WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
+        (WebKit::LayerTreeHostGtk::LayerTreeHostGtk):
+        (WebKit::LayerTreeHostGtk::layerFlushTimerFired):
+        (WebKit::LayerTreeHostGtk::flushAndRenderLayers):
+        * WebProcess/WebPage/gtk/LayerTreeHostGtk.h:
+
 2013-04-15  Michał Pakuła vel Rutka  <m.pakula@samsung.com>
 
         [EFL][WK2] Use C API in ewk_context_menu
index 066cde5..838f6f1 100644 (file)
@@ -71,6 +71,7 @@ LayerTreeHostGtk::LayerTreeHostGtk(WebPage* webPage)
     : LayerTreeHost(webPage)
     , m_isValid(true)
     , m_notifyAfterScheduledLayerFlush(false)
+    , m_lastFlushTime(0)
     , m_layerFlushSchedulingEnabled(true)
     , m_layerFlushTimerCallbackId(0)
 {
@@ -301,8 +302,11 @@ void LayerTreeHostGtk::layerFlushTimerFired()
 
     flushAndRenderLayers();
 
-    if (toTextureMapperLayer(m_rootLayer.get())->descendantsOrSelfHaveRunningAnimations() && !m_layerFlushTimerCallbackId)
-        m_layerFlushTimerCallbackId = g_timeout_add_full(GDK_PRIORITY_EVENTS, 1000.0 / 60.0, reinterpret_cast<GSourceFunc>(layerFlushTimerFiredCallback), this, 0);
+    if (toTextureMapperLayer(m_rootLayer.get())->descendantsOrSelfHaveRunningAnimations() && !m_layerFlushTimerCallbackId) {
+        const double targetFPS = 60;
+        double nextFlush = std::max((1 / targetFPS) - (currentTime() - m_lastFlushTime), 0.0);
+        m_layerFlushTimerCallbackId = g_timeout_add_full(GDK_PRIORITY_EVENTS, nextFlush * 1000.0, reinterpret_cast<GSourceFunc>(layerFlushTimerFiredCallback), this, 0);
+    }
 }
 
 bool LayerTreeHostGtk::flushPendingLayerChanges()
@@ -358,6 +362,7 @@ void LayerTreeHostGtk::flushAndRenderLayers()
     if (!flushPendingLayerChanges())
         return;
 
+    m_lastFlushTime = currentTime();
     // Our model is very simple. We always composite and render the tree immediately after updating it.
     compositeLayersToContext();
 
index ea46828..009025e 100644 (file)
@@ -104,6 +104,7 @@ private:
     PageOverlayLayerMap m_pageOverlayLayers;
     OwnPtr<WebCore::TextureMapper> m_textureMapper;
     OwnPtr<WebCore::GLContext> m_context;
+    double m_lastFlushTime;
     bool m_layerFlushSchedulingEnabled;
     unsigned m_layerFlushTimerCallbackId;
 };