summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2019-06-12 17:25:44 +0200
committerKonstantin Käfer <mail@kkaefer.com>2019-06-12 18:08:18 +0200
commitce91218b420cd9e57a3367679300f8ba4027d6c5 (patch)
treece4298d2f35793bf788d3834b07f63c611846641
parentd37212421955bb144f67905fbd1e7321a74b465b (diff)
downloadqtlocation-mapboxgl-ce91218b420cd9e57a3367679300f8ba4027d6c5.tar.gz
[core] don't call glFlush on every frame
-rw-r--r--src/mbgl/gfx/context.hpp3
-rw-r--r--src/mbgl/gl/context.cpp6
-rw-r--r--src/mbgl/gl/context.hpp2
-rw-r--r--src/mbgl/renderer/renderer_impl.cpp2
4 files changed, 12 insertions, 1 deletions
diff --git a/src/mbgl/gfx/context.hpp b/src/mbgl/gfx/context.hpp
index 64eddf3e5a..2c7cb14899 100644
--- a/src/mbgl/gfx/context.hpp
+++ b/src/mbgl/gfx/context.hpp
@@ -38,6 +38,9 @@ public:
// Called at the end of a frame.
virtual void performCleanup() = 0;
+ // Called when the app receives a memory warning and before it goes to the background.
+ virtual void reduceMemoryUsage() = 0;
+
public:
virtual std::unique_ptr<OffscreenTexture>
createOffscreenTexture(Size,
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp
index 3e88624d4f..4d9c2055de 100644
--- a/src/mbgl/gl/context.cpp
+++ b/src/mbgl/gl/context.cpp
@@ -682,7 +682,13 @@ void Context::performCleanup() {
abandonedRenderbuffers.data()));
abandonedRenderbuffers.clear();
}
+}
+
+void Context::reduceMemoryUsage() {
+ performCleanup();
+ // Ensure that all pending actions are executed to ensure that they happen before the app goes
+ // to the background.
MBGL_CHECK_ERROR(glFinish());
}
diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp
index 80278718d1..70f12e5a8d 100644
--- a/src/mbgl/gl/context.hpp
+++ b/src/mbgl/gl/context.hpp
@@ -96,6 +96,8 @@ public:
// Only call this while the OpenGL context is exclusive to this thread.
void performCleanup() override;
+ void reduceMemoryUsage() 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.
void reset();
diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp
index 96ba8d7554..c7cca3a659 100644
--- a/src/mbgl/renderer/renderer_impl.cpp
+++ b/src/mbgl/renderer/renderer_impl.cpp
@@ -666,7 +666,7 @@ void Renderer::Impl::reduceMemoryUse() {
for (const auto& entry : renderSources) {
entry.second->reduceMemoryUse();
}
- backend.getContext().performCleanup();
+ backend.getContext().reduceMemoryUsage();
imageManager->reduceMemoryUse();
observer->onInvalidate();
}