From a7f151ab487d656340d4ace415abacf9e8cecbf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Wed, 6 Mar 2019 18:26:32 +0100 Subject: [core] move Texture to the gfx namespace --- src/core-files.json | 3 +- src/mbgl/geometry/line_atlas.cpp | 4 +- src/mbgl/geometry/line_atlas.hpp | 8 +-- src/mbgl/gfx/context.hpp | 43 ++++++++++++++ src/mbgl/gfx/texture.hpp | 33 +++++++++++ src/mbgl/gl/context.cpp | 69 +++++++++++++---------- src/mbgl/gl/context.hpp | 55 +++++------------- src/mbgl/gl/texture.hpp | 33 ----------- src/mbgl/gl/texture_resource.hpp | 18 ++++++ src/mbgl/gl/types.hpp | 2 - src/mbgl/gl/value.hpp | 2 +- src/mbgl/renderer/buckets/hillshade_bucket.hpp | 6 +- src/mbgl/renderer/buckets/raster_bucket.hpp | 4 +- src/mbgl/renderer/image_manager.cpp | 4 +- src/mbgl/renderer/image_manager.hpp | 8 +-- src/mbgl/renderer/layers/render_heatmap_layer.hpp | 4 +- src/mbgl/renderer/layers/render_line_layer.hpp | 4 +- src/mbgl/tile/geometry_tile.hpp | 4 +- src/mbgl/util/offscreen_texture.cpp | 6 +- src/mbgl/util/offscreen_texture.hpp | 7 ++- test/gl/object.test.cpp | 2 +- 21 files changed, 182 insertions(+), 137 deletions(-) create mode 100644 src/mbgl/gfx/texture.hpp delete mode 100644 src/mbgl/gl/texture.hpp create mode 100644 src/mbgl/gl/texture_resource.hpp diff --git a/src/core-files.json b/src/core-files.json index 4521457bb1..40a7aab20d 100644 --- a/src/core-files.json +++ b/src/core-files.json @@ -508,6 +508,7 @@ "mbgl/gfx/index_vector.hpp": "src/mbgl/gfx/index_vector.hpp", "mbgl/gfx/primitives.hpp": "src/mbgl/gfx/primitives.hpp", "mbgl/gfx/stencil_mode.hpp": "src/mbgl/gfx/stencil_mode.hpp", + "mbgl/gfx/texture.hpp": "src/mbgl/gfx/texture.hpp", "mbgl/gfx/types.hpp": "src/mbgl/gfx/types.hpp", "mbgl/gfx/uniform.hpp": "src/mbgl/gfx/uniform.hpp", "mbgl/gfx/vertex_buffer.hpp": "src/mbgl/gfx/vertex_buffer.hpp", @@ -527,7 +528,7 @@ "mbgl/gl/program_binary_extension.hpp": "src/mbgl/gl/program_binary_extension.hpp", "mbgl/gl/renderbuffer.hpp": "src/mbgl/gl/renderbuffer.hpp", "mbgl/gl/state.hpp": "src/mbgl/gl/state.hpp", - "mbgl/gl/texture.hpp": "src/mbgl/gl/texture.hpp", + "mbgl/gl/texture_resource.hpp": "src/mbgl/gl/texture_resource.hpp", "mbgl/gl/types.hpp": "src/mbgl/gl/types.hpp", "mbgl/gl/uniform.hpp": "src/mbgl/gl/uniform.hpp", "mbgl/gl/value.hpp": "src/mbgl/gl/value.hpp", diff --git a/src/mbgl/geometry/line_atlas.cpp b/src/mbgl/geometry/line_atlas.cpp index e0114befcb..0e82b4ffc7 100644 --- a/src/mbgl/geometry/line_atlas.cpp +++ b/src/mbgl/geometry/line_atlas.cpp @@ -126,7 +126,7 @@ Size LineAtlas::getSize() const { return image.size; } -void LineAtlas::upload(gl::Context& context, gl::TextureUnit unit) { +void LineAtlas::upload(gl::Context& context, uint8_t unit) { if (!texture) { texture = context.createTexture(image, unit); } else if (dirty) { @@ -136,7 +136,7 @@ void LineAtlas::upload(gl::Context& context, gl::TextureUnit unit) { dirty = false; } -void LineAtlas::bind(gl::Context& context, gl::TextureUnit unit) { +void LineAtlas::bind(gl::Context& context, uint8_t unit) { upload(context, unit); context.bindTexture(*texture, unit, gfx::TextureFilterType::Linear, gfx::TextureMipMapType::No, gfx::TextureWrapType::Repeat, gfx::TextureWrapType::Clamp); diff --git a/src/mbgl/geometry/line_atlas.hpp b/src/mbgl/geometry/line_atlas.hpp index b1e7a670c1..f262232872 100644 --- a/src/mbgl/geometry/line_atlas.hpp +++ b/src/mbgl/geometry/line_atlas.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include @@ -33,11 +33,11 @@ public: ~LineAtlas(); // Binds the atlas texture to the GPU, and uploads data if it is out of date. - void bind(gl::Context&, gl::TextureUnit unit); + void bind(gl::Context&, uint8_t unit); // Uploads the texture to the GPU to be available when we need it. This is a lazy operation; // the texture is only bound when the data is out of date (=dirty). - void upload(gl::Context&, gl::TextureUnit unit); + void upload(gl::Context&, uint8_t unit); LinePatternPos getDashPosition(const std::vector&, LinePatternCap); LinePatternPos addDash(const std::vector& dasharray, LinePatternCap); @@ -47,7 +47,7 @@ public: private: const AlphaImage image; bool dirty; - mbgl::optional texture; + mbgl::optional texture; uint32_t nextRow = 0; std::unordered_map positions; }; diff --git a/src/mbgl/gfx/context.hpp b/src/mbgl/gfx/context.hpp index b57cfcb65c..05a87eeeac 100644 --- a/src/mbgl/gfx/context.hpp +++ b/src/mbgl/gfx/context.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include namespace mbgl { @@ -56,6 +57,48 @@ protected: createIndexBufferResource(const void* data, std::size_t size, const BufferUsageType) = 0; virtual void updateIndexBufferResource(const IndexBufferResource&, const void* data, std::size_t size) = 0; + +public: + // Create a texture from an image with data. + template + Texture createTexture(const Image& image, + uint8_t unit = 0, + TextureChannelDataType type = TextureChannelDataType::UnsignedByte) { + auto format = image.channels == 4 ? TexturePixelType::RGBA : TexturePixelType::Alpha; + return { image.size, + createTextureResource(image.size, image.data.get(), format, unit, type) }; + } + + // Creates an empty texture with the specified dimensions. + Texture createTexture(const Size size, + TexturePixelType format = TexturePixelType::RGBA, + uint8_t unit = 0, + TextureChannelDataType type = TextureChannelDataType::UnsignedByte) { + return { size, createTextureResource(size, nullptr, format, unit, type) }; + } + + template + void updateTexture(Texture& texture, + const Image& image, + uint8_t unit = 0, + TextureChannelDataType type = TextureChannelDataType::UnsignedByte) { + auto format = image.channels == 4 ? TexturePixelType::RGBA : TexturePixelType::Alpha; + updateTextureResource(*texture.resource, image.size, image.data.get(), format, unit, type); + texture.size = image.size; + } + + virtual void bindTexture(Texture&, + uint8_t unit = 0, + TextureFilterType = TextureFilterType::Nearest, + TextureMipMapType = TextureMipMapType::No, + TextureWrapType wrapX = TextureWrapType::Clamp, + TextureWrapType wrapY = TextureWrapType::Clamp) = 0; + +protected: + virtual std::unique_ptr createTextureResource( + Size, const void* data, TexturePixelType, uint8_t unit, TextureChannelDataType) = 0; + virtual void updateTextureResource(const TextureResource&, Size, const void* data, + TexturePixelType, uint8_t unit, TextureChannelDataType) = 0; }; } // namespace gfx diff --git a/src/mbgl/gfx/texture.hpp b/src/mbgl/gfx/texture.hpp new file mode 100644 index 0000000000..ca5ab5d5d5 --- /dev/null +++ b/src/mbgl/gfx/texture.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include +#include + +#include + +namespace mbgl { +namespace gfx { + +class TextureResource { +protected: + TextureResource() = default; +public: + virtual ~TextureResource() = default; +}; + +class Texture { +public: + Texture(Size size_, std::unique_ptr&& resource_) + : size(std::move(size_)), resource(std::move(resource_)) { + } + + Size size; + TextureFilterType filter = TextureFilterType::Nearest; + TextureMipMapType mipmap = TextureMipMapType::No; + TextureWrapType wrapX = TextureWrapType::Clamp; + TextureWrapType wrapY = TextureWrapType::Clamp; + std::unique_ptr resource; +}; + +} // namespace gfx +} // namespace mbgl diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index c8236e0b0a..2758e236e4 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -266,7 +267,7 @@ void Context::updateIndexBufferResource(const gfx::IndexBufferResource& resource } -UniqueTexture Context::createTexture() { +UniqueTexture Context::createUniqueTexture() { if (pooledTextures.empty()) { pooledTextures.resize(TextureMax); MBGL_CHECK_ERROR(glGenTextures(TextureMax, pooledTextures.data())); @@ -468,83 +469,91 @@ Framebuffer Context::createFramebuffer(const Renderbuffer& depthStencil) { if (color.size != depthStencil.size) { throw std::runtime_error("Renderbuffer size mismatch"); } auto fbo = createFramebuffer(); bindFramebuffer = fbo; - MBGL_CHECK_ERROR(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, - color.texture, 0)); + MBGL_CHECK_ERROR(glFramebufferTexture2D( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + reinterpret_cast(*color.resource).texture, 0)); bindDepthStencilRenderbuffer(depthStencil); checkFramebuffer(); return { color.size, std::move(fbo) }; } -Framebuffer Context::createFramebuffer(const Texture& color) { +Framebuffer Context::createFramebuffer(const gfx::Texture& color) { auto fbo = createFramebuffer(); bindFramebuffer = fbo; - MBGL_CHECK_ERROR(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, - color.texture, 0)); + MBGL_CHECK_ERROR(glFramebufferTexture2D( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + reinterpret_cast(*color.resource).texture, 0)); checkFramebuffer(); return { color.size, std::move(fbo) }; } Framebuffer -Context::createFramebuffer(const Texture& color, +Context::createFramebuffer(const gfx::Texture& color, const Renderbuffer& depthTarget) { if (color.size != depthTarget.size) { throw std::runtime_error("Renderbuffer size mismatch"); } auto fbo = createFramebuffer(); bindFramebuffer = fbo; - MBGL_CHECK_ERROR(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color.texture, 0)); - MBGL_CHECK_ERROR(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthTarget.renderbuffer)); + MBGL_CHECK_ERROR(glFramebufferTexture2D( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + reinterpret_cast(*color.resource).texture, 0)); + MBGL_CHECK_ERROR(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, + depthTarget.renderbuffer)); checkFramebuffer(); return { depthTarget.size, std::move(fbo) }; } -UniqueTexture Context::createTexture(const Size size, - const void* data, - gfx::TexturePixelType format, - TextureUnit unit, - gfx::TextureChannelDataType type) { - auto obj = createTexture(); +std::unique_ptr +Context::createTextureResource(const Size size, + const void* data, + gfx::TexturePixelType format, + uint8_t unit, + gfx::TextureChannelDataType type) { + auto obj = createUniqueTexture(); + std::unique_ptr resource = std::make_unique(std::move(obj)); pixelStoreUnpack = { 1 }; - updateTexture(obj, size, data, format, unit, type); + updateTextureResource(*resource, size, data, format, unit, type); // We are using clamp to edge here since OpenGL ES doesn't allow GL_REPEAT on NPOT textures. // We use those when the pixelRatio isn't a power of two, e.g. on iPhone 6 Plus. MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); 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)); - return obj; + return resource; } -void Context::updateTexture(TextureID id, - const Size size, - const void* data, - gfx::TexturePixelType format, - TextureUnit unit, - gfx::TextureChannelDataType type) { +void Context::updateTextureResource(const gfx::TextureResource& resource, + const Size size, + const void* data, + gfx::TexturePixelType format, + uint8_t unit, + gfx::TextureChannelDataType type) { activeTextureUnit = unit; - texture[unit] = id; + texture[unit] = reinterpret_cast(resource).texture; MBGL_CHECK_ERROR(glTexImage2D(GL_TEXTURE_2D, 0, Enum::to(format), size.width, size.height, 0, Enum::to(format), Enum::to(type), data)); } -void Context::bindTexture(Texture& obj, - TextureUnit unit, +void Context::bindTexture(gfx::Texture& obj, + uint8_t unit, gfx::TextureFilterType filter, gfx::TextureMipMapType mipmap, gfx::TextureWrapType wrapX, gfx::TextureWrapType wrapY) { + TextureID id = reinterpret_cast(*obj.resource).texture; if (filter != obj.filter || mipmap != obj.mipmap || wrapX != obj.wrapX || wrapY != obj.wrapY) { activeTextureUnit = unit; - texture[unit] = obj.texture; + texture[unit] = id; if (filter != obj.filter || mipmap != obj.mipmap) { MBGL_CHECK_ERROR(glTexParameteri( @@ -571,11 +580,11 @@ void Context::bindTexture(Texture& obj, wrapY == gfx::TextureWrapType::Clamp ? GL_CLAMP_TO_EDGE : GL_REPEAT)); obj.wrapY = wrapY; } - } else if (texture[unit] != obj.texture) { + } else if (texture[unit] != id) { // We are checking first to avoid setting the active texture without a subsequent // texture bind. activeTextureUnit = unit; - texture[unit] = obj.texture; + texture[unit] = id; } } diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp index 8b7b9346b3..1200e3b49a 100644 --- a/src/mbgl/gl/context.hpp +++ b/src/mbgl/gl/context.hpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -52,7 +51,7 @@ public: UniqueProgram createProgram(BinaryProgramFormat binaryFormat, const std::string& binaryProgram); void verifyProgramLinkage(ProgramID); void linkProgram(ProgramID); - UniqueTexture createTexture(); + UniqueTexture createUniqueTexture(); VertexArray createVertexArray(); #if MBGL_HAS_BINARY_PROGRAMS @@ -74,10 +73,10 @@ public: Framebuffer createFramebuffer(const Renderbuffer&, const Renderbuffer&); Framebuffer createFramebuffer(const Renderbuffer&); - Framebuffer createFramebuffer(const Texture&, + Framebuffer createFramebuffer(const gfx::Texture&, const Renderbuffer&); - Framebuffer createFramebuffer(const Texture&); - Framebuffer createFramebuffer(const Texture&, + Framebuffer createFramebuffer(const gfx::Texture&); + Framebuffer createFramebuffer(const gfx::Texture&, const Renderbuffer&); template void drawPixels(const Image& image) { @@ -97,40 +103,6 @@ public: } #endif // MBGL_USE_GLES2 - // Create a texture from an image with data. - template - Texture createTexture(const Image& image, - TextureUnit unit = 0, - 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) }; - } - - template - void updateTexture(Texture& obj, - const Image& image, - TextureUnit unit = 0, - 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, - gfx::TexturePixelType format = gfx::TexturePixelType::RGBA, - TextureUnit unit = 0, - gfx::TextureChannelDataType type = gfx::TextureChannelDataType::UnsignedByte) { - return { size, createTexture(size, nullptr, format, unit, type) }; - } - - void bindTexture(Texture&, - TextureUnit = 0, - 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 color, optional depth, optional stencil); @@ -248,8 +220,9 @@ private: std::unique_ptr 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, gfx::TexturePixelType, TextureUnit, gfx::TextureChannelDataType); - void updateTexture(TextureID, Size size, const void* data, gfx::TexturePixelType, TextureUnit, gfx::TextureChannelDataType); + std::unique_ptr createTextureResource(Size, const void* data, gfx::TexturePixelType, uint8_t, gfx::TextureChannelDataType) override; + void updateTextureResource(const gfx::TextureResource&, Size, const void* data, gfx::TexturePixelType, uint8_t, gfx::TextureChannelDataType) override; + UniqueFramebuffer createFramebuffer(); UniqueRenderbuffer createRenderbuffer(RenderbufferType, Size size); std::unique_ptr readFramebuffer(Size, gfx::TexturePixelType, bool flip); diff --git a/src/mbgl/gl/texture.hpp b/src/mbgl/gl/texture.hpp deleted file mode 100644 index 1b85ac6ebc..0000000000 --- a/src/mbgl/gl/texture.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace mbgl { -namespace gl { - -class Texture { -public: - Texture(Size size_, UniqueTexture texture_, - 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_), - mipmap(mipmap_), - wrapX(wrapX_), - wrapY(wrapY_) {} - - Size size; - UniqueTexture texture; - gfx::TextureFilterType filter; - gfx::TextureMipMapType mipmap; - gfx::TextureWrapType wrapX; - gfx::TextureWrapType wrapY; -}; - -} // namespace gl -} // namespace mbgl diff --git a/src/mbgl/gl/texture_resource.hpp b/src/mbgl/gl/texture_resource.hpp new file mode 100644 index 0000000000..4803f9b7f4 --- /dev/null +++ b/src/mbgl/gl/texture_resource.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include +#include + +namespace mbgl { +namespace gl { + +class TextureResource : public gfx::TextureResource { +public: + TextureResource(UniqueTexture&& texture_) : texture(std::move(texture_)) { + } + + UniqueTexture texture; +}; + +} // namespace gl +} // namespace mbgl diff --git a/src/mbgl/gl/types.hpp b/src/mbgl/gl/types.hpp index ab6b72656b..5cb486f0c9 100644 --- a/src/mbgl/gl/types.hpp +++ b/src/mbgl/gl/types.hpp @@ -25,8 +25,6 @@ using AttributeLocation = uint32_t; // "silently ignored". using UniformLocation = int32_t; -using TextureUnit = uint8_t; - enum class ShaderType : uint32_t { Vertex = 0x8B31, Fragment = 0x8B30 diff --git a/src/mbgl/gl/value.hpp b/src/mbgl/gl/value.hpp index 9c01039b99..15812a49bd 100644 --- a/src/mbgl/gl/value.hpp +++ b/src/mbgl/gl/value.hpp @@ -168,7 +168,7 @@ struct LineWidth { }; struct ActiveTextureUnit { - using Type = TextureUnit; + using Type = uint8_t; static const constexpr Type Default = 0; static void Set(const Type&); static Type Get(); diff --git a/src/mbgl/renderer/buckets/hillshade_bucket.hpp b/src/mbgl/renderer/buckets/hillshade_bucket.hpp index 50b05aaeef..906eac7e58 100644 --- a/src/mbgl/renderer/buckets/hillshade_bucket.hpp +++ b/src/mbgl/renderer/buckets/hillshade_bucket.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include #include @@ -29,8 +29,8 @@ public: void clear(); void setMask(TileMask&&); - optional dem; - optional texture; + optional dem; + optional texture; TileMask mask{ { 0, 0, 0 } }; diff --git a/src/mbgl/renderer/buckets/raster_bucket.hpp b/src/mbgl/renderer/buckets/raster_bucket.hpp index ea48a0c235..4c4ca50320 100644 --- a/src/mbgl/renderer/buckets/raster_bucket.hpp +++ b/src/mbgl/renderer/buckets/raster_bucket.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include #include @@ -27,7 +27,7 @@ public: void setMask(TileMask&&); std::shared_ptr image; - optional texture; + optional texture; TileMask mask{ { 0, 0, 0 } }; // Bucket specific vertices are used for Image Sources only diff --git a/src/mbgl/renderer/image_manager.cpp b/src/mbgl/renderer/image_manager.cpp index 594d79b5cb..4d0f010e49 100644 --- a/src/mbgl/renderer/image_manager.cpp +++ b/src/mbgl/renderer/image_manager.cpp @@ -167,7 +167,7 @@ Size ImageManager::getPixelSize() const { }; } -void ImageManager::upload(gl::Context& context, gl::TextureUnit unit) { +void ImageManager::upload(gl::Context& context, uint8_t unit) { if (!atlasTexture) { atlasTexture = context.createTexture(atlasImage, unit); } else if (dirty) { @@ -177,7 +177,7 @@ void ImageManager::upload(gl::Context& context, gl::TextureUnit unit) { dirty = false; } -void ImageManager::bind(gl::Context& context, gl::TextureUnit unit) { +void ImageManager::bind(gl::Context& context, uint8_t unit) { upload(context, unit); context.bindTexture(*atlasTexture, unit, gfx::TextureFilterType::Linear); } diff --git a/src/mbgl/renderer/image_manager.hpp b/src/mbgl/renderer/image_manager.hpp index 103491c58b..e4b251e92b 100644 --- a/src/mbgl/renderer/image_manager.hpp +++ b/src/mbgl/renderer/image_manager.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include @@ -65,8 +65,8 @@ private: public: optional getPattern(const std::string& name); - void bind(gl::Context&, gl::TextureUnit unit); - void upload(gl::Context&, gl::TextureUnit unit); + void bind(gl::Context&, uint8_t unit); + void upload(gl::Context&, uint8_t unit); Size getPixelSize() const; @@ -84,7 +84,7 @@ private: mapbox::ShelfPack shelfPack; std::unordered_map patterns; PremultipliedImage atlasImage; - mbgl::optional atlasTexture; + mbgl::optional atlasTexture; bool dirty = true; }; diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.hpp b/src/mbgl/renderer/layers/render_heatmap_layer.hpp index d63c30dcca..364628a2b2 100644 --- a/src/mbgl/renderer/layers/render_heatmap_layer.hpp +++ b/src/mbgl/renderer/layers/render_heatmap_layer.hpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -37,7 +37,7 @@ public: PremultipliedImage colorRamp; optional renderTexture; - optional colorRampTexture; + optional colorRampTexture; private: void updateColorRamp(); diff --git a/src/mbgl/renderer/layers/render_line_layer.hpp b/src/mbgl/renderer/layers/render_line_layer.hpp index af2a5a26e2..186b740234 100644 --- a/src/mbgl/renderer/layers/render_line_layer.hpp +++ b/src/mbgl/renderer/layers/render_line_layer.hpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include namespace mbgl { @@ -53,7 +53,7 @@ private: void updateColorRamp(); CrossfadeParameters crossfade; PremultipliedImage colorRamp; - optional colorRampTexture; + optional colorRampTexture; }; inline const RenderLineLayer* toRenderLineLayer(const RenderLayer* layer) { diff --git a/src/mbgl/tile/geometry_tile.hpp b/src/mbgl/tile/geometry_tile.hpp index c5c7cb6623..3f6f07e26e 100644 --- a/src/mbgl/tile/geometry_tile.hpp +++ b/src/mbgl/tile/geometry_tile.hpp @@ -132,8 +132,8 @@ private: FadeState fadeState = FadeState::Loaded; public: - optional glyphAtlasTexture; - optional iconAtlasTexture; + optional glyphAtlasTexture; + optional iconAtlasTexture; }; } // namespace mbgl diff --git a/src/mbgl/util/offscreen_texture.cpp b/src/mbgl/util/offscreen_texture.cpp index bf42f98ceb..6897732dc4 100644 --- a/src/mbgl/util/offscreen_texture.cpp +++ b/src/mbgl/util/offscreen_texture.cpp @@ -44,7 +44,7 @@ public: return context.readFramebuffer(size); } - gl::Texture& getTexture() { + gfx::Texture& getTexture() { assert(texture); return *texture; } @@ -57,7 +57,7 @@ private: gl::Context& context; const Size size; optional framebuffer; - optional texture; + optional texture; gl::Renderbuffer* depth = nullptr; const gfx::TextureChannelDataType type; }; @@ -87,7 +87,7 @@ PremultipliedImage OffscreenTexture::readStillImage() { return impl->readStillImage(); } -gl::Texture& OffscreenTexture::getTexture() { +gfx::Texture& OffscreenTexture::getTexture() { return impl->getTexture(); } diff --git a/src/mbgl/util/offscreen_texture.hpp b/src/mbgl/util/offscreen_texture.hpp index 5dc1ad0c56..9446fabecf 100644 --- a/src/mbgl/util/offscreen_texture.hpp +++ b/src/mbgl/util/offscreen_texture.hpp @@ -8,9 +8,12 @@ namespace mbgl { namespace gl { class Context; -class Texture; } // namespace gl +namespace gfx { +class Texture; +} // namespace gfx + class OffscreenTexture { public: OffscreenTexture(gl::Context&, @@ -28,7 +31,7 @@ public: PremultipliedImage readStillImage(); - gl::Texture& getTexture(); + gfx::Texture& getTexture(); const Size& getSize() const; diff --git a/test/gl/object.test.cpp b/test/gl/object.test.cpp index 8046927c54..a29b2ff958 100644 --- a/test/gl/object.test.cpp +++ b/test/gl/object.test.cpp @@ -51,7 +51,7 @@ TEST(GLObject, Store) { gl::Context context; EXPECT_TRUE(context.empty()); - gl::UniqueTexture texture = context.createTexture(); + gl::UniqueTexture texture = context.createUniqueTexture(); EXPECT_NE(texture.get(), 0u); texture.reset(); EXPECT_FALSE(context.empty()); -- cgit v1.2.1