void LayerTreeHostGtk::layerFlushTimerFired() { double fireTime = monotonicallyIncreasingTime(); flushAndRenderLayers(); if (m_layerFlushTimerCallback.isScheduled() || !toTextureMapperLayer(m_rootLayer.get())->descendantsOrSelfHaveRunningAnimations()) return; static const double targetFramerate = 1 / 60.0; // When rendering layers takes more time than the target delay (0.016), we end up scheduling layer flushes // immediately. Since the layer flush timer has a higher priority than WebCore timers, these are never // fired while we keep scheduling layer flushes immediately. double current = monotonicallyIncreasingTime(); double timeToNextFlush = std::max(targetFramerate - (current - fireTime), 0.0); if (timeToNextFlush) m_lastImmediateFlushTime = 0; else if (!m_lastImmediateFlushTime) m_lastImmediateFlushTime = current; if (shouldSkipNextFrameBecauseOfContinousImmediateFlushes(current, m_lastImmediateFlushTime)) { timeToNextFlush = targetFramerate; m_lastImmediateFlushTime = 0; } // Modified by ZRL for compiling #if 0 m_layerFlushTimerCallback.scheduleAfterDelay("[WebKit] layerFlushTimer", std::bind(&LayerTreeHostGtk::layerFlushTimerFired, this), std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<double>(timeToNextFlush)), layerFlushTimerPriority); #else std::function<void ()> fp = std::bind(&LayerTreeHostGtk::layerFlushTimerFired, this); m_layerFlushTimerCallback.scheduleAfterDelay("[WebKit] layerFlushTimer", fp, std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<double>(timeToNextFlush)), layerFlushTimerPriority); #endif }
void LayerTreeHostGtk::layerFlushTimerFired() { ASSERT(m_layerFlushTimerCallbackId); m_layerFlushTimerCallbackId = 0; 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); }
void LayerTreeHostGtk::layerFlushTimerFired() { ASSERT(m_layerFlushTimerCallbackId); m_layerFlushTimerCallbackId = 0; flushAndRenderLayers(); 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); g_source_set_name_by_id(m_layerFlushTimerCallbackId, "[WebKit] layerFlushTimerFiredCallback"); } }
bool LayerTreeHostGtk::renderFrame() { flushAndRenderLayers(); return downcast<GraphicsLayerTextureMapper>(*m_rootLayer).layer().descendantsOrSelfHaveRunningAnimations(); }