#pragma once #include "node_thread_pool.hpp" #include #include #include #include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wshadow" #include #pragma GCC diagnostic pop namespace mbgl { class Map; class HeadlessFrontend; } // namespace mbgl namespace node_mbgl { class NodeMapObserver : public mbgl::MapObserver { void onDidFailLoadingMap(std::exception_ptr) override; }; class NodeMap : public Nan::ObjectWrap, public mbgl::FileSource { public: struct RenderOptions; class RenderWorker; NodeMap(v8::Local); ~NodeMap(); static Nan::Persistent constructor; static void Init(v8::Local); static void New(const Nan::FunctionCallbackInfo&); static void Load(const Nan::FunctionCallbackInfo&); static void Loaded(const Nan::FunctionCallbackInfo&); static void Render(const Nan::FunctionCallbackInfo&); static void Release(const Nan::FunctionCallbackInfo&); static void Cancel(const Nan::FunctionCallbackInfo&); static void AddSource(const Nan::FunctionCallbackInfo&); static void AddLayer(const Nan::FunctionCallbackInfo&); static void RemoveLayer(const Nan::FunctionCallbackInfo&); static void AddImage(const Nan::FunctionCallbackInfo&); static void RemoveImage(const Nan::FunctionCallbackInfo&); static void SetLayoutProperty(const Nan::FunctionCallbackInfo&); static void SetPaintProperty(const Nan::FunctionCallbackInfo&); static void SetFilter(const Nan::FunctionCallbackInfo&); static void SetCenter(const Nan::FunctionCallbackInfo&); static void SetZoom(const Nan::FunctionCallbackInfo&); static void SetBearing(const Nan::FunctionCallbackInfo&); static void SetPitch(const Nan::FunctionCallbackInfo&); static void DumpDebugLogs(const Nan::FunctionCallbackInfo&); static void QueryRenderedFeatures(const Nan::FunctionCallbackInfo&); void startRender(RenderOptions options); void renderFinished(); void release(); void cancel(); static RenderOptions ParseOptions(v8::Local); std::unique_ptr request(const mbgl::Resource&, mbgl::FileSource::Callback); const float pixelRatio; NodeThreadPool threadpool; NodeMapObserver mapObserver; std::unique_ptr frontend; std::unique_ptr map; std::exception_ptr error; mbgl::PremultipliedImage image; std::unique_ptr callback; // Async for delivering the notifications of render completion. uv_async_t *async; bool loaded = false; }; }