diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-07-02 15:57:52 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-07-02 15:57:52 +0200 |
commit | cc9dab4024591a78c27e3e9d8be430ba35beb127 (patch) | |
tree | b65f4252a1cbccde47c5cf8e2d862df82067898f /include | |
parent | af87fb6c264e232a6945f7f6304989a459501720 (diff) | |
download | qtlocation-mapboxgl-cc9dab4024591a78c27e3e9d8be430ba35beb127.tar.gz |
parse rasterize values as well
Diffstat (limited to 'include')
-rw-r--r-- | include/llmr/renderer/prerendered_texture.hpp | 4 | ||||
-rw-r--r-- | include/llmr/style/class_properties.hpp | 11 | ||||
-rw-r--r-- | include/llmr/style/function_properties.hpp | 5 | ||||
-rw-r--r-- | include/llmr/style/rasterize_properties.hpp | 23 | ||||
-rw-r--r-- | include/llmr/style/style_parser.hpp | 10 |
5 files changed, 32 insertions, 21 deletions
diff --git a/include/llmr/renderer/prerendered_texture.hpp b/include/llmr/renderer/prerendered_texture.hpp index 6ca3cd5401..168284e1de 100644 --- a/include/llmr/renderer/prerendered_texture.hpp +++ b/include/llmr/renderer/prerendered_texture.hpp @@ -11,7 +11,7 @@ class Painter; class PrerenderedTexture : private util::noncopyable { public: - PrerenderedTexture(const PrerenderProperties &properties); + PrerenderedTexture(const RasterizedProperties &properties); ~PrerenderedTexture(); void bindTexture(); @@ -23,7 +23,7 @@ public: void blur(Painter& painter, uint16_t passes); public: - const PrerenderProperties properties; + const RasterizedProperties properties; private: GLint previous_fbo = 0; diff --git a/include/llmr/style/class_properties.hpp b/include/llmr/style/class_properties.hpp index a1720e1720..55d6aa2cc6 100644 --- a/include/llmr/style/class_properties.hpp +++ b/include/llmr/style/class_properties.hpp @@ -15,13 +15,12 @@ public: inline ClassProperties(ClassProperties &&properties) : properties(std::move(properties.properties)) {} - template <typename ...Args> - inline void set(Args&& ...args) { - properties.emplace(::std::forward<Args>(args)...); + inline void set(PropertyKey key, const PropertyValue &value) { + properties.emplace(key, value); } - template <typename ...Args> - inline void setTransition(Args&& ...args) { - transitions.emplace(::std::forward<Args>(args)...); + + inline void set(PropertyKey key, const PropertyTransition &transition) { + transitions.emplace(key, transition); } const PropertyTransition &getTransition(PropertyKey key, const PropertyTransition &defaultTransition) const; diff --git a/include/llmr/style/function_properties.hpp b/include/llmr/style/function_properties.hpp index d1e1a5b1c6..75714d1197 100644 --- a/include/llmr/style/function_properties.hpp +++ b/include/llmr/style/function_properties.hpp @@ -50,6 +50,7 @@ private: template <typename T> using Function = util::variant< + std::false_type, ConstantFunction<T>, LinearFunction<T>, ExponentialFunction<T>, @@ -61,6 +62,10 @@ struct FunctionEvaluator { typedef T result_type; inline FunctionEvaluator(float z) : z(z) {} + inline result_type operator()(const std::false_type &) { + return result_type(); + } + template <template <typename> class Fn> inline result_type operator()(const Fn<T>& fn) { return fn.evaluate(z); diff --git a/include/llmr/style/rasterize_properties.hpp b/include/llmr/style/rasterize_properties.hpp index 2e1fc32895..4cfe472899 100644 --- a/include/llmr/style/rasterize_properties.hpp +++ b/include/llmr/style/rasterize_properties.hpp @@ -3,22 +3,23 @@ #include <llmr/style/function_properties.hpp> -#include <boost/optional.hpp> - namespace llmr { -struct PrerenderProperties { - float buffer = 1.0f / 32.0f; - uint16_t size = 256; - uint16_t blur = 0; +class RasterizeProperties { +public: + Function<bool> enabled = ConstantFunction<bool>(false); + Function<float> buffer = ConstantFunction<float>(1.0f / 32.0f); + Function<float> size = ConstantFunction<float>(256); + Function<float> blur = ConstantFunction<float>(0); }; -class RasterizeProperties { +// The calculated properties for a layer in a tile. +class RasterizedProperties { public: - boost::optional<Function<bool>> enabled; - boost::optional<Function<float>> buffer; - boost::optional<Function<float>> size; - boost::optional<Function<float>> blur; + bool enabled = false; + float buffer = 1.0f / 32.0f; + uint16_t size = 256; + uint8_t blur = 0; }; } diff --git a/include/llmr/style/style_parser.hpp b/include/llmr/style/style_parser.hpp index 777a8934da..71aca68061 100644 --- a/include/llmr/style/style_parser.hpp +++ b/include/llmr/style/style_parser.hpp @@ -11,7 +11,7 @@ #include <unordered_map> #include <forward_list> - +#include <tuple> namespace llmr { @@ -50,7 +50,7 @@ private: void parseLayer(std::pair<JSVal, std::shared_ptr<StyleLayer>> &pair); void parseStyles(JSVal value, std::map<ClassID, ClassProperties> &styles); void parseStyle(JSVal, ClassProperties &properties); - std::unique_ptr<const RasterizeProperties> parseRasterize(JSVal value); + std::unique_ptr<RasterizeProperties> parseRasterize(JSVal value); void parseReference(JSVal value, std::shared_ptr<StyleLayer> &layer); void parseBucket(JSVal value, std::shared_ptr<StyleLayer> &layer); void parseRender(JSVal value, std::shared_ptr<StyleLayer> &layer); @@ -67,11 +67,17 @@ private: template <typename T> bool parseStyleProperty(const char *property_name, PropertyKey key, ClassProperties &klass, JSVal value); template <typename T> + bool parseStyleProperty(const char *property_name, T &target, JSVal value); + template <typename T> + std::tuple<bool, T> parseStyleProperty(JSVal value, const char *property_name); + template <typename T> bool parseStyleProperty(const char *property_name, const std::vector<PropertyKey> &keys, ClassProperties &klass, JSVal value); template <typename T> bool parseFunction(PropertyKey key, ClassProperties &klass, JSVal value); template <typename T> + std::tuple<bool, Function<T>> parseFunction(JSVal value); + template <typename T> T parseFunctionArgument(JSVal value); |