diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-06-30 11:46:03 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-06-30 11:46:03 +0200 |
commit | 93cd4c5c7b0939038eab38a6f6eb71eae4014acb (patch) | |
tree | 76d8efb417a20f16e32e3d5901fd5d9db351ac60 /include/llmr/style | |
parent | 8feedf7fc2f9b41a48d9f02ea572d312514f115f (diff) | |
download | qtlocation-mapboxgl-93cd4c5c7b0939038eab38a6f6eb71eae4014acb.tar.gz |
move StyleLayerGroup and PropertyTransition to their own files
Diffstat (limited to 'include/llmr/style')
-rw-r--r-- | include/llmr/style/applied_class_properties.hpp | 8 | ||||
-rw-r--r-- | include/llmr/style/class_properties.hpp | 10 | ||||
-rw-r--r-- | include/llmr/style/property_transition.hpp | 15 | ||||
-rw-r--r-- | include/llmr/style/style.hpp | 27 | ||||
-rw-r--r-- | include/llmr/style/style_layer.hpp | 14 | ||||
-rw-r--r-- | include/llmr/style/style_layer_group.hpp | 21 | ||||
-rw-r--r-- | include/llmr/style/style_parser.hpp | 2 |
7 files changed, 64 insertions, 33 deletions
diff --git a/include/llmr/style/applied_class_properties.hpp b/include/llmr/style/applied_class_properties.hpp index f90102200f..cda3a42a48 100644 --- a/include/llmr/style/applied_class_properties.hpp +++ b/include/llmr/style/applied_class_properties.hpp @@ -14,10 +14,10 @@ public: AppliedClassProperty(ClassID class_id, timestamp begin, timestamp end, const PropertyValue &value); public: - ClassID name; - timestamp begin; - timestamp end; - PropertyValue value; + const ClassID name; + const timestamp begin; + const timestamp end; + const PropertyValue value; }; diff --git a/include/llmr/style/class_properties.hpp b/include/llmr/style/class_properties.hpp index 79b16e51a7..3755563fec 100644 --- a/include/llmr/style/class_properties.hpp +++ b/include/llmr/style/class_properties.hpp @@ -3,16 +3,12 @@ #include <llmr/style/property_key.hpp> #include <llmr/style/property_value.hpp> +#include <llmr/style/property_transition.hpp> #include <map> namespace llmr { -struct ClassPropertyTransition { - uint16_t duration = 0; - uint16_t delay = 0; -}; - class ClassProperties { public: inline ClassProperties() {} @@ -28,7 +24,7 @@ public: transitions.emplace(::std::forward<Args>(args)...); } - inline const ClassPropertyTransition &getTransition(PropertyKey key, const ClassPropertyTransition &defaultTransition) const { + inline const PropertyTransition &getTransition(PropertyKey key, const PropertyTransition &defaultTransition) const { auto it = transitions.find(key); if (it == transitions.end()) { return defaultTransition; @@ -47,7 +43,7 @@ public: public: std::map<PropertyKey, PropertyValue> properties; - std::map<PropertyKey, ClassPropertyTransition> transitions; + std::map<PropertyKey, PropertyTransition> transitions; }; } diff --git a/include/llmr/style/property_transition.hpp b/include/llmr/style/property_transition.hpp new file mode 100644 index 0000000000..0175274436 --- /dev/null +++ b/include/llmr/style/property_transition.hpp @@ -0,0 +1,15 @@ +#ifndef LLMR_STYLE_PROPERTY_TRANSITION +#define LLMR_STYLE_PROPERTY_TRANSITION + +#include <cstdint> + +namespace llmr { + +struct PropertyTransition { + uint16_t duration = 0; + uint16_t delay = 0; +}; + +} + +#endif
\ No newline at end of file diff --git a/include/llmr/style/style.hpp b/include/llmr/style/style.hpp index 383aa5d75d..62864b75ff 100644 --- a/include/llmr/style/style.hpp +++ b/include/llmr/style/style.hpp @@ -1,11 +1,12 @@ #ifndef LLMR_STYLE_STYLE #define LLMR_STYLE_STYLE -#include <cstdint> +#include <llmr/style/property_transition.hpp> #include <llmr/util/time.hpp> #include <llmr/util/uv.hpp> +#include <cstdint> #include <map> #include <unordered_map> #include <vector> @@ -17,7 +18,7 @@ namespace llmr { class Sprite; class Source; class StyleLayer; -typedef std::vector<std::shared_ptr<StyleLayer>> StyleLayerGroup; +class StyleLayerGroup; class Style { public: @@ -26,20 +27,13 @@ public: public: Style(); - void reset(); - void loadJSON(const uint8_t *const data); size_t layerCount() const; - void cascade(float z); + void updateProperties(float z, timestamp t); - bool needsTransition() const; - void updateTransitions(timestamp now); - void cancelTransitions(); + void setDefaultTransitionDuration(uint16_t duration_milliseconds = 0); - void setDefaultTransitionDuration(uint64_t duration_milliseconds = 0); - - void updateSources(); const std::set<std::shared_ptr<Source>> getActiveSources() const; const std::vector<std::string> &getAppliedClasses() const; @@ -51,14 +45,17 @@ public: std::shared_ptr<StyleLayer> background; std::vector<std::string> appliedClasses; - private: - void updateSources(const std::shared_ptr<StyleLayerGroup> &layers); - void cascade(const std::shared_ptr<StyleLayerGroup> &layers, float z); + void updateSources(); + void updateSources(const std::shared_ptr<StyleLayerGroup> &group); + + void updateProperties(const std::shared_ptr<StyleLayerGroup> &group, float z, timestamp t); + + void updateClasses(); private: std::set<std::shared_ptr<Source>> activeSources; - uint64_t default_transition_duration = 0; + PropertyTransition defaultTransition; bool initial_render_complete = false; mutable uv::rwlock mtx; diff --git a/include/llmr/style/style_layer.hpp b/include/llmr/style/style_layer.hpp index b45982b794..89d4e14764 100644 --- a/include/llmr/style/style_layer.hpp +++ b/include/llmr/style/style_layer.hpp @@ -16,9 +16,7 @@ namespace llmr { class StyleBucket; - -class StyleLayer; -typedef std::vector<std::shared_ptr<StyleLayer>> StyleLayerGroup; +class StyleLayerGroup; class StyleLayer { public: @@ -33,16 +31,21 @@ public: } } + // Determines whether this layer is the background layer. bool isBackground() const; + // Updates the StyleProperties information in this layer by evaluating all + // pending transitions and applied classes in order. + void updateStyle(float z); + // Sets the list of classes and creates transitions to the currently applied values. void setClasses(const std::vector<std::string> &class_names, timestamp now, - const ClassPropertyTransition &defaultTransition); + const PropertyTransition &defaultTransition); private: // Applies all properties from a class, if they haven't been applied already. void applyClassProperties(ClassID class_id, std::set<PropertyKey> &already_applied, - timestamp now, const ClassPropertyTransition &defaultTransition); + timestamp now, const PropertyTransition &defaultTransition); public: // The name of this layer. @@ -74,7 +77,6 @@ public: std::shared_ptr<StyleLayerGroup> layers; }; - } #endif diff --git a/include/llmr/style/style_layer_group.hpp b/include/llmr/style/style_layer_group.hpp new file mode 100644 index 0000000000..73214830fe --- /dev/null +++ b/include/llmr/style/style_layer_group.hpp @@ -0,0 +1,21 @@ +#ifndef LLMR_STYLE_STYLE_LAYER_GROUP +#define LLMR_STYLE_STYLE_LAYER_GROUP + +#include <llmr/style/style_layer.hpp> + +#include <vector> + +namespace llmr { + +class StyleLayerGroup { +public: + void setClasses(const std::vector<std::string> &class_names, timestamp now, + const PropertyTransition &defaultTransition); + +public: + std::vector<std::shared_ptr<StyleLayer>> layers; +}; + +} + +#endif diff --git a/include/llmr/style/style_parser.hpp b/include/llmr/style/style_parser.hpp index 808d3188de..3c2a12a2a3 100644 --- a/include/llmr/style/style_parser.hpp +++ b/include/llmr/style/style_parser.hpp @@ -18,7 +18,7 @@ namespace llmr { enum class ClassID : uint32_t; class StyleLayer; -typedef std::vector<std::shared_ptr<StyleLayer>> StyleLayerGroup; +class StyleLayerGroup; class StyleParser { public: |