From abc5043339d1aa8eb25e449248ae5a95e00835a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Thu, 31 May 2018 14:41:10 +0200 Subject: [core] simplify attribute/location types --- include/mbgl/util/indexed_tuple.hpp | 3 +++ src/mbgl/gl/attribute.hpp | 15 ++++++--------- src/mbgl/renderer/paint_property_binder.hpp | 17 ++++------------- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/include/mbgl/util/indexed_tuple.hpp b/include/mbgl/util/indexed_tuple.hpp index ea4fe74624..cd8c0fecbb 100644 --- a/include/mbgl/util/indexed_tuple.hpp +++ b/include/mbgl/util/indexed_tuple.hpp @@ -50,4 +50,7 @@ public: } }; +template +using ExpandToType = T; + } // namespace mbgl diff --git a/src/mbgl/gl/attribute.hpp b/src/mbgl/gl/attribute.hpp index 3763f0a583..6bb38f6102 100644 --- a/src/mbgl/gl/attribute.hpp +++ b/src/mbgl/gl/attribute.hpp @@ -57,18 +57,15 @@ public: static constexpr size_t Dimensions = N; using Value = std::array; - using Location = AttributeLocation; - using Binding = AttributeBinding; - /* Create a binding for this attribute. The `attributeSize` parameter may be used to override the number of components available in the buffer for each vertex. Thus, a buffer with only one float for each vertex can be bound to a `vec2` attribute */ template - static Binding binding(const VertexBuffer& buffer, - std::size_t attributeIndex, - std::size_t attributeSize = N) { + static AttributeBinding binding(const VertexBuffer& buffer, + std::size_t attributeIndex, + std::size_t attributeSize = N) { static_assert(std::is_standard_layout::value, "vertex type must use standard layout"); assert(attributeSize >= 1); assert(attributeSize <= 4); @@ -84,7 +81,7 @@ public: }; } - static optional offsetBinding(const optional& binding, std::size_t vertexOffset) { + static optional offsetBinding(const optional& binding, std::size_t vertexOffset) { assert(vertexOffset <= std::numeric_limits::max()); if (binding) { AttributeBinding result = *binding; @@ -222,10 +219,10 @@ public: using Types = TypeList; using Locations = IndexedTuple< TypeList, - TypeList...>>; + TypeList>...>>; using Bindings = IndexedTuple< TypeList, - TypeList...>>; + TypeList>...>>; using NamedLocations = std::vector>; using Vertex = detail::Vertex; diff --git a/src/mbgl/renderer/paint_property_binder.hpp b/src/mbgl/renderer/paint_property_binder.hpp index aade672ae7..6a0f5e3a46 100644 --- a/src/mbgl/renderer/paint_property_binder.hpp +++ b/src/mbgl/renderer/paint_property_binder.hpp @@ -75,14 +75,12 @@ std::array zoomInterpolatedAttributeValue(const std::array template class PaintPropertyBinder { public: - using Attribute = ZoomInterpolatedAttributeType; - using AttributeBinding = typename Attribute::Binding; virtual ~PaintPropertyBinder() = default; virtual void populateVertexVector(const GeometryTileFeature& feature, std::size_t length) = 0; virtual void upload(gl::Context& context) = 0; - virtual optional attributeBinding(const PossiblyEvaluatedPropertyValue& currentValue) const = 0; + virtual optional attributeBinding(const PossiblyEvaluatedPropertyValue& currentValue) const = 0; virtual float interpolationFactor(float currentZoom) const = 0; virtual T uniformValue(const PossiblyEvaluatedPropertyValue& currentValue) const = 0; @@ -94,9 +92,6 @@ public: template class ConstantPaintPropertyBinder : public PaintPropertyBinder { public: - using Attribute = ZoomInterpolatedAttributeType; - using AttributeBinding = typename Attribute::Binding; - ConstantPaintPropertyBinder(T constant_) : constant(std::move(constant_)) { } @@ -104,7 +99,7 @@ public: void populateVertexVector(const GeometryTileFeature&, std::size_t) override {} void upload(gl::Context&) override {} - optional attributeBinding(const PossiblyEvaluatedPropertyValue&) const override { + optional attributeBinding(const PossiblyEvaluatedPropertyValue&) const override { return {}; } @@ -128,7 +123,6 @@ public: using BaseVertex = gl::detail::Vertex; using Attribute = ZoomInterpolatedAttributeType; - using AttributeBinding = typename Attribute::Binding; SourceFunctionPaintPropertyBinder(style::PropertyExpression expression_, T defaultValue_) : expression(std::move(expression_)), @@ -148,7 +142,7 @@ public: vertexBuffer = context.createVertexBuffer(std::move(vertexVector)); } - optional attributeBinding(const PossiblyEvaluatedPropertyValue& currentValue) const override { + optional attributeBinding(const PossiblyEvaluatedPropertyValue& currentValue) const override { if (currentValue.isConstant()) { return {}; } else { @@ -179,12 +173,9 @@ private: template class CompositeFunctionPaintPropertyBinder : public PaintPropertyBinder { public: - using BaseAttribute = A; - using BaseAttributeValue = typename BaseAttribute::Value; using Attribute = ZoomInterpolatedAttributeType; using AttributeValue = typename Attribute::Value; - using AttributeBinding = typename Attribute::Binding; using Vertex = gl::detail::Vertex; CompositeFunctionPaintPropertyBinder(style::PropertyExpression expression_, float zoom, T defaultValue_) @@ -209,7 +200,7 @@ public: vertexBuffer = context.createVertexBuffer(std::move(vertexVector)); } - optional attributeBinding(const PossiblyEvaluatedPropertyValue& currentValue) const override { + optional attributeBinding(const PossiblyEvaluatedPropertyValue& currentValue) const override { if (currentValue.isConstant()) { return {}; } else { -- cgit v1.2.1