- Revision
- 199048
- Author
- [email protected]
- Date
- 2016-04-04 23:15:43 -0700 (Mon, 04 Apr 2016)
Log Message
[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:
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (199047 => 199048)
--- trunk/Source/WebKit2/ChangeLog 2016-04-05 06:14:29 UTC (rev 199047)
+++ trunk/Source/WebKit2/ChangeLog 2016-04-05 06:15:43 UTC (rev 199048)
@@ -1,3 +1,35 @@
+2016-04-04 Zan Dobersek <[email protected]>
+
+ [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 <[email protected]>
Modern IDB: Dump blobs to disk before storing them in an object store.
Modified: trunk/Source/WebKit2/PlatformGTK.cmake (199047 => 199048)
--- trunk/Source/WebKit2/PlatformGTK.cmake 2016-04-05 06:14:29 UTC (rev 199047)
+++ trunk/Source/WebKit2/PlatformGTK.cmake 2016-04-05 06:15:43 UTC (rev 199048)
@@ -847,6 +847,7 @@
Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp
Shared/CoordinatedGraphics/SimpleViewportController.cpp
+ Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp
Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.cpp
Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
Added: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp (0 => 199048)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp (rev 0)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp 2016-04-05 06:15:43 UTC (rev 199048)
@@ -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)
Added: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h (0 => 199048)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h (rev 0)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h 2016-04-05 06:15:43 UTC (rev 199048)
@@ -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
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp (199047 => 199048)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp 2016-04-05 06:14:29 UTC (rev 199047)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp 2016-04-05 06:15:43 UTC (rev 199048)
@@ -24,12 +24,12 @@
*/
#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 @@
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));
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h (199047 => 199048)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h 2016-04-05 06:14:29 UTC (rev 199047)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h 2016-04-05 06:15:43 UTC (rev 199048)
@@ -44,11 +44,11 @@
}
namespace WebKit {
+
+class CompositingRunLoop;
class CoordinatedGraphicsScene;
class CoordinatedGraphicsSceneClient;
-class CompositingRunLoop;
-
class ThreadedCompositor : public SimpleViewportController::Client, public CoordinatedGraphicsSceneClient, public ThreadSafeRefCounted<ThreadedCompositor> {
WTF_MAKE_NONCOPYABLE(ThreadedCompositor);
WTF_MAKE_FAST_ALLOCATED;