diff options
Diffstat (limited to 'src/mbgl/gfx')
-rw-r--r-- | src/mbgl/gfx/attribute.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/gfx/context.hpp | 24 |
2 files changed, 24 insertions, 2 deletions
diff --git a/src/mbgl/gfx/attribute.hpp b/src/mbgl/gfx/attribute.hpp index 4f44d68d7b..f5188ccfdb 100644 --- a/src/mbgl/gfx/attribute.hpp +++ b/src/mbgl/gfx/attribute.hpp @@ -14,7 +14,7 @@ #define MBGL_DEFINE_ATTRIBUTE(type_, n_, name_) \ struct name_ { \ using Type = ::mbgl::gfx::AttributeType<type_, n_>; \ - static auto name() { \ + static constexpr auto name() { \ return #name_; \ } \ } diff --git a/src/mbgl/gfx/context.hpp b/src/mbgl/gfx/context.hpp index 90b62c94a4..e898006ff5 100644 --- a/src/mbgl/gfx/context.hpp +++ b/src/mbgl/gfx/context.hpp @@ -17,10 +17,14 @@ namespace gfx { class Context { protected: - Context(ContextType type_) : backend(type_) { + Context(ContextType type_, uint32_t maximumVertexBindingCount_) + : backend(type_), maximumVertexBindingCount(maximumVertexBindingCount_) { } +public: const ContextType backend; + static constexpr const uint32_t minimumRequiredVertexBindingCount = 8; + const uint32_t maximumVertexBindingCount; public: Context(Context&&) = delete; @@ -30,6 +34,10 @@ public: virtual ~Context() = default; public: + // Called at the end of a frame. + virtual void performCleanup() = 0; + +public: template <class Vertex> VertexBuffer<Vertex> createVertexBuffer(VertexVector<Vertex>&& v, @@ -92,11 +100,25 @@ public: texture.size = image.size; } + template <typename Image> + void updateTextureSub(Texture& texture, + const Image& image, + const uint16_t offsetX, + const uint16_t offsetY, + TextureChannelDataType type = TextureChannelDataType::UnsignedByte) { + assert(image.size.width + offsetX <= texture.size.width); + assert(image.size.height + offsetY <= texture.size.height); + auto format = image.channels == 4 ? TexturePixelType::RGBA : TexturePixelType::Alpha; + updateTextureResourceSub(*texture.resource, offsetX, offsetY, image.size, image.data.get(), format, type); + } + protected: virtual std::unique_ptr<TextureResource> createTextureResource( Size, const void* data, TexturePixelType, TextureChannelDataType) = 0; virtual void updateTextureResource(const TextureResource&, Size, const void* data, TexturePixelType, TextureChannelDataType) = 0; + virtual void updateTextureResourceSub(const TextureResource&, uint16_t xOffset, uint16_t yOffset, Size, const void* data, + TexturePixelType, TextureChannelDataType) = 0; public: DrawScope createDrawScope() { |