summaryrefslogtreecommitdiff
path: root/platform/node
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-01-26 18:52:44 +0100
committerKonstantin Käfer <mail@kkaefer.com>2017-01-27 11:44:16 +0100
commit62ea1f21858c69f6921c775ba7a3de201f0514d8 (patch)
tree7a4da88706e8a5513e1e13e993b2acc212cae3b1 /platform/node
parenta662508ddde4043ece36d8ea9b424368891d892c (diff)
downloadqtlocation-mapboxgl-62ea1f21858c69f6921c775ba7a3de201f0514d8.tar.gz
[core] remove trailing whitespace, add trailing newlines, add space after //
Diffstat (limited to 'platform/node')
-rw-r--r--platform/node/src/node_map.cpp38
-rw-r--r--platform/node/test/memory.test.js4
2 files changed, 21 insertions, 21 deletions
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp
index ea3517f2a6..b73206c6cb 100644
--- a/platform/node/src/node_map.cpp
+++ b/platform/node/src/node_map.cpp
@@ -582,18 +582,18 @@ void NodeMap::RemoveLayer(const Nan::FunctionCallbackInfo<v8::Value>& info) {
nodeMap->map->removeLayer(*Nan::Utf8String(info[0]));
}
-
+
void NodeMap::AddImage(const Nan::FunctionCallbackInfo<v8::Value>& info) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;
-
+
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());
if (!nodeMap->map) return Nan::ThrowError(releasedMessage());
-
+
if (info.Length() != 3) {
return Nan::ThrowTypeError("Three arguments required");
}
-
+
if (!info[0]->IsString()) {
return Nan::ThrowTypeError("First argument must be a string");
}
@@ -601,61 +601,61 @@ void NodeMap::AddImage(const Nan::FunctionCallbackInfo<v8::Value>& info) {
if (!info[1]->IsObject()) {
return Nan::ThrowTypeError("Second argument must be an object");
}
-
+
if (!info[2]->IsObject()) {
return Nan::ThrowTypeError("Third argument must be an object");
}
-
+
auto optionObject = Nan::To<v8::Object>(info[2]).ToLocalChecked();
-
+
if (!Nan::Get(optionObject, Nan::New("height").ToLocalChecked()).ToLocalChecked()->IsUint32()) {
return Nan::ThrowTypeError("height parameter required");
}
-
+
if (!Nan::Get(optionObject, Nan::New("width").ToLocalChecked()).ToLocalChecked()->IsUint32()) {
return Nan::ThrowTypeError("width parameter required");
}
-
+
if (!Nan::Get(optionObject, Nan::New("pixelRatio").ToLocalChecked()).ToLocalChecked()->IsUint32()) {
return Nan::ThrowTypeError("pixelRatio parameter required");
}
-
+
uint32_t imageHeight = Nan::Get(optionObject, Nan::New("height").ToLocalChecked()).ToLocalChecked()->Uint32Value();
uint32_t imageWidth = Nan::Get(optionObject, Nan::New("width").ToLocalChecked()).ToLocalChecked()->Uint32Value();
-
+
if (imageWidth > 1024 || imageHeight > 1024) {
return Nan::ThrowTypeError("Max height and width is 1024");
}
-
+
uint32_t pixelRatio = Nan::Get(optionObject, Nan::New("pixelRatio").ToLocalChecked()).ToLocalChecked()->Uint32Value();
auto imageBuffer = Nan::To<v8::Object>(info[1]).ToLocalChecked()->ToObject();
-
+
if (node::Buffer::Length(imageBuffer) != imageHeight * imageWidth * 4) {
return Nan::ThrowTypeError("Image size does not match buffer size");
}
-
+
std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(node::Buffer::Length(imageBuffer));
std::copy(node::Buffer::Data(imageBuffer), node::Buffer::Data(imageBuffer) + node::Buffer::Length(imageBuffer), data.get());
mbgl::PremultipliedImage cPremultipliedImage({ imageWidth, imageHeight}, std::move(data));
nodeMap->map->addImage(*Nan::Utf8String(info[0]), std::make_unique<mbgl::SpriteImage>(std::move(cPremultipliedImage), pixelRatio));
}
-
+
void NodeMap::RemoveImage(const Nan::FunctionCallbackInfo<v8::Value>& info) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;
-
+
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());
if (!nodeMap->map) return Nan::ThrowError(releasedMessage());
-
+
if (info.Length() != 1) {
return Nan::ThrowTypeError("One argument required");
}
-
+
if (!info[0]->IsString()) {
return Nan::ThrowTypeError("First argument must be a string");
}
-
+
nodeMap->map->removeImage(*Nan::Utf8String(info[0]));
}
diff --git a/platform/node/test/memory.test.js b/platform/node/test/memory.test.js
index ad54098832..e23cb60f89 100644
--- a/platform/node/test/memory.test.js
+++ b/platform/node/test/memory.test.js
@@ -27,7 +27,7 @@ var tile_raster = readFixture('raster.tile');
var tile_vector = readFixture('vector.tile');
test('Memory', function(t) {
- // Trigger garbage collection before starting test, then initialize
+ // Trigger garbage collection before starting test, then initialize
// heap size
if (typeof gc === 'function') gc();
var lastHeapSize = process.memoryUsage()['heapUsed'];
@@ -86,7 +86,7 @@ test('Memory', function(t) {
if (renderCount % (testParams.numRenderings / 10) == 0) {
// Manually trigger garbage collection
if (typeof gc === 'function') gc();
-
+
var currentHeapSize = process.memoryUsage()['heapUsed'];
// Print some progress, so slow build bots don't timeout.