diff options
author | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2019-02-14 16:56:17 +0200 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2019-05-10 14:20:38 +0300 |
commit | 06f1dc48a2fb317979ab48ce323115be5bd48f16 (patch) | |
tree | 5ef1e78a1f98a7a26034ca519e267bda235b2817 /platform/android/src | |
parent | 947bc75f56fae7f1e70f21b98730dc6b460b9194 (diff) | |
download | qtlocation-mapboxgl-06f1dc48a2fb317979ab48ce323115be5bd48f16.tar.gz |
[core] Make the BackgroundScheduler a singleton
- Do not carry it over everywhere as parameter, it is a shared
instance anyway and the lifecycle is pretty much the app lifecycle
from the moment we instantiate a map.
- Rename to BackgroundScheduler because it is a Scheduler that will
do tasks in the background, we don't make assumptions if it is a
thread pool or a single thread.
- Most importantly, remove the dependency from `core` on `platform`.
Diffstat (limited to 'platform/android/src')
-rw-r--r-- | platform/android/src/map_renderer.cpp | 4 | ||||
-rwxr-xr-x | platform/android/src/native_map_view.cpp | 6 | ||||
-rwxr-xr-x | platform/android/src/native_map_view.hpp | 2 | ||||
-rw-r--r-- | platform/android/src/snapshotter/map_snapshotter.cpp | 7 | ||||
-rw-r--r-- | platform/android/src/snapshotter/map_snapshotter.hpp | 2 | ||||
-rw-r--r-- | platform/android/src/style/sources/geojson_source.cpp | 7 |
6 files changed, 7 insertions, 21 deletions
diff --git a/platform/android/src/map_renderer.cpp b/platform/android/src/map_renderer.cpp index 64c00585f8..92444c404d 100644 --- a/platform/android/src/map_renderer.cpp +++ b/platform/android/src/map_renderer.cpp @@ -2,7 +2,6 @@ #include <mbgl/renderer/renderer.hpp> #include <mbgl/gfx/backend_scope.hpp> -#include <mbgl/util/shared_thread_pool.hpp> #include <mbgl/util/run_loop.hpp> #include <string> @@ -23,7 +22,6 @@ MapRenderer::MapRenderer(jni::JNIEnv& _env, , pixelRatio(pixelRatio_) , programCacheDir(jni::Make<std::string>(_env, programCacheDir_)) , localIdeographFontFamily(localIdeographFontFamily_ ? jni::Make<std::string>(_env, localIdeographFontFamily_) : optional<std::string>{}) - , threadPool(sharedThreadPool()) , mailbox(std::make_shared<Mailbox>(*this)) { } @@ -175,7 +173,7 @@ void MapRenderer::onSurfaceCreated(JNIEnv&) { // Create the new backend and renderer backend = std::make_unique<AndroidRendererBackend>(); - renderer = std::make_unique<Renderer>(*backend, pixelRatio, *threadPool, programCacheDir, localIdeographFontFamily); + renderer = std::make_unique<Renderer>(*backend, pixelRatio, programCacheDir, localIdeographFontFamily); rendererRef = std::make_unique<ActorRef<Renderer>>(*renderer, mailbox); // Set the observer on the new Renderer implementation diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp index 8f1ec9c576..ae53bcc802 100755 --- a/platform/android/src/native_map_view.cpp +++ b/platform/android/src/native_map_view.cpp @@ -21,7 +21,6 @@ #include <mbgl/util/exception.hpp> #include <mbgl/util/geo.hpp> #include <mbgl/util/image.hpp> -#include <mbgl/util/shared_thread_pool.hpp> #include <mbgl/util/logging.hpp> #include <mbgl/util/platform.hpp> #include <mbgl/util/projection.hpp> @@ -66,8 +65,7 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env, jni::jboolean _crossSourceCollisions) : javaPeer(_env, _obj) , mapRenderer(MapRenderer::getNativePeer(_env, jMapRenderer)) - , pixelRatio(_pixelRatio) - , threadPool(sharedThreadPool()) { + , pixelRatio(_pixelRatio) { // Get a reference to the JavaVM for callbacks if (_env.GetJavaVM(&vm) < 0) { @@ -89,7 +87,7 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env, // Create the core map map = std::make_unique<mbgl::Map>( - *rendererFrontend, *this, *threadPool, options, + *rendererFrontend, *this, options, mbgl::android::FileSource::getSharedResourceOptions(_env, jFileSource)); } diff --git a/platform/android/src/native_map_view.hpp b/platform/android/src/native_map_view.hpp index c9ba6089c3..9e6ad73dd7 100755 --- a/platform/android/src/native_map_view.hpp +++ b/platform/android/src/native_map_view.hpp @@ -4,7 +4,6 @@ #include <mbgl/map/camera.hpp> #include <mbgl/map/map.hpp> #include <mbgl/util/noncopyable.hpp> -#include <mbgl/util/default_thread_pool.hpp> #include <mbgl/util/run_loop.hpp> #include <mbgl/storage/network_status.hpp> @@ -258,7 +257,6 @@ private: int height = 64; // Ensure these are initialised last - std::shared_ptr<mbgl::ThreadPool> threadPool; std::unique_ptr<mbgl::Map> map; mbgl::EdgeInsets insets; }; diff --git a/platform/android/src/snapshotter/map_snapshotter.cpp b/platform/android/src/snapshotter/map_snapshotter.cpp index 47a2781cb5..2eca6595e1 100644 --- a/platform/android/src/snapshotter/map_snapshotter.cpp +++ b/platform/android/src/snapshotter/map_snapshotter.cpp @@ -2,7 +2,6 @@ #include <mbgl/renderer/renderer.hpp> #include <mbgl/style/style.hpp> -#include <mbgl/util/shared_thread_pool.hpp> #include <mbgl/util/logging.hpp> #include <mbgl/util/string.hpp> #include <mbgl/actor/scheduler.hpp> @@ -27,8 +26,7 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env, const jni::String& _programCacheDir, const jni::String& _localIdeographFontFamily) : javaPeer(_env, _obj) - , pixelRatio(_pixelRatio) - , threadPool(sharedThreadPool()) { + , pixelRatio(_pixelRatio) { // Get a reference to the JavaVM for callbacks if (_env.GetJavaVM(&vm) < 0) { @@ -58,8 +56,7 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env, showLogo = _showLogo; // Create the core snapshotter - snapshotter = std::make_unique<mbgl::MapSnapshotter>(threadPool, - style, + snapshotter = std::make_unique<mbgl::MapSnapshotter>(style, size, pixelRatio, cameraOptions, diff --git a/platform/android/src/snapshotter/map_snapshotter.hpp b/platform/android/src/snapshotter/map_snapshotter.hpp index e8c0885ff1..791aa61d6a 100644 --- a/platform/android/src/snapshotter/map_snapshotter.hpp +++ b/platform/android/src/snapshotter/map_snapshotter.hpp @@ -1,7 +1,6 @@ #pragma once #include <mbgl/map/map_snapshotter.hpp> -#include <mbgl/util/default_thread_pool.hpp> #include <mbgl/util/util.hpp> #include "../file_source.hpp" @@ -63,7 +62,6 @@ private: float pixelRatio; bool showLogo; - std::shared_ptr<mbgl::ThreadPool> threadPool; std::unique_ptr<Actor<mbgl::MapSnapshotter::Callback>> snapshotCallback; std::unique_ptr<mbgl::MapSnapshotter> snapshotter; diff --git a/platform/android/src/style/sources/geojson_source.cpp b/platform/android/src/style/sources/geojson_source.cpp index a9307afe67..5ff4864275 100644 --- a/platform/android/src/style/sources/geojson_source.cpp +++ b/platform/android/src/style/sources/geojson_source.cpp @@ -17,7 +17,6 @@ #include "../conversion/url_or_tileset.hpp" #include <string> -#include <mbgl/util/shared_thread_pool.hpp> // GeoJSONSource uses a "coalescing" model for high frequency asynchronous data update calls, // which in practice means, that any update that started processing is going to finish @@ -48,16 +47,14 @@ namespace android { : Source(env, std::make_unique<mbgl::style::GeoJSONSource>( jni::Make<std::string>(env, sourceId), convertGeoJSONOptions(env, options))) - , threadPool(sharedThreadPool()) - , converter(std::make_unique<Actor<FeatureConverter>>(*threadPool)) { + , converter(std::make_unique<Actor<FeatureConverter>>(Scheduler::GetBackground())) { } GeoJSONSource::GeoJSONSource(jni::JNIEnv& env, mbgl::style::Source& coreSource, AndroidRendererFrontend& frontend) : Source(env, coreSource, createJavaPeer(env), frontend) - , threadPool(sharedThreadPool()) - , converter(std::make_unique<Actor<FeatureConverter>>(*threadPool)) { + , converter(std::make_unique<Actor<FeatureConverter>>(Scheduler::GetBackground())) { } GeoJSONSource::~GeoJSONSource() = default; |