summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/core-files.cmake2
-rw-r--r--include/mbgl/util/image.hpp5
-rw-r--r--include/mbgl/util/premultiply.hpp (renamed from src/mbgl/util/premultiply.hpp)0
m---------mapbox-gl-js0
-rw-r--r--platform/node/src/node_map.cpp6
-rw-r--r--platform/node/test/suite_implementation.js2
-rw-r--r--test/util/image.test.cpp15
7 files changed, 25 insertions, 5 deletions
diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake
index 3594b55be6..17498ec427 100644
--- a/cmake/core-files.cmake
+++ b/cmake/core-files.cmake
@@ -511,6 +511,7 @@ set(MBGL_CORE_FILES
include/mbgl/util/noncopyable.hpp
include/mbgl/util/optional.hpp
include/mbgl/util/platform.hpp
+ include/mbgl/util/premultiply.hpp
include/mbgl/util/projection.hpp
include/mbgl/util/range.hpp
include/mbgl/util/run_loop.hpp
@@ -565,7 +566,6 @@ set(MBGL_CORE_FILES
src/mbgl/util/offscreen_texture.cpp
src/mbgl/util/offscreen_texture.hpp
src/mbgl/util/premultiply.cpp
- src/mbgl/util/premultiply.hpp
src/mbgl/util/rapidjson.hpp
src/mbgl/util/rect.hpp
src/mbgl/util/std.hpp
diff --git a/include/mbgl/util/image.hpp b/include/mbgl/util/image.hpp
index c019bb949c..a41b8462bd 100644
--- a/include/mbgl/util/image.hpp
+++ b/include/mbgl/util/image.hpp
@@ -40,11 +40,14 @@ public:
Image(Image&& o)
: size(o.size),
- data(std::move(o.data)) {}
+ data(std::move(o.data)) {
+ o.size.width = o.size.height = 0;
+ }
Image& operator=(Image&& o) {
size = o.size;
data = std::move(o.data);
+ o.size.width = o.size.height = 0;
return *this;
}
diff --git a/src/mbgl/util/premultiply.hpp b/include/mbgl/util/premultiply.hpp
index 532c7cb11d..532c7cb11d 100644
--- a/src/mbgl/util/premultiply.hpp
+++ b/include/mbgl/util/premultiply.hpp
diff --git a/mapbox-gl-js b/mapbox-gl-js
-Subproject d3b39cbba4f09d26ef51159aa56270e67006c51
+Subproject 431bce18e1b3a26851b8e5037b1017ba35c4111
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);
diff --git a/test/util/image.test.cpp b/test/util/image.test.cpp
index 0cd4a7d8af..4cacf89253 100644
--- a/test/util/image.test.cpp
+++ b/test/util/image.test.cpp
@@ -115,6 +115,21 @@ TEST(Image, Copy) {
EXPECT_THROW(PremultipliedImage::copy(src10, dst10, {0, 0}, {0, 1}, {0, max}), std::out_of_range);
}
+TEST(Image, Move) {
+ UnassociatedImage rgba({ 1, 1 });
+ rgba.data[0] = 255;
+ rgba.data[1] = 254;
+ rgba.data[2] = 253;
+ rgba.data[3] = 128;
+
+ auto moved = std::move(rgba);
+
+ EXPECT_EQ(0u, rgba.size.width);
+ EXPECT_EQ(nullptr, rgba.data.get());
+ EXPECT_EQ(254, moved.data[1]);
+ EXPECT_EQ(1u, moved.size.width);
+}
+
TEST(Image, Premultiply) {
UnassociatedImage rgba({ 1, 1 });
rgba.data[0] = 255;