diff --git a/include/mbgl/platform/default/headless_view.hpp b/include/mbgl/platform/default/headless_view.hpp index 07226b5f9..68f32ed1c 100644 --- a/include/mbgl/platform/default/headless_view.hpp +++ b/include/mbgl/platform/default/headless_view.hpp @@ -48,7 +48,7 @@ private: void createContext(); void loadExtensions(); void clearBuffers(); - bool isActive(); + bool isActive() const; private: std::shared_ptr display; diff --git a/platform/default/headless_display.cpp b/platform/default/headless_display.cpp index 093105706..fccc91c72 100644 --- a/platform/default/headless_display.cpp +++ b/platform/default/headless_display.cpp @@ -24,11 +24,9 @@ HeadlessDisplay::HeadlessDisplay() { CGLError error = CGLChoosePixelFormat(attributes, &pixelFormat, &num); if (error != kCGLNoError) { throw std::runtime_error(std::string("Error choosing pixel format:") + CGLErrorString(error) + "\n"); - return; } if (num <= 0) { throw std::runtime_error("No pixel formats found."); - return; } #endif diff --git a/platform/default/headless_view.cpp b/platform/default/headless_view.cpp index f94b924da..7fd3c37f3 100644 --- a/platform/default/headless_view.cpp +++ b/platform/default/headless_view.cpp @@ -1,4 +1,3 @@ - #include #include #include @@ -108,7 +107,7 @@ void HeadlessView::createContext() { #endif } -bool HeadlessView::isActive() { +bool HeadlessView::isActive() const { return std::this_thread::get_id() == thread; } diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index 851d5dc88..f5ebae110 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -37,7 +37,7 @@ static std::shared_ptr sharedDisplay() { return display; } -const static char* releasedMessage() { +static const char* releasedMessage() { return "Map resources have already been released"; } @@ -138,7 +138,7 @@ NAN_METHOD(NodeMap::New) { info.GetReturnValue().Set(info.This()); } -const std::string StringifyStyle(v8::Local styleHandle) { +std::string StringifyStyle(v8::Local styleHandle) { Nan::HandleScope scope; v8::Local JSON = Nan::Get( @@ -197,46 +197,46 @@ NAN_METHOD(NodeMap::Load) { info.GetReturnValue().SetUndefined(); } -std::unique_ptr NodeMap::ParseOptions(v8::Local obj) { +NodeMap::RenderOptions NodeMap::ParseOptions(v8::Local obj) { Nan::HandleScope scope; - auto options = std::make_unique(); + NodeMap::RenderOptions options; if (Nan::Has(obj, Nan::New("zoom").ToLocalChecked()).FromJust()) { - options->zoom = Nan::Get(obj, Nan::New("zoom").ToLocalChecked()).ToLocalChecked()->NumberValue(); + options.zoom = Nan::Get(obj, Nan::New("zoom").ToLocalChecked()).ToLocalChecked()->NumberValue(); } if (Nan::Has(obj, Nan::New("bearing").ToLocalChecked()).FromJust()) { - options->bearing = Nan::Get(obj, Nan::New("bearing").ToLocalChecked()).ToLocalChecked()->NumberValue(); + options.bearing = Nan::Get(obj, Nan::New("bearing").ToLocalChecked()).ToLocalChecked()->NumberValue(); } if (Nan::Has(obj, Nan::New("pitch").ToLocalChecked()).FromJust()) { - options->pitch = Nan::Get(obj, Nan::New("pitch").ToLocalChecked()).ToLocalChecked()->NumberValue(); + options.pitch = Nan::Get(obj, Nan::New("pitch").ToLocalChecked()).ToLocalChecked()->NumberValue(); } if (Nan::Has(obj, Nan::New("center").ToLocalChecked()).FromJust()) { auto centerObj = Nan::Get(obj, Nan::New("center").ToLocalChecked()).ToLocalChecked(); if (centerObj->IsArray()) { auto center = centerObj.As(); - if (center->Length() > 0) { options->longitude = Nan::Get(center, 0).ToLocalChecked()->NumberValue(); } - if (center->Length() > 1) { options->latitude = Nan::Get(center, 1).ToLocalChecked()->NumberValue(); } + if (center->Length() > 0) { options.longitude = Nan::Get(center, 0).ToLocalChecked()->NumberValue(); } + if (center->Length() > 1) { options.latitude = Nan::Get(center, 1).ToLocalChecked()->NumberValue(); } } } if (Nan::Has(obj, Nan::New("width").ToLocalChecked()).FromJust()) { - options->width = Nan::Get(obj, Nan::New("width").ToLocalChecked()).ToLocalChecked()->IntegerValue(); + options.width = Nan::Get(obj, Nan::New("width").ToLocalChecked()).ToLocalChecked()->IntegerValue(); } if (Nan::Has(obj, Nan::New("height").ToLocalChecked()).FromJust()) { - options->height = Nan::Get(obj, Nan::New("height").ToLocalChecked()).ToLocalChecked()->IntegerValue(); + options.height = Nan::Get(obj, Nan::New("height").ToLocalChecked()).ToLocalChecked()->IntegerValue(); } if (Nan::Has(obj, Nan::New("classes").ToLocalChecked()).FromJust()) { auto classes = Nan::Get(obj, Nan::New("classes").ToLocalChecked()).ToLocalChecked()->ToObject().As(); const int length = classes->Length(); - options->classes.reserve(length); + options.classes.reserve(length); for (int i = 0; i < length; i++) { - options->classes.push_back(std::string { *Nan::Utf8String(Nan::Get(classes, i).ToLocalChecked()->ToString()) }); + options.classes.push_back(std::string { *Nan::Utf8String(Nan::Get(classes, i).ToLocalChecked()->ToString()) }); } } @@ -295,13 +295,13 @@ NAN_METHOD(NodeMap::Render) { info.GetReturnValue().SetUndefined(); } -void NodeMap::startRender(std::unique_ptr options) { - view.resize(options->width, options->height); +void NodeMap::startRender(NodeMap::RenderOptions options) { + view.resize(options.width, options.height); map->update(mbgl::Update::Dimensions); - map->setClasses(options->classes); - map->setLatLngZoom(mbgl::LatLng(options->latitude, options->longitude), options->zoom); - map->setBearing(options->bearing); - map->setPitch(options->pitch); + map->setClasses(options.classes); + map->setLatLngZoom(mbgl::LatLng(options.latitude, options.longitude), options.zoom); + map->setBearing(options.bearing); + map->setPitch(options.pitch); map->renderStill([this](const std::exception_ptr eptr, mbgl::PremultipliedImage&& result) { if (eptr) { diff --git a/platform/node/src/node_map.hpp b/platform/node/src/node_map.hpp index 2c1cbd254..fe36ae7ed 100644 --- a/platform/node/src/node_map.hpp +++ b/platform/node/src/node_map.hpp @@ -28,7 +28,7 @@ public: static NAN_METHOD(Release); static NAN_METHOD(DumpDebugLogs); - void startRender(std::unique_ptr options); + void startRender(RenderOptions options); void renderFinished(); void release(); @@ -36,7 +36,7 @@ public: inline bool isLoaded() { return loaded; } inline bool isValid() { return valid; } - static std::unique_ptr ParseOptions(v8::Local); + static RenderOptions ParseOptions(v8::Local); static Nan::Persistent constructor; NodeMap(v8::Local);