diff options
Diffstat (limited to 'platform/node')
-rw-r--r-- | platform/node/CHANGELOG.md | 14 | ||||
-rw-r--r-- | platform/node/bitrise.yml | 3 | ||||
-rwxr-xr-x | platform/node/scripts/after_script.sh | 19 | ||||
-rwxr-xr-x | platform/node/scripts/after_success.sh | 13 | ||||
-rw-r--r-- | platform/node/src/node_logging.cpp (renamed from platform/node/src/node_log.cpp) | 2 | ||||
-rw-r--r-- | platform/node/src/node_logging.hpp (renamed from platform/node/src/node_log.hpp) | 2 | ||||
-rw-r--r-- | platform/node/src/node_map.cpp | 81 | ||||
-rw-r--r-- | platform/node/src/node_map.hpp | 6 | ||||
-rw-r--r-- | platform/node/src/node_mapbox_gl_native.cpp | 2 | ||||
-rw-r--r-- | platform/node/test/fixtures/zoom-center/expected.png | bin | 0 -> 882 bytes | |||
-rw-r--r-- | platform/node/test/js/map.test.js | 44 | ||||
-rw-r--r-- | platform/node/test/suite_implementation.js | 31 |
12 files changed, 172 insertions, 45 deletions
diff --git a/platform/node/CHANGELOG.md b/platform/node/CHANGELOG.md index d64aa5238c..aabed907e1 100644 --- a/platform/node/CHANGELOG.md +++ b/platform/node/CHANGELOG.md @@ -1,3 +1,17 @@ +# 3.4.2 - November 15, 2016 + +- Switches back to publishing Linux binaries with GLX, to eliminate a runtime dependency on `libOSMesa.so.8` and enable dynamically linking against `libGL.so` provided by an alternate implementation, such as the NVIDIA proproetary drivers ([#7503](https://github.com/mapbox/mapbox-gl-native/pull/7053)) + +# 3.4.1 - November 10, 2016 + +- Skips assigning clip IDs to tiles that won't be rendered, mitigating a `stencil mask overflow` error ([#6871](https://github.com/mapbox/mapbox-gl-native/pull/6871)) +- Fixes camera logic to avoid unnecessary or redundant setting of camera options ([#6990](https://github.com/mapbox/mapbox-gl-native/pull/6990)) + +# 3.4.0 - November 2, 2016 + +- Fixes Bitrise configuration to automatically publish macOS binaries ([#6789](https://github.com/mapbox/mapbox-gl-native/pull/6789)) +- Switches from using individual thread pools for each `mbgl::Map` object to sharing the built-in Node.js thread pool for NodeMap implementations ([#6687](https://github.com/mapbox/mapbox-gl-native/pull/6687)) + # 3.3.3 - September 6, 2016 - Switches to using a NodeRequest member function (with a JavaScript shim in front to preserve the API) instead of a new `v8::Context` to avoid a memory leak ([#5704](https://github.com/mapbox/mapbox-gl-native/pull/5704)) diff --git a/platform/node/bitrise.yml b/platform/node/bitrise.yml index 998e97301b..0323f944a3 100644 --- a/platform/node/bitrise.yml +++ b/platform/node/bitrise.yml @@ -57,6 +57,7 @@ workflows: #!/bin/bash set -eu -o pipefail make test-node || envman add --key RESULT --value $? + ./platform/node/scripts/after_script.sh ${BITRISE_BUILD_NUMBER} - script: title: Run publish script run_if: '{{enveq "SKIPCI" "false"}}' @@ -64,7 +65,7 @@ workflows: - content: |- #!/bin/bash set -eu -o pipefail - ./platform/node/scripts/after_script.sh ${BITRISE_BUILD_NUMBER} + ./platform/node/scripts/after_success.sh exit ${RESULT:-0} - slack: title: Post to Slack diff --git a/platform/node/scripts/after_script.sh b/platform/node/scripts/after_script.sh index c805e453a2..4228d13dfe 100755 --- a/platform/node/scripts/after_script.sh +++ b/platform/node/scripts/after_script.sh @@ -5,19 +5,10 @@ set -o pipefail JOB=$1 -if [[ -n ${PUBLISH:-} ]]; then - if [[ "${BUILDTYPE}" == "Debug" ]]; then - echo "Please run this script in release mode (BUILDTYPE=Release)." - exit 1 - else - ./node_modules/.bin/node-pre-gyp package publish info - fi -else - if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then - gzip --stdout node_modules/mapbox-gl-test-suite/render-tests/index.html | \ - aws s3 cp --acl public-read --content-encoding gzip --content-type text/html \ - - s3://mapbox/mapbox-gl-native/render-tests/$JOB/index.html +if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then + gzip --stdout node_modules/mapbox-gl-test-suite/render-tests/index.html | \ + aws s3 cp --acl public-read --content-encoding gzip --content-type text/html \ + - s3://mapbox/mapbox-gl-native/render-tests/$JOB/index.html - echo http://mapbox.s3.amazonaws.com/mapbox-gl-native/render-tests/$JOB/index.html - fi + echo http://mapbox.s3.amazonaws.com/mapbox-gl-native/render-tests/$JOB/index.html fi diff --git a/platform/node/scripts/after_success.sh b/platform/node/scripts/after_success.sh new file mode 100755 index 0000000000..7ef8f53545 --- /dev/null +++ b/platform/node/scripts/after_success.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -e +set -o pipefail + +if [[ -n ${PUBLISH:-} ]]; then + if [[ "${BUILDTYPE}" == "Debug" ]]; then + echo "Please run this script in release mode (BUILDTYPE=Release)." + exit 1 + else + ./node_modules/.bin/node-pre-gyp package publish info + fi +fi diff --git a/platform/node/src/node_log.cpp b/platform/node/src/node_logging.cpp index 0a97ebce36..5e7326e90a 100644 --- a/platform/node/src/node_log.cpp +++ b/platform/node/src/node_logging.cpp @@ -1,4 +1,4 @@ -#include "node_log.hpp" +#include "node_logging.hpp" #include <mbgl/util/enum.hpp> diff --git a/platform/node/src/node_log.hpp b/platform/node/src/node_logging.hpp index a19c61284b..a12603ba6e 100644 --- a/platform/node/src/node_log.hpp +++ b/platform/node/src/node_logging.hpp @@ -2,7 +2,7 @@ #include "util/async_queue.hpp" -#include <mbgl/platform/log.hpp> +#include <mbgl/util/logging.hpp> #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index 671bf3e0fd..acf83eef66 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -4,7 +4,7 @@ #include "node_conversion.hpp" #include "node_geojson.hpp" -#include <mbgl/platform/default/headless_display.hpp> +#include <mbgl/gl/headless_display.hpp> #include <mbgl/util/exception.hpp> #include <mbgl/style/conversion/source.hpp> #include <mbgl/style/conversion/layer.hpp> @@ -62,7 +62,9 @@ void NodeMap::Init(v8::Local<v8::Object> target) { Nan::SetPrototypeMethod(tpl, "setPaintProperty", SetPaintProperty); Nan::SetPrototypeMethod(tpl, "setFilter", SetFilter); Nan::SetPrototypeMethod(tpl, "setCenter", SetCenter); + Nan::SetPrototypeMethod(tpl, "setZoom", SetZoom); Nan::SetPrototypeMethod(tpl, "setBearing", SetBearing); + Nan::SetPrototypeMethod(tpl, "setPitch", SetPitch); Nan::SetPrototypeMethod(tpl, "dumpDebugLogs", DumpDebugLogs); Nan::SetPrototypeMethod(tpl, "queryRenderedFeatures", QueryRenderedFeatures); @@ -356,20 +358,39 @@ void NodeMap::Render(const Nan::FunctionCallbackInfo<v8::Value>& info) { } void NodeMap::startRender(NodeMap::RenderOptions options) { - map->setSize(std::array<uint16_t, 2>{{ static_cast<uint16_t>(options.width), - static_cast<uint16_t>(options.height) }}); + map->setSize({ options.width, options.height }); - const std::array<uint16_t, 2> fbSize{{ static_cast<uint16_t>(options.width * pixelRatio), - static_cast<uint16_t>(options.height * pixelRatio) }}; - if (!view || view->getSize() != fbSize) { + const mbgl::Size fbSize{ static_cast<uint32_t>(options.width * pixelRatio), + static_cast<uint32_t>(options.height * pixelRatio) }; + if (!view || view->size != fbSize) { view.reset(); view = std::make_unique<mbgl::OffscreenView>(backend.getContext(), fbSize); } - map->setClasses(options.classes); - map->setLatLngZoom(mbgl::LatLng(options.latitude, options.longitude), options.zoom); - map->setBearing(options.bearing); - map->setPitch(options.pitch); - map->setDebug(options.debugOptions); + + if (map->getClasses() != options.classes) { + map->setClasses(options.classes); + } + + if (map->getZoom() != options.zoom) { + map->setZoom(options.zoom); + } + + mbgl::LatLng latLng(options.latitude, options.longitude); + if (map->getLatLng() != latLng) { + map->setLatLng(latLng); + } + + if (map->getBearing() != options.bearing) { + map->setBearing(options.bearing); + } + + if (map->getPitch() != options.pitch) { + map->setPitch(options.pitch); + } + + if (map->getDebug() != options.debugOptions) { + map->setDebug(options.debugOptions); + } map->renderStill(*view, [this](const std::exception_ptr eptr) { if (eptr) { @@ -430,7 +451,7 @@ void NodeMap::renderFinished() { cb->Call(1, argv); } else if (img.data) { v8::Local<v8::Object> pixels = Nan::NewBuffer( - reinterpret_cast<char *>(img.data.get()), img.size(), + reinterpret_cast<char *>(img.data.get()), img.bytes(), // Retain the data until the buffer is deleted. [](char *, void * hint) { delete [] reinterpret_cast<uint8_t*>(hint); @@ -706,6 +727,23 @@ void NodeMap::SetCenter(const Nan::FunctionCallbackInfo<v8::Value>& info) { info.GetReturnValue().SetUndefined(); } +void NodeMap::SetZoom(const Nan::FunctionCallbackInfo<v8::Value>& info) { + auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder()); + if (!nodeMap->map) return Nan::ThrowError(releasedMessage()); + + if (info.Length() <= 0 || !info[0]->IsNumber()) { + return Nan::ThrowTypeError("First argument must be a number"); + } + + try { + nodeMap->map->setZoom(info[0]->NumberValue()); + } catch (const std::exception &ex) { + return Nan::ThrowError(ex.what()); + } + + info.GetReturnValue().SetUndefined(); +} + void NodeMap::SetBearing(const Nan::FunctionCallbackInfo<v8::Value>& info) { auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder()); if (!nodeMap->map) return Nan::ThrowError(releasedMessage()); @@ -723,6 +761,23 @@ void NodeMap::SetBearing(const Nan::FunctionCallbackInfo<v8::Value>& info) { info.GetReturnValue().SetUndefined(); } +void NodeMap::SetPitch(const Nan::FunctionCallbackInfo<v8::Value>& info) { + auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder()); + if (!nodeMap->map) return Nan::ThrowError(releasedMessage()); + + if (info.Length() <= 0 || !info[0]->IsNumber()) { + return Nan::ThrowTypeError("First argument must be a number"); + } + + try { + nodeMap->map->setPitch(info[0]->NumberValue()); + } catch (const std::exception &ex) { + return Nan::ThrowError(ex.what()); + } + + info.GetReturnValue().SetUndefined(); +} + void NodeMap::DumpDebugLogs(const Nan::FunctionCallbackInfo<v8::Value>& info) { auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder()); if (!nodeMap->map) return Nan::ThrowError(releasedMessage()); @@ -790,7 +845,7 @@ NodeMap::NodeMap(v8::Local<v8::Object> options) }()), backend(sharedDisplay()), map(std::make_unique<mbgl::Map>(backend, - std::array<uint16_t, 2>{{ 256, 256 }}, + mbgl::Size{ 256, 256 }, pixelRatio, *this, threadpool, diff --git a/platform/node/src/node_map.hpp b/platform/node/src/node_map.hpp index 45de2733cc..c68f543b02 100644 --- a/platform/node/src/node_map.hpp +++ b/platform/node/src/node_map.hpp @@ -4,8 +4,8 @@ #include <mbgl/map/map.hpp> #include <mbgl/storage/file_source.hpp> -#include <mbgl/platform/default/headless_backend.hpp> -#include <mbgl/platform/default/offscreen_view.hpp> +#include <mbgl/gl/headless_backend.hpp> +#include <mbgl/gl/offscreen_view.hpp> #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" @@ -41,7 +41,9 @@ public: static void SetPaintProperty(const Nan::FunctionCallbackInfo<v8::Value>&); static void SetFilter(const Nan::FunctionCallbackInfo<v8::Value>&); static void SetCenter(const Nan::FunctionCallbackInfo<v8::Value>&); + static void SetZoom(const Nan::FunctionCallbackInfo<v8::Value>&); static void SetBearing(const Nan::FunctionCallbackInfo<v8::Value>&); + static void SetPitch(const Nan::FunctionCallbackInfo<v8::Value>&); static void DumpDebugLogs(const Nan::FunctionCallbackInfo<v8::Value>&); static void QueryRenderedFeatures(const Nan::FunctionCallbackInfo<v8::Value>&); diff --git a/platform/node/src/node_mapbox_gl_native.cpp b/platform/node/src/node_mapbox_gl_native.cpp index 042def9fdd..cdcc982220 100644 --- a/platform/node/src/node_mapbox_gl_native.cpp +++ b/platform/node/src/node_mapbox_gl_native.cpp @@ -8,7 +8,7 @@ #include <mbgl/util/run_loop.hpp> #include "node_map.hpp" -#include "node_log.hpp" +#include "node_logging.hpp" #include "node_request.hpp" void RegisterModule(v8::Local<v8::Object> target, v8::Local<v8::Object> module) { diff --git a/platform/node/test/fixtures/zoom-center/expected.png b/platform/node/test/fixtures/zoom-center/expected.png Binary files differnew file mode 100644 index 0000000000..93365c04d2 --- /dev/null +++ b/platform/node/test/fixtures/zoom-center/expected.png diff --git a/platform/node/test/js/map.test.js b/platform/node/test/js/map.test.js index 7321572637..e3b287f68f 100644 --- a/platform/node/test/js/map.test.js +++ b/platform/node/test/js/map.test.js @@ -115,7 +115,9 @@ test('Map', function(t) { 'setPaintProperty', 'setFilter', 'setCenter', + 'setZoom', 'setBearing', + 'setPitch', 'dumpDebugLogs', 'queryRenderedFeatures' ]); @@ -369,6 +371,48 @@ test('Map', function(t) { map.release(); t.end(); }); + + // This can't be tested with a test-suite render test because zoom and center + // are set via a different code path when included as style properties. + t.test('sets zoom before center', function(t) { + var map = new mbgl.Map(options); + map.load({ + "version": 8, + "sources": { + "geojson": { + "type": "geojson", + "data": { + "type": "Point", + "coordinates": [ + 18.05489, + 59.32744 + ] + } + } + }, + "layers": [ + { + "id": "circle", + "type": "circle", + "source": "geojson", + "paint": { + "circle-color": "red" + } + } + ] + }); + map.render({width: 400, height: 400, zoom: 5, center: [18.05489, 59.32744]}, function(err, actual) { + t.error(err); + + var PNG = require('pngjs').PNG; + var pixelmatch = require('pixelmatch'); + var expected = PNG.sync.read( + fs.readFileSync(path.join(__dirname, '../fixtures/zoom-center/expected.png'))).data; + var numPixels = pixelmatch(actual, expected, undefined, 400, 400, { threshold: 0.13 }); + t.equal(numPixels, 0); + t.end(); + }); + }) }); t.test('request callback', function (t) { diff --git a/platform/node/test/suite_implementation.js b/platform/node/test/suite_implementation.js index bde8acde18..3abf4136c4 100644 --- a/platform/node/test/suite_implementation.js +++ b/platform/node/test/suite_implementation.js @@ -30,16 +30,17 @@ module.exports = function (style, options, callback) { callback(new Error('timed out after 20 seconds')); }, 20000); - options.center = style.center; - options.zoom = style.zoom; - options.bearing = style.bearing; - options.pitch = style.pitch; options.debug = { tileBorders: options.debug, collision: options.collisionDebug, overdraw: options.showOverdrawInspector, }; + options.center = style.center || [0, 0]; + options.zoom = style.zoom || 0; + options.bearing = style.bearing || 0; + options.pitch = style.pitch || 0; + map.load(style); applyOperations(options.operations, function() { @@ -60,16 +61,22 @@ module.exports = function (style, options, callback) { callback(); } else if (operation[0] === 'wait') { - var wait = function() { - if (map.loaded()) { - applyOperations(operations.slice(1), callback); - } else { - map.render(options, wait); - } - }; - wait(); + map.render(options, function () { + applyOperations(operations.slice(1), callback); + }); } else { + // Ensure that the next `map.render(options)` does not overwrite this change. + if (operation[0] === 'setCenter') { + options.center = operation[1]; + } else if (operation[0] === 'setZoom') { + options.zoom = operation[1]; + } else if (operation[0] === 'setBearing') { + options.bearing = operation[1]; + } else if (operation[0] === 'setPitch') { + options.pitch = operation[1]; + } + map[operation[0]].apply(map, operation.slice(1)); applyOperations(operations.slice(1), callback); } |