1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#pragma once
#include <mbgl/gfx/types.hpp>
#include <mbgl/util/size.hpp>
#include <mbgl/util/type_list.hpp>
#include <mbgl/util/indexed_tuple.hpp>
#include <memory>
#define MBGL_DEFINE_TEXTURE(name_) \
struct name_ { \
using Value = ::mbgl::gfx::TextureBinding; \
static constexpr auto name() { \
return #name_; \
} \
}
namespace mbgl {
namespace gfx {
class TextureResource {
protected:
TextureResource() = default;
public:
virtual ~TextureResource() = default;
};
class Texture {
public:
Texture(Size size_, std::unique_ptr<TextureResource>&& resource_)
: size(std::move(size_)), resource(std::move(resource_)) {
}
Size size;
std::unique_ptr<TextureResource> resource;
};
class TextureBinding {
public:
TextureBinding(TextureResource& resource_,
TextureFilterType filter_ = TextureFilterType::Nearest,
TextureMipMapType mipmap_ = TextureMipMapType::No,
TextureWrapType wrapX_ = TextureWrapType::Clamp,
TextureWrapType wrapY_ = TextureWrapType::Clamp)
: resource(&resource_), filter(filter_), mipmap(mipmap_), wrapX(wrapX_), wrapY(wrapY_) {
}
TextureResource* resource;
TextureFilterType filter;
TextureMipMapType mipmap;
TextureWrapType wrapX;
TextureWrapType wrapY;
};
template <class>
class TextureBindings;
template <class... Ts>
class TextureBindings<TypeList<Ts...>> final
: public IndexedTuple<TypeList<Ts...>, TypeList<ExpandToType<Ts, TextureBinding>...>> {
using Base = IndexedTuple<TypeList<Ts...>, TypeList<ExpandToType<Ts, TextureBinding>...>>;
public:
template <class... Args>
TextureBindings(Args&&... args) : Base(std::forward<Args>(args)...) {
}
};
} // namespace gfx
} // namespace mbgl
|