summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer/frame_history.hpp
blob: 04ebe2327644a5ead2dc14d34c86318b59c6aec9 (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
#pragma once

#include <array>

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

namespace mbgl {

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

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

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;

    mbgl::optional<gl::UniqueTexture> texture;
};

} // namespace mbgl