diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-05-18 12:01:19 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2017-05-19 14:13:07 +0200 |
commit | d664a3e05ebed51c19dc4adb30850792d5bf8f57 (patch) | |
tree | 9b3419e3e5a75706ceb3c06d788bedb1e9088121 | |
parent | 281d3d4f8cf10910e04131c8020fff0f2e359aa9 (diff) | |
download | qtlocation-mapboxgl-d664a3e05ebed51c19dc4adb30850792d5bf8f57.tar.gz |
[core] leave Image objects in a valid state after premultiply/unpremultiply
-rw-r--r-- | src/mbgl/util/premultiply.cpp | 2 | ||||
-rw-r--r-- | test/util/image.test.cpp | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/mbgl/util/premultiply.cpp b/src/mbgl/util/premultiply.cpp index 219273d7cc..d9fb2480de 100644 --- a/src/mbgl/util/premultiply.cpp +++ b/src/mbgl/util/premultiply.cpp @@ -9,6 +9,7 @@ PremultipliedImage premultiply(UnassociatedImage&& src) { PremultipliedImage dst; dst.size = src.size; + src.size = { 0, 0 }; dst.data = std::move(src.data); uint8_t* data = dst.data.get(); @@ -29,6 +30,7 @@ UnassociatedImage unpremultiply(PremultipliedImage&& src) { UnassociatedImage dst; dst.size = src.size; + src.size = { 0, 0 }; dst.data = std::move(src.data); uint8_t* data = dst.data.get(); diff --git a/test/util/image.test.cpp b/test/util/image.test.cpp index 4cacf89253..f4031f1bc1 100644 --- a/test/util/image.test.cpp +++ b/test/util/image.test.cpp @@ -142,4 +142,8 @@ TEST(Image, Premultiply) { EXPECT_EQ(127, image.data[1]); EXPECT_EQ(127, image.data[2]); EXPECT_EQ(128, image.data[3]); + EXPECT_EQ(1u, image.size.width); + EXPECT_EQ(1u, image.size.height); + EXPECT_EQ(0u, rgba.size.width); + EXPECT_EQ(0u, rgba.size.height); } |