summaryrefslogtreecommitdiff
path: root/src/mbgl/util/offscreen_texture.cpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-11-04 17:39:14 +0100
committerKonstantin Käfer <mail@kkaefer.com>2016-11-04 21:24:05 +0100
commitc90a55959980f9ef9678a45b9c9ded906d637b34 (patch)
tree7bf7a9041c269934b3bb25f2b84934f29d330d8b /src/mbgl/util/offscreen_texture.cpp
parenteed16cb1bb14c5de68e71ba7960cbe264cc08760 (diff)
downloadqtlocation-mapboxgl-c90a55959980f9ef9678a45b9c9ded906d637b34.tar.gz
[core] move framebuffer reading to gl::Context
Diffstat (limited to 'src/mbgl/util/offscreen_texture.cpp')
-rw-r--r--src/mbgl/util/offscreen_texture.cpp16
1 files changed, 1 insertions, 15 deletions
diff --git a/src/mbgl/util/offscreen_texture.cpp b/src/mbgl/util/offscreen_texture.cpp
index 6352e38ab7..aad20e59d3 100644
--- a/src/mbgl/util/offscreen_texture.cpp
+++ b/src/mbgl/util/offscreen_texture.cpp
@@ -1,6 +1,5 @@
#include <mbgl/util/offscreen_texture.hpp>
#include <mbgl/gl/context.hpp>
-#include <mbgl/gl/gl.hpp>
#include <cstring>
#include <cassert>
@@ -29,20 +28,7 @@ gl::Texture& OffscreenTexture::getTexture() {
}
PremultipliedImage OffscreenTexture::readStillImage() {
- PremultipliedImage image { size };
- MBGL_CHECK_ERROR(
- glReadPixels(0, 0, size.width, size.height, GL_RGBA, GL_UNSIGNED_BYTE, image.data.get()));
-
- const auto stride = image.stride();
- auto tmp = std::make_unique<uint8_t[]>(stride);
- uint8_t* rgba = image.data.get();
- for (int i = 0, j = size.height - 1; i < j; i++, j--) {
- std::memcpy(tmp.get(), rgba + i * stride, stride);
- std::memcpy(rgba + i * stride, rgba + j * stride, stride);
- std::memcpy(rgba + j * stride, tmp.get(), stride);
- }
-
- return image;
+ return context.readFramebuffer<PremultipliedImage>(size);
}