* 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)
66 lines
1.8 KiB
C++
66 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <mbgl/util/variant.hpp>
|
|
#include <mbgl/style/undefined.hpp>
|
|
#include <mbgl/style/function/camera_function.hpp>
|
|
#include <mbgl/style/function/source_function.hpp>
|
|
#include <mbgl/style/function/composite_function.hpp>
|
|
|
|
namespace mbgl {
|
|
namespace style {
|
|
|
|
template <class T>
|
|
class DataDrivenPropertyValue {
|
|
private:
|
|
using Value = variant<
|
|
Undefined,
|
|
T,
|
|
CameraFunction<T>,
|
|
SourceFunction<T>,
|
|
CompositeFunction<T>>;
|
|
|
|
Value value;
|
|
|
|
friend bool operator==(const DataDrivenPropertyValue& lhs,
|
|
const DataDrivenPropertyValue& rhs) {
|
|
return lhs.value == rhs.value;
|
|
}
|
|
|
|
friend bool operator!=(const DataDrivenPropertyValue& lhs,
|
|
const DataDrivenPropertyValue& rhs) {
|
|
return !(lhs == rhs);
|
|
}
|
|
|
|
public:
|
|
DataDrivenPropertyValue() = default;
|
|
DataDrivenPropertyValue( T v) : value(std::move(v)) {}
|
|
DataDrivenPropertyValue( CameraFunction<T> v) : value(std::move(v)) {}
|
|
DataDrivenPropertyValue( SourceFunction<T> v) : value(std::move(v)) {}
|
|
DataDrivenPropertyValue(CompositeFunction<T> v) : value(std::move(v)) {}
|
|
|
|
bool isUndefined() const {
|
|
return value.template is<Undefined>();
|
|
}
|
|
|
|
bool isDataDriven() const {
|
|
return value.template is<SourceFunction<T>>() || value.template is<CompositeFunction<T>>();
|
|
}
|
|
|
|
bool isZoomConstant() const {
|
|
return !value.template is<CameraFunction<T>>() && !value.template is<CompositeFunction<T>>();
|
|
}
|
|
|
|
template <class... Ts>
|
|
auto match(Ts&&... ts) const {
|
|
return value.match(std::forward<Ts>(ts)...);
|
|
}
|
|
|
|
template <typename Evaluator>
|
|
auto evaluate(const Evaluator& evaluator) const {
|
|
return Value::visit(value, evaluator);
|
|
}
|
|
};
|
|
|
|
} // namespace style
|
|
} // namespace mbgl
|