summaryrefslogtreecommitdiff
path: root/src/mbgl/gl
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-10-26 15:22:31 -0700
committerKonstantin Käfer <mail@kkaefer.com>2016-10-27 18:30:58 -0700
commit62b56b799a7d4fcd1a8f151eed878054b862da5b (patch)
tree34d510a69f9dd1bca30e9b137feffbd1eb6495d0 /src/mbgl/gl
parentef8017198ce8f0bd79ba5a5ed31e35a16e3433bb (diff)
downloadqtlocation-mapboxgl-62b56b799a7d4fcd1a8f151eed878054b862da5b.tar.gz
[core] change std::array<uint16_t, 2> to mbgl::Size
Diffstat (limited to 'src/mbgl/gl')
-rw-r--r--src/mbgl/gl/context.cpp12
-rw-r--r--src/mbgl/gl/context.hpp15
-rw-r--r--src/mbgl/gl/framebuffer.hpp5
-rw-r--r--src/mbgl/gl/renderbuffer.hpp5
-rw-r--r--src/mbgl/gl/texture.hpp5
-rw-r--r--src/mbgl/gl/value.cpp4
-rw-r--r--src/mbgl/gl/value.hpp8
7 files changed, 24 insertions, 30 deletions
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp
index 23b28a15df..bf9bae4fe7 100644
--- a/src/mbgl/gl/context.cpp
+++ b/src/mbgl/gl/context.cpp
@@ -143,16 +143,14 @@ UniqueFramebuffer Context::createFramebuffer() {
return UniqueFramebuffer{ std::move(id), { this } };
}
-UniqueRenderbuffer Context::createRenderbuffer(const RenderbufferType type,
- const uint16_t width,
- const uint16_t height) {
+UniqueRenderbuffer Context::createRenderbuffer(const RenderbufferType type, const Size size) {
RenderbufferID id = 0;
MBGL_CHECK_ERROR(glGenRenderbuffers(1, &id));
UniqueRenderbuffer renderbuffer{ std::move(id), { this } };
bindRenderbuffer = renderbuffer;
MBGL_CHECK_ERROR(
- glRenderbufferStorage(GL_RENDERBUFFER, static_cast<GLenum>(type), width, height));
+ glRenderbufferStorage(GL_RENDERBUFFER, static_cast<GLenum>(type), size.width, size.height));
return renderbuffer;
}
@@ -251,7 +249,7 @@ Framebuffer Context::createFramebuffer(const Texture& color) {
}
UniqueTexture
-Context::createTexture(uint16_t width, uint16_t height, const void* data, TextureUnit unit) {
+Context::createTexture(const Size size, const void* data, TextureUnit unit) {
auto obj = createTexture();
activeTexture = unit;
texture[unit] = obj;
@@ -259,8 +257,8 @@ Context::createTexture(uint16_t width, uint16_t height, const void* data, Textur
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST));
- MBGL_CHECK_ERROR(
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data));
+ MBGL_CHECK_ERROR(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width, size.height, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, data));
return obj;
}
diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp
index cf8bb2658b..6daf3f9bfb 100644
--- a/src/mbgl/gl/context.hpp
+++ b/src/mbgl/gl/context.hpp
@@ -49,10 +49,10 @@ public:
}
template <RenderbufferType type>
- Renderbuffer<type> createRenderbuffer(const std::array<uint16_t, 2>& size) {
+ Renderbuffer<type> createRenderbuffer(const Size size) {
static_assert(type == RenderbufferType::RGBA || type == RenderbufferType::DepthStencil,
"invalid renderbuffer type");
- return { size, createRenderbuffer(type, size[0], size[1]) };
+ return { size, createRenderbuffer(type, size) };
}
Framebuffer createFramebuffer(const Renderbuffer<RenderbufferType::RGBA>&,
@@ -65,13 +65,12 @@ public:
// Create a texture from an image with data.
template <typename Image>
Texture createTexture(const Image& image, TextureUnit unit = 0) {
- return { {{ image.width, image.height }},
- createTexture(image.width, image.height, image.data.get(), unit) };
+ return { image.size, createTexture(image.size, image.data.get(), unit) };
}
// Creates an empty texture with the specified dimensions.
- Texture createTexture(const std::array<uint16_t, 2>& size, TextureUnit unit = 0) {
- return { size, createTexture(size[0], size[1], nullptr, unit) };
+ Texture createTexture(const Size size, TextureUnit unit = 0) {
+ return { size, createTexture(size, nullptr, unit) };
}
void bindTexture(Texture&,
@@ -140,9 +139,9 @@ public:
private:
UniqueBuffer createVertexBuffer(const void* data, std::size_t size);
UniqueBuffer createIndexBuffer(const void* data, std::size_t size);
- UniqueTexture createTexture(uint16_t width, uint16_t height, const void* data, TextureUnit);
+ UniqueTexture createTexture(Size size, const void* data, TextureUnit);
UniqueFramebuffer createFramebuffer();
- UniqueRenderbuffer createRenderbuffer(RenderbufferType, uint16_t width, uint16_t height);
+ UniqueRenderbuffer createRenderbuffer(RenderbufferType, Size size);
void bindAttribute(const AttributeBinding&, std::size_t stride, const int8_t* offset);
friend detail::ProgramDeleter;
diff --git a/src/mbgl/gl/framebuffer.hpp b/src/mbgl/gl/framebuffer.hpp
index 880fed159e..91ed467b40 100644
--- a/src/mbgl/gl/framebuffer.hpp
+++ b/src/mbgl/gl/framebuffer.hpp
@@ -1,15 +1,14 @@
#pragma once
#include <mbgl/gl/object.hpp>
-
-#include <array>
+#include <mbgl/util/size.hpp>
namespace mbgl {
namespace gl {
class Framebuffer {
public:
- std::array<uint16_t, 2> size;
+ Size size;
gl::UniqueFramebuffer framebuffer;
};
diff --git a/src/mbgl/gl/renderbuffer.hpp b/src/mbgl/gl/renderbuffer.hpp
index 9e8993bb77..cc8ff13268 100644
--- a/src/mbgl/gl/renderbuffer.hpp
+++ b/src/mbgl/gl/renderbuffer.hpp
@@ -1,8 +1,7 @@
#pragma once
#include <mbgl/gl/object.hpp>
-
-#include <array>
+#include <mbgl/util/size.hpp>
namespace mbgl {
namespace gl {
@@ -11,7 +10,7 @@ template <RenderbufferType renderbufferType>
class Renderbuffer {
public:
using type = std::integral_constant<RenderbufferType, renderbufferType>;
- std::array<uint16_t, 2> size;
+ Size size;
gl::UniqueRenderbuffer renderbuffer;
};
diff --git a/src/mbgl/gl/texture.hpp b/src/mbgl/gl/texture.hpp
index 49e1323095..802dac9eb2 100644
--- a/src/mbgl/gl/texture.hpp
+++ b/src/mbgl/gl/texture.hpp
@@ -1,15 +1,14 @@
#pragma once
#include <mbgl/gl/object.hpp>
-
-#include <array>
+#include <mbgl/util/size.hpp>
namespace mbgl {
namespace gl {
class Texture {
public:
- std::array<uint16_t, 2> size;
+ Size size;
UniqueTexture texture;
TextureFilter filter = TextureFilter::Nearest;
TextureMipMap mipmap = TextureMipMap::No;
diff --git a/src/mbgl/gl/value.cpp b/src/mbgl/gl/value.cpp
index 14cd03efc4..b308dc9de5 100644
--- a/src/mbgl/gl/value.cpp
+++ b/src/mbgl/gl/value.cpp
@@ -244,14 +244,14 @@ ActiveTexture::Type ActiveTexture::Get() {
const constexpr Viewport::Type Viewport::Default;
void Viewport::Set(const Type& value) {
- MBGL_CHECK_ERROR(glViewport(value.x, value.y, value.width, value.height));
+ MBGL_CHECK_ERROR(glViewport(value.x, value.y, value.size.width, value.size.height));
}
Viewport::Type Viewport::Get() {
GLint viewport[4];
MBGL_CHECK_ERROR(glGetIntegerv(GL_VIEWPORT, viewport));
return { static_cast<int32_t>(viewport[0]), static_cast<int32_t>(viewport[1]),
- static_cast<uint16_t>(viewport[2]), static_cast<uint16_t>(viewport[3]) };
+ { static_cast<uint32_t>(viewport[2]), static_cast<uint32_t>(viewport[3]) } };
}
const constexpr BindFramebuffer::Type BindFramebuffer::Default;
diff --git a/src/mbgl/gl/value.hpp b/src/mbgl/gl/value.hpp
index 866ce389a4..becf2e63f4 100644
--- a/src/mbgl/gl/value.hpp
+++ b/src/mbgl/gl/value.hpp
@@ -2,6 +2,7 @@
#include <mbgl/gl/types.hpp>
#include <mbgl/util/color.hpp>
+#include <mbgl/util/size.hpp>
namespace mbgl {
namespace gl {
@@ -177,16 +178,15 @@ struct Viewport {
struct Type {
int32_t x;
int32_t y;
- uint16_t width;
- uint16_t height;
+ Size size;
};
- static const constexpr Type Default = { 0, 0, 0, 0 };
+ static const constexpr Type Default = { 0, 0, { 0, 0 } };
static void Set(const Type&);
static Type Get();
};
constexpr bool operator!=(const Viewport::Type& a, const Viewport::Type& b) {
- return a.x != b.x || a.y != b.y || a.width != b.width || a.height != b.height;
+ return a.x != b.x || a.y != b.y || a.size != b.size;
}
struct BindFramebuffer {