diff options
author | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2018-03-08 23:56:42 +0200 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2018-05-04 17:46:17 +0300 |
commit | 0eab78d63a573b5fa2e5046e44cbd0109df8cbc5 (patch) | |
tree | 790d3aa3095a5274cc6042ab2fbe5def3e7d43c7 /platform | |
parent | 4ad1413d94c13d52ee679de1fe5fe720cf32e4fe (diff) | |
download | qtlocation-mapboxgl-0eab78d63a573b5fa2e5046e44cbd0109df8cbc5.tar.gz |
Bump Mapbox GL Native
Bump version.
mapbox-gl-native @ 27b21363e62c105db0b040b4c5a5ef31170ebd30
Diffstat (limited to 'platform')
-rw-r--r-- | platform/default/mbgl/storage/offline.cpp | 2 | ||||
-rw-r--r-- | platform/default/mbgl/util/default_styles.hpp | 3 | ||||
-rw-r--r-- | platform/default/sqlite3.cpp | 11 | ||||
-rw-r--r-- | platform/qt/include/qmapbox.hpp | 22 | ||||
-rw-r--r-- | platform/qt/include/qmapboxgl.hpp | 5 | ||||
-rw-r--r-- | platform/qt/src/qmapbox.cpp | 22 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 80 |
7 files changed, 81 insertions, 64 deletions
diff --git a/platform/default/mbgl/storage/offline.cpp b/platform/default/mbgl/storage/offline.cpp index 7670790be9..598a0b182b 100644 --- a/platform/default/mbgl/storage/offline.cpp +++ b/platform/default/mbgl/storage/offline.cpp @@ -43,7 +43,7 @@ uint64_t OfflineTilePyramidRegionDefinition::tileCount(style::SourceType type, u const Range<uint8_t> clampedZoomRange = coveringZoomRange(type, tileSize, zoomRange); unsigned long result = 0;; for (uint8_t z = clampedZoomRange.min; z <= clampedZoomRange.max; z++) { - result += util::tileCount(bounds, z, tileSize); + result += util::tileCount(bounds, z); } return result; diff --git a/platform/default/mbgl/util/default_styles.hpp b/platform/default/mbgl/util/default_styles.hpp index 43dafb8083..13f08252a7 100644 --- a/platform/default/mbgl/util/default_styles.hpp +++ b/platform/default/mbgl/util/default_styles.hpp @@ -19,12 +19,9 @@ constexpr const DefaultStyle light = { "mapbox://styles/mapbox/light- constexpr const DefaultStyle dark = { "mapbox://styles/mapbox/dark-v9", "Dark", 9 }; constexpr const DefaultStyle satellite = { "mapbox://styles/mapbox/satellite-v9", "Satellite", 9 }; constexpr const DefaultStyle satelliteStreets = { "mapbox://styles/mapbox/satellite-streets-v10", "Satellite Streets", 10 }; -constexpr const DefaultStyle trafficDay = { "mapbox://styles/mapbox/traffic-day-v2", "Traffic Day", 2 }; -constexpr const DefaultStyle trafficNight = { "mapbox://styles/mapbox/traffic-night-v2", "Traffic Night", 2 }; const DefaultStyle orderedStyles[] = { streets, outdoors, light, dark, satellite, satelliteStreets, - trafficDay, trafficNight, }; const size_t numOrderedStyles = sizeof(orderedStyles) / sizeof(DefaultStyle); diff --git a/platform/default/sqlite3.cpp b/platform/default/sqlite3.cpp index 8a567d602e..8f9c34191f 100644 --- a/platform/default/sqlite3.cpp +++ b/platform/default/sqlite3.cpp @@ -291,11 +291,12 @@ template <> void Query::bind(int offset, const char *value) { } // We currently cannot use sqlite3_bind_blob64 / sqlite3_bind_text64 because they -// was introduced in SQLite 3.8.7, and we need to support earlier versions: -// iOS 8.0: 3.7.13 -// iOS 8.2: 3.8.5 -// According to http://stackoverflow.com/questions/14288128/what-version-of-sqlite-does-ios-provide, -// the first iOS version with 3.8.7+ was 9.0, with 3.8.8. +// were introduced in SQLite 3.8.7, and we need to support earlier versions: +// Android 11: 3.7 +// Android 21: 3.8 +// Android 24: 3.9 +// Per https://developer.android.com/reference/android/database/sqlite/package-summary. +// The first iOS version with 3.8.7+ was 9.0, with 3.8.8. void Query::bind(int offset, const char * value, std::size_t length, bool retain) { assert(stmt.impl); diff --git a/platform/qt/include/qmapbox.hpp b/platform/qt/include/qmapbox.hpp index 471616daee..369890343f 100644 --- a/platform/qt/include/qmapbox.hpp +++ b/platform/qt/include/qmapbox.hpp @@ -9,14 +9,10 @@ // This header follows the Qt coding style: https://wiki.qt.io/Qt_Coding_Style -#if !defined(QT_MAPBOXGL_STATIC) -# if defined(QT_BUILD_MAPBOXGL_LIB) -# define Q_MAPBOXGL_EXPORT Q_DECL_EXPORT -# else -# define Q_MAPBOXGL_EXPORT Q_DECL_IMPORT -# endif +#if defined(QT_BUILD_MAPBOXGL_LIB) + #define Q_MAPBOXGL_EXPORT Q_DECL_EXPORT #else -# define Q_MAPBOXGL_EXPORT + #define Q_MAPBOXGL_EXPORT Q_DECL_IMPORT #endif namespace QMapbox { @@ -116,12 +112,16 @@ struct Q_MAPBOXGL_EXPORT CustomLayerRenderParameters { double zoom; double bearing; double pitch; - double altitude; + double fieldOfView; }; -typedef void (*CustomLayerInitializeFunction)(void* context) ; -typedef void (*CustomLayerRenderFunction)(void* context, const CustomLayerRenderParameters&); -typedef void (*CustomLayerDeinitializeFunction)(void* context); +class Q_MAPBOXGL_EXPORT CustomLayerHostInterface { +public: + virtual ~CustomLayerHostInterface() = default; + virtual void initialize() = 0; + virtual void render(const CustomLayerRenderParameters&) = 0; + virtual void deinitialize() = 0; +}; } // namespace QMapbox diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp index b5676fbedd..79eb672d1f 100644 --- a/platform/qt/include/qmapboxgl.hpp +++ b/platform/qt/include/qmapboxgl.hpp @@ -230,10 +230,7 @@ public: void removeImage(const QString &name); void addCustomLayer(const QString &id, - QMapbox::CustomLayerInitializeFunction, - QMapbox::CustomLayerRenderFunction, - QMapbox::CustomLayerDeinitializeFunction, - void* context, + QScopedPointer<QMapbox::CustomLayerHostInterface>& host, const QString& before = QString()); void addLayer(const QVariantMap ¶ms, const QString& before = QString()); bool layerExists(const QString &id); diff --git a/platform/qt/src/qmapbox.cpp b/platform/qt/src/qmapbox.cpp index 1386a4b7aa..2180f22d07 100644 --- a/platform/qt/src/qmapbox.cpp +++ b/platform/qt/src/qmapbox.cpp @@ -158,27 +158,9 @@ namespace QMapbox { */ /*! - \typedef QMapbox::CustomLayerDeinitializeFunction + \class QMapbox::CustomLayerHostInterface - Represents a callback to be called when destroying a custom layer. - - \warning This is used for delegating the rendering of a layer to the user of - this API and is not officially supported. Use at your own risk. -*/ - -/*! - \typedef QMapbox::CustomLayerInitializeFunction - - Represents a callback to be called when initializing a custom layer. - - \warning This is used for delegating the rendering of a layer to the user of - this API and is not officially supported. Use at your own risk. -*/ - -/*! - \typedef QMapbox::CustomLayerRenderFunction - - Represents a callback to be called on each render pass for a custom layer. + Represents a host interface to be implemented for rendering custom layers. \warning This is used for delegating the rendering of a layer to the user of this API and is not officially supported. Use at your own risk. diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index 34fd5509fa..8c3355dc09 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -89,15 +89,33 @@ QThreadStorage<std::shared_ptr<mbgl::util::RunLoop>> loop; std::shared_ptr<mbgl::DefaultFileSource> sharedDefaultFileSource( const std::string& cachePath, const std::string& assetRoot, uint64_t maximumCacheSize) { - static std::weak_ptr<mbgl::DefaultFileSource> weak; - auto fs = weak.lock(); + static std::mutex mutex; + static std::unordered_map<std::string, std::weak_ptr<mbgl::DefaultFileSource>> fileSources; - if (!fs) { - weak = fs = std::make_shared<mbgl::DefaultFileSource>( - cachePath, assetRoot, maximumCacheSize); + std::lock_guard<std::mutex> lock(mutex); + + // Purge entries no longer in use. + for (auto it = fileSources.begin(); it != fileSources.end();) { + if (!it->second.lock()) { + it = fileSources.erase(it); + } else { + ++it; + } + } + + // Return an existing FileSource if available. + auto sharedFileSource = fileSources.find(cachePath); + if (sharedFileSource != fileSources.end()) { + return sharedFileSource->second.lock(); } - return fs; + // New path, create a new FileSource. + auto newFileSource = std::make_shared<mbgl::DefaultFileSource>( + cachePath, assetRoot, maximumCacheSize); + + fileSources[cachePath] = newFileSource; + + return newFileSource; } // Conversion helper functions. @@ -141,10 +159,9 @@ std::unique_ptr<mbgl::style::Image> toStyleImage(const QString &id, const QImage QMapboxGLSettings is used to configure QMapboxGL at the moment of its creation. Once created, the QMapboxGLSettings of a QMapboxGL can no longer be changed. - Cache-related settings are shared between all QMapboxGL instances because different - maps will share the same cache database file. The first map to configure cache properties - such as size and path will force the configuration to all newly instantiated QMapboxGL - objects. + Cache-related settings are shared between all QMapboxGL instances using the same cache path. + The first map to configure cache properties such as size will force the configuration + to all newly instantiated QMapboxGL objects using the same cache in the same process. \since 4.7 */ @@ -1356,20 +1373,43 @@ void QMapboxGL::removeSource(const QString& id) this API and is not officially supported. Use at your own risk. */ void QMapboxGL::addCustomLayer(const QString &id, - QMapbox::CustomLayerInitializeFunction initFn, - QMapbox::CustomLayerRenderFunction renderFn, - QMapbox::CustomLayerDeinitializeFunction deinitFn, - void *context, + QScopedPointer<QMapbox::CustomLayerHostInterface>& host, const QString& before) { + class HostWrapper : public mbgl::style::CustomLayerHost { + public: + QScopedPointer<QMapbox::CustomLayerHostInterface> ptr; + HostWrapper(QScopedPointer<QMapbox::CustomLayerHostInterface>& p) + : ptr(p.take()) { + } + + void initialize() { + ptr->initialize(); + } + + void render(const mbgl::style::CustomLayerRenderParameters& params) { + QMapbox::CustomLayerRenderParameters renderParams; + renderParams.width = params.width; + renderParams.height = params.height; + renderParams.latitude = params.latitude; + renderParams.longitude = params.longitude; + renderParams.zoom = params.zoom; + renderParams.bearing = params.bearing; + renderParams.pitch = params.pitch; + renderParams.fieldOfView = params.fieldOfView; + ptr->render(renderParams); + } + + void contextLost() { } + + void deinitialize() { + ptr->deinitialize(); + } + }; + d_ptr->mapObj->getStyle().addLayer(std::make_unique<mbgl::style::CustomLayer>( id.toStdString(), - reinterpret_cast<mbgl::style::CustomLayerInitializeFunction>(initFn), - // This cast is safe as long as both mbgl:: and QMapbox:: - // CustomLayerRenderParameters members remains the same. - (mbgl::style::CustomLayerRenderFunction)renderFn, - reinterpret_cast<mbgl::style::CustomLayerDeinitializeFunction>(deinitFn), - context), + std::make_unique<HostWrapper>(host)), before.isEmpty() ? mbgl::optional<std::string>() : mbgl::optional<std::string>(before.toStdString())); } |