[core] Obey "transition" property from style and its default value
This commit is contained in:
@@ -40,7 +40,7 @@ constexpr float MAX_ZOOM_F = MAX_ZOOM;
|
||||
|
||||
constexpr uint64_t DEFAULT_MAX_CACHE_SIZE = 50 * 1024 * 1024;
|
||||
|
||||
constexpr Duration DEFAULT_FADE_DURATION = Milliseconds(300);
|
||||
constexpr Duration DEFAULT_TRANSITION_DURATION = Milliseconds(300);
|
||||
constexpr Seconds CLOCK_SKEW_RETRY_TIMEOUT { 30 };
|
||||
|
||||
constexpr UnitBezier DEFAULT_TRANSITION_EASE = { 0, 0, 0.25, 1 };
|
||||
|
||||
@@ -115,7 +115,7 @@ Painter::Painter(gl::Context& context_,
|
||||
Painter::~Painter() = default;
|
||||
|
||||
bool Painter::needsAnimation() const {
|
||||
return frameHistory.needsAnimation(util::DEFAULT_FADE_DURATION);
|
||||
return frameHistory.needsAnimation(util::DEFAULT_TRANSITION_DURATION);
|
||||
}
|
||||
|
||||
void Painter::cleanup() {
|
||||
@@ -159,7 +159,7 @@ void Painter::render(RenderStyle& style, const FrameData& frame_, View& view) {
|
||||
}
|
||||
|
||||
frameHistory.record(frame.timePoint, state.getZoom(),
|
||||
frame.mapMode == MapMode::Continuous ? util::DEFAULT_FADE_DURATION : Milliseconds(0));
|
||||
frame.mapMode == MapMode::Continuous ? util::DEFAULT_TRANSITION_DURATION : Milliseconds(0));
|
||||
|
||||
|
||||
// - UPLOAD PASS -------------------------------------------------------------------------------
|
||||
|
||||
@@ -88,7 +88,7 @@ void RenderStyle::update(const UpdateParameters& parameters) {
|
||||
const PropertyEvaluationParameters evaluationParameters {
|
||||
zoomHistory,
|
||||
parameters.mode == MapMode::Continuous ? parameters.timePoint : Clock::time_point::max(),
|
||||
parameters.mode == MapMode::Continuous ? util::DEFAULT_FADE_DURATION : Duration::zero()
|
||||
parameters.mode == MapMode::Continuous ? util::DEFAULT_TRANSITION_DURATION : Duration::zero()
|
||||
};
|
||||
|
||||
const TileParameters tileParameters {
|
||||
|
||||
@@ -86,6 +86,10 @@ StyleParseResult Parser::parse(const std::string& json) {
|
||||
}
|
||||
}
|
||||
|
||||
if (document.HasMember("transition")) {
|
||||
parseTransition(document["transition"]);
|
||||
}
|
||||
|
||||
if (document.HasMember("light")) {
|
||||
parseLight(document["light"]);
|
||||
}
|
||||
@@ -115,6 +119,17 @@ StyleParseResult Parser::parse(const std::string& json) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Parser::parseTransition(const JSValue& value) {
|
||||
conversion::Error error;
|
||||
optional<TransitionOptions> converted = conversion::convert<TransitionOptions>(value, error);
|
||||
if (!converted) {
|
||||
Log::Warning(Event::ParseStyle, error.message);
|
||||
return;
|
||||
}
|
||||
|
||||
transition = std::move(*converted);
|
||||
}
|
||||
|
||||
void Parser::parseLight(const JSValue& value) {
|
||||
conversion::Error error;
|
||||
optional<Light> converted = conversion::convert<Light>(value, error);
|
||||
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
std::vector<std::unique_ptr<Source>> sources;
|
||||
std::vector<std::unique_ptr<Layer>> layers;
|
||||
|
||||
TransitionOptions transition;
|
||||
Light light;
|
||||
|
||||
std::string name;
|
||||
@@ -44,6 +45,7 @@ public:
|
||||
std::vector<FontStack> fontStacks() const;
|
||||
|
||||
private:
|
||||
void parseTransition(const JSValue&);
|
||||
void parseLight(const JSValue&);
|
||||
void parseSources(const JSValue&);
|
||||
void parseLayers(const JSValue&);
|
||||
|
||||
@@ -57,6 +57,7 @@ void Style::setJSON(const std::string& json) {
|
||||
images.clear();
|
||||
|
||||
transitionOptions = {};
|
||||
transitionOptions.duration = util::DEFAULT_TRANSITION_DURATION;
|
||||
|
||||
Parser parser;
|
||||
auto error = parser.parse(json);
|
||||
|
||||
Reference in New Issue
Block a user