summaryrefslogtreecommitdiff
path: root/src/mbgl/gfx/texture.hpp
blob: bbda44a8fb3c02c7f3324a3b3640a0f9707cf56f (plain)
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
#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>

namespace mbgl {
namespace gfx {

class TextureResource {
protected:
    TextureResource() = default;
public:
    virtual ~TextureResource() = default;
};

class Texture {
public:
    Texture(Size size_, std::unique_ptr<const TextureResource>&& resource_)
        : size(std::move(size_)), resource(std::move(resource_)) {
    }

    Size size;
    TextureFilterType filter = TextureFilterType::Nearest;
    TextureMipMapType mipmap = TextureMipMapType::No;
    TextureWrapType wrapX = TextureWrapType::Clamp;
    TextureWrapType wrapY = TextureWrapType::Clamp;
    std::unique_ptr<const TextureResource> resource;
};

class TextureBinding {
public:
    TextureBinding(const 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_) {
    }

    const TextureResource* resource;
    TextureFilterType filter;
    TextureMipMapType mipmap;
    TextureWrapType wrapX;
    TextureWrapType wrapY;
};

namespace detail {

template <class>
class TextureBindings;

template <class... Ts>
class TextureBindings<TypeList<Ts...>> {
public:
    using Type = IndexedTuple<TypeList<Ts...>, TypeList<ExpandToType<Ts, TextureBinding>...>>;
};

} // namespace detail

template <class TextureTypeList>
using TextureBindings = typename detail::TextureBindings<TextureTypeList>::Type;

} // namespace gfx
} // namespace mbgl