From 22c07596a0c1e2cca12df730be4448bbe79be13d Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Fri, 10 Nov 2017 11:32:37 -0500 Subject: [core] Split MapMode::Still into Static and Tile `Tile` makes sure the symbols in the resulting tile are tileable while symbols in `Still` match rendering in `Continuous` mode. --- platform/default/mbgl/map/map_snapshotter.cpp | 2 +- platform/node/CHANGELOG.md | 3 +++ platform/node/src/node_map.cpp | 13 +++++++++++-- platform/node/src/node_map.hpp | 1 + platform/node/test/suite_implementation.js | 16 ++++++++++------ 5 files changed, 26 insertions(+), 9 deletions(-) (limited to 'platform') diff --git a/platform/default/mbgl/map/map_snapshotter.cpp b/platform/default/mbgl/map/map_snapshotter.cpp index 7b4ec5913b..9341c23cfd 100644 --- a/platform/default/mbgl/map/map_snapshotter.cpp +++ b/platform/default/mbgl/map/map_snapshotter.cpp @@ -50,7 +50,7 @@ MapSnapshotter::Impl::Impl(FileSource& fileSource, const optional region, const optional programCacheDir) : frontend(size, pixelRatio, fileSource, scheduler, programCacheDir) - , map(frontend, MapObserver::nullObserver(), size, pixelRatio, fileSource, scheduler, MapMode::Still) { + , map(frontend, MapObserver::nullObserver(), size, pixelRatio, fileSource, scheduler, MapMode::Static) { map.getStyle().loadURL(styleURL); diff --git a/platform/node/CHANGELOG.md b/platform/node/CHANGELOG.md index 4b93fca25d..feb2b4185d 100644 --- a/platform/node/CHANGELOG.md +++ b/platform/node/CHANGELOG.md @@ -1,3 +1,6 @@ +# master +- The `Map` constructor now accepts a `mode` option which can be either `"static"` (default) or `"tile"`. It must be set to `"tile"` when rendering individual tiles in order for the symbols to match across tiles. + # 3.5.8 - October 19, 2017 - Fixes an issue that causes memory leaks when not deleting the frontend object in NodeMap::release() diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index 6deccf05bf..b8c5e9cc88 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -548,7 +548,7 @@ void NodeMap::cancel() { frontend = std::make_unique(mbgl::Size{ 256, 256 }, pixelRatio, *this, threadpool); map = std::make_unique(*frontend, mapObserver, frontend->getSize(), pixelRatio, - *this, threadpool, mbgl::MapMode::Still); + *this, threadpool, mode); // FIXME: Reload the style after recreating the map. We need to find // a better way of canceling an ongoing rendering on the core level @@ -1074,6 +1074,15 @@ NodeMap::NodeMap(v8::Local options) ->NumberValue() : 1.0; }()) + , mode([&] { + Nan::HandleScope scope; + if (Nan::Has(options, Nan::New("mode").ToLocalChecked()).FromJust() && + std::string(*v8::String::Utf8Value(Nan::Get(options, Nan::New("mode").ToLocalChecked()).ToLocalChecked()->ToString())) == "tile") { + return mbgl::MapMode::Tile; + } else { + return mbgl::MapMode::Static; + } + }()) , mapObserver(NodeMapObserver()) , frontend(std::make_unique(mbgl::Size { 256, 256 }, pixelRatio, *this, threadpool)) , map(std::make_unique(*frontend, @@ -1082,7 +1091,7 @@ NodeMap::NodeMap(v8::Local options) pixelRatio, *this, threadpool, - mbgl::MapMode::Still)), + mode)), async(new uv_async_t) { async->data = this; diff --git a/platform/node/src/node_map.hpp b/platform/node/src/node_map.hpp index 8e7f0a3e58..b84f4d576f 100644 --- a/platform/node/src/node_map.hpp +++ b/platform/node/src/node_map.hpp @@ -74,6 +74,7 @@ public: std::unique_ptr request(const mbgl::Resource&, mbgl::FileSource::Callback); const float pixelRatio; + mbgl::MapMode mode; NodeThreadPool threadpool; NodeMapObserver mapObserver; std::unique_ptr frontend; diff --git a/platform/node/test/suite_implementation.js b/platform/node/test/suite_implementation.js index c5987538d0..b0be2fa0eb 100644 --- a/platform/node/test/suite_implementation.js +++ b/platform/node/test/suite_implementation.js @@ -14,21 +14,25 @@ mbgl.on('message', function(msg) { var maps = new Map(); module.exports = function (style, options, callback) { + var tileMode = options.mapMode === 'tile'; if (options.recycleMap) { - if (maps.has(options.pixelRatio)) { - var map = maps.get(options.pixelRatio); + var key = options.pixelRatio + '/' + tileMode; + if (maps.has(key)) { + var map = maps.get(key); map.request = mapRequest; } else { - maps.set(options.pixelRatio, new mbgl.Map({ + maps.set(key, new mbgl.Map({ ratio: options.pixelRatio, - request: mapRequest + request: mapRequest, + mode: options.mapMode })); - var map = maps.get(options.pixelRatio); + var map = maps.get(key); } } else { var map = new mbgl.Map({ ratio: options.pixelRatio, - request: mapRequest + request: mapRequest, + mode: options.mapMode }); } -- cgit v1.2.1