summaryrefslogtreecommitdiff
path: root/src/mbgl/programs/attributes.hpp
diff options
context:
space:
mode:
authorAnand Thakker <anandthakker@users.noreply.github.com>2017-04-06 15:29:59 -0400
committerGitHub <noreply@github.com>2017-04-06 15:29:59 -0400
commit693c9f3641b3189b4cd439049904c95a516ae609 (patch)
tree8341a16f57ff184a2fe9e085c490e8762eb206ce /src/mbgl/programs/attributes.hpp
parentf9cc044357d60dd5cf15ba951384529f88802089 (diff)
downloadqtlocation-mapboxgl-693c9f3641b3189b4cd439049904c95a516ae609.tar.gz
[core] Add DDS support for {text,icon}-size (#8593)
* Update gl-js and generate style code * Factor out packUint8Pair() helper function * Draft implementation of DDS for {text,icon}-size Ports https://github.com/mapbox/mapbox-gl-js/pull/4455 * Fix text-size/composite-function-line-placement test * Refactor to PaintPropertyBinders-like strategy * Dedupe gl::Program construction * Use exponential function base for interpolation * Dedupe coveringZoomStops method * Fixup tests * Fix CI errors (hidden within #if block)
Diffstat (limited to 'src/mbgl/programs/attributes.hpp')
-rw-r--r--src/mbgl/programs/attributes.hpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/mbgl/programs/attributes.hpp b/src/mbgl/programs/attributes.hpp
index 7d39c04395..e9ca18927e 100644
--- a/src/mbgl/programs/attributes.hpp
+++ b/src/mbgl/programs/attributes.hpp
@@ -8,6 +8,16 @@
namespace mbgl {
namespace attributes {
+/*
+ * Pack a pair of values, interpreted as uint8's, into a single float.
+ * Used to conserve vertex attributes. Values are unpacked in the vertex
+ * shader using the `unpack_float()` function, defined in _prelude.vertex.glsl.
+ */
+template <typename T>
+inline uint16_t packUint8Pair(T a, T b) {
+ return static_cast<uint16_t>(a) * 256 + static_cast<uint16_t>(b);
+}
+
// Layout attributes
MBGL_DEFINE_ATTRIBUTE(int16_t, 2, a_pos);
@@ -15,10 +25,15 @@ MBGL_DEFINE_ATTRIBUTE(int16_t, 2, a_extrude);
MBGL_DEFINE_ATTRIBUTE(int16_t, 4, a_pos_offset);
MBGL_DEFINE_ATTRIBUTE(uint16_t, 2, a_texture_pos);
-template <std::size_t N>
+template <typename T, std::size_t N>
struct a_data {
static auto name() { return "a_data"; }
- using Type = gl::Attribute<uint8_t, N>;
+ using Type = gl::Attribute<T, N>;
+};
+
+struct a_size {
+ static auto name() { return "a_size"; }
+ using Type = gl::Attribute<uint16_t, 3>;
};
template <std::size_t N>