summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2019-03-06 17:27:00 +0100
committerKonstantin Käfer <mail@kkaefer.com>2019-03-12 11:03:54 +0100
commit2a25270298f358f815b22c87ece74fd3f37a42b5 (patch)
tree37e8e3c08f2531c98c962aba6fdb227ed6212e2c /src
parent60ceac5efc3d77199f773f08400fe1d53d5a1b90 (diff)
downloadqtlocation-mapboxgl-2a25270298f358f815b22c87ece74fd3f37a42b5.tar.gz
[core] move Texture related enums to gfx namespace
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/geometry/line_atlas.cpp4
-rw-r--r--src/mbgl/gfx/types.hpp28
-rw-r--r--src/mbgl/gl/context.cpp74
-rw-r--r--src/mbgl/gl/context.hpp36
-rw-r--r--src/mbgl/gl/defines.hpp10
-rw-r--r--src/mbgl/gl/enum.cpp42
-rw-r--r--src/mbgl/gl/texture.hpp17
-rw-r--r--src/mbgl/gl/types.hpp21
-rw-r--r--src/mbgl/renderer/image_manager.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_fill_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_heatmap_layer.cpp10
-rw-r--r--src/mbgl/renderer/layers/render_hillshade_layer.cpp4
-rw-r--r--src/mbgl/renderer/layers/render_line_layer.cpp4
-rw-r--r--src/mbgl/renderer/layers/render_raster_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_symbol_layer.cpp4
-rw-r--r--src/mbgl/renderer/renderer_impl.cpp4
-rw-r--r--src/mbgl/util/offscreen_texture.cpp12
-rw-r--r--src/mbgl/util/offscreen_texture.hpp4
19 files changed, 166 insertions, 116 deletions
diff --git a/src/mbgl/geometry/line_atlas.cpp b/src/mbgl/geometry/line_atlas.cpp
index 1bd6f987e1..e0114befcb 100644
--- a/src/mbgl/geometry/line_atlas.cpp
+++ b/src/mbgl/geometry/line_atlas.cpp
@@ -138,8 +138,8 @@ void LineAtlas::upload(gl::Context& context, gl::TextureUnit unit) {
void LineAtlas::bind(gl::Context& context, gl::TextureUnit unit) {
upload(context, unit);
- context.bindTexture(*texture, unit, gl::TextureFilter::Linear, gl::TextureMipMap::No,
- gl::TextureWrap::Repeat, gl::TextureWrap::Clamp);
+ context.bindTexture(*texture, unit, gfx::TextureFilterType::Linear, gfx::TextureMipMapType::No,
+ gfx::TextureWrapType::Repeat, gfx::TextureWrapType::Clamp);
}
} // namespace mbgl
diff --git a/src/mbgl/gfx/types.hpp b/src/mbgl/gfx/types.hpp
index 6082d99017..4c6a040b1f 100644
--- a/src/mbgl/gfx/types.hpp
+++ b/src/mbgl/gfx/types.hpp
@@ -133,5 +133,33 @@ enum class BufferUsageType : uint8_t {
DynamicDraw,
};
+enum class TexturePixelType : uint8_t {
+ RGBA,
+ Alpha,
+ Stencil,
+ Depth,
+ Luminance,
+};
+
+enum class TextureChannelDataType : uint8_t {
+ UnsignedByte,
+ HalfFloat,
+};
+
+enum class TextureMipMapType : bool {
+ No,
+ Yes
+};
+
+enum class TextureFilterType : bool {
+ Nearest,
+ Linear,
+};
+
+enum class TextureWrapType : bool {
+ Clamp,
+ Repeat,
+};
+
} // namespace gfx
} // namespace mbgl
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp
index df304eb7d4..c8236e0b0a 100644
--- a/src/mbgl/gl/context.cpp
+++ b/src/mbgl/gl/context.cpp
@@ -43,20 +43,6 @@ static_assert(std::is_same<VertexArrayID, GLuint>::value, "OpenGL type mismatch"
static_assert(std::is_same<FramebufferID, GLuint>::value, "OpenGL type mismatch");
static_assert(std::is_same<RenderbufferID, GLuint>::value, "OpenGL type mismatch");
-static_assert(std::is_same<std::underlying_type_t<TextureFormat>, GLenum>::value, "OpenGL type mismatch");
-static_assert(underlying_type(TextureFormat::RGBA) == GL_RGBA, "OpenGL type mismatch");
-static_assert(underlying_type(TextureFormat::Alpha) == GL_ALPHA, "OpenGL type mismatch");
-
-static_assert(std::is_same<std::underlying_type_t<TextureType>, GLenum>::value, "OpenGL type mismatch");
-static_assert(underlying_type(TextureType::UnsignedByte) == GL_UNSIGNED_BYTE, "OpenGL type mismatch");
-
-#if MBGL_USE_GLES2 && GL_HALF_FLOAT_OES
-static_assert(underlying_type(TextureType::HalfFloat) == GL_HALF_FLOAT_OES, "OpenGL type mismatch");
-#endif
-#if !MBGL_USE_GLES2 && GL_HALF_FLOAT_ARB
-static_assert(underlying_type(TextureType::HalfFloat) == GL_HALF_FLOAT_ARB, "OpenGL type mismatch");
-#endif
-
static_assert(underlying_type(UniformDataType::Float) == GL_FLOAT, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::FloatVec2) == GL_FLOAT_VEC2, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::FloatVec3) == GL_FLOAT_VEC3, "OpenGL type mismatch");
@@ -374,16 +360,17 @@ UniqueRenderbuffer Context::createRenderbuffer(const RenderbufferType type, cons
return renderbuffer;
}
-std::unique_ptr<uint8_t[]> Context::readFramebuffer(const Size size, const TextureFormat format, const bool flip) {
- const size_t stride = size.width * (format == TextureFormat::RGBA ? 4 : 1);
+std::unique_ptr<uint8_t[]> Context::readFramebuffer(const Size size, const gfx::TexturePixelType format, const bool flip) {
+ const size_t stride = size.width * (format == gfx::TexturePixelType::RGBA ? 4 : 1);
auto data = std::make_unique<uint8_t[]>(stride * size.height);
// When reading data from the framebuffer, make sure that we are storing the values
// tightly packed into the buffer to avoid buffer overruns.
pixelStorePack = { 1 };
- MBGL_CHECK_ERROR(glReadPixels(0, 0, size.width, size.height, static_cast<GLenum>(format),
- GL_UNSIGNED_BYTE, data.get()));
+ MBGL_CHECK_ERROR(glReadPixels(0, 0, size.width, size.height,
+ Enum<gfx::TexturePixelType>::to(format), GL_UNSIGNED_BYTE,
+ data.get()));
if (flip) {
auto tmp = std::make_unique<uint8_t[]>(stride);
@@ -399,12 +386,13 @@ std::unique_ptr<uint8_t[]> Context::readFramebuffer(const Size size, const Textu
}
#if not MBGL_USE_GLES2
-void Context::drawPixels(const Size size, const void* data, TextureFormat format) {
+void Context::drawPixels(const Size size, const void* data, gfx::TexturePixelType format) {
pixelStoreUnpack = { 1 };
- if (format != TextureFormat::RGBA) {
- format = static_cast<TextureFormat>(GL_LUMINANCE);
+ // TODO
+ if (format != gfx::TexturePixelType::RGBA) {
+ format = gfx::TexturePixelType::Luminance;
}
- MBGL_CHECK_ERROR(glDrawPixels(size.width, size.height, static_cast<GLenum>(format),
+ MBGL_CHECK_ERROR(glDrawPixels(size.width, size.height, Enum<gfx::TexturePixelType>::to(format),
GL_UNSIGNED_BYTE, data));
}
#endif // MBGL_USE_GLES2
@@ -517,8 +505,11 @@ Context::createFramebuffer(const Texture& color,
return { depthTarget.size, std::move(fbo) };
}
-UniqueTexture
-Context::createTexture(const Size size, const void* data, TextureFormat format, TextureUnit unit, TextureType type) {
+UniqueTexture Context::createTexture(const Size size,
+ const void* data,
+ gfx::TexturePixelType format,
+ TextureUnit unit,
+ gfx::TextureChannelDataType type) {
auto obj = createTexture();
pixelStoreUnpack = { 1 };
updateTexture(obj, size, data, format, unit, type);
@@ -531,21 +522,26 @@ Context::createTexture(const Size size, const void* data, TextureFormat format,
return obj;
}
-void Context::updateTexture(
- TextureID id, const Size size, const void* data, TextureFormat format, TextureUnit unit, TextureType type) {
+void Context::updateTexture(TextureID id,
+ const Size size,
+ const void* data,
+ gfx::TexturePixelType format,
+ TextureUnit unit,
+ gfx::TextureChannelDataType type) {
activeTextureUnit = unit;
texture[unit] = id;
- MBGL_CHECK_ERROR(glTexImage2D(GL_TEXTURE_2D, 0, static_cast<GLenum>(format), size.width,
- size.height, 0, static_cast<GLenum>(format), static_cast<GLenum>(type),
- data));
+ MBGL_CHECK_ERROR(glTexImage2D(GL_TEXTURE_2D, 0, Enum<gfx::TexturePixelType>::to(format),
+ size.width, size.height, 0,
+ Enum<gfx::TexturePixelType>::to(format),
+ Enum<gfx::TextureChannelDataType>::to(type), data));
}
void Context::bindTexture(Texture& obj,
TextureUnit unit,
- TextureFilter filter,
- TextureMipMap mipmap,
- TextureWrap wrapX,
- TextureWrap wrapY) {
+ gfx::TextureFilterType filter,
+ gfx::TextureMipMapType mipmap,
+ gfx::TextureWrapType wrapX,
+ gfx::TextureWrapType wrapY) {
if (filter != obj.filter || mipmap != obj.mipmap || wrapX != obj.wrapX || wrapY != obj.wrapY) {
activeTextureUnit = unit;
texture[unit] = obj.texture;
@@ -553,12 +549,12 @@ void Context::bindTexture(Texture& obj,
if (filter != obj.filter || mipmap != obj.mipmap) {
MBGL_CHECK_ERROR(glTexParameteri(
GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
- filter == TextureFilter::Linear
- ? (mipmap == TextureMipMap::Yes ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR)
- : (mipmap == TextureMipMap::Yes ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST)));
+ filter == gfx::TextureFilterType::Linear
+ ? (mipmap == gfx::TextureMipMapType::Yes ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR)
+ : (mipmap == gfx::TextureMipMapType::Yes ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST)));
MBGL_CHECK_ERROR(
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
- filter == TextureFilter::Linear ? GL_LINEAR : GL_NEAREST));
+ filter == gfx::TextureFilterType::Linear ? GL_LINEAR : GL_NEAREST));
obj.filter = filter;
obj.mipmap = mipmap;
}
@@ -566,13 +562,13 @@ void Context::bindTexture(Texture& obj,
MBGL_CHECK_ERROR(
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
- wrapX == TextureWrap::Clamp ? GL_CLAMP_TO_EDGE : GL_REPEAT));
+ wrapX == gfx::TextureWrapType::Clamp ? GL_CLAMP_TO_EDGE : GL_REPEAT));
obj.wrapX = wrapX;
}
if (wrapY != obj.wrapY) {
MBGL_CHECK_ERROR(
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
- wrapY == TextureWrap::Clamp ? GL_CLAMP_TO_EDGE : GL_REPEAT));
+ wrapY == gfx::TextureWrapType::Clamp ? GL_CLAMP_TO_EDGE : GL_REPEAT));
obj.wrapY = wrapY;
}
} else if (texture[unit] != obj.texture) {
diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp
index 70ba1ec107..8b7b9346b3 100644
--- a/src/mbgl/gl/context.hpp
+++ b/src/mbgl/gl/context.hpp
@@ -81,10 +81,10 @@ public:
const Renderbuffer<RenderbufferType::DepthComponent>&);
template <typename Image,
- TextureFormat format = Image::channels == 4 ? TextureFormat::RGBA
- : TextureFormat::Alpha>
+ gfx::TexturePixelType format = Image::channels == 4 ? gfx::TexturePixelType::RGBA
+ : gfx::TexturePixelType::Alpha>
Image readFramebuffer(const Size size, bool flip = true) {
- static_assert(Image::channels == (format == TextureFormat::RGBA ? 4 : 1),
+ static_assert(Image::channels == (format == gfx::TexturePixelType::RGBA ? 4 : 1),
"image format mismatch");
return { size, readFramebuffer(size, format, flip) };
}
@@ -92,7 +92,7 @@ public:
#if not MBGL_USE_GLES2
template <typename Image>
void drawPixels(const Image& image) {
- auto format = image.channels == 4 ? TextureFormat::RGBA : TextureFormat::Alpha;
+ auto format = image.channels == 4 ? gfx::TexturePixelType::RGBA : gfx::TexturePixelType::Alpha;
drawPixels(image.size, image.data.get(), format);
}
#endif // MBGL_USE_GLES2
@@ -101,8 +101,8 @@ public:
template <typename Image>
Texture createTexture(const Image& image,
TextureUnit unit = 0,
- TextureType type = TextureType::UnsignedByte) {
- auto format = image.channels == 4 ? TextureFormat::RGBA : TextureFormat::Alpha;
+ gfx::TextureChannelDataType type = gfx::TextureChannelDataType::UnsignedByte) {
+ auto format = image.channels == 4 ? gfx::TexturePixelType::RGBA : gfx::TexturePixelType::Alpha;
return { image.size, createTexture(image.size, image.data.get(), format, unit, type) };
}
@@ -110,26 +110,26 @@ public:
void updateTexture(Texture& obj,
const Image& image,
TextureUnit unit = 0,
- TextureType type = TextureType::UnsignedByte) {
- auto format = image.channels == 4 ? TextureFormat::RGBA : TextureFormat::Alpha;
+ gfx::TextureChannelDataType type = gfx::TextureChannelDataType::UnsignedByte) {
+ auto format = image.channels == 4 ? gfx::TexturePixelType::RGBA : gfx::TexturePixelType::Alpha;
updateTexture(obj.texture.get(), image.size, image.data.get(), format, unit, type);
obj.size = image.size;
}
// Creates an empty texture with the specified dimensions.
Texture createTexture(const Size size,
- TextureFormat format = TextureFormat::RGBA,
+ gfx::TexturePixelType format = gfx::TexturePixelType::RGBA,
TextureUnit unit = 0,
- TextureType type = TextureType::UnsignedByte) {
+ gfx::TextureChannelDataType type = gfx::TextureChannelDataType::UnsignedByte) {
return { size, createTexture(size, nullptr, format, unit, type) };
}
void bindTexture(Texture&,
TextureUnit = 0,
- TextureFilter = TextureFilter::Nearest,
- TextureMipMap = TextureMipMap::No,
- TextureWrap wrapX = TextureWrap::Clamp,
- TextureWrap wrapY = TextureWrap::Clamp);
+ gfx::TextureFilterType = gfx::TextureFilterType::Nearest,
+ gfx::TextureMipMapType = gfx::TextureMipMapType::No,
+ gfx::TextureWrapType wrapX = gfx::TextureWrapType::Clamp,
+ gfx::TextureWrapType wrapY = gfx::TextureWrapType::Clamp);
void clear(optional<mbgl::Color> color,
optional<float> depth,
@@ -248,13 +248,13 @@ private:
std::unique_ptr<const gfx::IndexBufferResource> createIndexBufferResource(const void* data, std::size_t size, const gfx::BufferUsageType) override;
void updateIndexBufferResource(const gfx::IndexBufferResource&, const void* data, std::size_t size) override;
- UniqueTexture createTexture(Size size, const void* data, TextureFormat, TextureUnit, TextureType);
- void updateTexture(TextureID, Size size, const void* data, TextureFormat, TextureUnit, TextureType);
+ UniqueTexture createTexture(Size size, const void* data, gfx::TexturePixelType, TextureUnit, gfx::TextureChannelDataType);
+ void updateTexture(TextureID, Size size, const void* data, gfx::TexturePixelType, TextureUnit, gfx::TextureChannelDataType);
UniqueFramebuffer createFramebuffer();
UniqueRenderbuffer createRenderbuffer(RenderbufferType, Size size);
- std::unique_ptr<uint8_t[]> readFramebuffer(Size, TextureFormat, bool flip);
+ std::unique_ptr<uint8_t[]> readFramebuffer(Size, gfx::TexturePixelType, bool flip);
#if not MBGL_USE_GLES2
- void drawPixels(Size size, const void* data, TextureFormat);
+ void drawPixels(Size size, const void* data, gfx::TexturePixelType);
#endif // MBGL_USE_GLES2
bool supportsVertexArrays() const;
diff --git a/src/mbgl/gl/defines.hpp b/src/mbgl/gl/defines.hpp
index 41c4cb07d6..75325dfb75 100644
--- a/src/mbgl/gl/defines.hpp
+++ b/src/mbgl/gl/defines.hpp
@@ -39,6 +39,7 @@
#define GL_DEPTH_ATTACHMENT 0x8D00
#define GL_DEPTH_BUFFER_BIT 0x00000100
#define GL_DEPTH_CLEAR_VALUE 0x0B73
+#define GL_DEPTH_COMPONENT 0x1902
#define GL_DEPTH_COMPONENT16 0x81A5
#define GL_DEPTH_FUNC 0x0B74
#define GL_DEPTH_RANGE 0x0B70
@@ -97,6 +98,7 @@
#define GL_LINE_STRIP 0x0003
#define GL_LINE_WIDTH 0x0B21
#define GL_LINK_STATUS 0x8B82
+#define GL_LUMINANCE 0x1909
#define GL_MAX_VERTEX_ATTRIBS 0x8869
#define GL_NEAREST 0x2600
#define GL_NEAREST_MIPMAP_NEAREST 0x2700
@@ -133,6 +135,7 @@
#define GL_STENCIL_CLEAR_VALUE 0x0B91
#define GL_STENCIL_FAIL 0x0B94
#define GL_STENCIL_FUNC 0x0B92
+#define GL_STENCIL_INDEX 0x1901
#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
#define GL_STENCIL_REF 0x0B97
@@ -159,15 +162,16 @@
#define GL_VIEWPORT 0x0BA2
#define GL_ZERO 0
-#ifndef MBGL_USE_GLES2
+#ifdef MBGL_USE_GLES2
+#define GL_HALF_FLOAT 0x8D61
+#else
#define GL_CURRENT_RASTER_POSITION 0x0B07
#define GL_DEPTH24_STENCIL8 0x88F0
#define GL_DEPTH_BIAS 0x0D1F
-#define GL_DEPTH_COMPONENT 0x1902
#define GL_DEPTH_SCALE 0x0D1E
+#define GL_HALF_FLOAT 0x140B
#define GL_INDEX_OFFSET 0x0D13
#define GL_INDEX_SHIFT 0x0D12
-#define GL_LUMINANCE 0x1909
#define GL_POINT_SIZE 0x0B11
#define GL_RGBA8 0x8058
#define GL_ZOOM_X 0x0D16
diff --git a/src/mbgl/gl/enum.cpp b/src/mbgl/gl/enum.cpp
index 81561360e9..c1a51944de 100644
--- a/src/mbgl/gl/enum.cpp
+++ b/src/mbgl/gl/enum.cpp
@@ -241,5 +241,47 @@ platform::GLenum Enum<gfx::BufferUsageType>::to(const gfx::BufferUsageType value
return GL_INVALID_ENUM;
}
+template <>
+gfx::TexturePixelType Enum<gfx::TexturePixelType>::from(const platform::GLint value) {
+ switch (value) {
+ case GL_RGBA: return gfx::TexturePixelType::RGBA;
+ case GL_ALPHA: return gfx::TexturePixelType::Alpha;
+ case GL_STENCIL_INDEX: return gfx::TexturePixelType::Stencil;
+ case GL_DEPTH_COMPONENT: return gfx::TexturePixelType::Depth;
+ case GL_LUMINANCE: return gfx::TexturePixelType::Luminance;
+ }
+ return {};
+}
+
+template <>
+platform::GLenum Enum<gfx::TexturePixelType>::to(const gfx::TexturePixelType value) {
+ switch (value) {
+ case gfx::TexturePixelType::RGBA: return GL_RGBA;
+ case gfx::TexturePixelType::Alpha: return GL_ALPHA;
+ case gfx::TexturePixelType::Stencil: return GL_STENCIL_INDEX;
+ case gfx::TexturePixelType::Depth: return GL_DEPTH_COMPONENT;
+ case gfx::TexturePixelType::Luminance: return GL_LUMINANCE;
+ }
+ return GL_INVALID_ENUM;
+}
+
+template <>
+gfx::TextureChannelDataType Enum<gfx::TextureChannelDataType>::from(const platform::GLint value) {
+ switch (value) {
+ case GL_UNSIGNED_BYTE: return gfx::TextureChannelDataType::UnsignedByte;
+ case GL_HALF_FLOAT: return gfx::TextureChannelDataType::HalfFloat;
+ }
+ return {};
+}
+
+template <>
+platform::GLenum Enum<gfx::TextureChannelDataType>::to(const gfx::TextureChannelDataType value) {
+ switch (value) {
+ case gfx::TextureChannelDataType::UnsignedByte: return GL_UNSIGNED_BYTE;
+ case gfx::TextureChannelDataType::HalfFloat: return GL_HALF_FLOAT;
+ }
+ return GL_INVALID_ENUM;
+}
+
} // namespace gl
} // namespace mbgl
diff --git a/src/mbgl/gl/texture.hpp b/src/mbgl/gl/texture.hpp
index 625e69233a..1b85ac6ebc 100644
--- a/src/mbgl/gl/texture.hpp
+++ b/src/mbgl/gl/texture.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include <mbgl/gfx/types.hpp>
#include <mbgl/gl/object.hpp>
#include <mbgl/util/size.hpp>
@@ -9,10 +10,10 @@ namespace gl {
class Texture {
public:
Texture(Size size_, UniqueTexture texture_,
- TextureFilter filter_ = TextureFilter::Nearest,
- TextureMipMap mipmap_ = TextureMipMap::No,
- TextureWrap wrapX_ = TextureWrap::Clamp,
- TextureWrap wrapY_ = TextureWrap::Clamp)
+ gfx::TextureFilterType filter_ = gfx::TextureFilterType::Nearest,
+ gfx::TextureMipMapType mipmap_ = gfx::TextureMipMapType::No,
+ gfx::TextureWrapType wrapX_ = gfx::TextureWrapType::Clamp,
+ gfx::TextureWrapType wrapY_ = gfx::TextureWrapType::Clamp)
: size(std::move(size_)),
texture(std::move(texture_)),
filter(filter_),
@@ -22,10 +23,10 @@ public:
Size size;
UniqueTexture texture;
- TextureFilter filter;
- TextureMipMap mipmap;
- TextureWrap wrapX;
- TextureWrap wrapY;
+ gfx::TextureFilterType filter;
+ gfx::TextureMipMapType mipmap;
+ gfx::TextureWrapType wrapX;
+ gfx::TextureWrapType wrapY;
};
} // namespace gl
diff --git a/src/mbgl/gl/types.hpp b/src/mbgl/gl/types.hpp
index 310960b970..ab6b72656b 100644
--- a/src/mbgl/gl/types.hpp
+++ b/src/mbgl/gl/types.hpp
@@ -42,27 +42,6 @@ enum class RenderbufferType : uint32_t {
#endif // MBGL_USE_GLES2
};
-enum class TextureMipMap : bool { No = false, Yes = true };
-enum class TextureFilter : bool { Nearest = false, Linear = true };
-enum class TextureWrap : bool { Clamp, Repeat };
-enum class TextureFormat : uint32_t {
- RGBA = 0x1908,
- Alpha = 0x1906,
-#if not MBGL_USE_GLES2
- Stencil = 0x1901,
- Depth = 0x1902,
-#endif // MBGL_USE_GLES2
-};
-
-enum class TextureType : uint32_t {
- UnsignedByte = 0x1401,
-#if MBGL_USE_GLES2
- HalfFloat = 0x8D61,
-#else
- HalfFloat = 0x140B,
-#endif // MBGL_USE_GLES2
-};
-
struct PixelStorageType {
int32_t alignment;
};
diff --git a/src/mbgl/renderer/image_manager.cpp b/src/mbgl/renderer/image_manager.cpp
index fc1f5bb167..594d79b5cb 100644
--- a/src/mbgl/renderer/image_manager.cpp
+++ b/src/mbgl/renderer/image_manager.cpp
@@ -179,7 +179,7 @@ void ImageManager::upload(gl::Context& context, gl::TextureUnit unit) {
void ImageManager::bind(gl::Context& context, gl::TextureUnit unit) {
upload(context, unit);
- context.bindTexture(*atlasTexture, unit, gl::TextureFilter::Linear);
+ context.bindTexture(*atlasTexture, unit, gfx::TextureFilterType::Linear);
}
} // namespace mbgl
diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
index 3224397fb7..d6ce18e85a 100644
--- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
+++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
@@ -136,7 +136,7 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource*
GeometryTile& geometryTile = static_cast<GeometryTile&>(tile.tile);
optional<ImagePosition> patternPosA = geometryTile.getPattern(fillPatternValue.from);
optional<ImagePosition> patternPosB = geometryTile.getPattern(fillPatternValue.to);
- parameters.context.bindTexture(*geometryTile.iconAtlasTexture, 0, gl::TextureFilter::Linear);
+ parameters.context.bindTexture(*geometryTile.iconAtlasTexture, 0, gfx::TextureFilterType::Linear);
FillExtrusionBucket& bucket = *bucket_;
draw(
diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp
index 51019875e3..5498031c4c 100644
--- a/src/mbgl/renderer/layers/render_fill_layer.cpp
+++ b/src/mbgl/renderer/layers/render_fill_layer.cpp
@@ -148,7 +148,7 @@ void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) {
optional<ImagePosition> patternPosA = geometryTile.getPattern(fillPatternValue.from);
optional<ImagePosition> patternPosB = geometryTile.getPattern(fillPatternValue.to);
- parameters.context.bindTexture(*geometryTile.iconAtlasTexture, 0, gl::TextureFilter::Linear);
+ parameters.context.bindTexture(*geometryTile.iconAtlasTexture, 0, gfx::TextureFilterType::Linear);
auto bucket_ = tile.tile.getBucket<FillBucket>(*baseImpl);
if (!bucket_) {
continue;
diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.cpp b/src/mbgl/renderer/layers/render_heatmap_layer.cpp
index a3a9a67de5..66421874af 100644
--- a/src/mbgl/renderer/layers/render_heatmap_layer.cpp
+++ b/src/mbgl/renderer/layers/render_heatmap_layer.cpp
@@ -56,7 +56,7 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
if (!renderTexture || renderTexture->getSize() != size) {
if (parameters.context.supportsHalfFloatTextures) {
- renderTexture = OffscreenTexture(parameters.context, size, gl::TextureType::HalfFloat);
+ renderTexture = OffscreenTexture(parameters.context, size, gfx::TextureChannelDataType::HalfFloat);
try {
renderTexture->bind();
@@ -68,7 +68,7 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
}
if (!parameters.context.supportsHalfFloatTextures || !renderTexture) {
- renderTexture = OffscreenTexture(parameters.context, size, gl::TextureType::UnsignedByte);
+ renderTexture = OffscreenTexture(parameters.context, size, gfx::TextureChannelDataType::UnsignedByte);
renderTexture->bind();
}
@@ -77,7 +77,7 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
}
if (!colorRampTexture) {
- colorRampTexture = parameters.context.createTexture(colorRamp, 1, gl::TextureType::UnsignedByte);
+ colorRampTexture = parameters.context.createTexture(colorRamp, 1, gfx::TextureChannelDataType::UnsignedByte);
}
parameters.context.clear(Color{ 0.0f, 0.0f, 0.0f, 1.0f }, {}, {});
@@ -133,8 +133,8 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
}
} else if (parameters.pass == RenderPass::Translucent) {
- parameters.context.bindTexture(renderTexture->getTexture(), 0, gl::TextureFilter::Linear);
- parameters.context.bindTexture(*colorRampTexture, 1, gl::TextureFilter::Linear);
+ parameters.context.bindTexture(renderTexture->getTexture(), 0, gfx::TextureFilterType::Linear);
+ parameters.context.bindTexture(*colorRampTexture, 1, gfx::TextureFilterType::Linear);
const auto& size = parameters.staticData.backendSize;
diff --git a/src/mbgl/renderer/layers/render_hillshade_layer.cpp b/src/mbgl/renderer/layers/render_hillshade_layer.cpp
index b7b8beb2ef..438d6a345f 100644
--- a/src/mbgl/renderer/layers/render_hillshade_layer.cpp
+++ b/src/mbgl/renderer/layers/render_hillshade_layer.cpp
@@ -130,7 +130,7 @@ void RenderHillshadeLayer::render(PaintParameters& parameters, RenderSource* src
OffscreenTexture view(parameters.context, { tilesize, tilesize });
view.bind();
- parameters.context.bindTexture(*bucket.dem, 0, gl::TextureFilter::Nearest, gl::TextureMipMap::No, gl::TextureWrap::Clamp, gl::TextureWrap::Clamp);
+ parameters.context.bindTexture(*bucket.dem, 0, gfx::TextureFilterType::Nearest, gfx::TextureMipMapType::No, gfx::TextureWrapType::Clamp, gfx::TextureWrapType::Clamp);
const Properties<>::PossiblyEvaluated properties;
const HillshadePrepareProgram::Binders paintAttributeData{ properties, 0 };
@@ -173,7 +173,7 @@ void RenderHillshadeLayer::render(PaintParameters& parameters, RenderSource* src
bucket.setPrepared(true);
} else if (parameters.pass == RenderPass::Translucent) {
assert(bucket.texture);
- parameters.context.bindTexture(*bucket.texture, 0, gl::TextureFilter::Linear, gl::TextureMipMap::No, gl::TextureWrap::Clamp, gl::TextureWrap::Clamp);
+ parameters.context.bindTexture(*bucket.texture, 0, gfx::TextureFilterType::Linear, gfx::TextureMipMapType::No, gfx::TextureWrapType::Clamp, gfx::TextureWrapType::Clamp);
if (bucket.vertexBuffer && bucket.indexBuffer && !bucket.segments.empty()) {
// Draw only the parts of the tile that aren't drawn by another tile in the layer.
diff --git a/src/mbgl/renderer/layers/render_line_layer.cpp b/src/mbgl/renderer/layers/render_line_layer.cpp
index b0c441f5a1..b38bc490a6 100644
--- a/src/mbgl/renderer/layers/render_line_layer.cpp
+++ b/src/mbgl/renderer/layers/render_line_layer.cpp
@@ -124,7 +124,7 @@ void RenderLineLayer::render(PaintParameters& parameters, RenderSource*) {
const auto linePatternValue = evaluated.get<LinePattern>().constantOr(Faded<std::basic_string<char>>{ "", ""});
assert(dynamic_cast<GeometryTile*>(&tile.tile));
GeometryTile& geometryTile = static_cast<GeometryTile&>(tile.tile);
- parameters.context.bindTexture(*geometryTile.iconAtlasTexture, 0, gl::TextureFilter::Linear);
+ parameters.context.bindTexture(*geometryTile.iconAtlasTexture, 0, gfx::TextureFilterType::Linear);
const Size texsize = geometryTile.iconAtlasTexture->size;
optional<ImagePosition> posA = geometryTile.getPattern(linePatternValue.from);
@@ -145,7 +145,7 @@ void RenderLineLayer::render(PaintParameters& parameters, RenderSource*) {
if (!colorRampTexture) {
colorRampTexture = parameters.context.createTexture(colorRamp);
}
- parameters.context.bindTexture(*colorRampTexture, 0, gl::TextureFilter::Linear);
+ parameters.context.bindTexture(*colorRampTexture, 0, gfx::TextureFilterType::Linear);
draw(parameters.programs.getLineLayerPrograms().lineGradient,
LineGradientProgram::uniformValues(
diff --git a/src/mbgl/renderer/layers/render_raster_layer.cpp b/src/mbgl/renderer/layers/render_raster_layer.cpp
index 1912c84fc7..30b180173c 100644
--- a/src/mbgl/renderer/layers/render_raster_layer.cpp
+++ b/src/mbgl/renderer/layers/render_raster_layer.cpp
@@ -123,7 +123,7 @@ void RenderRasterLayer::render(PaintParameters& parameters, RenderSource* source
);
};
- const gl::TextureFilter filter = evaluated.get<RasterResampling>() == RasterResamplingType::Nearest ? gl::TextureFilter::Nearest : gl::TextureFilter::Linear;
+ const gfx::TextureFilterType filter = evaluated.get<RasterResampling>() == RasterResamplingType::Nearest ? gfx::TextureFilterType::Nearest : gfx::TextureFilterType::Linear;
if (RenderImageSource* imageSource = source->as<RenderImageSource>()) {
if (imageSource->isEnabled() && imageSource->isLoaded() && !imageSource->bucket->needsUpload()) {
diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp
index 19edb6afbd..11eeb376ce 100644
--- a/src/mbgl/renderer/layers/render_symbol_layer.cpp
+++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp
@@ -158,7 +158,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
parameters.context.bindTexture(*geometryTile.iconAtlasTexture, 0,
bucket.sdfIcons || parameters.state.isChanging() || iconScaled || iconTransformed
- ? gl::TextureFilter::Linear : gl::TextureFilter::Nearest);
+ ? gfx::TextureFilterType::Linear : gfx::TextureFilterType::Nearest);
const Size texsize = geometryTile.iconAtlasTexture->size;
@@ -194,7 +194,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
}
if (bucket.hasTextData()) {
- parameters.context.bindTexture(*geometryTile.glyphAtlasTexture, 0, gl::TextureFilter::Linear);
+ parameters.context.bindTexture(*geometryTile.glyphAtlasTexture, 0, gfx::TextureFilterType::Linear);
auto values = textPropertyValues(evaluated_, layout);
const auto& paintPropertyValues = textPaintProperties(evaluated_);
diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp
index aee7a243d4..8aa3690524 100644
--- a/src/mbgl/renderer/renderer_impl.cpp
+++ b/src/mbgl/renderer/renderer_impl.cpp
@@ -487,7 +487,7 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
// Read the stencil buffer
const auto viewport = parameters.context.viewport.getCurrentValue();
- auto image = parameters.context.readFramebuffer<AlphaImage, gl::TextureFormat::Stencil>(viewport.size, false);
+ auto image = parameters.context.readFramebuffer<AlphaImage, gfx::TexturePixelType::Stencil>(viewport.size, false);
// Scale the Stencil buffer to cover the entire color space.
auto it = image.data.get();
@@ -572,7 +572,7 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
// Read the stencil buffer
auto viewport = parameters.context.viewport.getCurrentValue();
- auto image = parameters.context.readFramebuffer<AlphaImage, gl::TextureFormat::Depth>(viewport.size, false);
+ auto image = parameters.context.readFramebuffer<AlphaImage, gfx::TexturePixelType::Depth>(viewport.size, false);
parameters.context.pixelZoom = { 1, 1 };
parameters.context.rasterPos = { -1, -1, 0, 1 };
diff --git a/src/mbgl/util/offscreen_texture.cpp b/src/mbgl/util/offscreen_texture.cpp
index 03f555eae0..bf42f98ceb 100644
--- a/src/mbgl/util/offscreen_texture.cpp
+++ b/src/mbgl/util/offscreen_texture.cpp
@@ -11,21 +11,21 @@ OffscreenTexture& OffscreenTexture::operator=(OffscreenTexture&&) = default;
class OffscreenTexture::Impl {
public:
- Impl(gl::Context& context_, const Size size_, const gl::TextureType type_)
+ Impl(gl::Context& context_, const Size size_, const gfx::TextureChannelDataType type_)
: context(context_), size(std::move(size_)), type(type_) {
assert(!size.isEmpty());
}
Impl(gl::Context& context_,
const Size size_,
gl::Renderbuffer<gl::RenderbufferType::DepthComponent>& depth_,
- const gl::TextureType type_)
+ const gfx::TextureChannelDataType type_)
: context(context_), size(std::move(size_)), depth(&depth_), type(type_) {
assert(!size.isEmpty());
}
void bind() {
if (!framebuffer) {
- texture = context.createTexture(size, gl::TextureFormat::RGBA, 0, type);
+ texture = context.createTexture(size, gfx::TexturePixelType::RGBA, 0, type);
if (depth) {
framebuffer = context.createFramebuffer(*texture, *depth);
} else {
@@ -59,12 +59,12 @@ private:
optional<gl::Framebuffer> framebuffer;
optional<gl::Texture> texture;
gl::Renderbuffer<gl::RenderbufferType::DepthComponent>* depth = nullptr;
- const gl::TextureType type;
+ const gfx::TextureChannelDataType type;
};
OffscreenTexture::OffscreenTexture(gl::Context& context,
const Size size,
- const gl::TextureType type)
+ const gfx::TextureChannelDataType type)
: impl(std::make_unique<Impl>(context, std::move(size), type)) {
assert(!size.isEmpty());
}
@@ -72,7 +72,7 @@ OffscreenTexture::OffscreenTexture(gl::Context& context,
OffscreenTexture::OffscreenTexture(gl::Context& context,
const Size size,
gl::Renderbuffer<gl::RenderbufferType::DepthComponent>& renderbuffer,
- const gl::TextureType type)
+ const gfx::TextureChannelDataType type)
: impl(std::make_unique<Impl>(context, std::move(size), renderbuffer, type)) {
assert(!size.isEmpty());
}
diff --git a/src/mbgl/util/offscreen_texture.hpp b/src/mbgl/util/offscreen_texture.hpp
index c2aca9bacd..5dc1ad0c56 100644
--- a/src/mbgl/util/offscreen_texture.hpp
+++ b/src/mbgl/util/offscreen_texture.hpp
@@ -15,11 +15,11 @@ class OffscreenTexture {
public:
OffscreenTexture(gl::Context&,
Size size = { 256, 256 },
- gl::TextureType type = gl::TextureType::UnsignedByte);
+ gfx::TextureChannelDataType type = gfx::TextureChannelDataType::UnsignedByte);
OffscreenTexture(gl::Context&,
Size size,
gl::Renderbuffer<gl::RenderbufferType::DepthComponent>&,
- gl::TextureType type = gl::TextureType::UnsignedByte);
+ gfx::TextureChannelDataType type = gfx::TextureChannelDataType::UnsignedByte);
~OffscreenTexture();
OffscreenTexture(OffscreenTexture&&);
OffscreenTexture& operator=(OffscreenTexture&&);