s/AppliedClassProperties/AppliedClassPropertyValues/
This class stores a list of property values which belongs to the same property.
This commit is contained in:
@@ -2,28 +2,28 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
AppliedClassProperty::AppliedClassProperty(ClassID class_id, const TimePoint& begin_, const TimePoint& end_, const PropertyValue &value_)
|
||||
AppliedClassPropertyValue::AppliedClassPropertyValue(ClassID class_id, const TimePoint& begin_, const TimePoint& end_, const PropertyValue &value_)
|
||||
: name(class_id),
|
||||
begin(begin_),
|
||||
end(end_),
|
||||
value(value_) {}
|
||||
|
||||
// Returns the ID of the most recent
|
||||
ClassID AppliedClassProperties::mostRecent() const {
|
||||
ClassID AppliedClassPropertyValues::mostRecent() const {
|
||||
return propertyValues.empty() ? ClassID::Fallback : propertyValues.back().name;
|
||||
}
|
||||
|
||||
void AppliedClassProperties::add(ClassID class_id, const TimePoint& begin, const TimePoint& end, const PropertyValue &value) {
|
||||
void AppliedClassPropertyValues::add(ClassID class_id, const TimePoint& begin, const TimePoint& end, const PropertyValue &value) {
|
||||
propertyValues.emplace_back(class_id, begin, end, value);
|
||||
}
|
||||
|
||||
bool AppliedClassProperties::hasTransitions() const {
|
||||
bool AppliedClassPropertyValues::hasTransitions() const {
|
||||
return propertyValues.size() > 1;
|
||||
}
|
||||
|
||||
// Erase all items in the property list that are before a completed transition.
|
||||
// Then, if the only remaining property is a Fallback value, remove it too.
|
||||
void AppliedClassProperties::cleanup(const TimePoint& now) {
|
||||
void AppliedClassPropertyValues::cleanup(const TimePoint& now) {
|
||||
// Iterate backwards, but without using the rbegin/rend interface since we need forward
|
||||
// iterators to use .erase().
|
||||
for (auto it = propertyValues.end(), begin = propertyValues.begin(); it != begin;) {
|
||||
@@ -45,7 +45,7 @@ void AppliedClassProperties::cleanup(const TimePoint& now) {
|
||||
}
|
||||
}
|
||||
|
||||
bool AppliedClassProperties::empty() const {
|
||||
bool AppliedClassPropertyValues::empty() const {
|
||||
return propertyValues.empty();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class AppliedClassProperty {
|
||||
class AppliedClassPropertyValue {
|
||||
public:
|
||||
AppliedClassProperty(ClassID class_id, const TimePoint& begin, const TimePoint& end, const PropertyValue &value);
|
||||
AppliedClassPropertyValue(ClassID class_id, const TimePoint& begin, const TimePoint& end, const PropertyValue &value);
|
||||
|
||||
public:
|
||||
const ClassID name;
|
||||
@@ -21,9 +21,9 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class AppliedClassProperties {
|
||||
class AppliedClassPropertyValues {
|
||||
public:
|
||||
std::list<AppliedClassProperty> propertyValues;
|
||||
std::list<AppliedClassPropertyValue> propertyValues;
|
||||
|
||||
public:
|
||||
// Returns the ID of the most recent
|
||||
|
||||
@@ -54,7 +54,7 @@ void StyleLayer::setClasses(const std::vector<std::string> &class_names, const T
|
||||
continue;
|
||||
}
|
||||
|
||||
AppliedClassProperties &appliedProperties = property_pair.second;
|
||||
AppliedClassPropertyValues &appliedProperties = property_pair.second;
|
||||
// Make sure that we don't do double transitions to the fallback value.
|
||||
if (appliedProperties.mostRecent() != ClassID::Fallback) {
|
||||
// This property key hasn't been set by a previous class, so we need to add a transition
|
||||
@@ -93,7 +93,7 @@ void StyleLayer::applyClassProperties(const ClassID class_id,
|
||||
|
||||
// If the most recent transition is not the one with the highest priority, create
|
||||
// a transition.
|
||||
AppliedClassProperties &appliedProperties = appliedStyle[key];
|
||||
AppliedClassPropertyValues &appliedProperties = appliedStyle[key];
|
||||
if (appliedProperties.mostRecent() != class_id) {
|
||||
const PropertyTransition &transition =
|
||||
class_properties.getTransition(key, defaultTransition);
|
||||
@@ -137,7 +137,7 @@ template <typename T>
|
||||
void StyleLayer::applyStyleProperty(PropertyKey key, T &target, const float z, const TimePoint& now, const ZoomHistory &zoomHistory) {
|
||||
auto it = appliedStyle.find(key);
|
||||
if (it != appliedStyle.end()) {
|
||||
AppliedClassProperties &applied = it->second;
|
||||
AppliedClassPropertyValues &applied = it->second;
|
||||
// Iterate through all properties that we need to apply in order.
|
||||
const PropertyEvaluator<T> evaluator(z, zoomHistory);
|
||||
for (auto& property : applied.propertyValues) {
|
||||
@@ -155,7 +155,7 @@ template <typename T>
|
||||
void StyleLayer::applyTransitionedStyleProperty(PropertyKey key, T &target, const float z, const TimePoint& now, const ZoomHistory &zoomHistory) {
|
||||
auto it = appliedStyle.find(key);
|
||||
if (it != appliedStyle.end()) {
|
||||
AppliedClassProperties &applied = it->second;
|
||||
AppliedClassPropertyValues &applied = it->second;
|
||||
// Iterate through all properties that we need to apply in order.
|
||||
const PropertyEvaluator<T> evaluator(z, zoomHistory);
|
||||
for (auto& property : applied.propertyValues) {
|
||||
@@ -273,10 +273,10 @@ bool StyleLayer::hasTransitions() const {
|
||||
|
||||
void StyleLayer::cleanupAppliedStyleProperties(const TimePoint& now) {
|
||||
for (auto it = appliedStyle.begin(); it != appliedStyle.end();) {
|
||||
AppliedClassProperties& appliedPropertyValues = it->second;
|
||||
appliedPropertyValues.cleanup(now);
|
||||
AppliedClassPropertyValues& values = it->second;
|
||||
values.cleanup(now);
|
||||
// If the current properties object is empty, remove it from the map entirely.
|
||||
appliedPropertyValues.empty() ? appliedStyle.erase(it++) : ++it;
|
||||
values.empty() ? appliedStyle.erase(it++) : ++it;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
private:
|
||||
// For every property, stores a list of applied property values, with
|
||||
// optional transition times.
|
||||
std::map<PropertyKey, AppliedClassProperties> appliedStyle;
|
||||
std::map<PropertyKey, AppliedClassPropertyValues> appliedStyle;
|
||||
|
||||
public:
|
||||
// Stores the evaluated, and cascaded styling information, specific to this
|
||||
|
||||
Reference in New Issue
Block a user