[ThreadedCompositor] Move CompositingRunLoop class into a separate file
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Apr 2016 06:15:43 +0000 (06:15 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Apr 2016 06:15:43 +0000 (06:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=156170

Reviewed by Michael Catanzaro.

Move the CompositingRunLoop class from the ThreadedCompositor.cpp file
into its own implementation file, with the class declaration placed
into the accompanying header file. This follows the general rule of
keeping different class implementations in separate files.

No change in behavior, just refactoring.

* PlatformGTK.cmake:
* Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp: Added.
(WebKit::CompositingRunLoop::CompositingRunLoop):
(WebKit::CompositingRunLoop::callOnCompositingRunLoop):
(WebKit::CompositingRunLoop::setUpdateTimer):
(WebKit::CompositingRunLoop::stopUpdateTimer):
(WebKit::CompositingRunLoop::updateTimerFired):
* Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h: Added.
(WebKit::CompositingRunLoop::runLoop):
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
(WebKit::CompositingRunLoop::CompositingRunLoop): Deleted.
(WebKit::CompositingRunLoop::callOnCompositingRunLoop): Deleted.
(WebKit::CompositingRunLoop::setUpdateTimer): Deleted.
(WebKit::CompositingRunLoop::stopUpdateTimer): Deleted.
(WebKit::CompositingRunLoop::runLoop): Deleted.
(WebKit::CompositingRunLoop::updateTimerFired): Deleted.
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:

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

Source/WebKit2/ChangeLog
Source/WebKit2/PlatformGTK.cmake
Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp [new file with mode: 0644]
Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h [new file with mode: 0644]
Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h

index 5c4844b..b92c33a 100644 (file)
@@ -1,3 +1,35 @@
+2016-04-04  Zan Dobersek  <zdobersek@igalia.com>
+
+        [ThreadedCompositor] Move CompositingRunLoop class into a separate file
+        https://bugs.webkit.org/show_bug.cgi?id=156170
+
+        Reviewed by Michael Catanzaro.
+
+        Move the CompositingRunLoop class from the ThreadedCompositor.cpp file
+        into its own implementation file, with the class declaration placed
+        into the accompanying header file. This follows the general rule of
+        keeping different class implementations in separate files.
+
+        No change in behavior, just refactoring.
+
+        * PlatformGTK.cmake:
+        * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp: Added.
+        (WebKit::CompositingRunLoop::CompositingRunLoop):
+        (WebKit::CompositingRunLoop::callOnCompositingRunLoop):
+        (WebKit::CompositingRunLoop::setUpdateTimer):
+        (WebKit::CompositingRunLoop::stopUpdateTimer):
+        (WebKit::CompositingRunLoop::updateTimerFired):
+        * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h: Added.
+        (WebKit::CompositingRunLoop::runLoop):
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
+        (WebKit::CompositingRunLoop::CompositingRunLoop): Deleted.
+        (WebKit::CompositingRunLoop::callOnCompositingRunLoop): Deleted.
+        (WebKit::CompositingRunLoop::setUpdateTimer): Deleted.
+        (WebKit::CompositingRunLoop::stopUpdateTimer): Deleted.
+        (WebKit::CompositingRunLoop::runLoop): Deleted.
+        (WebKit::CompositingRunLoop::updateTimerFired): Deleted.
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
+
 2016-04-04  Brady Eidson  <beidson@apple.com>
 
         Modern IDB: Dump blobs to disk before storing them in an object store.
index beeaf9c..79ead64 100644 (file)
@@ -847,6 +847,7 @@ if (ENABLE_THREADED_COMPOSITOR)
         Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp
         Shared/CoordinatedGraphics/SimpleViewportController.cpp
 
+        Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp
         Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.cpp
         Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
 
diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp
new file mode 100644 (file)
index 0000000..071b655
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CompositingRunLoop.h"
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+
+#include <wtf/CurrentTime.h>
+
+namespace WebKit {
+
+CompositingRunLoop::CompositingRunLoop(std::function<void ()>&& updateFunction)
+    : m_runLoop(RunLoop::current())
+    , m_updateTimer(m_runLoop, this, &CompositingRunLoop::updateTimerFired)
+    , m_updateFunction(WTFMove(updateFunction))
+    , m_lastUpdateTime(0)
+{
+}
+
+void CompositingRunLoop::callOnCompositingRunLoop(std::function<void ()>&& function)
+{
+    if (&m_runLoop == &RunLoop::current()) {
+        function();
+        return;
+    }
+
+    m_runLoop.dispatch(WTFMove(function));
+}
+
+void CompositingRunLoop::setUpdateTimer(UpdateTiming timing)
+{
+    if (m_updateTimer.isActive())
+        return;
+
+    const static double targetFPS = 60;
+    double nextUpdateTime = 0;
+    if (timing == WaitUntilNextFrame)
+        nextUpdateTime = std::max((1 / targetFPS) - (monotonicallyIncreasingTime() - m_lastUpdateTime), 0.0);
+
+    m_updateTimer.startOneShot(nextUpdateTime);
+}
+
+void CompositingRunLoop::stopUpdateTimer()
+{
+    if (m_updateTimer.isActive())
+        m_updateTimer.stop();
+}
+
+void CompositingRunLoop::updateTimerFired()
+{
+    m_updateFunction();
+    m_lastUpdateTime = monotonicallyIncreasingTime();
+}
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS_THREADED)
diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h
new file mode 100644 (file)
index 0000000..c2fccff
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CompositingRunLoop_h
+#define CompositingRunLoop_h
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+
+#include <functional>
+#include <wtf/FastMalloc.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/RunLoop.h>
+
+namespace WebKit {
+
+class CompositingRunLoop {
+    WTF_MAKE_NONCOPYABLE(CompositingRunLoop);
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    enum UpdateTiming {
+        Immediate,
+        WaitUntilNextFrame,
+    };
+
+    CompositingRunLoop(std::function<void ()>&&);
+
+    void callOnCompositingRunLoop(std::function<void ()>&&);
+
+    void setUpdateTimer(UpdateTiming timing = Immediate);
+    void stopUpdateTimer();
+
+    RunLoop& runLoop() { return m_runLoop; }
+
+private:
+    void updateTimerFired();
+
+    RunLoop& m_runLoop;
+    RunLoop::Timer<CompositingRunLoop> m_updateTimer;
+    std::function<void ()> m_updateFunction;
+
+    double m_lastUpdateTime;
+};
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS_THREADED)
+
+#endif // CompositingRunLoop_h
index a468886..dd2c67d 100644 (file)
  */
 
 #include "config.h"
+#include "ThreadedCompositor.h"
 
 #if USE(COORDINATED_GRAPHICS_THREADED)
-#include "ThreadedCompositor.h"
 
+#include "CompositingRunLoop.h"
 #include <WebCore/TransformationMatrix.h>
-#include <wtf/CurrentTime.h>
 #include <wtf/RunLoop.h>
 #include <wtf/StdLibExtras.h>
 
@@ -43,72 +43,6 @@ using namespace WebCore;
 
 namespace WebKit {
 
-class CompositingRunLoop {
-    WTF_MAKE_NONCOPYABLE(CompositingRunLoop);
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    enum UpdateTiming {
-        Immediate,
-        WaitUntilNextFrame,
-    };
-
-    CompositingRunLoop(std::function<void()>&& updateFunction)
-        : m_runLoop(RunLoop::current())
-        , m_updateTimer(m_runLoop, this, &CompositingRunLoop::updateTimerFired)
-        , m_updateFunction(WTFMove(updateFunction))
-        , m_lastUpdateTime(0)
-    {
-    }
-
-    void callOnCompositingRunLoop(std::function<void()>&& function)
-    {
-        if (&m_runLoop == &RunLoop::current()) {
-            function();
-            return;
-        }
-
-        m_runLoop.dispatch(WTFMove(function));
-    }
-
-    void setUpdateTimer(UpdateTiming timing = Immediate)
-    {
-        if (m_updateTimer.isActive())
-            return;
-
-        const static double targetFPS = 60;
-        double nextUpdateTime = 0;
-        if (timing == WaitUntilNextFrame)
-            nextUpdateTime = std::max((1 / targetFPS) - (monotonicallyIncreasingTime() - m_lastUpdateTime), 0.0);
-
-        m_updateTimer.startOneShot(nextUpdateTime);
-    }
-
-    void stopUpdateTimer()
-    {
-        if (m_updateTimer.isActive())
-            m_updateTimer.stop();
-    }
-
-    RunLoop& runLoop()
-    {
-        return m_runLoop;
-    }
-
-private:
-
-    void updateTimerFired()
-    {
-        m_updateFunction();
-        m_lastUpdateTime = monotonicallyIncreasingTime();
-    }
-
-    RunLoop& m_runLoop;
-    RunLoop::Timer<CompositingRunLoop> m_updateTimer;
-    std::function<void()> m_updateFunction;
-
-    double m_lastUpdateTime;
-};
-
 Ref<ThreadedCompositor> ThreadedCompositor::create(Client* client)
 {
     return adoptRef(*new ThreadedCompositor(client));
index a99951b..3835252 100644 (file)
@@ -44,10 +44,10 @@ struct CoordinatedGraphicsState;
 }
 
 namespace WebKit {
-class CoordinatedGraphicsScene;
-class CoordinatedGraphicsSceneClient;
 
 class CompositingRunLoop;
+class CoordinatedGraphicsScene;
+class CoordinatedGraphicsSceneClient;
 
 class ThreadedCompositor : public SimpleViewportController::Client, public CoordinatedGraphicsSceneClient, public ThreadSafeRefCounted<ThreadedCompositor> {
     WTF_MAKE_NONCOPYABLE(ThreadedCompositor);