summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2019-03-20 10:34:02 +0100
committerAlf Watt <alf.watt@mapbox.com>2019-03-21 12:25:11 -0700
commit4b2bd713144d63ed4b57350c6612ed9b529c2524 (patch)
tree566c4be3d3f5457fdaf8b304fd6a56cba0e7ab3a
parentbf9e76c1cb2f6b0e1f6bc824d5c2d822595158b7 (diff)
downloadqtlocation-mapboxgl-4b2bd713144d63ed4b57350c6612ed9b529c2524.tar.gz
[core] move cleanup to gfx::Context
-rw-r--r--src/mbgl/gfx/context.hpp4
-rw-r--r--src/mbgl/gl/context.cpp14
-rw-r--r--src/mbgl/gl/context.hpp2
-rw-r--r--src/mbgl/renderer/renderer_impl.cpp15
4 files changed, 20 insertions, 15 deletions
diff --git a/src/mbgl/gfx/context.hpp b/src/mbgl/gfx/context.hpp
index 3653eeebe1..ff84cf34e8 100644
--- a/src/mbgl/gfx/context.hpp
+++ b/src/mbgl/gfx/context.hpp
@@ -34,6 +34,10 @@ public:
virtual ~Context() = default;
public:
+ // Called at the end of a frame.
+ virtual void performCleanup() = 0;
+
+public:
template <class Vertex>
VertexBuffer<Vertex>
createVertexBuffer(VertexVector<Vertex>&& v,
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp
index eff3c2160c..bc703db401 100644
--- a/src/mbgl/gl/context.cpp
+++ b/src/mbgl/gl/context.cpp
@@ -5,6 +5,7 @@
#include <mbgl/gl/texture_resource.hpp>
#include <mbgl/gl/draw_scope_resource.hpp>
#include <mbgl/gl/texture.hpp>
+#include <mbgl/gl/debugging.hpp>
#include <mbgl/gl/debugging_extension.hpp>
#include <mbgl/gl/vertex_array_extension.hpp>
#include <mbgl/gl/program_binary_extension.hpp>
@@ -706,6 +707,19 @@ void Context::draw(const gfx::DrawMode& drawMode,
}
void Context::performCleanup() {
+ // TODO: Find a better way to unbind VAOs after we're done with them without introducing
+ // unnecessary bind(0)/bind(N) sequences.
+ {
+ MBGL_DEBUG_GROUP(*this, "cleanup");
+
+ activeTextureUnit = 1;
+ texture[1] = 0;
+ activeTextureUnit = 0;
+ texture[0] = 0;
+
+ bindVertexArray = 0;
+ }
+
for (auto id : abandonedPrograms) {
if (program == id) {
program.setDirty();
diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp
index 8a67213628..338a294b47 100644
--- a/src/mbgl/gl/context.hpp
+++ b/src/mbgl/gl/context.hpp
@@ -110,7 +110,7 @@ public:
// Actually remove the objects we marked as abandoned with the above methods.
// Only call this while the OpenGL context is exclusive to this thread.
- void performCleanup();
+ void performCleanup() override;
// Drain pools and remove abandoned objects, in preparation for destroying the store.
// Only call this while the OpenGL context is exclusive to this thread.
diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp
index dee42a6128..aa47d56b47 100644
--- a/src/mbgl/renderer/renderer_impl.cpp
+++ b/src/mbgl/renderer/renderer_impl.cpp
@@ -589,19 +589,6 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
}
#endif
- // TODO: Find a better way to unbind VAOs after we're done with them without introducing
- // unnecessary bind(0)/bind(N) sequences.
- {
- MBGL_DEBUG_GROUP(parameters.context, "cleanup");
-
- glContext.activeTextureUnit = 1;
- glContext.texture[1] = 0;
- glContext.activeTextureUnit = 0;
- glContext.texture[0] = 0;
-
- glContext.bindVertexArray = 0;
- }
-
observer->onDidFinishRenderingFrame(
loaded ? RendererObserver::RenderMode::Full : RendererObserver::RenderMode::Partial,
updateParameters.mode == MapMode::Continuous && hasTransitions(parameters.timePoint)
@@ -615,7 +602,7 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
}
// Cleanup only after signaling completion
- glContext.performCleanup();
+ parameters.context.performCleanup();
}
std::vector<Feature> Renderer::Impl::queryRenderedFeatures(const ScreenLineString& geometry, const RenderedQueryOptions& options) const {