summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer/frame_history.hpp
blob: ec43e2beb57e8507f2b9b577b92db4c44b3883d8 (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
#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 {

namespace gl {
class Config;
} // namespace gl

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

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

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