[CoordinatedGraphics] VideoRenderRequestScheduler shouldn't dispatch to main thread...
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Dec 2015 09:48:34 +0000 (09:48 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Dec 2015 09:48:34 +0000 (09:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152584

Reviewed by Carlos Garcia Campos.

The VideoRenderRequestScheduler class should only send the repaint-requested
signal dispatch to the main thread when not using the threaded compositor.
In case that is used (guarded via WTF_USE_COORDINATED_GRAPHICS_THREADED), the
signal dispatch can be done on the current thread (normally a GStreamer thread)
since the actual GL texture update will be then dispatched to the compositor
thread (unlike when gstreamer-gl is used, when the update can be done on the
very same thread).

When that is the case we don't need the RunLoop::Timer, Condition and the
video sink GRefPtr protector that are otherwise used by this class, so these
can just be guarded with the USE(...) flag.

* platform/graphics/gstreamer/VideoSinkGStreamer.cpp:
(VideoRenderRequestScheduler::VideoRenderRequestScheduler):
(VideoRenderRequestScheduler::stop):
(VideoRenderRequestScheduler::requestRender):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp

index 9287dfd..159dfca 100644 (file)
@@ -1,5 +1,29 @@
 2015-12-30  Zan Dobersek  <zdobersek@igalia.com>
 
+        [CoordinatedGraphics] VideoRenderRequestScheduler shouldn't dispatch to main thread in threaded compositor
+        https://bugs.webkit.org/show_bug.cgi?id=152584
+
+        Reviewed by Carlos Garcia Campos.
+
+        The VideoRenderRequestScheduler class should only send the repaint-requested
+        signal dispatch to the main thread when not using the threaded compositor.
+        In case that is used (guarded via WTF_USE_COORDINATED_GRAPHICS_THREADED), the
+        signal dispatch can be done on the current thread (normally a GStreamer thread)
+        since the actual GL texture update will be then dispatched to the compositor
+        thread (unlike when gstreamer-gl is used, when the update can be done on the
+        very same thread).
+
+        When that is the case we don't need the RunLoop::Timer, Condition and the
+        video sink GRefPtr protector that are otherwise used by this class, so these
+        can just be guarded with the USE(...) flag.
+
+        * platform/graphics/gstreamer/VideoSinkGStreamer.cpp:
+        (VideoRenderRequestScheduler::VideoRenderRequestScheduler):
+        (VideoRenderRequestScheduler::stop):
+        (VideoRenderRequestScheduler::requestRender):
+
+2015-12-30  Zan Dobersek  <zdobersek@igalia.com>
+
         [TexMap] Clean up TextureMapperAnimation, TextureMapperAnimations
         https://bugs.webkit.org/show_bug.cgi?id=152112
 
index d6d2326..ca599de 100644 (file)
@@ -73,9 +73,11 @@ static GRefPtr<GstSample> webkitVideoSinkRequestRender(WebKitVideoSink*, GstBuff
 class VideoRenderRequestScheduler {
 public:
     VideoRenderRequestScheduler()
+#if !USE(COORDINATED_GRAPHICS_THREADED)
         : m_timer(RunLoop::main(), this, &VideoRenderRequestScheduler::render)
+#endif
     {
-#if PLATFORM(GTK)
+#if PLATFORM(GTK) && !USE(COORDINATED_GRAPHICS_THREADED)
         // Use a higher priority than WebCore timers (G_PRIORITY_HIGH_IDLE + 20).
         m_timer.setPriority(G_PRIORITY_HIGH_IDLE + 19);
 #endif
@@ -90,10 +92,12 @@ public:
     void stop()
     {
         LockHolder locker(m_sampleMutex);
-        m_timer.stop();
         m_sample = nullptr;
         m_unlocked = true;
+#if !USE(COORDINATED_GRAPHICS_THREADED)
+        m_timer.stop();
         m_dataCondition.notifyOne();
+#endif
     }
 
     bool requestRender(WebKitVideoSink* sink, GstBuffer* buffer)
@@ -106,14 +110,21 @@ public:
         if (!m_sample)
             return false;
 
+#if USE(COORDINATED_GRAPHICS_THREADED)
+        if (LIKELY(GST_IS_SAMPLE(m_sample.get())))
+            webkitVideoSinkRepaintRequested(sink, m_sample.get());
+        m_sample = nullptr;
+#else
         m_sink = sink;
         m_timer.startOneShot(0);
         m_dataCondition.wait(m_sampleMutex);
+#endif
         return true;
     }
 
 private:
 
+#if !USE(COORDINATED_GRAPHICS_THREADED)
     void render()
     {
         LockHolder locker(m_sampleMutex);
@@ -123,12 +134,16 @@ private:
             webkitVideoSinkRepaintRequested(sink.get(), sample.get());
         m_dataCondition.notifyOne();
     }
+#endif
 
-    RunLoop::Timer<VideoRenderRequestScheduler> m_timer;
     Lock m_sampleMutex;
-    Condition m_dataCondition;
     GRefPtr<GstSample> m_sample;
+
+#if !USE(COORDINATED_GRAPHICS_THREADED)
+    RunLoop::Timer<VideoRenderRequestScheduler> m_timer;
+    Condition m_dataCondition;
     GRefPtr<WebKitVideoSink> m_sink;
+#endif
 
     // If this is true all processing should finish ASAP
     // This is necessary because there could be a race between