From 0d2c0556f1378a7c1c4a21fbf177a77954c37142 Mon Sep 17 00:00:00 2001 From: Anand Thakker Date: Fri, 15 Jun 2018 16:31:16 -0400 Subject: Fixup: Use a raw pointer for MapSnapshotter's FileSource --- platform/android/src/snapshotter/map_snapshotter.cpp | 4 ++-- platform/android/src/snapshotter/map_snapshotter.hpp | 1 - platform/darwin/src/MGLMapSnapshotter.mm | 5 ++--- platform/default/mbgl/map/map_snapshotter.cpp | 12 +++++------- platform/default/mbgl/map/map_snapshotter.hpp | 2 +- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/platform/android/src/snapshotter/map_snapshotter.cpp b/platform/android/src/snapshotter/map_snapshotter.cpp index c5fd7e21d7..e8fcc61770 100644 --- a/platform/android/src/snapshotter/map_snapshotter.cpp +++ b/platform/android/src/snapshotter/map_snapshotter.cpp @@ -36,7 +36,7 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env, } jFileSource = FileSource::getNativePeer(_env, _jFileSource); - fileSource = std::shared_ptr(&mbgl::android::FileSource::getDefaultFileSource(_env, _jFileSource)); + auto& fileSource = mbgl::android::FileSource::getDefaultFileSource(_env, _jFileSource); auto size = mbgl::Size { static_cast(width), static_cast(height) }; optional cameraOptions; @@ -58,7 +58,7 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env, showLogo = _showLogo; // Create the core snapshotter - snapshotter = std::make_unique(fileSource, + snapshotter = std::make_unique(&fileSource, threadPool, style, size, diff --git a/platform/android/src/snapshotter/map_snapshotter.hpp b/platform/android/src/snapshotter/map_snapshotter.hpp index 47c7fd912a..7b72452c45 100644 --- a/platform/android/src/snapshotter/map_snapshotter.hpp +++ b/platform/android/src/snapshotter/map_snapshotter.hpp @@ -70,7 +70,6 @@ private: std::unique_ptr snapshotter; FileSource *jFileSource; - std::shared_ptr fileSource; void activateFilesource(JNIEnv&); void deactivateFilesource(JNIEnv&); bool activatedFilesource = false; diff --git a/platform/darwin/src/MGLMapSnapshotter.mm b/platform/darwin/src/MGLMapSnapshotter.mm index 1d52360d88..d9fa044217 100644 --- a/platform/darwin/src/MGLMapSnapshotter.mm +++ b/platform/darwin/src/MGLMapSnapshotter.mm @@ -86,7 +86,6 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64; @implementation MGLMapSnapshotter { std::shared_ptr _mbglThreadPool; - std::shared_ptr _mbglFileSource; std::unique_ptr _mbglMapSnapshotter; std::unique_ptr> _snapshotCallback; } @@ -439,7 +438,7 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64; - (void)setOptions:(MGLMapSnapshotOptions *)options { _options = options; - _mbglFileSource = std::shared_ptr([MGLOfflineStorage sharedOfflineStorage].mbglFileSource); + mbgl::DefaultFileSource *mbglFileSource = [MGLOfflineStorage sharedOfflineStorage].mbglFileSource; _mbglThreadPool = mbgl::sharedThreadPool(); std::string styleURL = std::string([options.styleURL.absoluteString UTF8String]); @@ -470,7 +469,7 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64; } // Create the snapshotter - _mbglMapSnapshotter = std::make_unique(_mbglFileSource, _mbglThreadPool, style, size, pixelRatio, cameraOptions, coordinateBounds); + _mbglMapSnapshotter = std::make_unique(mbglFileSource, _mbglThreadPool, style, size, pixelRatio, cameraOptions, coordinateBounds); } @end diff --git a/platform/default/mbgl/map/map_snapshotter.cpp b/platform/default/mbgl/map/map_snapshotter.cpp index d7703e15b2..149ef22e7a 100644 --- a/platform/default/mbgl/map/map_snapshotter.cpp +++ b/platform/default/mbgl/map/map_snapshotter.cpp @@ -13,7 +13,7 @@ namespace mbgl { class MapSnapshotter::Impl { public: - Impl(std::shared_ptr, + Impl(FileSource*, std::shared_ptr, const std::pair style, const Size&, @@ -40,13 +40,12 @@ public: void snapshot(ActorRef); private: - std::shared_ptr fileSource; std::shared_ptr scheduler; HeadlessFrontend frontend; Map map; }; -MapSnapshotter::Impl::Impl(std::shared_ptr fileSource_, +MapSnapshotter::Impl::Impl(FileSource* fileSource, std::shared_ptr scheduler_, const std::pair style, const Size& size, @@ -54,8 +53,7 @@ MapSnapshotter::Impl::Impl(std::shared_ptr fileSource_, const optional cameraOptions, const optional region, const optional programCacheDir) - : fileSource(std::move(fileSource_)) - , scheduler(std::move(scheduler_)) + : scheduler(std::move(scheduler_)) , frontend(size, pixelRatio, *fileSource, *scheduler, programCacheDir) , map(frontend, MapObserver::nullObserver(), size, pixelRatio, *fileSource, *scheduler, MapMode::Static) { @@ -153,7 +151,7 @@ LatLngBounds MapSnapshotter::Impl::getRegion() const { return map.latLngBoundsForCamera(getCameraOptions()); } -MapSnapshotter::MapSnapshotter(std::shared_ptr fileSource, +MapSnapshotter::MapSnapshotter(FileSource* fileSource, std::shared_ptr scheduler, const std::pair style, const Size& size, @@ -161,7 +159,7 @@ MapSnapshotter::MapSnapshotter(std::shared_ptr fileSource, const optional cameraOptions, const optional region, const optional programCacheDir) - : impl(std::make_unique>("Map Snapshotter", std::move(fileSource), std::move(scheduler), style, size, pixelRatio, cameraOptions, region, programCacheDir)) { + : impl(std::make_unique>("Map Snapshotter", fileSource, std::move(scheduler), style, size, pixelRatio, cameraOptions, region, programCacheDir)) { } MapSnapshotter::~MapSnapshotter() = default; diff --git a/platform/default/mbgl/map/map_snapshotter.hpp b/platform/default/mbgl/map/map_snapshotter.hpp index dd90d54b26..f40d1e4b77 100644 --- a/platform/default/mbgl/map/map_snapshotter.hpp +++ b/platform/default/mbgl/map/map_snapshotter.hpp @@ -25,7 +25,7 @@ class Style; class MapSnapshotter { public: - MapSnapshotter(std::shared_ptr fileSource, + MapSnapshotter(FileSource* fileSource, std::shared_ptr scheduler, const std::pair style, const Size&, -- cgit v1.2.1