summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer/frame_history.hpp
blob: 88c58d74a0941876e46e1bda8c1ad5e3b03a2c86 (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
#ifndef MBGL_RENDERER_FRAME_HISTORY
#define MBGL_RENDERER_FRAME_HISTORY

#include <array>

#include <mbgl/platform/platform.hpp>
#include <mbgl/gl/gl_object_store.hpp>
#include <mbgl/util/chrono.hpp>

namespace mbgl {

class FrameHistory {
public:
    FrameHistory();
    void record(const TimePoint&, float zoom, const Duration&);

    bool needsAnimation(const Duration&) const;
    void bind(gl::GLObjectStore&);
    void upload(gl::GLObjectStore&);

private:
    const int width = 256;
    const int height = 1;

    std::array<TimePoint, 256> changeTimes;
    std::array<uint8_t, 256> changeOpacities;
    std::array<uint8_t, 256> opacities;

    int16_t previousZoomIndex = 0;
    TimePoint previousTime = TimePoint::min();
    TimePoint time = TimePoint::min();
    bool firstFrame = true;
    bool changed = true;

    gl::TextureHolder texture;
};

} // namespace mbgl

#endif