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
71
72
73
74
75
76
77
78
79
80
|
#pragma once
#include <string>
#include <unordered_map>
#include <mbgl/actor/actor.hpp>
#include <mbgl/util/chrono.hpp>
#include <mbgl/text/placement_worker.hpp>
#include <mbgl/layout/symbol_projection.hpp>
#include <mbgl/renderer/buckets/symbol_bucket.hpp>
#include <unordered_set>
namespace mbgl {
class RenderSymbolLayer;
class OpacityState {
public:
OpacityState(bool placed);
OpacityState(const OpacityState& prevOpacityState, float increment, bool placed);
bool isHidden() const;
float opacity;
bool placed;
};
class JointOpacityState {
public:
JointOpacityState(bool placedIcon, bool placedText);
JointOpacityState(const JointOpacityState& prevOpacityState, float increment, bool placedIcon, bool placedText);
bool isHidden() const;
OpacityState icon;
OpacityState text;
};
class Placement {
public:
Placement(const TransformState&, MapMode mapMode, const mat4& projMatrix, const bool showCollisionBoxes, Scheduler&);
void addLayer(RenderSymbolLayer&);
void place();
bool isReady();
bool commit(const Placement& prevPlacement, TimePoint);
void updateLayerOpacities(RenderSymbolLayer&);
JointOpacityState getOpacity(uint32_t crossTileSymbolID) const;
float symbolFadeChange(TimePoint now) const;
bool hasTransitions(TimePoint now) const;
// TODO: public for queryRenderedFeatures
Immutable<PlacementResult> result;
bool stillRecent(TimePoint now) const;
void setRecent(TimePoint now);
void setStale();
private:
void placeLayerBucket(
const SymbolBucket::Core&,
const std::vector<uint32_t>& symbolCrossTileIDs,
const UnwrappedTileID&,
const OverscaledTileID&,
std::unordered_set<uint32_t>& seenCrossTileIDs);
void updateBucketOpacities(SymbolBucket&, std::unordered_set<uint32_t>&);
TransformState state;
const MapMode mapMode;
TimePoint commitTime;
const bool showCollisionBoxes;
const mat4 projMatrix;
Actor<PlacementWorker> worker;
std::future<Immutable<PlacementResult>> future;
Mutable<std::vector<std::vector<PlacementBucket>>> placementBucketLayers;
std::unordered_map<uint32_t,JointOpacityState> opacities;
TimePoint recentUntil;
bool stale = false;
};
} // namespace mbgl
|