summaryrefslogtreecommitdiff
path: root/include/mbgl/util/raster.hpp
blob: 04c85169e2dbefe463693801bc139d4e7b3d6aaf (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
69
70
#ifndef MBGL_UTIL_RASTER
#define MBGL_UTIL_RASTER

#include <mbgl/util/transition.hpp>
#include <mbgl/util/texturepool.hpp>
#include <mbgl/util/image.hpp>

#include <string>
#include <mutex>
#include <memory>

typedef struct uv_loop_s uv_loop_t;

namespace mbgl {

class Raster : public std::enable_shared_from_this<Raster> {

public:
    Raster(const std::shared_ptr<Texturepool> &texturepool);
    ~Raster();

    // load image data
    bool load(const std::string &img);

    // bind current texture
    void bind(bool linear = false);

    // loaded status
    bool isLoaded() const;

    // transitions
    void beginFadeInTransition();
    bool needsTransition() const;
    void updateTransitions(timestamp now);

public:
    // loaded image dimensions
    uint32_t width = 0, height = 0;

    // has been uploaded to texture
    bool textured = false;

    // the uploaded texture
    uint32_t texture = 0;

    // texture opacity
    double opacity = 0;

private:
    mutable std::mutex mtx;

    // raw pixels have been loaded
    bool loaded = false;

    // shared texture pool
    std::shared_ptr<Texturepool> texturepool;

    // min/mag filter
    uint32_t filter = 0;

    // the raw pixels
    std::unique_ptr<util::Image> img;

    // fade in transition
    std::shared_ptr<util::transition> fade_transition = nullptr;
};

}

#endif