From 4c1d03c257754ecc1555f3e31b3c6ccf45c4bf7b Mon Sep 17 00:00:00 2001 From: Ander Conselvan de Oliveira Date: Mon, 4 Nov 2019 08:12:23 +0200 Subject: [PATCH] [core] Fix MapSnapshotter build failure on Windows MSVC implementation of std::promise is buggy and only works with types that can be default-constructed. To avoid a compilation failure in the instantiation of ask() inside MapSnapshotter::getRegion(), which creates a std::promise, make LatLngBounds' default constructor public. --- benchmark/fixtures/api/cache.db | Bin 1298432 -> 1298432 bytes include/mbgl/util/geo.hpp | 9 ++------- platform/android/src/native_map_view.cpp | 2 +- platform/glfw/glfw_view.cpp | 11 +++++------ src/mbgl/map/transform.cpp | 6 +++--- src/mbgl/map/transform_state.cpp | 6 +----- test/map/map.test.cpp | 4 ++-- test/map/transform.test.cpp | 4 ++-- 8 files changed, 16 insertions(+), 26 deletions(-) diff --git a/benchmark/fixtures/api/cache.db b/benchmark/fixtures/api/cache.db index 64cd376892b0f445f9f64fc2578edcbee71fab52..5978c1659d097248eabf48d180165fe9034a44a4 100644 GIT binary patch delta 308 zcmZoz;NP&oe}WW~ z0Mj-B=D+K~>;ueg2Uyw;u(lmw+jf9mKMy3hapFbB?aT%ozv{tCHgL3U;M}%>>#seC zyX^xP#Jnxsf91gf3fzD7!HfXzD`3XNiMrca8n}P*gSAiKZkxc)fsAbijDPvT3setBounds(bounds); } diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index c39b2c904ab..9a2fefaadeb 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -288,11 +288,10 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, break; case GLFW_KEY_D: { static const std::vector bounds = { - mbgl::LatLngBounds::hull(mbgl::LatLng { -45.0, -170.0 }, mbgl::LatLng { 45.0, 170.0 }), // inside - mbgl::LatLngBounds::hull(mbgl::LatLng { -45.0, -200.0 }, mbgl::LatLng { 45.0, -160.0 }), // left IDL - mbgl::LatLngBounds::hull(mbgl::LatLng { -45.0, 160.0 }, mbgl::LatLng { 45.0, 200.0 }), // right IDL - mbgl::LatLngBounds::unbounded() - }; + mbgl::LatLngBounds::hull(mbgl::LatLng{-45.0, -170.0}, mbgl::LatLng{45.0, 170.0}), // inside + mbgl::LatLngBounds::hull(mbgl::LatLng{-45.0, -200.0}, mbgl::LatLng{45.0, -160.0}), // left IDL + mbgl::LatLngBounds::hull(mbgl::LatLng{-45.0, 160.0}, mbgl::LatLng{45.0, 200.0}), // right IDL + mbgl::LatLngBounds()}; static size_t nextBound = 0u; static mbgl::AnnotationID boundAnnotationID = std::numeric_limits::max(); @@ -301,7 +300,7 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, view->map->setBounds(mbgl::BoundOptions().withLatLngBounds(bound)); - if (bound == mbgl::LatLngBounds::unbounded()) { + if (bound == mbgl::LatLngBounds()) { view->map->removeAnnotation(boundAnnotationID); boundAnnotationID = std::numeric_limits::max(); } else { diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index e88bb5465cd..6b44e633d96 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -83,14 +83,14 @@ void Transform::jumpTo(const CameraOptions& camera) { */ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& animation) { Duration duration = animation.duration.value_or(Duration::zero()); - if (state.bounds == LatLngBounds::unbounded() && !isGestureInProgress() && duration != Duration::zero()) { + if (state.bounds == LatLngBounds() && !isGestureInProgress() && duration != Duration::zero()) { // reuse flyTo, without exaggerated animation, to achieve constant ground speed. return flyTo(camera, animation, true); } const EdgeInsets& padding = camera.padding.value_or(state.edgeInsets); LatLng startLatLng = getLatLng(LatLng::Unwrapped); const LatLng& unwrappedLatLng = camera.center.value_or(startLatLng); - const LatLng& latLng = state.bounds != LatLngBounds::unbounded() ? unwrappedLatLng : unwrappedLatLng.wrapped(); + const LatLng& latLng = state.bounds != LatLngBounds() ? unwrappedLatLng : unwrappedLatLng.wrapped(); double zoom = camera.zoom.value_or(getZoom()); double bearing = camera.bearing ? -*camera.bearing * util::DEG2RAD : getBearing(); double pitch = camera.pitch ? *camera.pitch * util::DEG2RAD : getPitch(); @@ -102,7 +102,7 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim return; } - if (state.bounds == LatLngBounds::unbounded()) { + if (state.bounds == LatLngBounds()) { if (isGestureInProgress()) { // If gesture in progress, we transfer the wrap rounds from the end longitude into // start, so the "scroll effect" of rounding the world is the same while assuring the diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index 61007422cb2..f3cd8c3886b 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -10,11 +10,7 @@ namespace mbgl { TransformState::TransformState(ConstrainMode constrainMode_, ViewportMode viewportMode_) - : bounds(LatLngBounds::unbounded()) - , constrainMode(constrainMode_) - , viewportMode(viewportMode_) -{ -} + : bounds(LatLngBounds()), constrainMode(constrainMode_), viewportMode(viewportMode_) {} #pragma mark - Matrix diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index 0eebc93f32c..9e37f97b8bd 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -316,7 +316,7 @@ TEST(Map, DefaultBoundOptions) { EXPECT_EQ(*bounds.minZoom, util::MIN_ZOOM); EXPECT_EQ(*bounds.maxZoom, util::DEFAULT_MAX_ZOOM); - EXPECT_EQ(*bounds.bounds, LatLngBounds::unbounded()); + EXPECT_EQ(*bounds.bounds, LatLngBounds()); } TEST(Map, MapOptions) { @@ -1053,4 +1053,4 @@ TEST(Map, NoHangOnMissingImage) { test.map.jumpTo(test.map.getStyle().getDefaultCamera()); // The test passes if the following call does not hang. test.frontend.render(test.map); -} \ No newline at end of file +} diff --git a/test/map/transform.test.cpp b/test/map/transform.test.cpp index 84fdb06b211..95fb744206e 100644 --- a/test/map/transform.test.cpp +++ b/test/map/transform.test.cpp @@ -609,7 +609,7 @@ TEST(Transform, LatLngBounds) { transform.jumpTo(CameraOptions().withCenter(LatLng()).withZoom(transform.getState().getMaxZoom())); // Default bounds. - ASSERT_EQ(transform.getState().getLatLngBounds(), LatLngBounds::unbounded()); + ASSERT_EQ(transform.getState().getLatLngBounds(), LatLngBounds()); ASSERT_EQ(transform.getLatLng(), nullIsland); // Invalid bounds. @@ -617,7 +617,7 @@ TEST(Transform, LatLngBounds) { transform.setLatLngBounds(LatLngBounds::empty()); ASSERT_TRUE(false) << "Should throw"; } catch (...) { - ASSERT_EQ(transform.getState().getLatLngBounds(), LatLngBounds::unbounded()); + ASSERT_EQ(transform.getState().getLatLngBounds(), LatLngBounds()); } transform.jumpTo(CameraOptions().withCenter(sanFrancisco));