#include #include #include namespace mbgl { namespace style { template Faded CrossFadedPropertyEvaluator::operator()(const Undefined&) const { return calculate(defaultValue, defaultValue, defaultValue); } template Faded CrossFadedPropertyEvaluator::operator()(const T& constant) const { return calculate(constant, constant, constant); } template T getBiggestStopLessThan(const Function& function, float z) { const auto& stops = function.getStops(); for (uint32_t i = 0; i < stops.size(); i++) { if (stops[i].first > z) { return stops[i == 0 ? i : i - 1].second; } } return stops.at(stops.size() - 1).second; } template Faded CrossFadedPropertyEvaluator::operator()(const Function& function) const { return calculate(getBiggestStopLessThan(function, parameters.z - 1.0f), getBiggestStopLessThan(function, parameters.z), getBiggestStopLessThan(function, parameters.z + 1.0f)); } template Faded CrossFadedPropertyEvaluator::calculate(const T& min, const T& mid, const T& max) const { const float z = parameters.z; const float fraction = z - std::floor(z); const std::chrono::duration d = parameters.defaultFadeDuration; const float t = std::min((parameters.now - parameters.zoomHistory.lastIntegerZoomTime) / d, 1.0f); return z > parameters.zoomHistory.lastIntegerZoom ? Faded { min, mid, 2.0f, 1.0f, fraction + (1.0f - fraction) * t } : Faded { max, mid, 0.5f, 1.0f, 1 - (1 - t) * fraction }; } template class CrossFadedPropertyEvaluator; template class CrossFadedPropertyEvaluator>; } // namespace style } // namespace mbgl