diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-01-11 15:00:56 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-01-13 13:40:31 -0800 |
commit | 5a7d2fd60ec4bd1639a1223ec5d2c54c534d0392 (patch) | |
tree | d37991995bd21955379e690b677fc288109aa2c1 /platform | |
parent | 86c8446d3a4390ff6577d070ac8b5fa3ad3c5cd1 (diff) | |
download | qtlocation-mapboxgl-5a7d2fd60ec4bd1639a1223ec5d2c54c534d0392.tar.gz |
[core] Eliminate platform::assetRoot()
I regenerated assets.zip so that all file paths have an `assets/` prefix, as the Android AssetFileSource implementation asserts, and removed `TEST_DATA` from the paths.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/src/asset_file_source.cpp | 2 | ||||
-rw-r--r-- | platform/android/src/asset_root.cpp | 15 | ||||
-rw-r--r-- | platform/android/src/native_map_view.cpp | 5 | ||||
-rw-r--r-- | platform/darwin/asset_root.mm | 16 | ||||
-rw-r--r-- | platform/default/asset_file_source.cpp | 2 | ||||
-rw-r--r-- | platform/default/asset_root.cpp | 28 | ||||
-rw-r--r-- | platform/default/default_file_source.cpp | 4 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 2 | ||||
-rw-r--r-- | platform/linux/main.cpp | 2 | ||||
-rw-r--r-- | platform/osx/src/MGLMapView.mm | 5 |
10 files changed, 12 insertions, 69 deletions
diff --git a/platform/android/src/asset_file_source.cpp b/platform/android/src/asset_file_source.cpp index 1f02f9cf4a..7eb2007778 100644 --- a/platform/android/src/asset_file_source.cpp +++ b/platform/android/src/asset_file_source.cpp @@ -99,7 +99,7 @@ private: AssetFileSource::AssetFileSource(const std::string& root) : thread(std::make_unique<util::Thread<Impl>>( util::ThreadContext{"AssetFileSource", util::ThreadType::Worker, util::ThreadPriority::Regular}, - root.empty() ? platform::assetRoot() : root)) { + root)) { } AssetFileSource::~AssetFileSource() = default; diff --git a/platform/android/src/asset_root.cpp b/platform/android/src/asset_root.cpp deleted file mode 100644 index 5720f5731c..0000000000 --- a/platform/android/src/asset_root.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include <mbgl/platform/platform.hpp> -#include "jni.hpp" - -#include <libgen.h> - -namespace mbgl { -namespace platform { - -// Returns the path to the root folder of the application. -const std::string &assetRoot() { - return mbgl::android::apkPath; -} - -} -} diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp index 96b48e12c6..5d6e240797 100644 --- a/platform/android/src/native_map_view.cpp +++ b/platform/android/src/native_map_view.cpp @@ -75,7 +75,10 @@ NativeMapView::NativeMapView(JNIEnv *env, jobject obj_, float pixelRatio_, int a return; } - fileSource = std::make_unique<mbgl::DefaultFileSource>(mbgl::android::cachePath + "/mbgl-cache.db"); + fileSource = std::make_unique<mbgl::DefaultFileSource>( + mbgl::android::cachePath + "/mbgl-cache.db", + mbgl::android::apkPath); + map = std::make_unique<mbgl::Map>(*this, *fileSource, MapMode::Continuous); float zoomFactor = map->getMaxZoom() - map->getMinZoom() + 1; diff --git a/platform/darwin/asset_root.mm b/platform/darwin/asset_root.mm deleted file mode 100644 index a4a3d13c88..0000000000 --- a/platform/darwin/asset_root.mm +++ /dev/null @@ -1,16 +0,0 @@ -#import <Foundation/Foundation.h> - -#include <mbgl/platform/platform.hpp> - -namespace mbgl { -namespace platform { - -// Returns the path to the root folder of the application. -const std::string &assetRoot() { - static const std::string root = []() -> std::string { - return [[[[NSBundle mainBundle] resourceURL] path] UTF8String]; - }(); - return root; -} -} -} diff --git a/platform/default/asset_file_source.cpp b/platform/default/asset_file_source.cpp index 5aa5730c94..2573966c72 100644 --- a/platform/default/asset_file_source.cpp +++ b/platform/default/asset_file_source.cpp @@ -67,7 +67,7 @@ private: AssetFileSource::AssetFileSource(const std::string& root) : thread(std::make_unique<util::Thread<Impl>>( util::ThreadContext{"AssetFileSource", util::ThreadType::Worker, util::ThreadPriority::Regular}, - root.empty() ? platform::assetRoot() : root)) { + root)) { } AssetFileSource::~AssetFileSource() = default; diff --git a/platform/default/asset_root.cpp b/platform/default/asset_root.cpp deleted file mode 100644 index 2b20018c40..0000000000 --- a/platform/default/asset_root.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include <mbgl/platform/platform.hpp> - -#include <uv.h> -#include <libgen.h> - -namespace mbgl { -namespace platform { - -// Returns the path to the root folder of the application. -const std::string &assetRoot() { - static const std::string root = []() -> std::string { - size_t max = 0; - std::string dir; - do { - // Gradually increase the length of the string in case the path was truncated. - max += 256; - dir.resize(max); - uv_exepath(const_cast<char *>(dir.data()), &max); - } while (max == dir.size()); - dir.resize(max - 1); - dir = dirname(const_cast<char *>(dir.c_str())); - return dir; - }(); - return root; -} - -} -} diff --git a/platform/default/default_file_source.cpp b/platform/default/default_file_source.cpp index 8f2f024a11..fcb45ee29a 100644 --- a/platform/default/default_file_source.cpp +++ b/platform/default/default_file_source.cpp @@ -31,8 +31,8 @@ public: OnlineFileSource onlineFileSource; }; -DefaultFileSource::DefaultFileSource(const std::string& cachePath, const std::string& root) - : impl(std::make_unique<DefaultFileSource::Impl>(cachePath, root)) { +DefaultFileSource::DefaultFileSource(const std::string& cachePath, const std::string& assetRoot) + : impl(std::make_unique<DefaultFileSource::Impl>(cachePath, assetRoot)) { } DefaultFileSource::~DefaultFileSource() = default; diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 0fdf2ea66a..25474997e0 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -280,7 +280,7 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) NSString *libraryDirectory = [paths objectAtIndex:0]; fileCachePath = [libraryDirectory stringByAppendingPathComponent:@"cache.db"]; } - _mbglFileSource = new mbgl::DefaultFileSource([fileCachePath UTF8String]); + _mbglFileSource = new mbgl::DefaultFileSource([fileCachePath UTF8String], [[[[NSBundle mainBundle] resourceURL] path] UTF8String]); // setup mbgl map _mbglMap = new mbgl::Map(*_mbglView, *_mbglFileSource, mbgl::MapMode::Continuous); diff --git a/platform/linux/main.cpp b/platform/linux/main.cpp index d6cf10fe70..f90b5de849 100644 --- a/platform/linux/main.cpp +++ b/platform/linux/main.cpp @@ -105,7 +105,7 @@ int main(int argc, char *argv[]) { view = std::make_unique<GLFWView>(fullscreen, benchmark); - mbgl::DefaultFileSource fileSource("/tmp/mbgl-cache.db"); + mbgl::DefaultFileSource fileSource("/tmp/mbgl-cache.db", "."); fileSource.setMaximumCacheEntrySize(1 * 1024 * 1024); // 1 MB fileSource.setMaximumCacheSize(50 * 1024 * 1024); // 50 MB diff --git a/platform/osx/src/MGLMapView.mm b/platform/osx/src/MGLMapView.mm index 64aa592f7c..947dd41b17 100644 --- a/platform/osx/src/MGLMapView.mm +++ b/platform/osx/src/MGLMapView.mm @@ -246,7 +246,7 @@ public: error:nil]; NSURL *cacheURL = [cacheDirectoryURL URLByAppendingPathComponent:@"cache.db"]; NSString *cachePath = cacheURL ? cacheURL.path : @""; - _mbglFileSource = new mbgl::DefaultFileSource(cachePath.UTF8String); + _mbglFileSource = new mbgl::DefaultFileSource(cachePath.UTF8String, [[[[NSBundle mainBundle] resourceURL] path] UTF8String]); _mbglMap = new mbgl::Map(*_mbglView, *_mbglFileSource, mbgl::MapMode::Continuous); @@ -524,8 +524,7 @@ public: } if (![styleURL scheme]) { - // Assume a relative path into the application’s resource folder, - // defined in mbgl::platform::assetRoot(). + // Assume a relative path into the application’s resource folder. styleURL = [NSURL URLWithString:[@"asset://" stringByAppendingString:styleURL.absoluteString]]; } |