summaryrefslogtreecommitdiff
path: root/src/mbgl/gfx/context.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/gfx/context.hpp')
-rw-r--r--src/mbgl/gfx/context.hpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mbgl/gfx/context.hpp b/src/mbgl/gfx/context.hpp
index ff84cf34e8..e898006ff5 100644
--- a/src/mbgl/gfx/context.hpp
+++ b/src/mbgl/gfx/context.hpp
@@ -100,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() {