diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-12-20 15:04:22 -0200 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2017-01-24 11:36:59 +0200 |
commit | 9ac54eecbacbc7d39026656c8558f317b99c57ed (patch) | |
tree | bc2612ee7e4748987c5c223f5a14f12f398e1e62 | |
parent | 3e2fc894f73e5750ad365d7ca3563d535928a17b (diff) | |
download | qtlocation-mapboxgl-9ac54eecbacbc7d39026656c8558f317b99c57ed.tar.gz |
[gcc4.9] Only do bracket initialization where GCC4.9 can handle it
GCC 4.9 cannot do bracket initialization when one of the attributes
already has a default value.
-rw-r--r-- | include/mbgl/annotation/annotation.hpp | 8 | ||||
-rw-r--r-- | include/mbgl/style/transition_options.hpp | 10 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/annotation/fill_annotation_impl.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/annotation/line_annotation_impl.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/annotation/shape_annotation_impl.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/gl/context.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/gl/texture.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/gl/uniform.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/sprite/sprite_atlas.cpp | 10 | ||||
-rw-r--r-- | src/mbgl/sprite/sprite_atlas.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/style/property_parsing.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/tile/geometry_tile_data.cpp | 5 | ||||
-rw-r--r-- | test/api/annotations.test.cpp | 50 | ||||
-rw-r--r-- | test/map/map.test.cpp | 2 |
15 files changed, 69 insertions, 52 deletions
diff --git a/include/mbgl/annotation/annotation.hpp b/include/mbgl/annotation/annotation.hpp index a72c65b8c4..a84bea1c18 100644 --- a/include/mbgl/annotation/annotation.hpp +++ b/include/mbgl/annotation/annotation.hpp @@ -28,6 +28,10 @@ using ShapeAnnotationGeometry = variant< class LineAnnotation { public: + LineAnnotation(const ShapeAnnotationGeometry &geometry_, const style::PropertyValue<float> &opacity_, + const style::PropertyValue<float> &width_, const style::PropertyValue<Color> &color_) : + geometry(geometry_), opacity(opacity_), width(width_), color(color_) {} + ShapeAnnotationGeometry geometry; style::PropertyValue<float> opacity { 1.0f }; style::PropertyValue<float> width { 1.0f }; @@ -36,6 +40,10 @@ public: class FillAnnotation { public: + FillAnnotation(const ShapeAnnotationGeometry &geometry_, const style::PropertyValue<float> &opacity_, + const style::PropertyValue<Color> &color_, const style::PropertyValue<Color> &outlineColor_) : + geometry(geometry_), opacity(opacity_), color(color_), outlineColor(outlineColor_) {} + ShapeAnnotationGeometry geometry; style::PropertyValue<float> opacity { 1.0f }; style::PropertyValue<Color> color { Color::black() }; diff --git a/include/mbgl/style/transition_options.hpp b/include/mbgl/style/transition_options.hpp index e2a156e665..eab6ef7039 100644 --- a/include/mbgl/style/transition_options.hpp +++ b/include/mbgl/style/transition_options.hpp @@ -12,10 +12,12 @@ public: optional<Duration> delay = {}; TransitionOptions reverseMerge(const TransitionOptions& defaults) const { - return { - duration ? duration : defaults.duration, - delay ? delay : defaults.delay - }; + TransitionOptions options; + + options.duration = duration ? duration : defaults.duration; + options.delay = delay ? delay : defaults.delay; + + return options; } explicit operator bool() const { diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index 86604a945f..5836852ac2 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -845,7 +845,11 @@ void QMapboxGL::setTransitionOptions(qint64 duration, qint64 delay) { return std::chrono::duration_cast<mbgl::Duration>(mbgl::Milliseconds(value)); }; - d_ptr->mapObj->setTransitionOptions(mbgl::style::TransitionOptions{ convert(duration), convert(delay) }); + mbgl::style::TransitionOptions transitionOptions; + transitionOptions.duration = convert(duration); + transitionOptions.delay = convert(delay); + + d_ptr->mapObj->setTransitionOptions(transitionOptions); } mbgl::Annotation fromPointAnnotation(const PointAnnotation &pointAnnotation) { diff --git a/src/mbgl/annotation/fill_annotation_impl.cpp b/src/mbgl/annotation/fill_annotation_impl.cpp index 3e91524e86..061d9044f8 100644 --- a/src/mbgl/annotation/fill_annotation_impl.cpp +++ b/src/mbgl/annotation/fill_annotation_impl.cpp @@ -9,7 +9,7 @@ using namespace style; FillAnnotationImpl::FillAnnotationImpl(AnnotationID id_, FillAnnotation annotation_, uint8_t maxZoom_) : ShapeAnnotationImpl(id_, maxZoom_), - annotation({ ShapeAnnotationGeometry::visit(annotation_.geometry, CloseShapeAnnotation{}), annotation_.opacity, annotation_.color, annotation_.outlineColor }) { + annotation(ShapeAnnotationGeometry::visit(annotation_.geometry, CloseShapeAnnotation{}), annotation_.opacity, annotation_.color, annotation_.outlineColor) { } void FillAnnotationImpl::updateStyle(Style& style) const { diff --git a/src/mbgl/annotation/line_annotation_impl.cpp b/src/mbgl/annotation/line_annotation_impl.cpp index 15fa2c67f3..e01f637641 100644 --- a/src/mbgl/annotation/line_annotation_impl.cpp +++ b/src/mbgl/annotation/line_annotation_impl.cpp @@ -9,7 +9,7 @@ using namespace style; LineAnnotationImpl::LineAnnotationImpl(AnnotationID id_, LineAnnotation annotation_, uint8_t maxZoom_) : ShapeAnnotationImpl(id_, maxZoom_), - annotation({ ShapeAnnotationGeometry::visit(annotation_.geometry, CloseShapeAnnotation{}), annotation_.opacity, annotation_.width, annotation_.color }) { + annotation(ShapeAnnotationGeometry::visit(annotation_.geometry, CloseShapeAnnotation{}), annotation_.opacity, annotation_.width, annotation_.color) { } void LineAnnotationImpl::updateStyle(Style& style) const { diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp index d3ddf62b9e..d0a6f6239e 100644 --- a/src/mbgl/annotation/shape_annotation_impl.cpp +++ b/src/mbgl/annotation/shape_annotation_impl.cpp @@ -24,7 +24,14 @@ void ShapeAnnotationImpl::updateTileData(const CanonicalTileID& tileID, Annotati if (!shapeTiler) { mapbox::geometry::feature_collection<double> features; features.emplace_back(ShapeAnnotationGeometry::visit(geometry(), [] (auto&& geom) { +#if !defined(__GNUC__) || __GNUC__ >= 5 return Feature { std::move(geom) }; +#else + Feature feature; + feature.geometry = std::move(geom); + + return feature; +#endif })); mapbox::geojsonvt::Options options; options.maxZoom = maxZoom; diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp index 093afa20ed..056c262c0f 100644 --- a/src/mbgl/gl/context.hpp +++ b/src/mbgl/gl/context.hpp @@ -91,7 +91,7 @@ public: template <typename Image> Texture createTexture(const Image& image, TextureUnit unit = 0) { auto format = image.channels == 4 ? TextureFormat::RGBA : TextureFormat::Alpha; - return { image.size, createTexture(image.size, image.data.get(), format, unit) }; + return Texture(image.size, [&] { return createTexture(image.size, image.data.get(), format, unit); }); } template <typename Image> @@ -105,7 +105,7 @@ public: Texture createTexture(const Size size, TextureFormat format = TextureFormat::RGBA, TextureUnit unit = 0) { - return { size, createTexture(size, nullptr, format, unit) }; + return Texture(size, [&] { return createTexture(size, nullptr, format, unit); }); } void bindTexture(Texture&, diff --git a/src/mbgl/gl/texture.hpp b/src/mbgl/gl/texture.hpp index 5330689ac2..ffa08ec80a 100644 --- a/src/mbgl/gl/texture.hpp +++ b/src/mbgl/gl/texture.hpp @@ -3,11 +3,15 @@ #include <mbgl/gl/object.hpp> #include <mbgl/util/size.hpp> +#include <functional> + namespace mbgl { namespace gl { class Texture { public: + Texture(Size size_, std::function<UniqueTexture()> getTexture) : size(size_), texture(getTexture()) {} + Size size; UniqueTexture texture; TextureFilter filter = TextureFilter::Nearest; diff --git a/src/mbgl/gl/uniform.hpp b/src/mbgl/gl/uniform.hpp index 726cd4fe10..5c0980baf0 100644 --- a/src/mbgl/gl/uniform.hpp +++ b/src/mbgl/gl/uniform.hpp @@ -28,6 +28,8 @@ public: class State { public: + State(UniformLocation location_) : location(std::move(location_)) {} + void operator=(const Value& value) { if (!current || *current != value.t) { current = value.t; @@ -67,7 +69,7 @@ public: using Values = IndexedTuple<TypeList<Us...>, TypeList<typename Us::Value...>>; static State state(const ProgramID& id) { - return State { { uniformLocation(id, Us::name) }... }; + return State(typename Us::State(uniformLocation(id, Us::name))...); } static std::function<void ()> binder(State& state, Values&& values_) { diff --git a/src/mbgl/sprite/sprite_atlas.cpp b/src/mbgl/sprite/sprite_atlas.cpp index ea055ce5ec..6a5ef97092 100644 --- a/src/mbgl/sprite/sprite_atlas.cpp +++ b/src/mbgl/sprite/sprite_atlas.cpp @@ -224,11 +224,11 @@ optional<SpriteAtlasPosition> SpriteAtlas::getPosition(const std::string& name, const float w = spriteImage->getWidth() * (*img).relativePixelRatio; const float h = spriteImage->getHeight() * (*img).relativePixelRatio; - return SpriteAtlasPosition { - {{ float(spriteImage->getWidth()), spriteImage->getHeight() }}, - {{ float(rect.x + padding) / size.width, float(rect.y + padding) / size.height }}, - {{ float(rect.x + padding + w) / size.width, float(rect.y + padding + h) / size.height }} - }; + return SpriteAtlasPosition( + std::array<float, 2> {{ float(spriteImage->getWidth()), float(spriteImage->getHeight()) }}, + std::array<float, 2> {{ float(rect.x + padding) / size.width, float(rect.y + padding) / size.height }}, + std::array<float, 2> {{ float(rect.x + padding + w) / size.width, float(rect.y + padding + h) / size.height }} + ); } void copyBitmap(const uint32_t *src, const uint32_t srcStride, const uint32_t srcX, const uint32_t srcY, diff --git a/src/mbgl/sprite/sprite_atlas.hpp b/src/mbgl/sprite/sprite_atlas.hpp index c79aec135e..397d1d5233 100644 --- a/src/mbgl/sprite/sprite_atlas.hpp +++ b/src/mbgl/sprite/sprite_atlas.hpp @@ -28,6 +28,7 @@ class SpritePosition; class SpriteAtlasPosition { public: + SpriteAtlasPosition(std::array<float, 2> size_, std::array<float, 2> tl_, std::array<float, 2> br_) : size(std::move(size_)), tl(std::move(tl_)), br(std::move(br_)) {} std::array<float, 2> size = {{ 0, 0 }}; std::array<float, 2> tl = {{ 0, 0 }}; std::array<float, 2> br = {{ 0, 0 }}; diff --git a/src/mbgl/style/property_parsing.cpp b/src/mbgl/style/property_parsing.cpp index 16ce0f4adc..e89e7601d1 100644 --- a/src/mbgl/style/property_parsing.cpp +++ b/src/mbgl/style/property_parsing.cpp @@ -22,7 +22,11 @@ optional<TransitionOptions> parseTransitionOptions(const char *, const JSValue& return {}; } - return TransitionOptions { duration, delay }; + TransitionOptions options; + options.duration = std::move(duration); + options.delay = std::move(delay); + + return options; } } // namespace style diff --git a/src/mbgl/tile/geometry_tile_data.cpp b/src/mbgl/tile/geometry_tile_data.cpp index 2e465a6f65..f891e5aa04 100644 --- a/src/mbgl/tile/geometry_tile_data.cpp +++ b/src/mbgl/tile/geometry_tile_data.cpp @@ -208,7 +208,12 @@ static Feature::geometry_type convertGeometry(const GeometryTileFeature& geometr } Feature convertFeature(const GeometryTileFeature& geometryTileFeature, const CanonicalTileID& tileID) { +#if !defined(__GNUC__) || __GNUC__ >= 5 Feature feature { convertGeometry(geometryTileFeature, tileID) }; +#else + Feature feature; + feature.geometry = convertGeometry(geometryTileFeature, tileID); +#endif feature.properties = geometryTileFeature.getProperties(); feature.id = geometryTileFeature.getID(); return feature; diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp index 72a2d62bde..bfa36b29ef 100644 --- a/test/api/annotations.test.cpp +++ b/test/api/annotations.test.cpp @@ -58,9 +58,7 @@ TEST(Annotations, LineAnnotation) { AnnotationTest test; LineString<double> line = {{ { 0, 0 }, { 45, 45 }, { 30, 0 } }}; - LineAnnotation annotation { line }; - annotation.color = Color::red(); - annotation.width = { 5 }; + LineAnnotation annotation(line, 1.0f, 5, Color::red()); test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotation(annotation); @@ -74,8 +72,7 @@ TEST(Annotations, FillAnnotation) { AnnotationTest test; Polygon<double> polygon = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }}; - FillAnnotation annotation { polygon }; - annotation.color = Color::red(); + FillAnnotation annotation(polygon, 1.0f, Color::red(), {}); test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotation(annotation); @@ -93,14 +90,11 @@ TEST(Annotations, AntimeridianAnnotationSmall) { test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); LineString<double> line = {{ { antimeridian, 20 }, { antimeridian, -20 } }}; - LineAnnotation lineAnnotation { line }; - lineAnnotation.color = Color::red(); - lineAnnotation.width = { 2 }; + LineAnnotation lineAnnotation(line, 1.0f, 2, Color::red()); test.map.addAnnotation(lineAnnotation); Polygon<double> polygon = {{ {{ { antimeridian+10, 0 }, { antimeridian - 10, 10 }, { antimeridian-10, -10 } }} }}; - FillAnnotation polygonAnnotation { polygon }; - polygonAnnotation.color = Color::blue(); + FillAnnotation polygonAnnotation(polygon, 1.0f, Color::blue(), {}); test.map.addAnnotation(polygonAnnotation); test.checkRendering("antimeridian_annotation_small"); @@ -114,14 +108,11 @@ TEST(Annotations, AntimeridianAnnotationLarge) { test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); LineString<double> line = {{ { antimeridian, 20 }, { antimeridian, -20 } }}; - LineAnnotation lineAnnotation { line }; - lineAnnotation.color = Color::red(); - lineAnnotation.width = { 2 }; + LineAnnotation lineAnnotation(line, 1.0f, 2, Color::red()); test.map.addAnnotation(lineAnnotation); Polygon<double> polygon = {{ {{ { antimeridian-10, 0 }, { -antimeridian+10, 10 }, { -antimeridian+10, -10 } }} }}; - FillAnnotation polygonAnnotation { polygon }; - polygonAnnotation.color = Color::blue(); + FillAnnotation polygonAnnotation(polygon, 1.0f, Color::blue(), {}); test.map.addAnnotation(polygonAnnotation); test.checkRendering("antimeridian_annotation_large"); @@ -131,10 +122,8 @@ TEST(Annotations, OverlappingFillAnnotation) { AnnotationTest test; Polygon<double> polygon = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }}; - FillAnnotation underlaidAnnotation { polygon }; - underlaidAnnotation.color = Color::green(); - FillAnnotation overlaidAnnotation { polygon }; - overlaidAnnotation.color = Color::red(); + FillAnnotation underlaidAnnotation(polygon, 1.0f, Color::green(), {}); + FillAnnotation overlaidAnnotation(polygon, 1.0f, Color::red(), {}); test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); test.map.addAnnotation(underlaidAnnotation); @@ -172,8 +161,7 @@ TEST(Annotations, NonImmediateAdd) { test::render(test.map, test.view); Polygon<double> polygon = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }}; - FillAnnotation annotation { polygon }; - annotation.color = Color::red(); + FillAnnotation annotation(polygon, 1.0f, Color::red(), {}); test.map.addAnnotation(annotation); test.checkRendering("non_immediate_add"); @@ -210,9 +198,7 @@ TEST(Annotations, UpdateSymbolAnnotationIcon) { TEST(Annotations, UpdateLineAnnotationGeometry) { AnnotationTest test; - LineAnnotation annotation { LineString<double> {{ { 0, 0 }, { 45, 45 }, { 30, 0 } }} }; - annotation.color = Color::red(); - annotation.width = { 5 }; + LineAnnotation annotation(LineString<double> {{ { 0, 0 }, { 45, 45 }, { 30, 0 } }}, 1.0f, 5, Color::red()); test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); AnnotationID line = test.map.addAnnotation(annotation); @@ -227,9 +213,7 @@ TEST(Annotations, UpdateLineAnnotationGeometry) { TEST(Annotations, UpdateLineAnnotationStyle) { AnnotationTest test; - LineAnnotation annotation { LineString<double> {{ { 0, 0 }, { 45, 45 }, { 30, 0 } }} }; - annotation.color = Color::red(); - annotation.width = { 5 }; + LineAnnotation annotation(LineString<double> {{ { 0, 0 }, { 45, 45 }, { 30, 0 } }}, 1.0f, 5, Color::red()); test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); AnnotationID line = test.map.addAnnotation(annotation); @@ -245,8 +229,7 @@ TEST(Annotations, UpdateLineAnnotationStyle) { TEST(Annotations, UpdateFillAnnotationGeometry) { AnnotationTest test; - FillAnnotation annotation { Polygon<double> {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }} }; - annotation.color = Color::red(); + FillAnnotation annotation(Polygon<double> {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }}, 1.0f, Color::red(), {}); test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); AnnotationID fill = test.map.addAnnotation(annotation); @@ -262,8 +245,7 @@ TEST(Annotations, UpdateFillAnnotationStyle) { AnnotationTest test; Polygon<double> polygon = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }}; - FillAnnotation annotation { polygon }; - annotation.color = Color::red(); + FillAnnotation annotation(polygon, 1.0f, Color::red(), {}); test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); AnnotationID fill = test.map.addAnnotation(annotation); @@ -292,9 +274,7 @@ TEST(Annotations, RemoveShape) { AnnotationTest test; LineString<double> line = {{ { 0, 0 }, { 45, 45 } }}; - LineAnnotation annotation { line }; - annotation.color = Color::red(); - annotation.width = { 5 }; + LineAnnotation annotation(line, 1.0f, 5, Color::red()); test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); AnnotationID shape = test.map.addAnnotation(annotation); @@ -308,7 +288,7 @@ TEST(Annotations, RemoveShape) { TEST(Annotations, ImmediateRemoveShape) { AnnotationTest test; - test.map.removeAnnotation(test.map.addAnnotation(LineAnnotation { LineString<double>() })); + test.map.removeAnnotation(test.map.addAnnotation(LineAnnotation(LineString<double>(), 1.0f, 1.0f, {}))); test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); test::render(test.map, test.view); diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index 8eedeb3c01..31995d16e0 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -199,7 +199,7 @@ TEST(Map, StyleExpiredWithAnnotations) { fileSource.respond(Resource::Style, response); EXPECT_EQ(1u, fileSource.requests.size()); - map.addAnnotation(LineAnnotation { LineString<double> {{ { 0, 0 }, { 10, 10 } }} }); + map.addAnnotation(LineAnnotation(LineString<double> {{ { 0, 0 }, { 10, 10 } }}, 1.0f, 1.0f, {})); EXPECT_EQ(1u, fileSource.requests.size()); fileSource.respond(Resource::Style, response); |