summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer/frame_history.cpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-07-07 19:13:16 +0200
committerKonstantin Käfer <mail@kkaefer.com>2016-07-08 13:11:25 +0200
commit4f26c8122a57cd5fe35a10dc2e125500179a75a5 (patch)
tree02381c3db2adedcc6afa721137a6fb318ec915dd /src/mbgl/renderer/frame_history.cpp
parentaaa30c8a19bd608baf4c190f794258919365c36d (diff)
downloadqtlocation-mapboxgl-4f26c8122a57cd5fe35a10dc2e125500179a75a5.tar.gz
[core] track texture state to avoid redundand binds
Diffstat (limited to 'src/mbgl/renderer/frame_history.cpp')
-rw-r--r--src/mbgl/renderer/frame_history.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/mbgl/renderer/frame_history.cpp b/src/mbgl/renderer/frame_history.cpp
index 68b6bf863e..fc9d9b6616 100644
--- a/src/mbgl/renderer/frame_history.cpp
+++ b/src/mbgl/renderer/frame_history.cpp
@@ -1,5 +1,6 @@
#include <mbgl/renderer/frame_history.hpp>
#include <mbgl/math/minmax.hpp>
+#include <mbgl/gl/gl_config.hpp>
namespace mbgl {
@@ -57,11 +58,11 @@ bool FrameHistory::needsAnimation(const Duration& duration) const {
return (time - previousTime) < duration;
}
-void FrameHistory::upload(gl::ObjectStore& store) {
+void FrameHistory::upload(gl::ObjectStore& store, gl::Config& config, uint32_t unit) {
if (changed) {
const bool first = !texture;
- bind(store);
+ bind(store, config, unit);
if (first) {
MBGL_CHECK_ERROR(glTexImage2D(
@@ -94,10 +95,11 @@ void FrameHistory::upload(gl::ObjectStore& store) {
}
}
-void FrameHistory::bind(gl::ObjectStore& store) {
+void FrameHistory::bind(gl::ObjectStore& store, gl::Config& config, uint32_t unit) {
if (!texture) {
texture = store.createTexture();
- MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, *texture));
+ config.activeTexture = unit;
+ config.texture[unit] = *texture;
#ifndef GL_ES_VERSION_2_0
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0));
#endif
@@ -105,10 +107,10 @@ void FrameHistory::bind(gl::ObjectStore& store) {
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST));
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
- } else {
- MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, *texture));
+ } else if (config.texture[unit] != *texture) {
+ config.activeTexture = unit;
+ config.texture[unit] = *texture;
}
-
}
} // namespace mbgl