diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/map/map.hpp | 11 | ||||
-rw-r--r-- | include/mbgl/map/view.hpp | 4 | ||||
-rw-r--r-- | include/mbgl/renderer/painter.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/style/class_dictionary.hpp | 13 | ||||
-rw-r--r-- | include/mbgl/util/uv_detail.hpp | 13 |
5 files changed, 26 insertions, 17 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index a69943aa74..7e4687ea6f 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -63,6 +63,9 @@ public: // Triggers a cleanup that releases resources. void cleanup(); + // Releases resources immediately + void terminate(); + // Controls buffer swapping. bool needsSwap(); void swapped(); @@ -143,10 +146,10 @@ public: private: // uv async callbacks - static void render(uv_async_t *async); - static void terminate(uv_async_t *async); - static void cleanup(uv_async_t *async); - static void delete_async(uv_handle_t *handle); + static void render(uv_async_t *async, int status); + static void terminate(uv_async_t *async, int status); + static void cleanup(uv_async_t *async, int status); + static void delete_async(uv_handle_t *handle, int status); // Setup void setup(); diff --git a/include/mbgl/map/view.hpp b/include/mbgl/map/view.hpp index bbdcd97c79..395a05d435 100644 --- a/include/mbgl/map/view.hpp +++ b/include/mbgl/map/view.hpp @@ -35,6 +35,10 @@ public: // renderer setup since the render thread doesn't switch the contexts. virtual void make_active() = 0; + // Called from the render thread. Makes the GL context inactive in the current + // thread. This is called once just before the rendering thread terminates. + virtual void make_inactive() = 0; + // Returns the base framebuffer object, if any, and 0 if using the system // provided framebuffer. virtual unsigned int root_fbo() { diff --git a/include/mbgl/renderer/painter.hpp b/include/mbgl/renderer/painter.hpp index 13c2050bd0..0f9bd79173 100644 --- a/include/mbgl/renderer/painter.hpp +++ b/include/mbgl/renderer/painter.hpp @@ -64,6 +64,7 @@ public: // lazy initialization) in case rendering continues. void cleanup(); + void terminate(); // Renders the backdrop of the OpenGL view. This also paints in areas where we don't have any // tiles whatsoever. @@ -124,6 +125,7 @@ public: private: void setupShaders(); + void deleteShaders(); mat4 translatedMatrix(const mat4& matrix, const std::array<float, 2> &translation, const Tile::ID &id, TranslateAnchorType anchor); void prepareTile(const Tile& tile); diff --git a/include/mbgl/style/class_dictionary.hpp b/include/mbgl/style/class_dictionary.hpp index c7f9c6a284..ecf80be3e3 100644 --- a/include/mbgl/style/class_dictionary.hpp +++ b/include/mbgl/style/class_dictionary.hpp @@ -14,17 +14,22 @@ enum class ClassID : uint32_t { }; class ClassDictionary { +private: + ClassDictionary(); + public: + static ClassDictionary &Get(); + // Returns an ID for a class name. If the class name does not yet have an ID, one is // auto-generated and stored for future reference. - static ClassID Lookup(const std::string &class_name); + ClassID lookup(const std::string &class_name); // Returns either Fallback, Default or Named, depending on the type of the class id. - static ClassID Normalize(ClassID id); + ClassID normalize(ClassID id); private: - static std::unordered_map<std::string, ClassID> store; - static uint32_t offset; + std::unordered_map<std::string, ClassID> store = { { "", ClassID::Default } }; + uint32_t offset = 0; }; } diff --git a/include/mbgl/util/uv_detail.hpp b/include/mbgl/util/uv_detail.hpp index e0a57ce65d..a80423f822 100644 --- a/include/mbgl/util/uv_detail.hpp +++ b/include/mbgl/util/uv_detail.hpp @@ -23,18 +23,13 @@ private: class loop { public: - inline loop() { - if (uv_loop_init(&l) != 0) { - throw std::runtime_error("failed to initialize loop"); - } - } - - inline ~loop() { uv_loop_close(&l); } + inline loop() : l(uv_loop_new()) {} + inline ~loop() { uv_loop_delete(l); } - inline uv_loop_t *operator*() { return &l; } + inline uv_loop_t *operator*() { return l; } private: - uv_loop_t l; + uv_loop_t *l; }; class mutex { |