diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-03-07 17:50:02 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-03-12 11:03:54 +0100 |
commit | e27f33062994a1b0155b44b9d471e48e93b09f8e (patch) | |
tree | eff2ba71134b9721c16fd53378b9256b94396712 /src/mbgl/gfx | |
parent | cb64c380fbbd209cb68af60e76b7a770805353a8 (diff) | |
download | qtlocation-mapboxgl-e27f33062994a1b0155b44b9d471e48e93b09f8e.tar.gz |
[core] add texture bindings to draw call instead of Context member fn
Diffstat (limited to 'src/mbgl/gfx')
-rw-r--r-- | src/mbgl/gfx/context.hpp | 22 | ||||
-rw-r--r-- | src/mbgl/gfx/texture.hpp | 20 |
2 files changed, 18 insertions, 24 deletions
diff --git a/src/mbgl/gfx/context.hpp b/src/mbgl/gfx/context.hpp index 05a87eeeac..5ec73b8a41 100644 --- a/src/mbgl/gfx/context.hpp +++ b/src/mbgl/gfx/context.hpp @@ -62,43 +62,33 @@ public: // Create a texture from an image with data. template <typename Image> 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) }; + createTextureResource(image.size, image.data.get(), format, 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) }; + return { size, createTextureResource(size, nullptr, format, type) }; } template <typename Image> 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); + updateTextureResource(*texture.resource, image.size, image.data.get(), format, 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<const TextureResource> createTextureResource( - Size, const void* data, TexturePixelType, uint8_t unit, TextureChannelDataType) = 0; + virtual std::unique_ptr<TextureResource> createTextureResource( + Size, const void* data, TexturePixelType, TextureChannelDataType) = 0; virtual void updateTextureResource(const TextureResource&, Size, const void* data, - TexturePixelType, uint8_t unit, TextureChannelDataType) = 0; + TexturePixelType, TextureChannelDataType) = 0; }; } // namespace gfx diff --git a/src/mbgl/gfx/texture.hpp b/src/mbgl/gfx/texture.hpp index bbda44a8fb..758bdd1b09 100644 --- a/src/mbgl/gfx/texture.hpp +++ b/src/mbgl/gfx/texture.hpp @@ -7,6 +7,14 @@ #include <memory> +#define MBGL_DEFINE_TEXTURE(name_) \ + struct name_ { \ + using Value = ::mbgl::gfx::TextureBinding; \ + static constexpr auto name() { \ + return #name_; \ + } \ + } + namespace mbgl { namespace gfx { @@ -19,21 +27,17 @@ public: class Texture { public: - Texture(Size size_, std::unique_ptr<const TextureResource>&& resource_) + Texture(Size size_, std::unique_ptr<TextureResource>&& 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<const TextureResource> resource; + std::unique_ptr<TextureResource> resource; }; class TextureBinding { public: - TextureBinding(const TextureResource& resource_, + TextureBinding(TextureResource& resource_, TextureFilterType filter_ = TextureFilterType::Nearest, TextureMipMapType mipmap_ = TextureMipMapType::No, TextureWrapType wrapX_ = TextureWrapType::Clamp, @@ -41,7 +45,7 @@ public: : resource(&resource_), filter(filter_), mipmap(mipmap_), wrapX(wrapX_), wrapY(wrapY_) { } - const TextureResource* resource; + TextureResource* resource; TextureFilterType filter; TextureMipMapType mipmap; TextureWrapType wrapX; |