diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-04-01 13:48:20 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-04-05 11:49:17 +0200 |
commit | 865f8a6c03540e329ed6caef354799fb58b7ab6e (patch) | |
tree | 8c748a0ef16dc88ed0ceeadea71f20bfd99cdf96 /include/mbgl/gfx | |
parent | ebd850803278a6ffbca0bc8a5b96d415b239aeb8 (diff) | |
download | qtlocation-mapboxgl-865f8a6c03540e329ed6caef354799fb58b7ab6e.tar.gz |
[core] add gfx::Renderable and gfx::OffscreenTexture
Diffstat (limited to 'include/mbgl/gfx')
-rw-r--r-- | include/mbgl/gfx/renderable.hpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/include/mbgl/gfx/renderable.hpp b/include/mbgl/gfx/renderable.hpp new file mode 100644 index 0000000000..3a973e6693 --- /dev/null +++ b/include/mbgl/gfx/renderable.hpp @@ -0,0 +1,44 @@ +#pragma once + +#include <mbgl/util/size.hpp> + +#include <memory> +#include <cassert> + +namespace mbgl { +namespace gfx { + +class RenderableResource { +protected: + explicit RenderableResource() = default; + +public: + virtual ~RenderableResource() = default; + RenderableResource(const RenderableResource&) = delete; + RenderableResource& operator=(const RenderableResource&) = delete; +}; + +class Renderable { +protected: + Renderable(const Size size_, std::unique_ptr<RenderableResource> resource_) + : size(size_), resource(std::move(resource_)) { + } + +public: + Size getSize() const { + return size; + } + + template <typename T> + T& getResource() const { + assert(resource); + return static_cast<T&>(*resource); + } + +protected: + Size size; + std::unique_ptr<RenderableResource> resource; +}; + +} // namespace gfx +} // namespace mbgl |