summaryrefslogtreecommitdiff
path: root/src/mbgl/gl
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-03-16 17:00:43 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-03-17 08:27:53 -0700
commitff413f6b99d7cb7b7482d56479f10e0a8fe83046 (patch)
treea0a7aab5a9eb785565b6d8c90632d864aa1101a5 /src/mbgl/gl
parent0dca6cd9bfdb1fb77f7755d639f92a6a1ba06dc1 (diff)
downloadqtlocation-mapboxgl-ff413f6b99d7cb7b7482d56479f10e0a8fe83046.tar.gz
[core] Fix overspecialization of PaintPropertyBinder template
PaintPropertyBinder and subclass templates were being instantiated for every unique attribute type (e.g. a_color, a_fill_color, a_halo_color) even though they behave identically for a given property value type (e.g. Color). To fix this, a unique type such as a_color no longer derives from gl::Attribute<...> -- instead it has an inner Type typedef, which should be used wherever neither a unique type nor attribute name is required. This reduces binary size substantially: VM SIZE FILE SIZE ++++++++++++++ GROWING ++++++++++++++ -------------- SHRINKING -------------- -2.0% -49.3Ki __TEXT,__text -49.3Ki -2.0% -3.1% -5.21Ki [None] -2.79Ki -1.6% -2.1% -4.12Ki __TEXT,__const -4.12Ki -2.1% -1.4% -4.04Ki __TEXT,__gcc_except_tab -4.04Ki -1.4% -19.3% -3.62Ki __DATA,__data -3.62Ki -19.3% -2.5% -1.65Ki __TEXT,__unwind_info -1.65Ki -2.5% -4.2% -8 __DATA,__mod_init_func 0 [ = ] -1.9% -68.0Ki TOTAL -65.6Ki -1.9%
Diffstat (limited to 'src/mbgl/gl')
-rw-r--r--src/mbgl/gl/attribute.hpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/mbgl/gl/attribute.hpp b/src/mbgl/gl/attribute.hpp
index 43e2c2d794..ab97ada0f2 100644
--- a/src/mbgl/gl/attribute.hpp
+++ b/src/mbgl/gl/attribute.hpp
@@ -113,8 +113,11 @@ public:
}
};
-#define MBGL_DEFINE_ATTRIBUTE(type_, n_, name_) \
- struct name_ : ::mbgl::gl::Attribute<type_, n_> { static auto name() { return #name_; } }
+#define MBGL_DEFINE_ATTRIBUTE(type_, n_, name_) \
+ struct name_ { \
+ static auto name() { return #name_; } \
+ using Type = ::mbgl::gl::Attribute<type_, n_>; \
+ }
namespace detail {
@@ -234,15 +237,15 @@ public:
using Types = TypeList<As...>;
using Locations = IndexedTuple<
TypeList<As...>,
- TypeList<typename As::Location...>>;
+ TypeList<typename As::Type::Location...>>;
using Bindings = IndexedTuple<
TypeList<As...>,
- TypeList<typename As::Binding...>>;
+ TypeList<typename As::Type::Binding...>>;
using VariableBindings = IndexedTuple<
TypeList<As...>,
- TypeList<optional<typename As::VariableBinding>...>>;
+ TypeList<optional<typename As::Type::VariableBinding>...>>;
- using Vertex = detail::Vertex<As...>;
+ using Vertex = detail::Vertex<typename As::Type...>;
template <class A>
static constexpr std::size_t Index = TypeIndex<A, As...>::value;
@@ -253,7 +256,7 @@ public:
template <class DrawMode>
static Bindings allVariableBindings(const VertexBuffer<Vertex, DrawMode>& buffer) {
- return Bindings { As::variableBinding(buffer, Index<As>)... };
+ return Bindings { As::Type::variableBinding(buffer, Index<As>)... };
}
static void bind(Context& context,
@@ -261,11 +264,11 @@ public:
VariableBindings& oldBindings,
const Bindings& newBindings,
std::size_t vertexOffset) {
- util::ignore({ (As::bind(context,
- locations.template get<As>(),
- oldBindings.template get<As>(),
- newBindings.template get<As>(),
- vertexOffset), 0)... });
+ util::ignore({ (As::Type::bind(context,
+ locations.template get<As>(),
+ oldBindings.template get<As>(),
+ newBindings.template get<As>(),
+ vertexOffset), 0)... });
}
};