summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLeith Bade <leith@leithalweapon.geek.nz>2014-06-24 00:41:28 +1000
committerMike Morris <michael.patrick.morris@gmail.com>2014-09-10 18:31:20 -0400
commit71549e7b93b6b44ed38e8915d8735c136889c3f1 (patch)
tree41713e8771be946304e9f04cf4477b34e17cd6e8 /src
parentc004c036964e9012b08aa4a2f8b16094630d62be (diff)
downloadqtlocation-mapboxgl-71549e7b93b6b44ed38e8915d8735c136889c3f1.tar.gz
Adds the function Map::terminate() to allow all GL resources held
by the map to be released immediately. Map::terminate() will call any GL functions on the current thread without blocking or defering to the rendering thread. This function allows a GL context to be destroyed and recreated safely without having to delete the Map object. Fixes mapbox/mapbox-gl-native#341 Conflicts: include/llmr/renderer/painter.hpp test/headless.cpp
Diffstat (limited to 'src')
-rw-r--r--src/map/map.cpp6
-rw-r--r--src/renderer/painter.cpp19
2 files changed, 25 insertions, 0 deletions
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()) {