summaryrefslogtreecommitdiff
path: root/src/mbgl/gfx/draw_scope.hpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2019-04-02 22:47:24 +0200
committerKonstantin Käfer <mail@kkaefer.com>2019-04-05 11:49:17 +0200
commitebd850803278a6ffbca0bc8a5b96d415b239aeb8 (patch)
tree3ff807a5fa1bde413120997e00fcab68044544f6 /src/mbgl/gfx/draw_scope.hpp
parentc02010ab6c8958f6897921c82cf47411de759269 (diff)
downloadqtlocation-mapboxgl-ebd850803278a6ffbca0bc8a5b96d415b239aeb8.tar.gz
[core] add getResource template to gfx::*Resource classes
Diffstat (limited to 'src/mbgl/gfx/draw_scope.hpp')
-rw-r--r--src/mbgl/gfx/draw_scope.hpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mbgl/gfx/draw_scope.hpp b/src/mbgl/gfx/draw_scope.hpp
index 60aae7a44c..5cdb588317 100644
--- a/src/mbgl/gfx/draw_scope.hpp
+++ b/src/mbgl/gfx/draw_scope.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <memory>
+#include <cassert>
namespace mbgl {
namespace gfx {
@@ -14,6 +15,16 @@ public:
class DrawScope {
public:
+ explicit DrawScope(std::unique_ptr<DrawScopeResource> resource_) : resource(std::move(resource_)) {
+ }
+
+ template <typename T = DrawScopeResource>
+ T& getResource() const {
+ assert(resource);
+ return static_cast<T&>(*resource);
+ }
+
+protected:
std::unique_ptr<DrawScopeResource> resource;
};