summaryrefslogtreecommitdiff
path: root/src/mbgl/util/offscreen_texture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/util/offscreen_texture.cpp')
-rw-r--r--src/mbgl/util/offscreen_texture.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/mbgl/util/offscreen_texture.cpp b/src/mbgl/util/offscreen_texture.cpp
index 40bb70b70e..6352e38ab7 100644
--- a/src/mbgl/util/offscreen_texture.cpp
+++ b/src/mbgl/util/offscreen_texture.cpp
@@ -7,9 +7,9 @@
namespace mbgl {
-OffscreenTexture::OffscreenTexture(gl::Context& context_, std::array<uint16_t, 2> size_)
- : context(context_), size(std::move(size_)) {
- assert(size[0] > 0 && size[1] > 0);
+OffscreenTexture::OffscreenTexture(gl::Context& context_, const Size size_)
+ : size(std::move(size_)), context(context_) {
+ assert(size);
}
void OffscreenTexture::bind() {
@@ -20,7 +20,7 @@ void OffscreenTexture::bind() {
context.bindFramebuffer = framebuffer->framebuffer;
}
- context.viewport = { 0, 0, size[0], size[1] };
+ context.viewport = { 0, 0, size };
}
gl::Texture& OffscreenTexture::getTexture() {
@@ -29,13 +29,14 @@ gl::Texture& OffscreenTexture::getTexture() {
}
PremultipliedImage OffscreenTexture::readStillImage() {
- PremultipliedImage image { size[0], size[1] };
- MBGL_CHECK_ERROR(glReadPixels(0, 0, size[0], size[1], GL_RGBA, GL_UNSIGNED_BYTE, image.data.get()));
+ 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[1] - 1; i < j; i++, j--) {
+ 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);