summaryrefslogtreecommitdiff
path: root/src/mbgl/util/offscreen_texture.cpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-10-04 12:45:11 +0200
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-10-04 14:00:30 -0700
commit07315711d6b191a5812065bb76ab5beb33d995d9 (patch)
tree89afc1b90ac64660596ffb94512bbd23adbf80cc /src/mbgl/util/offscreen_texture.cpp
parente103d92b1814fc3a735c05ce9be70be3409c201a (diff)
downloadqtlocation-mapboxgl-07315711d6b191a5812065bb76ab5beb33d995d9.tar.gz
[core] remove Raster object in favor of a more low-level Texture object
Diffstat (limited to 'src/mbgl/util/offscreen_texture.cpp')
-rw-r--r--src/mbgl/util/offscreen_texture.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/mbgl/util/offscreen_texture.cpp b/src/mbgl/util/offscreen_texture.cpp
index 194527d1b0..51049f8282 100644
--- a/src/mbgl/util/offscreen_texture.cpp
+++ b/src/mbgl/util/offscreen_texture.cpp
@@ -10,16 +10,15 @@ void OffscreenTexture::bind(gl::Context& context,
std::array<uint16_t, 2> size) {
assert(size[0] > 0 && size[1] > 0);
- if (raster.getSize() != size) {
- raster.load(PremultipliedImage(size[0], size[1], nullptr));
- raster.upload(context, 0);
+ if (!texture || texture->size != size) {
+ texture = context.createTexture(size);
}
if (!framebuffer) {
framebuffer = context.createFramebuffer();
context.bindFramebuffer = *framebuffer;
MBGL_CHECK_ERROR(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
- raster.getID(), 0));
+ texture->texture, 0));
GLenum status = MBGL_CHECK_ERROR(glCheckFramebufferStatus(GL_FRAMEBUFFER));
if (status != GL_FRAMEBUFFER_COMPLETE) {
@@ -55,12 +54,17 @@ void OffscreenTexture::bind(gl::Context& context,
context.viewport = { 0, 0, size[0], size[1] };
}
-Raster& OffscreenTexture::getTexture() {
- return raster;
+gl::Texture& OffscreenTexture::getTexture() {
+ return *texture;
}
std::array<uint16_t, 2> OffscreenTexture::getSize() const {
- return raster.getSize();
+ if (texture) {
+ // Use explicit dereference instead of -> due to clang 3.5 bug
+ return (*texture).size;
+ } else {
+ return {{ 0, 0 }};
+ }
}
} // namespace mbgl