diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2017-07-05 18:04:15 +0300 |
---|---|---|
committer | Ivo van Dongen <ivovandongen@users.noreply.github.com> | 2017-07-18 10:45:12 +0200 |
commit | a5a0558bde5d67617b6f305179063cd4e0ac329e (patch) | |
tree | 346e4a6831ff991c5e805b1ae0616839ac9c7b62 /platform | |
parent | 815ffb253b555c9a99b7d63a343745db05802c76 (diff) | |
download | qtlocation-mapboxgl-a5a0558bde5d67617b6f305179063cd4e0ac329e.tar.gz |
[test] allow only a single shared display to avoid egl errors
Diffstat (limited to 'platform')
-rw-r--r-- | platform/darwin/src/headless_backend_cgl.cpp | 2 | ||||
-rw-r--r-- | platform/default/mbgl/gl/headless_backend.cpp | 4 | ||||
-rw-r--r-- | platform/default/mbgl/gl/headless_backend.hpp | 1 | ||||
-rw-r--r-- | platform/default/mbgl/gl/headless_display.hpp | 16 | ||||
-rw-r--r-- | platform/linux/src/headless_backend_egl.cpp | 2 | ||||
-rw-r--r-- | platform/linux/src/headless_backend_glx.cpp | 2 | ||||
-rw-r--r-- | platform/node/src/node_map.cpp | 12 |
7 files changed, 19 insertions, 20 deletions
diff --git a/platform/darwin/src/headless_backend_cgl.cpp b/platform/darwin/src/headless_backend_cgl.cpp index 6ad98f4326..3b0c3aaf35 100644 --- a/platform/darwin/src/headless_backend_cgl.cpp +++ b/platform/darwin/src/headless_backend_cgl.cpp @@ -51,7 +51,7 @@ gl::ProcAddress HeadlessBackend::initializeExtension(const char* name) { bool HeadlessBackend::hasDisplay() { if (!display) { - display.reset(new HeadlessDisplay); + display = HeadlessDisplay::create(); } return bool(display); } diff --git a/platform/default/mbgl/gl/headless_backend.cpp b/platform/default/mbgl/gl/headless_backend.cpp index e17e8f5c11..9076be4cbb 100644 --- a/platform/default/mbgl/gl/headless_backend.cpp +++ b/platform/default/mbgl/gl/headless_backend.cpp @@ -11,10 +11,6 @@ namespace mbgl { HeadlessBackend::HeadlessBackend() = default; -HeadlessBackend::HeadlessBackend(std::shared_ptr<HeadlessDisplay> display_) - : display(std::move(display_)) { -} - HeadlessBackend::~HeadlessBackend() { BackendScope guard { *this, getScopeType() }; context.reset(); diff --git a/platform/default/mbgl/gl/headless_backend.hpp b/platform/default/mbgl/gl/headless_backend.hpp index 133c2096d9..5f39eb9f00 100644 --- a/platform/default/mbgl/gl/headless_backend.hpp +++ b/platform/default/mbgl/gl/headless_backend.hpp @@ -12,7 +12,6 @@ class HeadlessDisplay; class HeadlessBackend : public RendererBackend { public: HeadlessBackend(); - HeadlessBackend(std::shared_ptr<HeadlessDisplay>); ~HeadlessBackend() override; void updateAssumedState() override; diff --git a/platform/default/mbgl/gl/headless_display.hpp b/platform/default/mbgl/gl/headless_display.hpp index a5c95085b8..8c294655e5 100644 --- a/platform/default/mbgl/gl/headless_display.hpp +++ b/platform/default/mbgl/gl/headless_display.hpp @@ -6,13 +6,27 @@ namespace mbgl { class HeadlessDisplay { public: - HeadlessDisplay(); + static std::shared_ptr<HeadlessDisplay> create() { + static std::weak_ptr<HeadlessDisplay> instance; + + auto shared = instance.lock(); + + if (!shared) { + instance = shared = std::shared_ptr<HeadlessDisplay>(new HeadlessDisplay()); + } + + return shared; + } + + ~HeadlessDisplay(); template <typename DisplayAttribute> DisplayAttribute attribute() const; private: + HeadlessDisplay(); + class Impl; std::unique_ptr<Impl> impl; }; diff --git a/platform/linux/src/headless_backend_egl.cpp b/platform/linux/src/headless_backend_egl.cpp index d98b2edc03..0784173af7 100644 --- a/platform/linux/src/headless_backend_egl.cpp +++ b/platform/linux/src/headless_backend_egl.cpp @@ -67,7 +67,7 @@ gl::ProcAddress HeadlessBackend::initializeExtension(const char* name) { bool HeadlessBackend::hasDisplay() { if (!display) { - display.reset(new HeadlessDisplay); + display = HeadlessDisplay::create(); } return bool(display); }; diff --git a/platform/linux/src/headless_backend_glx.cpp b/platform/linux/src/headless_backend_glx.cpp index eec0e7656f..0ba7f08630 100644 --- a/platform/linux/src/headless_backend_glx.cpp +++ b/platform/linux/src/headless_backend_glx.cpp @@ -50,7 +50,7 @@ gl::ProcAddress HeadlessBackend::initializeExtension(const char* name) { bool HeadlessBackend::hasDisplay() { if (!display) { - display.reset(new HeadlessDisplay); + display = HeadlessDisplay::create(); } return bool(display); }; diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index b4e93455ea..079112b4c8 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -5,7 +5,6 @@ #include "node_geojson.hpp" #include "node_renderer_frontend.hpp" -#include <mbgl/gl/headless_display.hpp> #include <mbgl/util/exception.hpp> #include <mbgl/renderer/renderer.hpp> #include <mbgl/renderer/backend_scope.hpp> @@ -35,17 +34,11 @@ struct NodeMap::RenderOptions { Nan::Persistent<v8::Function> NodeMap::constructor; -static std::shared_ptr<mbgl::HeadlessDisplay> sharedDisplay() { - static auto display = std::make_shared<mbgl::HeadlessDisplay>(); - return display; -} - static const char* releasedMessage() { return "Map resources have already been released"; } -NodeBackend::NodeBackend() - : HeadlessBackend(sharedDisplay()) {} +NodeBackend::NodeBackend(): HeadlessBackend() {} void NodeMapObserver::onDidFailLoadingMap(std::exception_ptr error) { std::rethrow_exception(error); @@ -81,9 +74,6 @@ void NodeMap::Init(v8::Local<v8::Object> target) { constructor.Reset(tpl->GetFunction()); Nan::Set(target, Nan::New("Map").ToLocalChecked(), tpl->GetFunction()); - - // Initialize display connection on module load. - sharedDisplay(); } /** |