summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-11-22 15:17:51 +0100
committerKonstantin Käfer <mail@kkaefer.com>2016-11-22 20:58:51 +0100
commit117863f1114551407c481abc752f5fcfd139c878 (patch)
tree4c408a8a3809df59fdfac1bc622ea79fbdbe611e /platform
parent3bc79e316e343d59f77811bca4ed6c594431e91c (diff)
downloadqtlocation-mapboxgl-117863f1114551407c481abc752f5fcfd139c878.tar.gz
[build] move headless rendering files to platform/default
Diffstat (limited to 'platform')
-rw-r--r--platform/darwin/src/headless_backend_cgl.cpp4
-rw-r--r--platform/darwin/src/headless_backend_eagl.mm2
-rw-r--r--platform/darwin/src/headless_display_cgl.cpp2
-rw-r--r--platform/default/headless_backend_osmesa.cpp2
-rw-r--r--platform/default/mbgl/gl/headless_backend.cpp (renamed from platform/default/headless_backend.cpp)4
-rw-r--r--platform/default/mbgl/gl/headless_backend.hpp57
-rw-r--r--platform/default/mbgl/gl/headless_display.cpp (renamed from platform/default/headless_display.cpp)2
-rw-r--r--platform/default/mbgl/gl/headless_display.hpp20
-rw-r--r--platform/default/mbgl/gl/offscreen_view.cpp (renamed from platform/default/offscreen_view.cpp)2
-rw-r--r--platform/default/mbgl/gl/offscreen_view.hpp33
-rw-r--r--platform/ios/config.cmake9
-rw-r--r--platform/linux/config.cmake9
-rw-r--r--platform/linux/src/headless_backend_egl.cpp4
-rw-r--r--platform/linux/src/headless_backend_glx.cpp4
-rw-r--r--platform/linux/src/headless_display_egl.cpp2
-rw-r--r--platform/linux/src/headless_display_glx.cpp2
-rw-r--r--platform/macos/config.cmake7
-rw-r--r--platform/node/src/node_map.cpp2
-rw-r--r--platform/node/src/node_map.hpp4
-rw-r--r--platform/qt/config.cmake11
-rw-r--r--platform/qt/test/headless_backend_qt.cpp2
21 files changed, 153 insertions, 31 deletions
diff --git a/platform/darwin/src/headless_backend_cgl.cpp b/platform/darwin/src/headless_backend_cgl.cpp
index dd062dd6af..7069738fb1 100644
--- a/platform/darwin/src/headless_backend_cgl.cpp
+++ b/platform/darwin/src/headless_backend_cgl.cpp
@@ -1,5 +1,5 @@
-#include <mbgl/platform/default/headless_backend.hpp>
-#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/gl/headless_backend.hpp>
+#include <mbgl/gl/headless_display.hpp>
#include <OpenGL/OpenGL.h>
#include <CoreFoundation/CoreFoundation.h>
diff --git a/platform/darwin/src/headless_backend_eagl.mm b/platform/darwin/src/headless_backend_eagl.mm
index aa5efe6de3..bd4a202ec5 100644
--- a/platform/darwin/src/headless_backend_eagl.mm
+++ b/platform/darwin/src/headless_backend_eagl.mm
@@ -1,4 +1,4 @@
-#include <mbgl/platform/default/headless_backend.hpp>
+#include <mbgl/gl/headless_backend.hpp>
#include <mbgl/gl/extension.hpp>
diff --git a/platform/darwin/src/headless_display_cgl.cpp b/platform/darwin/src/headless_display_cgl.cpp
index e2907a80c9..90d187d3db 100644
--- a/platform/darwin/src/headless_display_cgl.cpp
+++ b/platform/darwin/src/headless_display_cgl.cpp
@@ -1,4 +1,4 @@
-#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/gl/headless_display.hpp>
#include <OpenGL/OpenGL.h>
diff --git a/platform/default/headless_backend_osmesa.cpp b/platform/default/headless_backend_osmesa.cpp
index 04709d4a1b..3dac5913ac 100644
--- a/platform/default/headless_backend_osmesa.cpp
+++ b/platform/default/headless_backend_osmesa.cpp
@@ -1,4 +1,4 @@
-#include <mbgl/platform/default/headless_backend.hpp>
+#include <mbgl/gl/headless_backend.hpp>
#include <mbgl/platform/log.hpp>
#include <GL/osmesa.h>
diff --git a/platform/default/headless_backend.cpp b/platform/default/mbgl/gl/headless_backend.cpp
index 30ce8d2230..0bfdf11c98 100644
--- a/platform/default/headless_backend.cpp
+++ b/platform/default/mbgl/gl/headless_backend.cpp
@@ -1,5 +1,5 @@
-#include <mbgl/platform/default/headless_backend.hpp>
-#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/gl/headless_backend.hpp>
+#include <mbgl/gl/headless_display.hpp>
#include <cassert>
#include <stdexcept>
diff --git a/platform/default/mbgl/gl/headless_backend.hpp b/platform/default/mbgl/gl/headless_backend.hpp
new file mode 100644
index 0000000000..da8c55e044
--- /dev/null
+++ b/platform/default/mbgl/gl/headless_backend.hpp
@@ -0,0 +1,57 @@
+#pragma once
+
+#include <mbgl/gl/extension.hpp>
+
+#include <mbgl/map/backend.hpp>
+
+#include <memory>
+#include <functional>
+
+namespace mbgl {
+
+class HeadlessDisplay;
+
+class HeadlessBackend : public Backend {
+public:
+ HeadlessBackend();
+ HeadlessBackend(std::shared_ptr<HeadlessDisplay>);
+ ~HeadlessBackend() override;
+
+ void invalidate() override;
+ void activate() override;
+ void deactivate() override;
+ void notifyMapChange(MapChange) override;
+
+ void setMapChangeCallback(std::function<void(MapChange)>&& cb) { mapChangeCallback = std::move(cb); }
+
+ struct Impl {
+ virtual ~Impl() {}
+ virtual void activateContext() = 0;
+ virtual void deactivateContext() {}
+ };
+
+private:
+ // Implementation specific functions
+ static gl::glProc initializeExtension(const char*);
+
+ bool hasContext() const { return bool(impl); }
+ bool hasDisplay();
+
+ void createContext();
+
+private:
+ void destroyContext();
+
+ void activateContext();
+ void deactivateContext();
+
+ std::unique_ptr<Impl> impl;
+ std::shared_ptr<HeadlessDisplay> display;
+
+ bool extensionsLoaded = false;
+ bool active = false;
+
+ std::function<void(MapChange)> mapChangeCallback;
+};
+
+} // namespace mbgl
diff --git a/platform/default/headless_display.cpp b/platform/default/mbgl/gl/headless_display.cpp
index 4ab111f775..6247046c29 100644
--- a/platform/default/headless_display.cpp
+++ b/platform/default/mbgl/gl/headless_display.cpp
@@ -1,4 +1,4 @@
-#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/gl/headless_display.hpp>
namespace mbgl {
diff --git a/platform/default/mbgl/gl/headless_display.hpp b/platform/default/mbgl/gl/headless_display.hpp
new file mode 100644
index 0000000000..a5c95085b8
--- /dev/null
+++ b/platform/default/mbgl/gl/headless_display.hpp
@@ -0,0 +1,20 @@
+#pragma once
+
+#include <memory>
+
+namespace mbgl {
+
+class HeadlessDisplay {
+public:
+ HeadlessDisplay();
+ ~HeadlessDisplay();
+
+ template <typename DisplayAttribute>
+ DisplayAttribute attribute() const;
+
+private:
+ class Impl;
+ std::unique_ptr<Impl> impl;
+};
+
+} // namespace mbgl
diff --git a/platform/default/offscreen_view.cpp b/platform/default/mbgl/gl/offscreen_view.cpp
index 574686ebc9..16faf6a4a9 100644
--- a/platform/default/offscreen_view.cpp
+++ b/platform/default/mbgl/gl/offscreen_view.cpp
@@ -1,4 +1,4 @@
-#include <mbgl/platform/default/offscreen_view.hpp>
+#include <mbgl/gl/offscreen_view.hpp>
#include <mbgl/gl/context.hpp>
#include <cstring>
diff --git a/platform/default/mbgl/gl/offscreen_view.hpp b/platform/default/mbgl/gl/offscreen_view.hpp
new file mode 100644
index 0000000000..0e839e14cc
--- /dev/null
+++ b/platform/default/mbgl/gl/offscreen_view.hpp
@@ -0,0 +1,33 @@
+#pragma once
+
+#include <mbgl/map/view.hpp>
+#include <mbgl/gl/framebuffer.hpp>
+#include <mbgl/gl/renderbuffer.hpp>
+#include <mbgl/util/optional.hpp>
+#include <mbgl/util/image.hpp>
+
+namespace mbgl {
+
+namespace gl {
+class Context;
+} // namespace gl
+
+class OffscreenView : public View {
+public:
+ OffscreenView(gl::Context&, Size size = { 256, 256 });
+
+ void bind() override;
+
+ PremultipliedImage readStillImage();
+
+public:
+ const Size size;
+
+private:
+ gl::Context& context;
+ optional<gl::Framebuffer> framebuffer;
+ optional<gl::Renderbuffer<gl::RenderbufferType::RGBA>> color;
+ optional<gl::Renderbuffer<gl::RenderbufferType::DepthStencil>> depthStencil;
+};
+
+} // namespace mbgl
diff --git a/platform/ios/config.cmake b/platform/ios/config.cmake
index 56cb5344ae..565cfc8a13 100644
--- a/platform/ios/config.cmake
+++ b/platform/ios/config.cmake
@@ -42,10 +42,13 @@ macro(mbgl_platform_core)
PRIVATE platform/darwin/src/image.mm
# Headless view
+ PRIVATE platform/default/mbgl/gl/headless_backend.cpp
+ PRIVATE platform/default/mbgl/gl/headless_backend.hpp
PRIVATE platform/darwin/src/headless_backend_eagl.mm
- PRIVATE platform/default/headless_backend.cpp
- PRIVATE platform/default/headless_display.cpp
- PRIVATE platform/default/offscreen_view.cpp
+ PRIVATE platform/default/mbgl/gl/headless_display.cpp
+ PRIVATE platform/default/mbgl/gl/headless_display.hpp
+ PRIVATE platform/default/mbgl/gl/offscreen_view.cpp
+ PRIVATE platform/default/mbgl/gl/offscreen_view.hpp
# Thread pool
PRIVATE platform/default/mbgl/util/default_thread_pool.cpp
diff --git a/platform/linux/config.cmake b/platform/linux/config.cmake
index 312577a185..20679f53e9 100644
--- a/platform/linux/config.cmake
+++ b/platform/linux/config.cmake
@@ -18,7 +18,7 @@ macro(mbgl_platform_core)
if(WITH_OSMESA)
target_sources(mbgl-core
PRIVATE platform/default/headless_backend_osmesa.cpp
- PRIVATE platform/default/headless_display.cpp
+ PRIVATE platform/default/mbgl/gl/headless_display.cpp
)
target_add_mason_package(mbgl-core PUBLIC mesa)
elseif(WITH_EGL)
@@ -78,8 +78,11 @@ macro(mbgl_platform_core)
PRIVATE platform/default/webp_reader.cpp
# Headless view
- PRIVATE platform/default/headless_backend.cpp
- PRIVATE platform/default/offscreen_view.cpp
+ PRIVATE platform/default/mbgl/gl/headless_backend.cpp
+ PRIVATE platform/default/mbgl/gl/headless_backend.hpp
+ PRIVATE platform/default/mbgl/gl/headless_display.hpp
+ PRIVATE platform/default/mbgl/gl/offscreen_view.cpp
+ PRIVATE platform/default/mbgl/gl/offscreen_view.hpp
# Thread pool
PRIVATE platform/default/mbgl/util/default_thread_pool.cpp
diff --git a/platform/linux/src/headless_backend_egl.cpp b/platform/linux/src/headless_backend_egl.cpp
index 0fb33ea0e0..6288cf3805 100644
--- a/platform/linux/src/headless_backend_egl.cpp
+++ b/platform/linux/src/headless_backend_egl.cpp
@@ -1,5 +1,5 @@
-#include <mbgl/platform/default/headless_backend.hpp>
-#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/gl/headless_backend.hpp>
+#include <mbgl/gl/headless_display.hpp>
#include <mbgl/platform/log.hpp>
diff --git a/platform/linux/src/headless_backend_glx.cpp b/platform/linux/src/headless_backend_glx.cpp
index e1ea9cef15..79e3fe1390 100644
--- a/platform/linux/src/headless_backend_glx.cpp
+++ b/platform/linux/src/headless_backend_glx.cpp
@@ -1,5 +1,5 @@
-#include <mbgl/platform/default/headless_backend.hpp>
-#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/gl/headless_backend.hpp>
+#include <mbgl/gl/headless_display.hpp>
#include <mbgl/platform/log.hpp>
diff --git a/platform/linux/src/headless_display_egl.cpp b/platform/linux/src/headless_display_egl.cpp
index 4be519cfcd..95c2ebb6a6 100644
--- a/platform/linux/src/headless_display_egl.cpp
+++ b/platform/linux/src/headless_display_egl.cpp
@@ -1,4 +1,4 @@
-#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/gl/headless_display.hpp>
#include <mbgl/platform/log.hpp>
#include <mbgl/util/string.hpp>
diff --git a/platform/linux/src/headless_display_glx.cpp b/platform/linux/src/headless_display_glx.cpp
index 2023d4dcd2..4275ebb646 100644
--- a/platform/linux/src/headless_display_glx.cpp
+++ b/platform/linux/src/headless_display_glx.cpp
@@ -1,4 +1,4 @@
-#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/gl/headless_display.hpp>
#include <GL/glx.h>
diff --git a/platform/macos/config.cmake b/platform/macos/config.cmake
index 13b434117f..6c518becf2 100644
--- a/platform/macos/config.cmake
+++ b/platform/macos/config.cmake
@@ -42,10 +42,13 @@ macro(mbgl_platform_core)
PRIVATE platform/darwin/src/image.mm
# Headless view
+ PRIVATE platform/default/mbgl/gl/headless_backend.cpp
+ PRIVATE platform/default/mbgl/gl/headless_backend.hpp
PRIVATE platform/darwin/src/headless_backend_cgl.cpp
+ PRIVATE platform/default/mbgl/gl/headless_display.hpp
PRIVATE platform/darwin/src/headless_display_cgl.cpp
- PRIVATE platform/default/headless_backend.cpp
- PRIVATE platform/default/offscreen_view.cpp
+ PRIVATE platform/default/mbgl/gl/offscreen_view.cpp
+ PRIVATE platform/default/mbgl/gl/offscreen_view.hpp
# Thread pool
PRIVATE platform/default/mbgl/util/default_thread_pool.cpp
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp
index c0f86dfb6a..48a954504c 100644
--- a/platform/node/src/node_map.cpp
+++ b/platform/node/src/node_map.cpp
@@ -4,7 +4,7 @@
#include "node_conversion.hpp"
#include "node_geojson.hpp"
-#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/gl/headless_display.hpp>
#include <mbgl/util/exception.hpp>
#include <mbgl/style/conversion/source.hpp>
#include <mbgl/style/conversion/layer.hpp>
diff --git a/platform/node/src/node_map.hpp b/platform/node/src/node_map.hpp
index 20ed1af4f4..c68f543b02 100644
--- a/platform/node/src/node_map.hpp
+++ b/platform/node/src/node_map.hpp
@@ -4,8 +4,8 @@
#include <mbgl/map/map.hpp>
#include <mbgl/storage/file_source.hpp>
-#include <mbgl/platform/default/headless_backend.hpp>
-#include <mbgl/platform/default/offscreen_view.hpp>
+#include <mbgl/gl/headless_backend.hpp>
+#include <mbgl/gl/offscreen_view.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
diff --git a/platform/qt/config.cmake b/platform/qt/config.cmake
index 80274f5ba1..30781fa428 100644
--- a/platform/qt/config.cmake
+++ b/platform/qt/config.cmake
@@ -43,11 +43,14 @@ endmacro()
macro(mbgl_platform_test)
target_sources(mbgl-test
PRIVATE test/src/main.cpp
- PRIVATE platform/qt/test/headless_backend_qt.cpp
PRIVATE platform/qt/test/qmapboxgl.cpp
- PRIVATE platform/default/headless_backend.cpp
- PRIVATE platform/default/headless_display.cpp
- PRIVATE platform/default/offscreen_view.cpp
+ PRIVATE platform/default/mbgl/gl/headless_backend.cpp
+ PRIVATE platform/default/mbgl/gl/headless_backend.hpp
+ PRIVATE platform/default/mbgl/gl/headless_display.cpp
+ PRIVATE platform/default/mbgl/gl/headless_display.hpp
+ PRIVATE platform/default/mbgl/gl/offscreen_view.cpp
+ PRIVATE platform/default/mbgl/gl/offscreen_view.hpp
+ PRIVATE platform/qt/test/headless_backend_qt.cpp
)
set_source_files_properties(
diff --git a/platform/qt/test/headless_backend_qt.cpp b/platform/qt/test/headless_backend_qt.cpp
index f6552c4557..1992cab2fa 100644
--- a/platform/qt/test/headless_backend_qt.cpp
+++ b/platform/qt/test/headless_backend_qt.cpp
@@ -1,4 +1,4 @@
-#include <mbgl/platform/default/headless_backend.hpp>
+#include <mbgl/gl/headless_backend.hpp>
#include <QApplication>
#include <QGLContext>