summaryrefslogtreecommitdiff
path: root/src/mbgl/gfx/context.hpp
diff options
context:
space:
mode:
authorTim Watson <tewatson89@gmail.com>2019-04-03 14:51:13 -0700
committerGitHub <noreply@github.com>2019-04-03 14:51:13 -0700
commit0ff25060dae4858a1b60e2277dbd8921de7a6785 (patch)
treed29d578b9b9d6cfb0999b7a30819d379b85172b7 /src/mbgl/gfx/context.hpp
parentba2b7a74c420856401d344ff15b27771175c9819 (diff)
parent0f416fbbde9b146eb28a4bf88586738d12505007 (diff)
downloadqtlocation-mapboxgl-0ff25060dae4858a1b60e2277dbd8921de7a6785.tar.gz
Merge pull request #1 from mapbox/masterupstream/friedbunny-external-pr-14135
Merge Master
Diffstat (limited to 'src/mbgl/gfx/context.hpp')
-rw-r--r--src/mbgl/gfx/context.hpp24
1 files changed, 23 insertions, 1 deletions
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() {