summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-06-12 15:21:15 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-06-15 07:43:51 -0700
commit5a8729182652a5cb4d78644a5b9b9a2a2ff343b6 (patch)
tree32a946fe3e728a4436d720058bd98c364f7760ac /src
parentae5b0391b62b537ba6813df54221283685edd6f2 (diff)
downloadqtlocation-mapboxgl-5a8729182652a5cb4d78644a5b9b9a2a2ff343b6.tar.gz
[core] Obey "transition" property from style and its default value
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/renderer/painter.cpp4
-rw-r--r--src/mbgl/renderer/render_style.cpp2
-rw-r--r--src/mbgl/style/parser.cpp15
-rw-r--r--src/mbgl/style/parser.hpp2
-rw-r--r--src/mbgl/style/style.cpp1
5 files changed, 21 insertions, 3 deletions
diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp
index 1f55c168a6..edec98047d 100644
--- a/src/mbgl/renderer/painter.cpp
+++ b/src/mbgl/renderer/painter.cpp
@@ -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 -------------------------------------------------------------------------------
diff --git a/src/mbgl/renderer/render_style.cpp b/src/mbgl/renderer/render_style.cpp
index c8918fc2ee..589a493621 100644
--- a/src/mbgl/renderer/render_style.cpp
+++ b/src/mbgl/renderer/render_style.cpp
@@ -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 {
diff --git a/src/mbgl/style/parser.cpp b/src/mbgl/style/parser.cpp
index 725feb3fc2..467b44632c 100644
--- a/src/mbgl/style/parser.cpp
+++ b/src/mbgl/style/parser.cpp
@@ -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);
diff --git a/src/mbgl/style/parser.hpp b/src/mbgl/style/parser.hpp
index 32b8a7a8bc..401b5ff513 100644
--- a/src/mbgl/style/parser.hpp
+++ b/src/mbgl/style/parser.hpp
@@ -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&);
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index 27ca58e85d..94e003df51 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -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);