summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2018-05-31 14:41:10 +0200
committerMolly Lloyd <mollymerp@users.noreply.github.com>2018-08-31 13:08:47 -0700
commitabc5043339d1aa8eb25e449248ae5a95e00835a3 (patch)
treec2dc30d9ae6e9a5ce5c72bb0339a80e19dd5bbd0 /src
parent0dac3bc60c549c46f341984439d6fd007fe2ffe6 (diff)
downloadqtlocation-mapboxgl-abc5043339d1aa8eb25e449248ae5a95e00835a3.tar.gz
[core] simplify attribute/location types
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/gl/attribute.hpp15
-rw-r--r--src/mbgl/renderer/paint_property_binder.hpp17
2 files changed, 10 insertions, 22 deletions
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<T, N>;
- 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 <class Vertex, class DrawMode>
- static Binding binding(const VertexBuffer<Vertex, DrawMode>& buffer,
- std::size_t attributeIndex,
- std::size_t attributeSize = N) {
+ static AttributeBinding binding(const VertexBuffer<Vertex, DrawMode>& buffer,
+ std::size_t attributeIndex,
+ std::size_t attributeSize = N) {
static_assert(std::is_standard_layout<Vertex>::value, "vertex type must use standard layout");
assert(attributeSize >= 1);
assert(attributeSize <= 4);
@@ -84,7 +81,7 @@ public:
};
}
- static optional<Binding> offsetBinding(const optional<Binding>& binding, std::size_t vertexOffset) {
+ static optional<AttributeBinding> offsetBinding(const optional<AttributeBinding>& binding, std::size_t vertexOffset) {
assert(vertexOffset <= std::numeric_limits<uint32_t>::max());
if (binding) {
AttributeBinding result = *binding;
@@ -222,10 +219,10 @@ public:
using Types = TypeList<As...>;
using Locations = IndexedTuple<
TypeList<As...>,
- TypeList<optional<typename As::Type::Location>...>>;
+ TypeList<ExpandToType<As, optional<AttributeLocation>>...>>;
using Bindings = IndexedTuple<
TypeList<As...>,
- TypeList<optional<typename As::Type::Binding>...>>;
+ TypeList<ExpandToType<As, optional<AttributeBinding>>...>>;
using NamedLocations = std::vector<std::pair<const std::string, AttributeLocation>>;
using Vertex = detail::Vertex<typename As::Type...>;
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<float, N*2> zoomInterpolatedAttributeValue(const std::array<float, N>
template <class T, class A>
class PaintPropertyBinder {
public:
- using Attribute = ZoomInterpolatedAttributeType<A>;
- 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> attributeBinding(const PossiblyEvaluatedPropertyValue<T>& currentValue) const = 0;
+ virtual optional<gl::AttributeBinding> attributeBinding(const PossiblyEvaluatedPropertyValue<T>& currentValue) const = 0;
virtual float interpolationFactor(float currentZoom) const = 0;
virtual T uniformValue(const PossiblyEvaluatedPropertyValue<T>& currentValue) const = 0;
@@ -94,9 +92,6 @@ public:
template <class T, class A>
class ConstantPaintPropertyBinder : public PaintPropertyBinder<T, A> {
public:
- using Attribute = ZoomInterpolatedAttributeType<A>;
- 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> attributeBinding(const PossiblyEvaluatedPropertyValue<T>&) const override {
+ optional<gl::AttributeBinding> attributeBinding(const PossiblyEvaluatedPropertyValue<T>&) const override {
return {};
}
@@ -128,7 +123,6 @@ public:
using BaseVertex = gl::detail::Vertex<BaseAttribute>;
using Attribute = ZoomInterpolatedAttributeType<A>;
- using AttributeBinding = typename Attribute::Binding;
SourceFunctionPaintPropertyBinder(style::PropertyExpression<T> expression_, T defaultValue_)
: expression(std::move(expression_)),
@@ -148,7 +142,7 @@ public:
vertexBuffer = context.createVertexBuffer(std::move(vertexVector));
}
- optional<AttributeBinding> attributeBinding(const PossiblyEvaluatedPropertyValue<T>& currentValue) const override {
+ optional<gl::AttributeBinding> attributeBinding(const PossiblyEvaluatedPropertyValue<T>& currentValue) const override {
if (currentValue.isConstant()) {
return {};
} else {
@@ -179,12 +173,9 @@ private:
template <class T, class A>
class CompositeFunctionPaintPropertyBinder : public PaintPropertyBinder<T, A> {
public:
- using BaseAttribute = A;
- using BaseAttributeValue = typename BaseAttribute::Value;
using Attribute = ZoomInterpolatedAttributeType<A>;
using AttributeValue = typename Attribute::Value;
- using AttributeBinding = typename Attribute::Binding;
using Vertex = gl::detail::Vertex<Attribute>;
CompositeFunctionPaintPropertyBinder(style::PropertyExpression<T> expression_, float zoom, T defaultValue_)
@@ -209,7 +200,7 @@ public:
vertexBuffer = context.createVertexBuffer(std::move(vertexVector));
}
- optional<AttributeBinding> attributeBinding(const PossiblyEvaluatedPropertyValue<T>& currentValue) const override {
+ optional<gl::AttributeBinding> attributeBinding(const PossiblyEvaluatedPropertyValue<T>& currentValue) const override {
if (currentValue.isConstant()) {
return {};
} else {