diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-03-19 14:02:10 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-03-20 15:40:47 +0100 |
commit | 53ab65d81165daf4e23ce28fa0e42861724ea687 (patch) | |
tree | 402a535476210bf3527b487011a0f7ccb78ef73d /src/mbgl/renderer/paint_property_binder.hpp | |
parent | 0ad2375e1047353fc65fabce3ac9123dc095179e (diff) | |
download | qtlocation-mapboxgl-53ab65d81165daf4e23ce28fa0e42861724ea687.tar.gz |
[core] use constexpr string concatenation for uniform/attribute names
Diffstat (limited to 'src/mbgl/renderer/paint_property_binder.hpp')
-rw-r--r-- | src/mbgl/renderer/paint_property_binder.hpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/mbgl/renderer/paint_property_binder.hpp b/src/mbgl/renderer/paint_property_binder.hpp index 6c2c07950d..d233e6f2e0 100644 --- a/src/mbgl/renderer/paint_property_binder.hpp +++ b/src/mbgl/renderer/paint_property_binder.hpp @@ -4,6 +4,7 @@ #include <mbgl/gfx/uniform.hpp> #include <mbgl/gfx/attribute.hpp> #include <mbgl/programs/attributes.hpp> +#include <mbgl/util/literal.hpp> #include <mbgl/util/type_list.hpp> #include <mbgl/renderer/possibly_evaluated_property_value.hpp> #include <mbgl/renderer/paint_property_statistics.hpp> @@ -431,17 +432,15 @@ PaintPropertyBinder<T, UniformValueType, PossiblyEvaluatedType, As...>::create(c } template <class Attr> -struct ZoomInterpolatedAttribute { - static auto attributeName() { return Attr::attributeName(); } +struct ZoomInterpolatedAttribute : public Attr { using Type = ZoomInterpolatedAttributeType<typename Attr::Type>; }; template <class Attr> struct InterpolationUniform { using Value = float; - static auto uniformName() { - static const std::string name = Attr::attributeName() + std::string("_t"); - return name.c_str(); + static constexpr auto name() { + return concat_literals<&Attr::name, &string_literal<'_', 't'>::value>::value(); } }; @@ -551,9 +550,13 @@ public: template <class... Us> struct UniformDefines<TypeList<Us...>> { + static constexpr auto define() { + return "#define HAS_UNIFORM_u_"; + } + static void appendDefines(std::vector<std::string>& defines) { util::ignore({ - (defines.push_back(std::string("#define HAS_UNIFORM_") + Us::uniformName()), 0)... + (defines.push_back(concat_literals<&define, &Us::name, &string_literal<'\n'>::value>::value()), 0)... }); } }; |