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

#include <mbgl/style/image_impl.hpp>
#include <mbgl/style/source_impl.hpp>
#include <mbgl/style/layer_impl.hpp>
#include <mbgl/util/immutable.hpp>
#include <mbgl/util/variant.hpp>

#include <unordered_map>

namespace mbgl {

template <class T>
class StyleChange {
public:
    T before;
    T after;
};

template <class T>
class StyleDifference {
public:
    std::unordered_map<std::string, T> added;
    std::unordered_map<std::string, T> removed;
    std::unordered_map<std::string, StyleChange<T>> changed;
};

using ImmutableImage = Immutable<style::Image::Impl>;
using ImageDifference = StyleDifference<ImmutableImage>;

ImageDifference diffImages(const Immutable<std::vector<ImmutableImage>>&,
                           const Immutable<std::vector<ImmutableImage>>&);

using ImmutableSource = Immutable<style::Source::Impl>;
using SourceDifference = StyleDifference<ImmutableSource>;

SourceDifference diffSources(const Immutable<std::vector<ImmutableSource>>&,
                             const Immutable<std::vector<ImmutableSource>>&);

using ImmutableLayer = Immutable<style::Layer::Impl>;
using LayerDifference = StyleDifference<ImmutableLayer>;

LayerDifference diffLayers(const Immutable<std::vector<ImmutableLayer>>&,
                           const Immutable<std::vector<ImmutableLayer>>&);

bool hasLayoutDifference(const LayerDifference&, const std::string& layerID);

} // namespace mbgl