diff options
author | Molly Lloyd <molly@mapbox.com> | 2018-06-14 14:35:39 -0700 |
---|---|---|
committer | Molly Lloyd <mollymerp@users.noreply.github.com> | 2018-08-31 13:08:47 -0700 |
commit | 4a5dc37245d23805d13865f5ef9c5f26e539a9ca (patch) | |
tree | de77bfeff6f7afbe02210c9189bf72da59293083 /src/mbgl/gl | |
parent | ec62e321531b1a836074056e86de8e20018280fb (diff) | |
download | qtlocation-mapboxgl-4a5dc37245d23805d13865f5ef9c5f26e539a9ca.tar.gz |
[core] Implement CrossFadedDataDrivenProperty to add support for feature expressions in `*-pattern` properties
Diffstat (limited to 'src/mbgl/gl')
-rw-r--r-- | src/mbgl/gl/uniform.cpp | 19 | ||||
-rw-r--r-- | src/mbgl/gl/uniform.hpp | 20 |
2 files changed, 26 insertions, 13 deletions
diff --git a/src/mbgl/gl/uniform.cpp b/src/mbgl/gl/uniform.cpp index 2946980c19..3d8a8d53d9 100644 --- a/src/mbgl/gl/uniform.cpp +++ b/src/mbgl/gl/uniform.cpp @@ -79,6 +79,11 @@ void bindUniform<std::array<uint16_t, 2>>(UniformLocation location, const std::a bindUniform(location, util::convert<float>(t)); } +template <> +void bindUniform<std::array<uint16_t, 4>>(UniformLocation location, const std::array<uint16_t, 4>& t) { + bindUniform(location, util::convert<float>(t)); +} + // Add more as needed. #ifndef NDEBUG @@ -125,6 +130,12 @@ bool verifyUniform<std::array<float, 3>>(const ActiveUniform& uniform) { } template <> +bool verifyUniform<std::array<float, 4>>(const ActiveUniform& uniform) { + assert(uniform.size == 1 && uniform.type == UniformDataType::FloatVec4); + return true; +} + +template <> bool verifyUniform<std::array<double, 16>>(const ActiveUniform& uniform) { assert(uniform.size == 1 && uniform.type == UniformDataType::FloatMat4); return true; @@ -168,6 +179,14 @@ bool verifyUniform<std::array<uint16_t, 2>>(const ActiveUniform& uniform) { return true; } +template <> +bool verifyUniform<std::array<uint16_t, 4>>(const ActiveUniform& uniform) { + assert(uniform.size == 1 && + (uniform.type == UniformDataType::IntVec4 || + uniform.type == UniformDataType::FloatVec4)); + return true; +} + // Add more as needed. #endif diff --git a/src/mbgl/gl/uniform.hpp b/src/mbgl/gl/uniform.hpp index d8a167c382..f8eaf369a2 100644 --- a/src/mbgl/gl/uniform.hpp +++ b/src/mbgl/gl/uniform.hpp @@ -16,13 +16,6 @@ namespace gl { template <class T> void bindUniform(UniformLocation, const T&); -template <class Tag, class T> -class UniformValue { -public: - explicit UniformValue(T t_) : t(std::move(t_)) {} - T t; -}; - class ActiveUniform { public: std::size_t size; @@ -42,7 +35,8 @@ ActiveUniforms activeUniforms(ProgramID); template <class Tag, class T> class Uniform { public: - using Value = UniformValue<Tag, T>; + // TODO should maybe remove this altogether bc it is now redundant? + using Value = T; using Type = T; @@ -50,10 +44,10 @@ public: public: State(UniformLocation location_) : location(std::move(location_)) {} - void operator=(const Value& value) { - if (location >= 0 && (!current || *current != value.t)) { - current = value.t; - bindUniform(location, value.t); + void operator=(const Type& value) { + if (location >= 0 && (!current || *current != value)) { + current = value; + bindUniform(location, value); } } @@ -103,7 +97,7 @@ public: : false)... }); #endif - return State { { uniformLocation(id, Us::name()) }... }; + return State(uniformLocation(id, Us::name())...); } template <class Program> |