summaryrefslogtreecommitdiff
path: root/src/mbgl/gl
diff options
context:
space:
mode:
authorAnsis Brammanis <ansis.brammanis@gmail.com>2019-04-02 12:57:45 -0400
committerGitHub <noreply@github.com>2019-04-02 12:57:45 -0400
commit2455275bf47e1671a92eb2c1296c6b48f11f6b2e (patch)
treead027661edc899feae56ad8b50ebd208f7a36d12 /src/mbgl/gl
parent805b1402452da74042b995d693c48ee4b79ae337 (diff)
downloadqtlocation-mapboxgl-2455275bf47e1671a92eb2c1296c6b48f11f6b2e.tar.gz
add onStyleImageMissing to allow dynamically loaded or generated images (#14253)
Also make `Style#updateImage(...)` much faster when the image doesn't change size. This can be useful for asynchronously generating images.
Diffstat (limited to 'src/mbgl/gl')
-rw-r--r--src/mbgl/gl/context.cpp18
-rw-r--r--src/mbgl/gl/context.hpp1
2 files changed, 19 insertions, 0 deletions
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp
index 5ce035f691..6cee364379 100644
--- a/src/mbgl/gl/context.cpp
+++ b/src/mbgl/gl/context.cpp
@@ -546,6 +546,24 @@ void Context::updateTextureResource(const gfx::TextureResource& resource,
Enum<gfx::TextureChannelDataType>::to(type), data));
}
+void Context::updateTextureResourceSub(const gfx::TextureResource& resource,
+ const uint16_t xOffset,
+ const uint16_t yOffset,
+ const Size size,
+ const void* data,
+ gfx::TexturePixelType format,
+ gfx::TextureChannelDataType type) {
+ // Always use texture unit 0 for manipulating it.
+ activeTextureUnit = 0;
+ texture[0] = static_cast<const gl::TextureResource&>(resource).texture;
+ MBGL_CHECK_ERROR(glTexSubImage2D(GL_TEXTURE_2D, 0,
+ xOffset, yOffset,
+ size.width, size.height,
+ Enum<gfx::TexturePixelType>::to(format),
+ Enum<gfx::TextureChannelDataType>::to(type), data));
+}
+
+
std::unique_ptr<gfx::DrawScopeResource> Context::createDrawScopeResource() {
return std::make_unique<gl::DrawScopeResource>(createVertexArray());
}
diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp
index a4e6184ddb..d46727cb7a 100644
--- a/src/mbgl/gl/context.hpp
+++ b/src/mbgl/gl/context.hpp
@@ -211,6 +211,7 @@ private:
std::unique_ptr<gfx::TextureResource> createTextureResource(Size, const void* data, gfx::TexturePixelType, gfx::TextureChannelDataType) override;
void updateTextureResource(const gfx::TextureResource&, Size, const void* data, gfx::TexturePixelType, gfx::TextureChannelDataType) override;
+ void updateTextureResourceSub(const gfx::TextureResource&, const uint16_t xOffset, const uint16_t yOffset, Size, const void* data, gfx::TexturePixelType, gfx::TextureChannelDataType) override;
std::unique_ptr<gfx::DrawScopeResource> createDrawScopeResource() override;