diff options
author | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2017-05-02 09:54:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-02 09:54:06 -0700 |
commit | 5c52401d5504ab4b84d1510042c6b97504c50933 (patch) | |
tree | 3bd2feb4e985f5402ec0fc112aab6717426d46aa /platform/node | |
parent | 3f0c89d633a5056006557ad5f4b9e446807d00ee (diff) | |
download | qtlocation-mapboxgl-5c52401d5504ab4b84d1510042c6b97504c50933.tar.gz |
[core] Make Map.addImage tests pass (#8843)
Fix Node tests suite implementation to parse pixelRatio from style json
Premultiply images in the node binding before sending to mbgl core
Diffstat (limited to 'platform/node')
-rw-r--r-- | platform/node/src/node_map.cpp | 6 | ||||
-rw-r--r-- | platform/node/test/suite_implementation.js | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index ab49ca6405..1c8bf6d1d2 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -12,6 +12,7 @@ #include <mbgl/style/image.hpp> #include <mbgl/map/backend_scope.hpp> #include <mbgl/map/query.hpp> +#include <mbgl/util/premultiply.hpp> #include <unistd.h> @@ -682,8 +683,9 @@ void NodeMap::AddImage(const Nan::FunctionCallbackInfo<v8::Value>& info) { std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(imageLength); std::copy(imageDataBuffer, imageDataBuffer + imageLength, data.get()); - mbgl::PremultipliedImage cPremultipliedImage({ imageWidth, imageHeight}, std::move(data)); - + + mbgl::UnassociatedImage cImage({ imageWidth, imageHeight}, std::move(data)); + mbgl::PremultipliedImage cPremultipliedImage = mbgl::util::premultiply(std::move(cImage)); nodeMap->map->addImage(*Nan::Utf8String(info[0]), std::make_unique<mbgl::style::Image>(std::move(cPremultipliedImage), pixelRatio)); } diff --git a/platform/node/test/suite_implementation.js b/platform/node/test/suite_implementation.js index a5e96f7265..8ac372b7c3 100644 --- a/platform/node/test/suite_implementation.js +++ b/platform/node/test/suite_implementation.js @@ -76,7 +76,7 @@ module.exports = function (style, options, callback) { map.addImage(operation[1], img.data, { height: img.height, width: img.width, - pixelRatio: 1 + pixelRatio: operation[3] || 1 }); applyOperations(operations.slice(1), callback); |