summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/glfw_view.cpp5
-rw-r--r--include/mbgl/map/map.hpp3
-rw-r--r--include/mbgl/renderer/painter.hpp2
-rw-r--r--src/map/map.cpp6
-rw-r--r--src/renderer/painter.cpp19
5 files changed, 34 insertions, 1 deletions
diff --git a/common/glfw_view.cpp b/common/glfw_view.cpp
index 724b8bf180..0908786bb6 100644
--- a/common/glfw_view.cpp
+++ b/common/glfw_view.cpp
@@ -8,7 +8,10 @@ GLFWView::GLFWView(bool fullscreen) : fullscreen(fullscreen) {
#endif
}
-GLFWView::~GLFWView() { glfwTerminate(); }
+GLFWView::~GLFWView() {
+ map->terminate();
+ glfwTerminate();
+}
void GLFWView::initialize(mbgl::Map *map) {
View::initialize(map);
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index fba38879ed..0d2926d04b 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -53,6 +53,9 @@ public:
// Triggers a cleanup that releases resources.
void cleanup();
+ // Releases resources immediately
+ void terminate();
+
// Controls buffer swapping.
bool needsSwap();
void swapped();
diff --git a/include/mbgl/renderer/painter.hpp b/include/mbgl/renderer/painter.hpp
index 75529d1136..15331b9b67 100644
--- a/include/mbgl/renderer/painter.hpp
+++ b/include/mbgl/renderer/painter.hpp
@@ -63,6 +63,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.
@@ -123,6 +124,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/src/map/map.cpp b/src/map/map.cpp
index de7a7032dc..00f0ac91cc 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -153,6 +153,12 @@ void Map::cleanup(uv_async_t *async) {
map->painter.cleanup();
}
+void Map::terminate() {
+ view.make_active();
+ painter.terminate();
+ view.make_inactive();
+}
+
void Map::render(uv_async_t *async) {
Map *map = static_cast<Map *>(async->data);
diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp
index c1705cd7cf..b1522a56b5 100644
--- a/src/renderer/painter.cpp
+++ b/src/renderer/painter.cpp
@@ -82,9 +82,28 @@ void Painter::setupShaders() {
if (!gaussianShader) gaussianShader = std::make_unique<GaussianShader>();
}
+void Painter::deleteShaders() {
+ plainShader = nullptr;
+ outlineShader = nullptr;
+ lineShader = nullptr;
+ linejoinShader = nullptr;
+ patternShader = nullptr;
+ iconShader = nullptr;
+ rasterShader = nullptr;
+ textShader = nullptr;
+ dotShader = nullptr;
+ compositeShader = nullptr;
+ gaussianShader = nullptr;
+}
+
void Painter::cleanup() {
}
+void Painter::terminate() {
+ cleanup();
+ deleteShaders();
+}
+
void Painter::resize() {
const TransformState &state = map.getState();
if (gl_viewport != state.getFramebufferDimensions()) {