[core] remove trailing whitespace, add trailing newlines, add space after //
This commit is contained in:
@@ -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]));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user