summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2019-07-04 08:45:45 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2019-07-04 11:45:10 +0300
commit16f1854a9ca98c00a5058c55e8a59df2c3463f4d (patch)
treee0383b4ccfd1f0eb43d8e9c96aaefdcd8e5a3912
parent869ff70e0dbfeab16b20bb1a8d765db153312a42 (diff)
downloadqtlocation-mapboxgl-16f1854a9ca98c00a5058c55e8a59df2c3463f4d.tar.gz
[node] Parse 'sdf' option when adding an image
-rw-r--r--platform/node/CHANGELOG.md1
-rw-r--r--platform/node/src/node_map.cpp7
2 files changed, 7 insertions, 1 deletions
diff --git a/platform/node/CHANGELOG.md b/platform/node/CHANGELOG.md
index d049944b6a..e03a64b049 100644
--- a/platform/node/CHANGELOG.md
+++ b/platform/node/CHANGELOG.md
@@ -3,6 +3,7 @@
- Add `crossSourceCollisions` map option, with default of `true`. When set to `false`, cross-source collision detection is disabled. ([#12820] (https://github.com/mapbox/mapbox-gl-native/issues/12820))
- Fixed bugs in coercion expression operators ("to-array" applied to empty arrays, "to-color" applied to colors, and "to-number" applied to null) [#12864](https://github.com/mapbox/mapbox-gl-native/pull/12864)
- Fixed an issue where fill and line layers would occasionally flicker on zoom ([#12982](https://github.com/mapbox/mapbox-gl-native/pull/12982))
+- Add an option to set whether or not an image should be treated as a SDF ([#15054](https://github.com/mapbox/mapbox-gl-native/issues/15054))
# 4.0.0
- Many new features and enhancements, including:
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp
index e59982ad99..641816dc00 100644
--- a/platform/node/src/node_map.cpp
+++ b/platform/node/src/node_map.cpp
@@ -779,6 +779,11 @@ void NodeMap::AddImage(const Nan::FunctionCallbackInfo<v8::Value>& info) {
return Nan::ThrowTypeError("Max height and width is 1024");
}
+ bool sdf = false;
+ if (Nan::Get(optionObject, Nan::New("sdf").ToLocalChecked()).ToLocalChecked()->IsBoolean()) {
+ sdf = Nan::Get(optionObject, Nan::New("sdf").ToLocalChecked()).ToLocalChecked()->BooleanValue();
+ }
+
float pixelRatio = Nan::Get(optionObject, Nan::New("pixelRatio").ToLocalChecked()).ToLocalChecked()->NumberValue();
auto imageBuffer = Nan::To<v8::Object>(info[1]).ToLocalChecked()->ToObject();
@@ -794,7 +799,7 @@ void NodeMap::AddImage(const Nan::FunctionCallbackInfo<v8::Value>& info) {
mbgl::UnassociatedImage cImage({ imageWidth, imageHeight}, std::move(data));
mbgl::PremultipliedImage cPremultipliedImage = mbgl::util::premultiply(std::move(cImage));
- nodeMap->map->getStyle().addImage(std::make_unique<mbgl::style::Image>(*Nan::Utf8String(info[0]), std::move(cPremultipliedImage), pixelRatio));
+ nodeMap->map->getStyle().addImage(std::make_unique<mbgl::style::Image>(*Nan::Utf8String(info[0]), std::move(cPremultipliedImage), pixelRatio, sdf));
}
void NodeMap::RemoveImage(const Nan::FunctionCallbackInfo<v8::Value>& info) {