From 874fa41c128c2c3c7e075b0dcde727d6cf678866 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Mon, 6 Jun 2016 16:18:46 +0300 Subject: [PATCH 01/31] [android] Do not use lock-free types on Android They are not supported by ARMv5 and the compiler is generating bogus code. std::atomic might be implemented lock-free for some types, but we are going to introduce a naive polyfill to make sure that doesn't happen on ARMv5 (only). --- platform/android/src/async_task.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/platform/android/src/async_task.cpp b/platform/android/src/async_task.cpp index 4a68c1c09..7b78eadb0 100644 --- a/platform/android/src/async_task.cpp +++ b/platform/android/src/async_task.cpp @@ -12,7 +12,7 @@ namespace util { class AsyncTask::Impl : public RunLoop::Impl::Runnable { public: Impl(std::function&& fn) - : task(std::move(fn)) { + : queued(true), task(std::move(fn)) { loop->initRunnable(this); } @@ -21,7 +21,8 @@ public: } void maySend() { - if (!queued.test_and_set()) { + if (queued) { + queued = false; loop->addRunnable(this); } } @@ -32,7 +33,7 @@ public: void runTask() override { loop->removeRunnable(this); - queued.clear(); + queued = true; task(); } @@ -42,7 +43,9 @@ private: RunLoop::Impl* loop = reinterpret_cast(RunLoop::getLoopHandle()); - std::atomic_flag queued = ATOMIC_FLAG_INIT; + // TODO: Use std::atomic_flag if we ever drop + // support for ARMv5 + std::atomic queued; std::function task; }; From 7b8698b47a0ff5c4adaf474e47f89434f287f183 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Fri, 3 Jun 2016 16:40:15 +0300 Subject: [PATCH 02/31] [core] Naive atomic type for ARMv5 std::atomic is implemented lock free which doesn't work on ARMv5 and seems like the compiler is generating bogus code. This workaround is a naive implementation using regular mutexes. --- include/mbgl/storage/network_status.hpp | 5 +-- include/mbgl/util/run_loop.hpp | 10 +++--- platform/android/src/async_task.cpp | 4 +-- platform/android/src/run_loop_impl.hpp | 4 +-- src/mbgl/geometry/glyph_atlas.hpp | 4 +-- src/mbgl/renderer/bucket.hpp | 5 ++- src/mbgl/sprite/sprite_atlas.hpp | 4 +-- src/mbgl/storage/network_status.cpp | 2 +- src/mbgl/style/bucket_parameters.hpp | 6 ++-- src/mbgl/text/glyph_pbf.hpp | 4 +-- src/mbgl/tile/tile_worker.cpp | 2 +- src/mbgl/tile/tile_worker.hpp | 6 ++-- src/mbgl/tile/vector_tile_data.hpp | 4 +-- src/mbgl/util/atomic.hpp | 45 +++++++++++++++++++++++++ src/mbgl/util/thread.hpp | 1 + 15 files changed, 76 insertions(+), 30 deletions(-) create mode 100644 src/mbgl/util/atomic.hpp diff --git a/include/mbgl/storage/network_status.hpp b/include/mbgl/storage/network_status.hpp index d7f502a3b..1b5471a44 100644 --- a/include/mbgl/storage/network_status.hpp +++ b/include/mbgl/storage/network_status.hpp @@ -1,6 +1,7 @@ #pragma once -#include +#include + #include #include @@ -26,7 +27,7 @@ public: static void Unsubscribe(util::AsyncTask* async); private: - static std::atomic online; + static util::Atomic online; static std::mutex mtx; static std::set observers; }; diff --git a/include/mbgl/util/run_loop.hpp b/include/mbgl/util/run_loop.hpp index 9703fe7bc..56965c97e 100644 --- a/include/mbgl/util/run_loop.hpp +++ b/include/mbgl/util/run_loop.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -9,7 +10,6 @@ #include #include #include -#include namespace mbgl { namespace util { @@ -59,7 +59,7 @@ public: template std::unique_ptr invokeCancellable(Fn&& fn, Args&&... args) { - auto flag = std::make_shared>(); + auto flag = std::make_shared>(); *flag = false; auto tuple = std::make_tuple(std::move(args)...); @@ -77,7 +77,7 @@ public: template std::unique_ptr invokeWithCallback(Fn&& fn, Cb&& callback, Args&&... args) { - auto flag = std::make_shared>(); + auto flag = std::make_shared>(); *flag = false; // Create a lambda L1 that invokes another lambda L2 on the current RunLoop R, that calls @@ -114,7 +114,7 @@ private: template class Invoker : public WorkTask { public: - Invoker(F&& f, P&& p, std::shared_ptr> canceled_ = nullptr) + Invoker(F&& f, P&& p, std::shared_ptr> canceled_ = nullptr) : canceled(std::move(canceled_)), func(std::move(f)), params(std::move(p)) { @@ -148,7 +148,7 @@ private: } std::recursive_mutex mutex; - std::shared_ptr> canceled; + std::shared_ptr> canceled; F func; P params; diff --git a/platform/android/src/async_task.cpp b/platform/android/src/async_task.cpp index 7b78eadb0..6a9263baf 100644 --- a/platform/android/src/async_task.cpp +++ b/platform/android/src/async_task.cpp @@ -1,9 +1,9 @@ #include "run_loop_impl.hpp" #include +#include #include -#include #include namespace mbgl { @@ -45,7 +45,7 @@ private: // TODO: Use std::atomic_flag if we ever drop // support for ARMv5 - std::atomic queued; + util::Atomic queued; std::function task; }; diff --git a/platform/android/src/run_loop_impl.hpp b/platform/android/src/run_loop_impl.hpp index 5cf723117..d855728b6 100644 --- a/platform/android/src/run_loop_impl.hpp +++ b/platform/android/src/run_loop_impl.hpp @@ -2,10 +2,10 @@ #include "jni.hpp" +#include #include #include -#include #include #include #include @@ -47,7 +47,7 @@ private: bool detach = false; ALooper* loop = nullptr; - std::atomic running; + util::Atomic running; std::recursive_mutex mtx; std::list runnables; diff --git a/src/mbgl/geometry/glyph_atlas.hpp b/src/mbgl/geometry/glyph_atlas.hpp index d4a51761a..d3e2a6219 100644 --- a/src/mbgl/geometry/glyph_atlas.hpp +++ b/src/mbgl/geometry/glyph_atlas.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -11,7 +12,6 @@ #include #include #include -#include namespace mbgl { @@ -53,7 +53,7 @@ private: BinPack bin; std::unordered_map, FontStackHash> index; const std::unique_ptr data; - std::atomic dirty; + util::Atomic dirty; mbgl::optional texture; }; diff --git a/src/mbgl/renderer/bucket.hpp b/src/mbgl/renderer/bucket.hpp index c7ebe480e..f12ed1fb9 100644 --- a/src/mbgl/renderer/bucket.hpp +++ b/src/mbgl/renderer/bucket.hpp @@ -2,11 +2,10 @@ #include #include +#include #include #include -#include - #define BUFFER_OFFSET_0 ((GLbyte*)nullptr) #define BUFFER_OFFSET(i) ((BUFFER_OFFSET_0) + (i)) @@ -50,7 +49,7 @@ public: virtual void swapRenderData() {} protected: - std::atomic uploaded; + util::Atomic uploaded; }; diff --git a/src/mbgl/sprite/sprite_atlas.hpp b/src/mbgl/sprite/sprite_atlas.hpp index 249b863c9..3d91f5c9d 100644 --- a/src/mbgl/sprite/sprite_atlas.hpp +++ b/src/mbgl/sprite/sprite_atlas.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -10,7 +11,6 @@ #include #include #include -#include #include #include @@ -92,7 +92,7 @@ private: std::map images; std::set uninitialized; std::unique_ptr data; - std::atomic dirty; + util::Atomic dirty; bool fullUploadRequired = true; mbgl::optional texture; uint32_t filter = 0; diff --git a/src/mbgl/storage/network_status.cpp b/src/mbgl/storage/network_status.cpp index 1ef5619bd..bc538a5f3 100644 --- a/src/mbgl/storage/network_status.cpp +++ b/src/mbgl/storage/network_status.cpp @@ -9,7 +9,7 @@ namespace mbgl { -std::atomic NetworkStatus::online(true); +util::Atomic NetworkStatus::online(true); std::mutex NetworkStatus::mtx; std::set NetworkStatus::observers; diff --git a/src/mbgl/style/bucket_parameters.hpp b/src/mbgl/style/bucket_parameters.hpp index f85e1e17e..8c1da72f2 100644 --- a/src/mbgl/style/bucket_parameters.hpp +++ b/src/mbgl/style/bucket_parameters.hpp @@ -3,9 +3,9 @@ #include #include #include +#include #include -#include namespace mbgl { @@ -24,7 +24,7 @@ class BucketParameters { public: BucketParameters(const OverscaledTileID& tileID_, const GeometryTileLayer& layer_, - const std::atomic& obsolete_, + const util::Atomic& obsolete_, uintptr_t tileUID_, bool& partialParse_, SpriteStore& spriteStore_, @@ -51,7 +51,7 @@ public: const OverscaledTileID& tileID; const GeometryTileLayer& layer; - const std::atomic& obsolete; + const util::Atomic& obsolete; uintptr_t tileUID; bool& partialParse; SpriteStore& spriteStore; diff --git a/src/mbgl/text/glyph_pbf.hpp b/src/mbgl/text/glyph_pbf.hpp index 85f4b62e6..c238cbb5d 100644 --- a/src/mbgl/text/glyph_pbf.hpp +++ b/src/mbgl/text/glyph_pbf.hpp @@ -2,10 +2,10 @@ #include #include +#include #include #include -#include #include #include #include @@ -29,7 +29,7 @@ public: } private: - std::atomic parsed; + util::Atomic parsed; std::unique_ptr req; GlyphStoreObserver* observer = nullptr; }; diff --git a/src/mbgl/tile/tile_worker.cpp b/src/mbgl/tile/tile_worker.cpp index b2283043d..1890aa7c4 100644 --- a/src/mbgl/tile/tile_worker.cpp +++ b/src/mbgl/tile/tile_worker.cpp @@ -24,7 +24,7 @@ TileWorker::TileWorker(const OverscaledTileID& id_, SpriteStore& spriteStore_, GlyphAtlas& glyphAtlas_, GlyphStore& glyphStore_, - const std::atomic& obsolete_, + const util::Atomic& obsolete_, const MapMode mode_) : id(id_), sourceID(std::move(sourceID_)), diff --git a/src/mbgl/tile/tile_worker.hpp b/src/mbgl/tile/tile_worker.hpp index 2757c0f9b..631a8c929 100644 --- a/src/mbgl/tile/tile_worker.hpp +++ b/src/mbgl/tile/tile_worker.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -12,7 +13,6 @@ #include #include #include -#include #include namespace mbgl { @@ -50,7 +50,7 @@ public: SpriteStore&, GlyphAtlas&, GlyphStore&, - const std::atomic&, + const util::Atomic&, const MapMode); ~TileWorker(); @@ -75,7 +75,7 @@ private: SpriteStore& spriteStore; GlyphAtlas& glyphAtlas; GlyphStore& glyphStore; - const std::atomic& obsolete; + const util::Atomic& obsolete; const MapMode mode; bool partialParse = false; diff --git a/src/mbgl/tile/vector_tile_data.hpp b/src/mbgl/tile/vector_tile_data.hpp index e7de39e03..df2a23fda 100644 --- a/src/mbgl/tile/vector_tile_data.hpp +++ b/src/mbgl/tile/vector_tile_data.hpp @@ -3,9 +3,9 @@ #include #include #include +#include #include -#include #include #include @@ -69,7 +69,7 @@ private: PlacementConfig targetConfig; // Used to signal the worker that it should abandon parsing this tile as soon as possible. - std::atomic obsolete { false }; + util::Atomic obsolete { false }; }; } // namespace mbgl diff --git a/src/mbgl/util/atomic.hpp b/src/mbgl/util/atomic.hpp new file mode 100644 index 000000000..3f68bf46a --- /dev/null +++ b/src/mbgl/util/atomic.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include +#include + +namespace mbgl { +namespace util { + +// std::atomic is implemented lock free which +// is not supported by ARMv5 but the code generated +// seems to be using that and not working at all, +// thus, this naive implementation using mutexes. +#if defined(__ANDROID__) && defined(__ARM_ARCH_5TE__) + +template +class Atomic { +public: + Atomic() = default; + explicit Atomic(const T& data_) : data(data_) {} + + void operator=(const T& other) { + std::lock_guard lock(mtx); + data = other; + } + + operator bool() const { + std::lock_guard lock(mtx); + + return data; + } + +private: + T data; + mutable std::mutex mtx; +}; + +#else + +template +using Atomic = std::atomic; + +#endif + +} // namespace util +} // namespace mbgl diff --git a/src/mbgl/util/thread.hpp b/src/mbgl/util/thread.hpp index 9efd5ea92..c5f9d7338 100644 --- a/src/mbgl/util/thread.hpp +++ b/src/mbgl/util/thread.hpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include From 313d9ce09c53d3d946a7150b7998f1b081612ff9 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Mon, 6 Jun 2016 16:11:22 +0300 Subject: [PATCH 03/31] [core] log2 polyfill for ARMv5 ARMv5 doesn't have a FPU and apparently the soft code for log2() is wrong and giving weird results. log() works, so we use a log() based log2() implementation for ARMv5. --- src/mbgl/map/map.cpp | 2 +- src/mbgl/map/transform_state.cpp | 2 +- src/mbgl/util/math.cpp | 12 +++++++++++- src/mbgl/util/math.hpp | 2 ++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 194a98153..b08d3ef71 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -510,7 +510,7 @@ CameraOptions Map::cameraForLatLngs(const std::vector& latLngs, optional scaleY -= (padding->top + padding->bottom) / height; } double minScale = ::fmin(scaleX, scaleY); - double zoom = ::log2(getScale() * minScale); + double zoom = util::log2(getScale() * minScale); zoom = util::clamp(zoom, getMinZoom(), getMaxZoom()); // Calculate the center point of a virtual bounds that is extended in all directions by padding. diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index ac8b6396c..fab5991de 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -222,7 +222,7 @@ double TransformState::zoomScale(double zoom) const { } double TransformState::scaleZoom(double s) const { - return ::log2(s); + return util::log2(s); } double TransformState::worldSize() const { diff --git a/src/mbgl/util/math.cpp b/src/mbgl/util/math.cpp index a52475410..0e86849ad 100644 --- a/src/mbgl/util/math.cpp +++ b/src/mbgl/util/math.cpp @@ -21,5 +21,15 @@ uint32_t ceil_log2(uint64_t x) { return y; } +double log2(double x) { +// log2() is producing wrong results on ARMv5 binaries +// running on ARMv7+ CPUs. +#if defined(__ANDROID__) && defined(__ARM_ARCH_5TE__) + return std::log(x) / 0.6931471805599453; // log(x) / log(2) +#else + return ::log2(x); +#endif +} + } // namespace util -} // namespace mbgl \ No newline at end of file +} // namespace mbgl diff --git a/src/mbgl/util/math.hpp b/src/mbgl/util/math.hpp index ef60f76ff..bfedc2a42 100644 --- a/src/mbgl/util/math.hpp +++ b/src/mbgl/util/math.hpp @@ -110,5 +110,7 @@ T smoothstep(T edge0, T edge1, T x) { // (== number of bits required to store x) uint32_t ceil_log2(uint64_t x); +double log2(double x); + } // namespace util } // namespace mbgl From 47d6903f4e41cc3d4a0bacc1c1938ef8ede642ca Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 6 Jun 2016 12:45:40 -0700 Subject: [PATCH 04/31] [core] Revert line-round-limit default to 1 (#5260) Refs #5258, #5234. --- scripts/generate-style-code.js | 5 +++++ src/mbgl/style/layers/line_layer_properties.hpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js index 0f2dcdc42..637959844 100644 --- a/scripts/generate-style-code.js +++ b/scripts/generate-style-code.js @@ -46,6 +46,11 @@ global.propertyType = function (property) { } global.defaultValue = function (property) { + // https://github.com/mapbox/mapbox-gl-native/issues/5258 + if (property.name === 'line-round-limit') { + return 1; + } + switch (property.type) { case 'number': return property.default; diff --git a/src/mbgl/style/layers/line_layer_properties.hpp b/src/mbgl/style/layers/line_layer_properties.hpp index e0c63b516..01a853422 100644 --- a/src/mbgl/style/layers/line_layer_properties.hpp +++ b/src/mbgl/style/layers/line_layer_properties.hpp @@ -20,7 +20,7 @@ public: LayoutProperty lineCap { LineCapType::Butt }; LayoutProperty lineJoin { LineJoinType::Miter }; LayoutProperty lineMiterLimit { 2 }; - LayoutProperty lineRoundLimit { 1.05 }; + LayoutProperty lineRoundLimit { 1 }; }; class LinePaintProperties { From 126f388fdbb3b9572aa1ccafaf27967da385ccdd Mon Sep 17 00:00:00 2001 From: Young Hahn Date: Mon, 6 Jun 2016 17:54:07 -0400 Subject: [PATCH 05/31] Update shaders hash (#5261) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b8d31d9cd..ccb7c2017 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "csscolorparser": "^1.0.2", "ejs": "^2.4.1", "express": "^4.11.1", - "mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#e032997109c0ead5394ff64f2f0ea6b0f8efdc3f", + "mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#be09fce1d01e63de69f019e953261832d16ec88c", "mapbox-gl-style-spec": "^8.5.1", "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#f45fd7aba98650c7f3bf778c9cbbfd3b548a4ee8", "node-gyp": "^3.3.1", From 62149410fa49b7ceb6ae3491a1fcde506e13669b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Sun, 5 Jun 2016 00:37:42 -0700 Subject: [PATCH 06/31] [ios, osx] Ignore multipoints Ignore multipoints (as opposed to polylines and polygons) when adding annotations, just like we ignore multipolylines, multipolygons, and shape collections. In osxapp, break multipoint features into points before adding them as annotations. --- platform/ios/app/MBXViewController.m | 2 +- platform/ios/src/MGLMapView.h | 14 ++++++++------ platform/ios/src/MGLMapView.mm | 19 +++++++++++-------- platform/osx/app/MapDocument.m | 13 ++++++++++++- platform/osx/src/MGLMapView.h | 14 ++++++++------ platform/osx/src/MGLMapView.mm | 14 +++++++++----- 6 files changed, 49 insertions(+), 27 deletions(-) diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index 70f777422..6ae3eb98d 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -575,7 +575,7 @@ static NSString * const MBXViewControllerAnnotationViewReuseIdentifer = @"MBXVie - (MGLAnnotationView *)mapView:(MGLMapView *)mapView viewForAnnotation:(id)annotation { // Use GL backed pins for dropped pin annotations - if ([annotation isMemberOfClass:[MBXDroppedPinAnnotation class]]) + if ([annotation isKindOfClass:[MBXDroppedPinAnnotation class]]) { return nil; } diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h index d02c3a93a..63d799bda 100644 --- a/platform/ios/src/MGLMapView.h +++ b/platform/ios/src/MGLMapView.h @@ -882,9 +882,10 @@ IB_DESIGNABLE Adds an annotation to the map view. @note `MGLMultiPolyline`, `MGLMultiPolygon`, and `MGLShapeCollection` objects - cannot be added to the map view at this time. Any multipolyline, - multipolygon, or shape collection object that is passed into this method is - silently ignored. + cannot be added to the map view at this time. Nor can `MGLMultiPoint` + objects that are not instances of `MGLPolyline` or `MGLPolygon`. Any + multipoint, multipolyline, multipolygon, or shape collection object that is + specified is silently ignored. @param annotation The annotation object to add to the receiver. This object must conform to the `MGLAnnotation` protocol. The map view retains the @@ -895,9 +896,10 @@ IB_DESIGNABLE Adds an array of annotations to the map view. @note `MGLMultiPolyline`, `MGLMultiPolygon`, and `MGLShapeCollection` objects - cannot be added to the map view at this time. Any multipolyline, - multipolygon, or shape collection objects that are passed in are silently - ignored. + cannot be added to the map view at this time. Nor can `MGLMultiPoint` + objects that are not instances of `MGLPolyline` or `MGLPolygon`. Any + multipoint, multipolyline, multipolygon, or shape collection objects that + are specified are silently ignored. @param annotations An array of annotation objects. Each object in the array must conform to the `MGLAnnotation` protocol. The map view retains each diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 1ad758dc7..b05c5e41d 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -2835,7 +2835,14 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) if ([annotation isKindOfClass:[MGLMultiPoint class]]) { - // The multipoint knows how to style itself (with the map view’s help). + // Actual multipoints aren’t supported as annotations. + if ([annotation isMemberOfClass:[MGLMultiPoint class]] + || [annotation isMemberOfClass:[MGLMultiPointFeature class]]) + { + continue; + } + + // The polyline or polygon knows how to style itself (with the map view’s help). MGLMultiPoint *multiPoint = (MGLMultiPoint *)annotation; if (!multiPoint.pointCount) { continue; @@ -2846,13 +2853,9 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) context.annotation = annotation; _annotationContextsByAnnotationTag[annotationTag] = context; } - else if ([annotation isKindOfClass:[MGLMultiPolyline class]] - || [annotation isKindOfClass:[MGLMultiPolygon class]] - || [annotation isKindOfClass:[MGLShapeCollection class]]) - { - continue; - } - else + else if ( ! [annotation isKindOfClass:[MGLMultiPolyline class]] + || ![annotation isKindOfClass:[MGLMultiPolygon class]] + || ![annotation isKindOfClass:[MGLShapeCollection class]]) { MGLAnnotationView *annotationView; NSString *symbolName; diff --git a/platform/osx/app/MapDocument.m b/platform/osx/app/MapDocument.m index 427412674..e9f3b9959 100644 --- a/platform/osx/app/MapDocument.m +++ b/platform/osx/app/MapDocument.m @@ -18,7 +18,18 @@ NS_ARRAY_OF(id ) *MBXFlattenedShapes(NS_ARRAY_OF(id shape in shapes) { NSArray *subshapes; - if ([shape isKindOfClass:[MGLMultiPolyline class]]) { + // Flatten multipoints but not polylines or polygons. + if ([shape isMemberOfClass:[MGLMultiPoint class]]) { + NSUInteger pointCount = [(MGLMultiPoint *)shape pointCount]; + CLLocationCoordinate2D *coordinates = [(MGLMultiPoint *)shape coordinates]; + NSMutableArray *pointAnnotations = [NSMutableArray arrayWithCapacity:pointCount]; + for (NSUInteger i = 0; i < pointCount; i++) { + MGLPointAnnotation *pointAnnotation = [[MGLPointAnnotation alloc] init]; + pointAnnotation.coordinate = coordinates[i]; + [pointAnnotations addObject:pointAnnotation]; + } + subshapes = pointAnnotations; + } else if ([shape isKindOfClass:[MGLMultiPolyline class]]) { subshapes = [(MGLMultiPolyline *)shape polylines]; } else if ([shape isKindOfClass:[MGLMultiPolygon class]]) { subshapes = [(MGLMultiPolygon *)shape polygons]; diff --git a/platform/osx/src/MGLMapView.h b/platform/osx/src/MGLMapView.h index 5c7e75135..7b3efd293 100644 --- a/platform/osx/src/MGLMapView.h +++ b/platform/osx/src/MGLMapView.h @@ -535,9 +535,10 @@ IB_DESIGNABLE Adds an annotation to the map view. @note `MGLMultiPolyline`, `MGLMultiPolygon`, and `MGLShapeCollection` objects - cannot be added to the map view at this time. Any multipolyline, - multipolygon, or shape collection object that is passed into this method is - silently ignored. + cannot be added to the map view at this time. Nor can `MGLMultiPoint` + objects that are not instances of `MGLPolyline` or `MGLPolygon`. Any + multipoint, multipolyline, multipolygon, or shape collection object that is + specified is silently ignored. @param annotation The annotation object to add to the receiver. This object must conform to the `MGLAnnotation` protocol. The map view retains the @@ -549,9 +550,10 @@ IB_DESIGNABLE Adds an array of annotations to the map view. @note `MGLMultiPolyline`, `MGLMultiPolygon`, and `MGLShapeCollection` objects - cannot be added to the map view at this time. Any multipolyline, - multipolygon, or shape collection objects that are passed in are silently - ignored. + cannot be added to the map view at this time. Nor can `MGLMultiPoint` + objects that are not instances of `MGLPolyline` or `MGLPolygon`. Any + multipoint, multipolyline, multipolygon, or shape collection objects that + are specified are silently ignored. @param annotations An array of annotation objects. Each object in the array must conform to the `MGLAnnotation` protocol. The map view retains each diff --git a/platform/osx/src/MGLMapView.mm b/platform/osx/src/MGLMapView.mm index 03b94c25b..ac4eae9d3 100644 --- a/platform/osx/src/MGLMapView.mm +++ b/platform/osx/src/MGLMapView.mm @@ -1608,6 +1608,12 @@ public: NSAssert([annotation conformsToProtocol:@protocol(MGLAnnotation)], @"Annotation does not conform to MGLAnnotation"); if ([annotation isKindOfClass:[MGLMultiPoint class]]) { + // Actual multipoints aren’t supported as annotations. + if ([annotation isMemberOfClass:[MGLMultiPoint class]] + || [annotation isMemberOfClass:[MGLMultiPointFeature class]]) { + continue; + } + // The multipoint knows how to style itself (with the map view’s help). MGLMultiPoint *multiPoint = (MGLMultiPoint *)annotation; if (!multiPoint.pointCount) { @@ -1618,11 +1624,9 @@ public: MGLAnnotationContext context; context.annotation = annotation; _annotationContextsByAnnotationTag[annotationTag] = context; - } else if ([annotation isKindOfClass:[MGLMultiPolyline class]] - || [annotation isKindOfClass:[MGLMultiPolygon class]] - || [annotation isKindOfClass:[MGLShapeCollection class]]) { - continue; - } else { + } else if (![annotation isKindOfClass:[MGLMultiPolyline class]] + || ![annotation isKindOfClass:[MGLMultiPolygon class]] + || ![annotation isKindOfClass:[MGLShapeCollection class]]) { MGLAnnotationImage *annotationImage = nil; if (delegateHasImagesForAnnotations) { annotationImage = [self.delegate mapView:self imageForAnnotation:annotation]; From 654f0156397b68420bc48dfa2d53589ea7c8042e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Sun, 5 Jun 2016 00:06:31 -0700 Subject: [PATCH 07/31] [ios] Removed unused annotation image code Removed unused annotation image code from iosapp, now that bulk-added point annotations are backed by annotation views. --- platform/ios/app/MBXViewController.m | 76 ---------------------------- 1 file changed, 76 deletions(-) diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index 6ae3eb98d..8317aee1d 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -603,82 +603,6 @@ static NSString * const MBXViewControllerAnnotationViewReuseIdentifer = @"MBXVie return annotationView; } -- (MGLAnnotationImage *)mapView:(MGLMapView * __nonnull)mapView imageForAnnotation:(id __nonnull)annotation -{ - if ([annotation isKindOfClass:[MBXDroppedPinAnnotation class]] - || [annotation isKindOfClass:[MBXCustomCalloutAnnotation class]]) - { - return nil; // use default marker - } - - NSString *title = [(MGLPointAnnotation *)annotation title]; - if (!title.length) return nil; - NSString *lastTwoCharacters = [title substringFromIndex:title.length - 2]; - - MGLAnnotationImage *annotationImage = [mapView dequeueReusableAnnotationImageWithIdentifier:lastTwoCharacters]; - - if ( ! annotationImage) - { - UIColor *color; - - // make every tenth annotation blue - if ([lastTwoCharacters hasSuffix:@"0"]) { - color = [UIColor blueColor]; - } else { - color = [UIColor redColor]; - } - - UIImage *image = [self imageWithText:lastTwoCharacters backgroundColor:color]; - annotationImage = [MGLAnnotationImage annotationImageWithImage:image reuseIdentifier:lastTwoCharacters]; - - // don't allow touches on blue annotations - if ([color isEqual:[UIColor blueColor]]) annotationImage.enabled = NO; - } - - return annotationImage; -} - -- (UIImage *)imageWithText:(NSString *)text backgroundColor:(UIColor *)color -{ - CGRect rect = CGRectMake(0, 0, 20, 15); - - UIGraphicsBeginImageContextWithOptions(rect.size, NO, [[UIScreen mainScreen] scale]); - - CGContextRef ctx = UIGraphicsGetCurrentContext(); - - CGContextSetFillColorWithColor(ctx, [[color colorWithAlphaComponent:0.75] CGColor]); - CGContextFillRect(ctx, rect); - - CGContextSetStrokeColorWithColor(ctx, [[UIColor blackColor] CGColor]); - CGContextStrokeRectWithWidth(ctx, rect, 2); - - NSAttributedString *drawString = [[NSAttributedString alloc] initWithString:text attributes:@{ - NSFontAttributeName: [UIFont fontWithName:@"Arial-BoldMT" size:12], - NSForegroundColorAttributeName: [UIColor whiteColor], - }]; - CGSize stringSize = drawString.size; - CGRect stringRect = CGRectMake((rect.size.width - stringSize.width) / 2, - (rect.size.height - stringSize.height) / 2, - stringSize.width, - stringSize.height); - [drawString drawInRect:stringRect]; - - UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - return image; -} - -- (void)mapView:(MGLMapView *)mapView didDeselectAnnotation:(id)annotation { - NSString *title = [(MGLPointAnnotation *)annotation title]; - if ( ! title.length) - { - return; - } - NSString *lastTwoCharacters = [title substringFromIndex:title.length - 2]; - MGLAnnotationImage *annotationImage = [mapView dequeueReusableAnnotationImageWithIdentifier:lastTwoCharacters]; - annotationImage.image = annotationImage.image ? nil : [self imageWithText:lastTwoCharacters backgroundColor:[UIColor grayColor]]; -} - - (BOOL)mapView:(__unused MGLMapView *)mapView annotationCanShowCallout:(__unused id )annotation { return YES; From b3d9e125b1538f7642b70eb1014afe89208dc419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Sun, 5 Jun 2016 00:45:11 -0700 Subject: [PATCH 08/31] [ios] Avoid adding icon when relocating annotation Fixed an issue that caused a default annotation icon to appear beneath an annotation view when relocating the annotation. --- platform/ios/src/MGLMapView.mm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index b05c5e41d..74e2f1e73 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1779,8 +1779,16 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) if (annotation == [self annotationWithTag:annotationTag]) { const mbgl::Point point = MGLPointFromLocationCoordinate2D(annotation.coordinate); - MGLAnnotationImage *annotationImage = [self imageOfAnnotationWithTag:annotationTag]; - _mbglMap->updateAnnotation(annotationTag, mbgl::SymbolAnnotation { point, annotationImage.styleIconIdentifier.UTF8String ?: "" }); + + MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(annotationTag); + NSString *symbolName; + if (!annotationContext.annotationView) + { + MGLAnnotationImage *annotationImage = [self imageOfAnnotationWithTag:annotationTag]; + symbolName = annotationImage.styleIconIdentifier; + } + + _mbglMap->updateAnnotation(annotationTag, mbgl::SymbolAnnotation { point, symbolName.UTF8String ?: "" }); if (annotationTag == _selectedAnnotationTag) { [self deselectAnnotation:annotation animated:YES]; From b761aad4e62162bd17fbf639146a82281228318f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Sun, 5 Jun 2016 13:21:13 -0700 Subject: [PATCH 09/31] [ios] Bring annotation view to front when selected Fixes #991. --- platform/ios/src/MGLMapView.mm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 74e2f1e73..bd8762c47 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -3395,10 +3395,13 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) { MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(annotationTag); - if (annotationContext.annotationView) + MGLAnnotationView *annotationView = annotationContext.annotationView; + if (annotationView) { // Annotations represented by views use the view frame as the positioning rect. - positioningRect = annotationContext.annotationView.frame; + positioningRect = annotationView.frame; + + [annotationView.superview bringSubviewToFront:annotationView]; } } From 5e6f8d4ce5ad5c6ccb3e9a4525ec52a414e067a1 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Mon, 6 Jun 2016 16:15:29 +0300 Subject: [PATCH 10/31] [core] Use initializer list for Unique* objects --- src/mbgl/gl/object_store.hpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/mbgl/gl/object_store.hpp b/src/mbgl/gl/object_store.hpp index e43021401..3ae1b6e2f 100644 --- a/src/mbgl/gl/object_store.hpp +++ b/src/mbgl/gl/object_store.hpp @@ -20,27 +20,27 @@ class ObjectStore; struct ProgramDeleter { ObjectStore* store; - void operator()(GLuint id) const; + void operator()(GLuint) const; }; struct ShaderDeleter { ObjectStore* store; - void operator()(GLuint id) const; + void operator()(GLuint) const; }; struct BufferDeleter { ObjectStore* store; - void operator()(GLuint id) const; + void operator()(GLuint) const; }; struct TextureDeleter { ObjectStore* store; - void operator()(GLuint id) const; + void operator()(GLuint) const; }; struct VAODeleter { ObjectStore* store; - void operator()(GLuint id) const; + void operator()(GLuint) const; }; using ObjectPool = std::array; @@ -62,36 +62,36 @@ public: ~ObjectStore(); UniqueProgram createProgram() { - return UniqueProgram(MBGL_CHECK_ERROR(glCreateProgram()), { this }); + return UniqueProgram { MBGL_CHECK_ERROR(glCreateProgram()), { this } }; } UniqueShader createShader(GLenum type) { - return UniqueShader(MBGL_CHECK_ERROR(glCreateShader(type)), { this }); + return UniqueShader { MBGL_CHECK_ERROR(glCreateShader(type)), { this } }; } UniqueBuffer createBuffer() { GLuint id = 0; MBGL_CHECK_ERROR(glGenBuffers(1, &id)); - return UniqueBuffer(std::move(id), { this }); + return UniqueBuffer { std::move(id), { this } }; } UniqueTexture createTexture() { GLuint id = 0; MBGL_CHECK_ERROR(glGenTextures(1, &id)); - return UniqueTexture(std::move(id), { this }); + return UniqueTexture { std::move(id), { this } }; } UniqueVAO createVAO() { GLuint id = 0; MBGL_CHECK_ERROR(gl::GenVertexArrays(1, &id)); - return UniqueVAO(std::move(id), { this }); + return UniqueVAO { std::move(id), { this } }; } UniqueTexturePool createTexturePool() { ObjectPool ids; MBGL_CHECK_ERROR(glGenTextures(TextureMax, ids.data())); assert(ids.size() == size_t(TextureMax)); - return UniqueTexturePool(std::move(ids), { this }); + return UniqueTexturePool { std::move(ids), { this } }; } // Actually remove the objects we marked as abandoned with the above methods. From 858311d19b9879cf6ac1fea2d8746e136be3c4a3 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Mon, 6 Jun 2016 19:44:22 +0300 Subject: [PATCH 11/31] [core] Do not expose TexturePool::Impl Now using the same Pimpl mechanism from mbgl::Map. --- src/mbgl/gl/texture_pool.cpp | 77 +++++++++++++++++++++++++----------- src/mbgl/gl/texture_pool.hpp | 21 +++------- 2 files changed, 60 insertions(+), 38 deletions(-) diff --git a/src/mbgl/gl/texture_pool.cpp b/src/mbgl/gl/texture_pool.cpp index 8818cbef0..87e5aed25 100644 --- a/src/mbgl/gl/texture_pool.cpp +++ b/src/mbgl/gl/texture_pool.cpp @@ -7,35 +7,68 @@ namespace mbgl { namespace gl { -GLuint TexturePool::getTextureID(gl::ObjectStore& store) { - auto nextAvailableID = [](auto& pool_) { - auto it = pool_.availableIDs.begin(); - GLuint id = *it; - pool_.availableIDs.erase(it); - return id; +class TexturePool::Impl : private util::noncopyable { +public: + class Group : private util::noncopyable { + public: + Group(gl::ObjectStore& store) : pool(store.createTexturePool()), availableIDs(gl::TextureMax) { + std::copy(pool.get().begin(), pool.get().end(), availableIDs.begin()); + } + + Group(Group&& o) : pool(std::move(o.pool)), availableIDs(std::move(o.availableIDs)) {} + Group& operator=(Group&& o) { pool = std::move(o.pool); availableIDs = std::move(o.availableIDs); return *this; } + + gl::UniqueTexturePool pool; + std::vector availableIDs; }; - for (auto& pool : pools) { - if (pool.availableIDs.empty()) continue; - return nextAvailableID(pool); + GLuint getTextureID(gl::ObjectStore& store) { + auto nextAvailableID = [](auto& pool_) { + auto it = pool_.availableIDs.begin(); + GLuint id = *it; + pool_.availableIDs.erase(it); + return id; + }; + + for (auto& pool : pools) { + if (pool.availableIDs.empty()) continue; + return nextAvailableID(pool); + } + + // All texture IDs are in use. + pools.emplace_back(Group { store }); + return nextAvailableID(pools.back()); } - // All texture IDs are in use. - pools.emplace_back(Impl { store }); - return nextAvailableID(pools.back()); + void releaseTextureID(GLuint& id) { + for (auto it = pools.begin(); it != pools.end(); ++it) { + if (std::find(it->pool.get().begin(), it->pool.get().end(), id) != it->pool.get().end()) { + it->availableIDs.push_back(id); + id = 0; + if (GLsizei(it->availableIDs.size()) == gl::TextureMax) { + pools.erase(it); + } + return; + } + } + } + +private: + std::vector pools; +}; + +TexturePool::TexturePool() : impl(std::make_unique()) { +} + +TexturePool::~TexturePool() { +} + +GLuint TexturePool::getTextureID(gl::ObjectStore& store) { + return impl->getTextureID(store); } void TexturePool::releaseTextureID(GLuint& id) { - for (auto it = pools.begin(); it != pools.end(); ++it) { - if (std::find(it->pool.get().begin(), it->pool.get().end(), id) != it->pool.get().end()) { - it->availableIDs.push_back(id); - id = 0; - if (GLsizei(it->availableIDs.size()) == gl::TextureMax) { - pools.erase(it); - } - return; - } - } + impl->releaseTextureID(id); } } // namespace gl diff --git a/src/mbgl/gl/texture_pool.hpp b/src/mbgl/gl/texture_pool.hpp index a32ec7674..9ab7d14ef 100644 --- a/src/mbgl/gl/texture_pool.hpp +++ b/src/mbgl/gl/texture_pool.hpp @@ -4,33 +4,22 @@ #include #include -#include #include -#include namespace mbgl { namespace gl { class TexturePool : private util::noncopyable { public: + TexturePool(); + ~TexturePool(); + GLuint getTextureID(gl::ObjectStore&); void releaseTextureID(GLuint&); private: - class Impl : private util::noncopyable { - public: - Impl(gl::ObjectStore& store) : pool(store.createTexturePool()), availableIDs(gl::TextureMax) { - std::copy(pool.get().begin(), pool.get().end(), availableIDs.begin()); - } - - Impl(Impl&& o) : pool(std::move(o.pool)), availableIDs(std::move(o.availableIDs)) {} - Impl& operator=(Impl&& o) { pool = std::move(o.pool); availableIDs = std::move(o.availableIDs); return *this; } - - gl::UniqueTexturePool pool; - std::vector availableIDs; - }; - - std::vector pools; + class Impl; + const std::unique_ptr impl; }; } // namespace gl From 83d349ee16f1918d7e0275d47b9c22abc1a4f50c Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Mon, 6 Jun 2016 20:17:12 +0300 Subject: [PATCH 12/31] [core] Use RAII for TexturePool textures TexturePool now disposes acquirable ids via SharedTexture, which guarantees that these are going back to TexturePool once released. --- src/mbgl/gl/texture_pool.cpp | 30 ++++++++++++------------ src/mbgl/gl/texture_pool.hpp | 16 +++++++++++-- src/mbgl/util/raster.cpp | 19 +++++---------- src/mbgl/util/raster.hpp | 9 +++----- test/gl/object.cpp | 45 +++++++++++++++--------------------- 5 files changed, 57 insertions(+), 62 deletions(-) diff --git a/src/mbgl/gl/texture_pool.cpp b/src/mbgl/gl/texture_pool.cpp index 87e5aed25..53e29b907 100644 --- a/src/mbgl/gl/texture_pool.cpp +++ b/src/mbgl/gl/texture_pool.cpp @@ -9,20 +9,20 @@ namespace gl { class TexturePool::Impl : private util::noncopyable { public: - class Group : private util::noncopyable { + class Pool : private util::noncopyable { public: - Group(gl::ObjectStore& store) : pool(store.createTexturePool()), availableIDs(gl::TextureMax) { + Pool(gl::ObjectStore& store) : pool(store.createTexturePool()), availableIDs(gl::TextureMax) { std::copy(pool.get().begin(), pool.get().end(), availableIDs.begin()); } - Group(Group&& o) : pool(std::move(o.pool)), availableIDs(std::move(o.availableIDs)) {} - Group& operator=(Group&& o) { pool = std::move(o.pool); availableIDs = std::move(o.availableIDs); return *this; } + Pool(Pool&& o) : pool(std::move(o.pool)), availableIDs(std::move(o.availableIDs)) {} + Pool& operator=(Pool&& o) { pool = std::move(o.pool); availableIDs = std::move(o.availableIDs); return *this; } gl::UniqueTexturePool pool; std::vector availableIDs; }; - GLuint getTextureID(gl::ObjectStore& store) { + GLuint acquireTexture(gl::ObjectStore& store) { auto nextAvailableID = [](auto& pool_) { auto it = pool_.availableIDs.begin(); GLuint id = *it; @@ -36,15 +36,14 @@ public: } // All texture IDs are in use. - pools.emplace_back(Group { store }); + pools.emplace_back(Pool { store }); return nextAvailableID(pools.back()); } - void releaseTextureID(GLuint& id) { + void releaseTexture(GLuint id) { for (auto it = pools.begin(); it != pools.end(); ++it) { if (std::find(it->pool.get().begin(), it->pool.get().end(), id) != it->pool.get().end()) { it->availableIDs.push_back(id); - id = 0; if (GLsizei(it->availableIDs.size()) == gl::TextureMax) { pools.erase(it); } @@ -54,21 +53,22 @@ public: } private: - std::vector pools; + std::vector pools; }; +void TextureReleaser::operator()(GLuint id) const { + assert(pool); + pool->impl->releaseTexture(id); +} + TexturePool::TexturePool() : impl(std::make_unique()) { } TexturePool::~TexturePool() { } -GLuint TexturePool::getTextureID(gl::ObjectStore& store) { - return impl->getTextureID(store); -} - -void TexturePool::releaseTextureID(GLuint& id) { - impl->releaseTextureID(id); +SharedTexture TexturePool::acquireTexture(gl::ObjectStore& store) { + return SharedTexture { impl->acquireTexture(store) , { this } }; } } // namespace gl diff --git a/src/mbgl/gl/texture_pool.hpp b/src/mbgl/gl/texture_pool.hpp index 9ab7d14ef..3c38343f6 100644 --- a/src/mbgl/gl/texture_pool.hpp +++ b/src/mbgl/gl/texture_pool.hpp @@ -4,20 +4,32 @@ #include #include +#include + #include namespace mbgl { namespace gl { +class TexturePool; + +struct TextureReleaser { + TexturePool* pool; + void operator()(GLuint) const; +}; + +using SharedTexture = std_experimental::unique_resource; + class TexturePool : private util::noncopyable { public: TexturePool(); ~TexturePool(); - GLuint getTextureID(gl::ObjectStore&); - void releaseTextureID(GLuint&); + SharedTexture acquireTexture(gl::ObjectStore&); private: + friend TextureReleaser; + class Impl; const std::unique_ptr impl; }; diff --git a/src/mbgl/util/raster.cpp b/src/mbgl/util/raster.cpp index 70fdf7b02..514472010 100644 --- a/src/mbgl/util/raster.cpp +++ b/src/mbgl/util/raster.cpp @@ -13,12 +13,6 @@ Raster::Raster(gl::TexturePool& texturePool_) : texturePool(texturePool_) {} -Raster::~Raster() { - if (textured) { - texturePool.releaseTextureID(textureID); - } -} - bool Raster::isLoaded() const { std::lock_guard lock(mtx); return loaded; @@ -42,10 +36,10 @@ void Raster::bind(bool linear, gl::ObjectStore& store) { return; } - if (img.data && !textured) { + if (img.data && !texture) { upload(store); - } else if (textured) { - MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, textureID)); + } else if (texture) { + MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, *texture)); } GLint new_filter = linear ? GL_LINEAR : GL_NEAREST; @@ -57,15 +51,14 @@ void Raster::bind(bool linear, gl::ObjectStore& store) { } void Raster::upload(gl::ObjectStore& store) { - if (img.data && !textured) { - textureID = texturePool.getTextureID(store); - MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, textureID)); + if (img.data && !texture) { + texture = texturePool.acquireTexture(store); + MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, *texture)); #ifndef GL_ES_VERSION_2_0 MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0)); #endif MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); MBGL_CHECK_ERROR(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, img.data.release())); - textured = true; } } diff --git a/src/mbgl/util/raster.hpp b/src/mbgl/util/raster.hpp index ff16112d9..ecf026b5f 100644 --- a/src/mbgl/util/raster.hpp +++ b/src/mbgl/util/raster.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include @@ -14,7 +15,6 @@ class Raster : public std::enable_shared_from_this { public: Raster(gl::TexturePool&); - ~Raster(); // load image data void load(PremultipliedImage); @@ -33,11 +33,8 @@ public: GLsizei width = 0; GLsizei height = 0; - // has been uploaded to texture - bool textured = false; - - // the uploaded texture - GLuint textureID = 0; + // GL buffer object handle. + mbgl::optional texture; // texture opacity double opacity = 0; diff --git a/test/gl/object.cpp b/test/gl/object.cpp index 4511fc4d1..1ed2bc91d 100644 --- a/test/gl/object.cpp +++ b/test/gl/object.cpp @@ -130,29 +130,31 @@ TEST(GLObject, TexturePool) { mbgl::gl::TexturePool pool; + std::vector ids; + // Fill an entire texture pool. for (auto i = 0; i != mbgl::gl::TextureMax; ++i) { - EXPECT_EQ(pool.getTextureID(store), GLuint(i + 1)); + ids.push_back(pool.acquireTexture(store)); + EXPECT_EQ(ids.back().get(), GLuint(i + 1)); EXPECT_TRUE(store.empty()); } // Reuse texture ids from the same pool. for (auto i = 0; i != mbgl::gl::TextureMax; ++i) { - GLuint id = i + 1; - pool.releaseTextureID(id); - EXPECT_EQ(id, 0); - EXPECT_EQ(pool.getTextureID(store), GLuint(i + 1)); + ids[i].reset(); + ids.push_back(pool.acquireTexture(store)); + EXPECT_EQ(ids.back().get(), GLuint(i + 1)); EXPECT_TRUE(store.empty()); } // Trigger a new texture pool creation. { - GLuint id = pool.getTextureID(store); + mbgl::gl::SharedTexture id = pool.acquireTexture(store); EXPECT_EQ(id, mbgl::gl::TextureMax + 1); EXPECT_TRUE(store.empty()); - pool.releaseTextureID(id); - EXPECT_EQ(id, 0); + id.reset(); + // Last used texture from pool triggers pool recycling. EXPECT_FALSE(store.empty()); @@ -161,35 +163,26 @@ TEST(GLObject, TexturePool) { } // First pool is still full, thus creating a new pool. - GLuint id1 = pool.getTextureID(store); - EXPECT_GT(id1, mbgl::gl::TextureMax); + mbgl::gl::SharedTexture id1 = pool.acquireTexture(store); + EXPECT_GT(id1.get(), mbgl::gl::TextureMax); EXPECT_TRUE(store.empty()); // Release all textures from the first pool. - for (auto i = 0; i != mbgl::gl::TextureMax; ++i) { - GLuint id = i + 1; - pool.releaseTextureID(id); - if (i == mbgl::gl::TextureMax - 1) { - // Last texture from pool triggers pool recycling. - EXPECT_FALSE(store.empty()); - } else { - EXPECT_TRUE(store.empty()); - } - } + ids.clear(); + EXPECT_FALSE(store.empty()); store.performCleanup(); EXPECT_TRUE(store.empty()); // The first pool is now gone, the next pool is now in use. - GLuint id2 = pool.getTextureID(store); - EXPECT_GT(id2, id1); - pool.releaseTextureID(id2); - EXPECT_EQ(id2, 0); + mbgl::gl::SharedTexture id2 = pool.acquireTexture(store); + EXPECT_GT(id2.get(), id1.get()); + + id2.reset(); EXPECT_TRUE(store.empty()); // Last used texture from the pool triggers pool recycling. - pool.releaseTextureID(id1); - EXPECT_EQ(id1, 0); + id1.reset(); EXPECT_FALSE(store.empty()); store.performCleanup(); From aa88ca4757f182dcab5b66172144701185ec28ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Mon, 6 Jun 2016 18:20:50 +0200 Subject: [PATCH 13/31] [core] remove unused code --- src/mbgl/geometry/buffer.hpp | 13 ------------ src/mbgl/renderer/renderable.hpp | 11 ---------- src/mbgl/style/source.hpp | 1 - src/mbgl/util/assert.hpp | 10 --------- src/mbgl/util/channel.hpp | 36 -------------------------------- test/test.gypi | 1 - test/util/assert.cpp | 9 -------- 7 files changed, 81 deletions(-) delete mode 100644 src/mbgl/renderer/renderable.hpp delete mode 100644 src/mbgl/util/assert.hpp delete mode 100644 src/mbgl/util/channel.hpp delete mode 100644 test/util/assert.cpp diff --git a/src/mbgl/geometry/buffer.hpp b/src/mbgl/geometry/buffer.hpp index 1712ca988..6465b6f8e 100644 --- a/src/mbgl/geometry/buffer.hpp +++ b/src/mbgl/geometry/buffer.hpp @@ -88,19 +88,6 @@ protected: return reinterpret_cast(array) + (pos - itemSize); } - // Get a pointer to the item at a given index. - inline void *getElement(size_t i) { - if (array == nullptr) { - throw std::runtime_error("Buffer was already deleted or doesn't contain elements"); - } - - if (i * itemSize >= pos) { - throw std::runtime_error("Can't get element after array bounds"); - } else { - return reinterpret_cast(array) + (i * itemSize); - } - } - public: static const size_t itemSize = item_size; diff --git a/src/mbgl/renderer/renderable.hpp b/src/mbgl/renderer/renderable.hpp deleted file mode 100644 index 27acfc4d0..000000000 --- a/src/mbgl/renderer/renderable.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include - -namespace mbgl { - -struct Renderable { - ClipID& clip; -}; - -} // namespace mbgl diff --git a/src/mbgl/style/source.hpp b/src/mbgl/style/source.hpp index cadc45c25..07e1aeaf5 100644 --- a/src/mbgl/style/source.hpp +++ b/src/mbgl/style/source.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include diff --git a/src/mbgl/util/assert.hpp b/src/mbgl/util/assert.hpp deleted file mode 100644 index 47fc13f94..000000000 --- a/src/mbgl/util/assert.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include - -// Based on FreeBSD's src/include/assert.h -// Licensed under the original BSD license -#define assert_always(expr) \ - ((void)((expr) ? ((void)0) : ((void)fprintf(stderr, "%s:%u: failed assertion `%s'\n", \ - __FILE__, __LINE__, #expr), \ - abort()))) diff --git a/src/mbgl/util/channel.hpp b/src/mbgl/util/channel.hpp deleted file mode 100644 index 319205b44..000000000 --- a/src/mbgl/util/channel.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include - -#include -#include -#include - -namespace mbgl { - -template -class Channel : public mbgl::util::noncopyable { -public: - void send(const T& t) { - std::unique_lock lock(mutex); - queue.push(t); - condition.notify_one(); - } - - T receive() { - std::unique_lock lock(mutex); - condition.wait(lock, [&](){ return !queue.empty(); }); - - T t = queue.front(); - queue.pop(); - - return t; - } - -private: - std::mutex mutex; - std::condition_variable condition; - std::queue queue; -}; - -} diff --git a/test/test.gypi b/test/test.gypi index f9a25e4e8..b7e7b5c32 100644 --- a/test/test.gypi +++ b/test/test.gypi @@ -18,7 +18,6 @@ ], 'sources': [ - 'util/assert.cpp', 'util/async_task.cpp', 'util/geo.cpp', 'util/image.cpp', diff --git a/test/util/assert.cpp b/test/util/assert.cpp deleted file mode 100644 index cf7baf8ca..000000000 --- a/test/util/assert.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include - -#include - -using namespace mbgl; - -TEST(Assert, Always) { - EXPECT_DEATH_IF_SUPPORTED(assert_always(true == false), "failed assertion `true == false'"); -} From 8b28b6ab6b5735a51b15d76baae284658a633c9d Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Tue, 7 Jun 2016 14:43:59 +0300 Subject: [PATCH 14/31] [core] Renamed OutlineShader's color uniform Part of https://github.com/mapbox/mapbox-gl-shaders/issues/8. --- scripts/build-shaders.py | 5 ++--- src/mbgl/renderer/painter_fill.cpp | 4 ++-- src/mbgl/shader/outline_shader.hpp | 8 ++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/scripts/build-shaders.py b/scripts/build-shaders.py index 60e855212..d94a8cdd5 100755 --- a/scripts/build-shaders.py +++ b/scripts/build-shaders.py @@ -28,7 +28,7 @@ def replace_uniform_pragmas(line): if pragma_mapbox_regex.match(line): params = line.split() u_method = params[2] - u_name = "color" if color_regex.match(params[3]) else params[3] + u_name = params[3] u_precision = params[4] u_type = "vec4" if color_regex.match(u_name) else "float" if u_method == "define": @@ -37,10 +37,9 @@ def replace_uniform_pragmas(line): type_ = u_type, name = u_name) else: - return """ {precision} {type_} {glsl_name} = u_{name};""".format( + return """ {precision} {type_} {name} = u_{name};""".format( precision = u_precision, type_ = u_type, - glsl_name = params[3], name = u_name) else: return line diff --git a/src/mbgl/renderer/painter_fill.cpp b/src/mbgl/renderer/painter_fill.cpp index b89686c81..4c6ad1ba0 100644 --- a/src/mbgl/renderer/painter_fill.cpp +++ b/src/mbgl/renderer/painter_fill.cpp @@ -55,7 +55,7 @@ void Painter::renderFill(FillBucket& bucket, outlineShader->u_matrix = vtxMatrix; config.lineWidth = 2.0f; // This is always fixed and does not depend on the pixelRatio! - outlineShader->u_color = stroke_color; + outlineShader->u_outline_color = stroke_color; outlineShader->u_opacity = opacity; // Draw the entire line @@ -184,7 +184,7 @@ void Painter::renderFill(FillBucket& bucket, outlineShader->u_matrix = vtxMatrix; config.lineWidth = 2.0f; // This is always fixed and does not depend on the pixelRatio! - outlineShader->u_color = fill_color; + outlineShader->u_outline_color = fill_color; outlineShader->u_opacity = opacity; // Draw the entire line diff --git a/src/mbgl/shader/outline_shader.hpp b/src/mbgl/shader/outline_shader.hpp index 22b9013af..25c873b4f 100644 --- a/src/mbgl/shader/outline_shader.hpp +++ b/src/mbgl/shader/outline_shader.hpp @@ -11,10 +11,10 @@ public: void bind(GLbyte *offset) final; - UniformMatrix<4> u_matrix = {"u_matrix", *this}; - Uniform> u_color = {"u_color", *this}; - Uniform u_opacity = {"u_opacity", *this}; - Uniform> u_world = {"u_world", *this}; + UniformMatrix<4> u_matrix = {"u_matrix", *this}; + Uniform> u_outline_color = {"u_outline_color", *this}; + Uniform u_opacity = {"u_opacity", *this}; + Uniform> u_world = {"u_world", *this}; }; } // namespace mbgl From 269124ec2624ee9185391e7529ec7eaa4173d8e7 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Tue, 7 Jun 2016 14:56:04 +0300 Subject: [PATCH 15/31] [core] Include type in #pragmas Part of https://github.com/mapbox/mapbox-gl-shaders/pull/13. --- package.json | 2 +- scripts/build-shaders.py | 26 ++++++++++---------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index ccb7c2017..1176e2f9d 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "csscolorparser": "^1.0.2", "ejs": "^2.4.1", "express": "^4.11.1", - "mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#be09fce1d01e63de69f019e953261832d16ec88c", + "mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#8dfd9653e6659cb2837a4b98f3e8e1d559b29a09", "mapbox-gl-style-spec": "^8.5.1", "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#f45fd7aba98650c7f3bf778c9cbbfd3b548a4ee8", "node-gyp": "^3.3.1", diff --git a/scripts/build-shaders.py b/scripts/build-shaders.py index d94a8cdd5..3b02cdc88 100755 --- a/scripts/build-shaders.py +++ b/scripts/build-shaders.py @@ -20,27 +20,21 @@ with open(input_file, "r") as f: # Replace uniform pragmas -pragma_mapbox_regex = re.compile("(\s*)\#pragma \mapbox\: (initialize|define) (.*) (lowp|mediump|highp)") -color_regex = re.compile("(.*)color") +pragma_mapbox_regex = re.compile("(\s*)\#pragma \mapbox\: (define|initialize) (low|medium|high)p (float|vec(2|3|4)) (.*)") def replace_uniform_pragmas(line): - # FIXME We should obtain these from the source code. if pragma_mapbox_regex.match(line): params = line.split() - u_method = params[2] - u_name = params[3] - u_precision = params[4] - u_type = "vec4" if color_regex.match(u_name) else "float" - if u_method == "define": - return """uniform {precision} {type_} u_{name};""".format( - precision = u_precision, - type_ = u_type, - name = u_name) + if params[2] == "define": + return """uniform {u_precision} {u_type} u_{u_name};""".format( + u_precision = params[3], + u_type = params[4], + u_name = params[5]) else: - return """ {precision} {type_} {name} = u_{name};""".format( - precision = u_precision, - type_ = u_type, - name = u_name) + return """ {u_precision} {u_type} {u_name} = u_{u_name};""".format( + u_precision = params[3], + u_type = params[4], + u_name = params[5]) else: return line From 680fcd09b145b56dd6112eb9be901e5b558ab94d Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Tue, 7 Jun 2016 16:12:53 +0300 Subject: [PATCH 16/31] Revert "[core] Use release() instead of get()/reset() in Raster" No one owned the data after release(), so this wasn't being free'd. reset() does that, thus this patch causes a huge memory leak. --- src/mbgl/util/raster.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mbgl/util/raster.cpp b/src/mbgl/util/raster.cpp index 514472010..3146a0051 100644 --- a/src/mbgl/util/raster.cpp +++ b/src/mbgl/util/raster.cpp @@ -59,6 +59,7 @@ void Raster::upload(gl::ObjectStore& store) { #endif MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); - MBGL_CHECK_ERROR(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, img.data.release())); + MBGL_CHECK_ERROR(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, img.data.get())); + img.data.reset(); } } From 4294b0f83a6894cd6a1679c7fb427eefeac5a7a6 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Tue, 7 Jun 2016 16:04:03 +0300 Subject: [PATCH 17/31] [core] mbgl::Image is now movable, noncopyable --- include/mbgl/util/image.hpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/include/mbgl/util/image.hpp b/include/mbgl/util/image.hpp index fbb0686a7..124cdca7c 100644 --- a/include/mbgl/util/image.hpp +++ b/include/mbgl/util/image.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include #include #include @@ -12,7 +14,7 @@ enum ImageAlphaMode { }; template -class Image { +class Image : private util::noncopyable { public: Image() = default; @@ -26,6 +28,18 @@ public: height(h), data(std::move(data_)) {} + Image(Image&& o) + : width(o.width), + height(o.height), + data(std::move(o.data)) {} + + Image& operator=(Image&& o) { + width = o.width; + height = o.height; + data = std::move(o.data); + return *this; + } + bool operator==(const Image& rhs) const { return width == rhs.width && height == rhs.height && std::equal(data.get(), data.get() + size(), rhs.data.get(), From ba5d2a4b4de20f57763016826c03cae82b25471f Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 7 Jun 2016 11:57:53 -0400 Subject: [PATCH 18/31] node-v3.2.1 --- package.json | 6 +++--- platform/node/CHANGELOG.md | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 1176e2f9d..0b7f7e2d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mapbox-gl-native", - "version": "3.2.0", + "version": "3.2.1", "description": "Renders map tiles with Mapbox GL", "keywords": [ "mapbox", @@ -13,8 +13,8 @@ }, "license": "BSD-2-Clause", "dependencies": { - "nan": "^2.3.3", - "node-pre-gyp": "^0.6.26" + "nan": "^2.3.5", + "node-pre-gyp": "^0.6.28" }, "devDependencies": { "aws-sdk": "^2.3.5", diff --git a/platform/node/CHANGELOG.md b/platform/node/CHANGELOG.md index a8f1d5be7..e1bff6cc2 100644 --- a/platform/node/CHANGELOG.md +++ b/platform/node/CHANGELOG.md @@ -1,3 +1,7 @@ +# 3.2.1 + +- Fixes a memory leak in raster image data ([#5269](https://github.com/mapbox/mapbox-gl-native/pull/5269)) + # 3.2.0 - Switches to [earcut.hpp](https://github.com/mapbox/earcut.hpp) for tessellation ([#2444](https://github.com/mapbox/mapbox-gl-native/pull/2444)) From 20fe1d2be4302ce1d6b604d185068c069c9345ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 7 Jun 2016 12:22:10 -0700 Subject: [PATCH 19/31] [ios] Point podspec to API reference (#5267) The Documentation link on CocoaPods.org should point to the API reference, not to the main ios-sdk front page, which is already linked right above. --- platform/ios/Mapbox-iOS-SDK-symbols.podspec | 2 +- platform/ios/Mapbox-iOS-SDK.podspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/ios/Mapbox-iOS-SDK-symbols.podspec b/platform/ios/Mapbox-iOS-SDK-symbols.podspec index a29e9467e..3642d8b7d 100644 --- a/platform/ios/Mapbox-iOS-SDK-symbols.podspec +++ b/platform/ios/Mapbox-iOS-SDK-symbols.podspec @@ -10,7 +10,7 @@ Pod::Spec.new do |m| m.author = { 'Mapbox' => 'mobile@mapbox.com' } m.screenshot = 'https://raw.githubusercontent.com/mapbox/mapbox-gl-native/master/platform/ios/screenshot.png' m.social_media_url = 'https://twitter.com/mapbox' - m.documentation_url = 'https://www.mapbox.com/ios-sdk/' + m.documentation_url = 'https://www.mapbox.com/ios-sdk/api/' m.source = { :http => "https://mapbox.s3.amazonaws.com/mapbox-gl-native/ios/builds/mapbox-ios-sdk-#{m.version.to_s}-dynamic.zip", diff --git a/platform/ios/Mapbox-iOS-SDK.podspec b/platform/ios/Mapbox-iOS-SDK.podspec index 33b83e537..da9213dba 100644 --- a/platform/ios/Mapbox-iOS-SDK.podspec +++ b/platform/ios/Mapbox-iOS-SDK.podspec @@ -10,7 +10,7 @@ Pod::Spec.new do |m| m.author = { 'Mapbox' => 'mobile@mapbox.com' } m.screenshot = 'https://raw.githubusercontent.com/mapbox/mapbox-gl-native/master/platform/ios/screenshot.png' m.social_media_url = 'https://twitter.com/mapbox' - m.documentation_url = 'https://www.mapbox.com/ios-sdk/' + m.documentation_url = 'https://www.mapbox.com/ios-sdk/api/' m.source = { :http => "https://mapbox.s3.amazonaws.com/mapbox-gl-native/ios/builds/mapbox-ios-sdk-#{m.version.to_s}-dynamic.zip", From cfac92460675034dca5a134173d9b48f64b75f7e Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Tue, 7 Jun 2016 22:42:18 +0300 Subject: [PATCH 20/31] [core] s/SharedTexture/PooledTexture/ --- src/mbgl/gl/texture_pool.cpp | 4 ++-- src/mbgl/gl/texture_pool.hpp | 4 ++-- src/mbgl/util/raster.hpp | 2 +- test/gl/object.cpp | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/mbgl/gl/texture_pool.cpp b/src/mbgl/gl/texture_pool.cpp index 53e29b907..c4984b018 100644 --- a/src/mbgl/gl/texture_pool.cpp +++ b/src/mbgl/gl/texture_pool.cpp @@ -67,8 +67,8 @@ TexturePool::TexturePool() : impl(std::make_unique()) { TexturePool::~TexturePool() { } -SharedTexture TexturePool::acquireTexture(gl::ObjectStore& store) { - return SharedTexture { impl->acquireTexture(store) , { this } }; +PooledTexture TexturePool::acquireTexture(gl::ObjectStore& store) { + return PooledTexture { impl->acquireTexture(store) , { this } }; } } // namespace gl diff --git a/src/mbgl/gl/texture_pool.hpp b/src/mbgl/gl/texture_pool.hpp index 3c38343f6..1cdcdf220 100644 --- a/src/mbgl/gl/texture_pool.hpp +++ b/src/mbgl/gl/texture_pool.hpp @@ -18,14 +18,14 @@ struct TextureReleaser { void operator()(GLuint) const; }; -using SharedTexture = std_experimental::unique_resource; +using PooledTexture = std_experimental::unique_resource; class TexturePool : private util::noncopyable { public: TexturePool(); ~TexturePool(); - SharedTexture acquireTexture(gl::ObjectStore&); + PooledTexture acquireTexture(gl::ObjectStore&); private: friend TextureReleaser; diff --git a/src/mbgl/util/raster.hpp b/src/mbgl/util/raster.hpp index ecf026b5f..b539032d8 100644 --- a/src/mbgl/util/raster.hpp +++ b/src/mbgl/util/raster.hpp @@ -34,7 +34,7 @@ public: GLsizei height = 0; // GL buffer object handle. - mbgl::optional texture; + mbgl::optional texture; // texture opacity double opacity = 0; diff --git a/test/gl/object.cpp b/test/gl/object.cpp index 1ed2bc91d..f2b21ec9f 100644 --- a/test/gl/object.cpp +++ b/test/gl/object.cpp @@ -130,7 +130,7 @@ TEST(GLObject, TexturePool) { mbgl::gl::TexturePool pool; - std::vector ids; + std::vector ids; // Fill an entire texture pool. for (auto i = 0; i != mbgl::gl::TextureMax; ++i) { @@ -149,7 +149,7 @@ TEST(GLObject, TexturePool) { // Trigger a new texture pool creation. { - mbgl::gl::SharedTexture id = pool.acquireTexture(store); + mbgl::gl::PooledTexture id = pool.acquireTexture(store); EXPECT_EQ(id, mbgl::gl::TextureMax + 1); EXPECT_TRUE(store.empty()); @@ -163,7 +163,7 @@ TEST(GLObject, TexturePool) { } // First pool is still full, thus creating a new pool. - mbgl::gl::SharedTexture id1 = pool.acquireTexture(store); + mbgl::gl::PooledTexture id1 = pool.acquireTexture(store); EXPECT_GT(id1.get(), mbgl::gl::TextureMax); EXPECT_TRUE(store.empty()); @@ -175,7 +175,7 @@ TEST(GLObject, TexturePool) { EXPECT_TRUE(store.empty()); // The first pool is now gone, the next pool is now in use. - mbgl::gl::SharedTexture id2 = pool.acquireTexture(store); + mbgl::gl::PooledTexture id2 = pool.acquireTexture(store); EXPECT_GT(id2.get(), id1.get()); id2.reset(); From 62bc6e29c822d823ca6bb54d056835ec95d3aa73 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Tue, 7 Jun 2016 18:42:50 +0300 Subject: [PATCH 21/31] [core] Fix deleter mismatch delete[] was being called for a malloc() allocated C buffer. Found by valgrind: ``` ==23065== Mismatched free() / delete / delete [] ==23065== at 0x4C2F77B: operator delete[](void*) (vg_replace_malloc.c:621) ==23065== by 0x50C5529: std::default_delete::operator()(unsigned char*) const (unique_ptr.h:119) ==23065== by 0x523EC85: std::unique_ptr >::reset(unsigned char*) (unique_ptr.h:581) ==23065== by 0x523E3D4: mbgl::Raster::upload(mbgl::gl::ObjectStore&) (raster.cpp:63) ==23065== by 0x520CA08: mbgl::RasterBucket::upload(mbgl::gl::ObjectStore&) (raster_bucket.cpp:16) ==23065== by 0x520E56A: mbgl::Painter::render(mbgl::style::Style const&, mbgl::FrameData const&, mbgl::SpriteAtlas&) (painter.cpp:130) ==23065== by 0x52BE15A: mbgl::Map::Impl::render() (map.cpp:265) ==23065== by 0x52BD9BE: mbgl::Map::render() (map.cpp:175) ==23065== by 0x50C9EB4: QMapboxGL::render() (qmapboxgl.cpp:579) ==23065== by 0x4056D3: MapWindow::paintGL() (mapwindow.cpp:166) ``` --- platform/default/webp_reader.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/default/webp_reader.cpp b/platform/default/webp_reader.cpp index 37d23da11..5b0eaf474 100644 --- a/platform/default/webp_reader.cpp +++ b/platform/default/webp_reader.cpp @@ -15,8 +15,11 @@ PremultipliedImage decodeWebP(const uint8_t* data, size_t size) { throw std::runtime_error("failed to retrieve WebP basic header information"); } - std::unique_ptr webp(WebPDecodeRGBA(data, size, &width, &height)); - if (!webp) { + int stride = width * 4; + size_t webpSize = stride * height; + auto webp = std::make_unique(webpSize); + + if (!WebPDecodeRGBAInto(data, size, webp.get(), webpSize, stride)) { throw std::runtime_error("failed to decode WebP data"); } From 9746f76744b16cd3dd883eb85552ce8b260df2e1 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Tue, 7 Jun 2016 13:55:14 -0700 Subject: [PATCH 22/31] [docs] Reorganize and update development instructions (#5233) iOS - Add section headers. - Add more detail to `make` packaging commands and emphasize that Debug is the default build type. - Manually checking out git submodules is no longer necessary. Core - Add 'Keeping up to date' section that mentions submodules. --- INSTALL.md | 4 ++++ platform/ios/DEVELOPING.md | 42 +++++++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index d0f063840..b16dcafb4 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -54,3 +54,7 @@ See the relevant SDK documentation for next steps: * [Mapbox Qt SDK](platform/qt/) * [Mapbox GL Native on Linux](platform/linux/) * [node-mapbox-gl-native](platform/node/) + +## 4: Keeping up to date + +This repository uses Git submodules, which should be automatically checked out when you first run a `make` command for one of the above platforms. These submodules are not updated automatically and we recommended that you run `git submodule update` after pulling down new commits to this repository. diff --git a/platform/ios/DEVELOPING.md b/platform/ios/DEVELOPING.md index 67481d4f8..d771f7541 100644 --- a/platform/ios/DEVELOPING.md +++ b/platform/ios/DEVELOPING.md @@ -8,30 +8,42 @@ The Mapbox iOS SDK and iosapp demo application build against the iOS 7.0 SDK. Th ## Building the SDK -[Install core dependencies](../../INSTALL.md), then run +Make sure that you have the [core dependencies](../../INSTALL.md) installed. + +Create and open an Xcode workspace that includes both the SDK source and some Objective-C test applications by running: ```bash make iproj ``` -which will create and open an Xcode workspace that includes both the SDK source and some Objective-C test applications. Before building, use the scheme picker button in the toolbar to change the scheme to “iosapp” and the destination to one of the simulators or connected devices listed in the menu. +### Xcode schemes -“iosapp” is only one of several shared schemes. Others include: +Before building, use the scheme picker button in the toolbar to change the scheme to **iosapp** and the destination to one of the simulators or connected devices listed in the menu. -* “CI” builds exactly what gets built for continuous integration on Bitrise. -* “bench” is a simple benchmarking application. For more consistent results between runs, run platform/ios/benchmark/assets/{glyphs,tiles}/download.sh to download any necessary resources. -* “dynamic” builds the SDK as a dynamic framework. -* “static” builds the SDK as a static library and separate resource bundle. -* “dynamic+static” is a combination of the “dynamic” and “static” schemes. +**iosapp** is only one of several shared schemes. Others include: + +* **CI** builds exactly what gets built for continuous integration on Bitrise. +* **bench** is a simple benchmarking application. For more consistent results between runs, run `platform/ios/benchmark/assets/{glyphs,tiles}/download.sh` to download any necessary resources. +* **dynamic** builds the SDK as a dynamic framework. +* **static** builds the SDK as a static library and separate resource bundle. +* **dynamic+static** is a combination of the **dynamic** and **static** schemes. If you don’t have an Apple Developer account, change the destination to a simulator such as “iPhone 6s” before you run and build the app. -`iproj` is only one of several available `make` rules. Others include: +### Packaging builds -* `make ipackage` builds both dynamic and static frameworks in the Release configuration for devices and the iOS Simulator. +Install [jazzy](https://github.com/realm/jazzy) for generating API documentation: + +```bash +[sudo] gem install jazzy +``` + +Build and package the SDK by using one of the following commands: + +* `make ipackage` builds both dynamic and static frameworks in the Debug configuration for devices and the iOS Simulator. +* `make iframework` builds a dynamic framework in the Debug configuration for devices and the iOS Simulator. The CocoaPods pod downloads the output of this target. * `make ipackage-sim` builds a dynamic framework in the Debug configuration for the iOS simulator. This is the fastest target. -* `make ipackage-strip` builds both dynamic and static frameworks in the Release configuration, stripped of debug symbols, for devices and the iOS Simulator. -* `make iframework` builds a dynamic framework in the Release configuration for devices and the iOS Simulator. The CocoaPods pod downloads the output of this target. +* `make ipackage-strip` builds both dynamic and static frameworks in the Debug configuration, stripped of debug symbols, for devices and the iOS Simulator. * `make ifabric` builds a special static framework for compatibility with the Fabric Mac application. You can customize the build output by passing the following arguments into the `make` invocation: @@ -41,12 +53,14 @@ You can customize the build output by passing the following arguments into the ` * `FORMAT=dynamic` builds only a dynamic framework. `FORMAT=static` builds only a static framework, for compatibility with iOS 7.x. * `SYMBOLS=NO` strips the build output of any debug symbols, yielding much smaller binaries. -These targets require that you install [jazzy](https://github.com/realm/jazzy) for generating API documentation: +An example command that creates a dynamic framework suitable for eventual App Store distribution: ```bash -[sudo] gem install jazzy +make iframework BUILDTYPE=Release SYMBOLS=NO ``` +The products of these build commands can be found in the `build/ios/pkg` folder at the base of the repository. + ## Contributing ### Adding a source code file From e503f9279fd1079e12772c6a9d8b8d4ee64a53f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 7 Jun 2016 14:14:41 -0700 Subject: [PATCH 23/31] Fix crash in userLocationVerticalAlignment, analyzer warning (#5278) * [ios] Fixed crash in userLocationVerticalAlignment Avoid creating an array with nil. Fixes #5274. * [ios] Fixed analyzer warning Fixed a write-without-read analyzer warning introduced in #5235. --- platform/ios/CHANGELOG.md | 1 + platform/ios/src/MGLMapView.mm | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 8c2eeca35..fd176a947 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -21,6 +21,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CON - Fixed an issue preventing KVO change notifications from being generated on MGLMapView’s `userTrackingMode` key path when `-setUserTrackingMode:animated:` is called. ([#4724](https://github.com/mapbox/mapbox-gl-native/pull/4724)) - Rendering now occurs on the main thread, fixing a hang when calling `-[MGLMapView styleURL]` before the map view has fully loaded or while the application is in the background. ([#2909](https://github.com/mapbox/mapbox-gl-native/pull/2909)) - Improved responsiveness when zooming in then immediately panning around. ([#4595](https://github.com/mapbox/mapbox-gl-native/pull/4595)) +- Fixed a crash setting MGLMapView’s `userLocationVerticalAlignment` property before a user location update has occurred. ([#5274](https://github.com/mapbox/mapbox-gl-native/issues/5274)) - Added category methods on NSValue for converting to and from the structure types defined in MGLGeometry.h. ([#4802](https://github.com/mapbox/mapbox-gl-native/pull/4802)) - Added NSFormatter subclasses for converting geographic coordinates and directions into display strings. ([#4802](https://github.com/mapbox/mapbox-gl-native/pull/4802)) - Added a new method, `-[MGLMapView cameraThatFitsCoordinateBounds:]`, to get a camera that you can pass into `-setCamera:` that fits the given coordinate bounds. ([#4790](https://github.com/mapbox/mapbox-gl-native/pull/4790)) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index bd8762c47..5d1bcb110 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -2103,8 +2103,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) } std::sort(visibleAnnotations.begin(), visibleAnnotations.end()); - auto foundElement = std::find(visibleAnnotations.begin(), visibleAnnotations.end(), - ((MGLAnnotationAccessibilityElement *)element).tag); + auto foundElement = std::find(visibleAnnotations.begin(), visibleAnnotations.end(), tag); if (foundElement == visibleAnnotations.end()) { return NSNotFound; @@ -3846,9 +3845,10 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) [self.locationManager stopUpdatingHeading]; - if (self.userLocationAnnotationView) + CLLocation *location = self.userLocation.location; + if (location && self.userLocationAnnotationView) { - [self locationManager:self.locationManager didUpdateLocations:@[self.userLocation.location] animated:animated]; + [self locationManager:self.locationManager didUpdateLocations:@[location] animated:animated]; } break; @@ -3896,7 +3896,11 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) _userLocationVerticalAlignment = alignment; if (self.userTrackingMode != MGLUserTrackingModeNone) { - [self locationManager:self.locationManager didUpdateLocations:@[self.userLocation.location] animated:animated]; + CLLocation *location = self.userLocation.location; + if (location) + { + [self locationManager:self.locationManager didUpdateLocations:@[location] animated:animated]; + } } } From fe92d590bbe23748c691aa991f5608409a4b5924 Mon Sep 17 00:00:00 2001 From: Jesse Bounds Date: Thu, 26 May 2016 16:34:26 -0700 Subject: [PATCH 24/31] [ios] Force update from display link when display link is created. This forces the call of the map view's display link target when the display link is created. When a map view is shown the first time this is not required. However, if the display link was torn down and then recreated due to the map view being removed / obscured in the view hierarchy the map view delegate may expect to be informed when the map view did finish loading the map when it is shown again. This adds a call to `updateFromDisplayLink` just after a display link is created which helps trigger a full refresh of the map in the sense that all delegate methods get exercised including `mapViewDidFinishLoadingMap`. --- platform/ios/src/MGLMapView.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 359827ae6..57e59be10 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -913,6 +913,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) _displayLink.frameInterval = MGLTargetFrameInterval; [_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; _needsDisplayRefresh = YES; + [self updateFromDisplayLink]; } else if ( ! isVisible && _displayLink) { From c9c0767a1d5163b8e4b6a8c2c7f44eafdff711a0 Mon Sep 17 00:00:00 2001 From: Jesse Bounds Date: Fri, 27 May 2016 16:26:48 -0700 Subject: [PATCH 25/31] [ios] Update telem domain and certs Change domain from api -> events Replace old certs with new ones with the same name. The new certs have an expiry that is further out. --- .../resources/api_mapbox_com-digicert.der | Bin 2077 -> 1913 bytes .../resources/api_mapbox_com-geotrust.der | Bin 1969 -> 1757 bytes platform/ios/src/MGLAPIClient.m | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/default/resources/api_mapbox_com-digicert.der b/platform/default/resources/api_mapbox_com-digicert.der index d84cee390869435b9b0672232b5597f347b67faf..e8ef427f3302ce3bbc2f024ed67bf5a6b8aae199 100644 GIT binary patch delta 1009 zcmVOWY76uS(>yKS< z^eEt?Go7(shpD>gtz67_p8ah%j$nVVV{G6I&TSMslz|C_PQ~2m=9HS2%I|eZ``t2<@FSEg1gpd-G2|B83F?V z00Eb18bA_0xTyG*Hr*U4zPd)*u(?%ML+0BX7Z9S90mhb9T5Z-FcX3iWp-t5 zbaRvV1F{NB1_M)9i1cCu= z1cCu+0cQYplcEJAQB>a(-sS)R1Oos@Fhl|%8tg=i;o{R2)6~Oaj0>%^9!sE<*Ta>x zP16s-vNuz_0w6b<5~^vM0W!?3TtG>_J7f~`Pe)L)u?y*OL%>%qgO-yR1}0Qg-xJ=u z000C707o!I0w6~dVi?O6q!Q8bR~ZrL?D5MPsv%2j&LNQUJB?L00WUG$ zHLGKPBEvF?Xf694BXETKn~JlUwe9?|*6j3iW|rLZ4y~W6w=5t65BO#oaqXx__9_5q z>L2_t&{d+6d|K82xDaN@totP1(NtZ5&sm!i)Y$~mV=S2WfJgd?gu4kpy{(Is-x5b@?71g=x`=V%K@My@j4(c2=rOx%uP#nN6*5uepzrp`Qzv%fCcA2>yuUEHVZ%u;*z zsaxJYmrgWJ+Qe5mwODzDli~N=-=$ycn{EX>iY)JJl&ZEbyK|5Awx7kzjk_juZNHoM znBi;MnmY^S&U{T(>pYO^TtD4K_Q~aE_s$6{Kh z43T6Ekra@~WMAe@TuvZQD6m)?SWf0-v6}3|GF!5qjZ2%2k%jSEB@+u1OA}*05N9)H zGL%hXRSEKWS$Ns-~%#@9XRhSqz!jV|jR*mIL3vQ1zftnFYq5-Y~~|x`>(F6cXHFmggNuKUYmJaZgMHBS_shCW9Q(; zD%3Bu@GV^P?flPk_p-X5t+~1DfYfRB3J#C=`&Mn;k^Nya(Bip0-v55Sc{lwrn+lin z+G^%0)7!<5X{LX+bltkPUNx?ap?vatR+W07!6(jx4fZf_18V#Be@kTT4hy+TgGPJj zm%D{Fmt`*3jSOo#vN*i=YC(7hP)Q%-vek82(^GjgFByN?+$SfKp2NpF-Q%zCN_*xS zu~`ZRylk9WZ60mkc^MhGSs9p{7#SG?pPA)NE?ctl?4Gs1D?$SKK6`FdTFKPC z0ajMq3n%_ck(%$is82#>ALkFjn5#=-cu(%V$Mn9Z*DOaFcSs?RRjtQ3{7EhLT`91 zAW3dxE-@M~7zP7X1Op5aWp-t5baRuF0W5#PEaingfwZA9XNM97S2NquY-jm}ByNDu zIa-gaB&>;YxE9;EWNe2b++CRlf=jQ;l04#ru%P!6?~6UK>9xmQ&0|H?I|i_{hwk#>ej9FSU&&3=m8(e7t+9E6JN z+12=3IE23BMNCn4jUK!8QuSJBP?1Q@*-PNZG-z&Um~;I#WJR2!laP3g*LHuW6-7bbPo^M? zfvtgPaDFb1odMNch>blF#Lc$szRUms0aWf;Dpddg1Oos^Fhv3(0EHSJ@Wk6ZXGCF2 zMyZL@gSzbjwYUK)L{o+y$pqL!HUc0fj)EI+Xgr@c`M+k(rM(E^e5ppPh^ce8S8XU% z5I->hbpWKf36QjtJ_R08RPI?Sf&c&n0{})aL;@g8q=`_soXQ1{1%#dPV1L*we_ev? z3l+r4;)5kGHI;$_ARRe3*lB1`>jdZ92GmZZw}1DWJM&OG)RjQJI4ehA7?ULiCVy1! zSt@V<00aX7M=(VKAa`I~?^i~UB(e-}mLE@HmsEmpHBzlh=CngM_(}@^3j!ek;$~oI z8FH(8KbdRFcb@c&LSWa)6>H~e7&qluF(H%wFbxI?Duzgg_YDC73k3iJf&l>lWwI97 z+VpRoKE2qSM`nVb#`DD+EU>i}+ke1{SHZ)ZhWKpt{UYrZ^xdikaq0-~G8`KAJqe{V zbNiy4Qb-uc6AR3ihKicRHRUw^kf4nmVG6|3EI6V${vo>i+$?r)Hp}1e|Np(QA6j66 zHe?_s5QG7?%-yW;4Zbf~Zy7AWFeLG}vy?>cUd|GeB>)Rp3Ye#;hw(Sagt~GI!~JPvh`}x09fJNq xY%@PWgy%Ea64`3NX8oQN1F=+tb3QhmeAE@V7W!A1Z8 delta 1215 zcmcc1yOCespox90K@;2515-M{QNK=AzrU5A zG->w2_?p#Bvhl>#7=D4!9-7mCEUltI468BDS7(i07LJs2YK7h z?3}YK!04NA?vHCMd&9VNOcyRz$Tnf+so%QkS$~N@%d;Iy`?~}??zesa<|lLg$t>;b zhFvxJR+cCCJDqoaV5*rY9?U+g(n!kXbJX>amflxsQ;vPGNto`r=Fyw{(^~1bBmd7e znRd0sINQ+fx}__d&Xad3m)fpRFkd8S&MEolfNO*GhRyzeZXCHAvL~m_@ma7=`t2Kk zRx7mEN7OPgGcqtPZeqS_(8PSvpz$OyfMf+(8V?#Y?rRcC)GNu%NiEjP1&5+ua(-@; zP!blgWGrGSm|`NpU`G)R1RE)ks0WfjvP2*WLnIkPBn4fB4-~5#m_m6LfIOkV(m2DQ zaq472=4q2RFmIlGn?<$W=bYN-Z43-7%nWV@E=&qW7gJ`Z1cwBzKFz9}>$OC&dkIUu z?X?vaY76pryUdUO#H1iETB-8%&eu(+e)1&q&SlV8bftEOT#iEB^7nVecN+CvU?^h< z6JeXBfBn##%U>Vvb=hQh+^uZqo|%F%2i{Ma5qhoj!d(UiMxeD{ih!s?y=6aJm%m}h#E_X_(q`K<4YxC|#QnIg-ikXv)%`u7dIf1Zmz5i@xl z;=8&`PPsQBX3d_n$6NZQl(pheCx{3u>f_!hB40zc% zwc0$|zVk9NaSo<%dRy%)bM@+u&oR4t%qBV23%V_Rkjviq zHTET!*w3UDXG2ZqMFpzdx;-=JNXWLylUwS4o=w}s-=EFTU*Ni>+|Oi%ti|f69ik$e z-|TFw*5&n_b|nH%snG~(vR|;s}zcR5__GETQbfn_uf!p(zM($uW4mX zVv=)B;Xe*7H+Oy4kZbKN7kQ$zj=0>-yZkDDfB%I2n(3$V7u6s7*7d5ee!=btZt=-H gk)Mw&zxyDk Date: Tue, 7 Jun 2016 15:08:11 -0700 Subject: [PATCH 26/31] [ios] Update changelog and bump version to 3.2.3 --- platform/ios/CHANGELOG.md | 5 +++++ platform/ios/Mapbox-iOS-SDK-symbols.podspec | 2 +- platform/ios/Mapbox-iOS-SDK.podspec | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index a12fa0244..c0eaa9b7f 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -2,6 +2,11 @@ Mapbox welcomes participation and contributions from everyone. If you’d like to do so please see [CONTRIBUTING.md](https://github.com/mapbox/mapbox-gl-native/blob/master/CONTRIBUTING.md) first to get started. +## 3.2.3 + +- Fixed an issue preventing `-[MGLMapViewDelegate mapViewDidFinishLoadingMap:]` from being called when returning to the view controller containing the map view from another view controller. ([#5164](https://github.com/mapbox/mapbox-gl-native/pull/5164)) +- Declarations in the API documentation are shown in both Objective-C and Swift. ([realm/jazzy#530](https://github.com/realm/jazzy/pull/530)) + ## 3.2.2 - Existing MGLStyle class methods that return default style URLs have been deprecated in favor of new methods that require an explicit style version parameter. The deprecated, unversioned methods continue to return version 8 of the respective styles and will not be updated as new versions of the styles are released. ([#4759](https://github.com/mapbox/mapbox-gl-native/pull/4759)) diff --git a/platform/ios/Mapbox-iOS-SDK-symbols.podspec b/platform/ios/Mapbox-iOS-SDK-symbols.podspec index 8f081f265..5b3ef8311 100644 --- a/platform/ios/Mapbox-iOS-SDK-symbols.podspec +++ b/platform/ios/Mapbox-iOS-SDK-symbols.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |m| m.name = 'Mapbox-iOS-SDK' - m.version = '3.2.2-symbols' + m.version = '3.2.3-symbols' m.summary = 'Open source vector map solution for iOS with full styling capabilities.' m.description = 'Open source, OpenGL-based vector map solution for iOS with full styling capabilities and Cocoa Touch APIs.' diff --git a/platform/ios/Mapbox-iOS-SDK.podspec b/platform/ios/Mapbox-iOS-SDK.podspec index 086d4ddc4..a93e002a5 100644 --- a/platform/ios/Mapbox-iOS-SDK.podspec +++ b/platform/ios/Mapbox-iOS-SDK.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |m| m.name = 'Mapbox-iOS-SDK' - m.version = '3.2.2' + m.version = '3.2.3' m.summary = 'Open source vector map solution for iOS with full styling capabilities.' m.description = 'Open source, OpenGL-based vector map solution for iOS with full styling capabilities and Cocoa Touch APIs.' From 6c05e51cbc0781d6826370a618dc61855b79bb4f Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 8 Jun 2016 16:24:39 -0700 Subject: [PATCH 27/31] [linux] Mesa 11.2.2 (#5290) --- .mason | 2 +- scripts/travis_setup.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.mason b/.mason index ec5ff7cc3..0d0689065 160000 --- a/.mason +++ b/.mason @@ -1 +1 @@ -Subproject commit ec5ff7cc35d1dec325a00f4d8feff7fa3f6da2ab +Subproject commit 0d06890655b5f2995682ea5b73aeb94010f8c898 diff --git a/scripts/travis_setup.sh b/scripts/travis_setup.sh index e9fa87811..dfd045224 100755 --- a/scripts/travis_setup.sh +++ b/scripts/travis_setup.sh @@ -45,8 +45,8 @@ git submodule update --init .mason # Install and set up to load a more recent version of mesa mapbox_time "install_mesa" \ -mason install mesa 10.4.3 -export LD_LIBRARY_PATH="`mason prefix mesa 10.4.3`/lib:${LD_LIBRARY_PATH:-}" +mason install mesa 11.2.2 +export LD_LIBRARY_PATH="`mason prefix mesa 11.2.2`/lib:${LD_LIBRARY_PATH:-}" # Install and set up to load awscli pip install --user awscli From fd8753748267de7c7a729c53e714ba6f55fa06b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Thu, 9 Jun 2016 09:29:42 -0700 Subject: [PATCH 28/31] [osx] MGLMapView needs to be layer-backed Clarified the installation instructions to explain how to make the map view layer-backed on OS X. --- platform/osx/INSTALL.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/platform/osx/INSTALL.md b/platform/osx/INSTALL.md index 8a4323aa8..63b894722 100644 --- a/platform/osx/INSTALL.md +++ b/platform/osx/INSTALL.md @@ -21,7 +21,15 @@ Grab a [prebuilt release](https://github.com/mapbox/mapbox-gl-native/releases/) ## Usage -In a storyboard or XIB, add a view to your view controller. (Drag Custom View from the Object library to the View Controller scene on the Interface Builder canvas.) In the Identity inspector, set the view’s custom class to `MGLMapView`. If you need to manipulate the map view programmatically: +In a storyboard or XIB: + +1. Add a view to your view controller or window. (Drag Custom View from the Object library to the View Controller scene on the Interface Builder canvas. In a XIB, drag it instead to the window on the canvas.) +2. In the Identity inspector, set the view’s custom class to `MGLMapView`. +3. MGLMapView needs to be layer-backed: + * You can make the window layer-backed by selecting the window and checking Full Size Content View in the Attributes inspector. This allows the map view to underlap the title bar and toolbar. + * Alternatively, if you don’t want the entire window to be layer-backed, you can make just the map view layer-backed by selecting it and checking its entry under the View Effects inspector’s Core Animation Layer section. + +If you need to manipulate the map view programmatically: 1. Switch to the Assistant Editor. 1. Import the `Mapbox` module. From 8bbb7216367890b9a8d0e5bc7899d180e3af1e87 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Wed, 8 Jun 2016 14:57:46 +0300 Subject: [PATCH 29/31] [Qt][build] Updated valgrind supression and make it a target for Qt --- Makefile | 10 +- configure | 1 + platform/qt/scripts/configure.sh | 2 + scripts/valgrind.sh | 16 +++ scripts/valgrind.sup | 179 +++++++++++++++++++++++-------- 5 files changed, 161 insertions(+), 47 deletions(-) create mode 100755 scripts/valgrind.sh diff --git a/Makefile b/Makefile index ad1ebba79..3f8332938 100644 --- a/Makefile +++ b/Makefile @@ -239,6 +239,13 @@ run-qt-app: qt-app run-qt-qml-app: qt-qml-app cd $(QT_OUTPUT_PATH)/$(BUILDTYPE) && ./qquickmapboxgl +test-valgrind-qt: $(QT_MAKEFILE) node_modules + $(QT_ENV) $(MAKE) -j$(JOBS) -C $(QT_OUTPUT_PATH) test + ./scripts/valgrind.sh $(QT_OUTPUT_PATH)/$(BUILDTYPE)/test --gtest_catch_exceptions=0 --gtest_filter=-*.Load + +run-valgrind-qt-app: qt-app + ./scripts/valgrind.sh $(QT_OUTPUT_PATH)/$(BUILDTYPE)/qmapboxgl --test -platform offscreen + #### Linux targets ##################################################### LINUX_OUTPUT_PATH = build/linux-$(shell uname -m) @@ -270,9 +277,6 @@ test: $(LINUX_MAKEFILE) run-glfw-app: glfw-app cd $(LINUX_OUTPUT_PATH)/$(BUILDTYPE) && ./mapbox-glfw -run-valgrind-glfw-app: glfw-app - cd $(LINUX_OUTPUT_PATH)/$(BUILDTYPE) && valgrind --leak-check=full --suppressions=../../../scripts/valgrind.sup ./mapbox-glfw - ifneq (,$(shell which gdb)) GDB = gdb -batch -return-child-result -ex 'set print thread-events off' -ex 'run' -ex 'thread apply all bt' --args endif diff --git a/configure b/configure index 69acbde01..67148de71 100755 --- a/configure +++ b/configure @@ -123,6 +123,7 @@ print_flags webp static_libs cflags ldflags print_flags jni.hpp cflags print_flags earcut cflags print_flags benchmark static_libs cflags ldflags +print_flags valgrind CONFIG+=" } } diff --git a/platform/qt/scripts/configure.sh b/platform/qt/scripts/configure.sh index 4b855f7c5..5f31c853d 100644 --- a/platform/qt/scripts/configure.sh +++ b/platform/qt/scripts/configure.sh @@ -28,6 +28,8 @@ if [ "$MASON_PLATFORM" == "osx" ]; then CONFIG+=" 'opengl_ldflags%': ['-framework OpenGL', '-framework CoreFoundation'],"$LN } else + VALGRIND_VERSION=latest + function print_opengl_flags { CONFIG+=" 'opengl_cflags%': $(quote_flags $(pkg-config gl x11 --cflags)),"$LN CONFIG+=" 'opengl_ldflags%': $(quote_flags $(pkg-config gl x11 --libs)),"$LN diff --git a/scripts/valgrind.sh b/scripts/valgrind.sh new file mode 100755 index 000000000..009e18c43 --- /dev/null +++ b/scripts/valgrind.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +PARAMS="\ + --leak-check=full \ + --show-leak-kinds=definite \ + --errors-for-leak-kinds=definite \ + --error-exitcode=1 \ + --gen-suppressions=all \ + --suppressions=scripts/valgrind.sup" + +export VALGRIND_LIB=$(.mason/mason prefix valgrind latest)/lib/valgrind + +$(.mason/mason prefix valgrind latest)/bin/valgrind $PARAMS $@ diff --git a/scripts/valgrind.sup b/scripts/valgrind.sup index fcde049d9..f21f54be5 100644 --- a/scripts/valgrind.sup +++ b/scripts/valgrind.sup @@ -1,91 +1,182 @@ { - Valgrind gets confused with buffers managed by the graphics driver + Graphics driver buffers Memcheck:Leak ... - obj:/usr/*/dri/r600_dri.so + obj:*/r600_dri.* + obj:*/r600_dri.* + obj:*/r600_dri.* ... } { - GLFW _glfwCreateCursor() + Graphics driver buffers Memcheck:Leak - match-leak-kinds: reachable ... - obj:/usr/*/libX11.so.6.3.0 - ... - fun:_glfwCreateCursor + obj:*/i965_dri.* + obj:*/i965_dri.* + obj:*/i965_dri.* ... } { - GLFW _glfwPlatform*() + Graphics driver buffers Memcheck:Leak - match-leak-kinds: reachable ... - fun:_glfwPlatform* + obj:*/nouveau_dri.* + obj:*/nouveau_dri.* + obj:*/nouveau_dri.* ... } { - Buffer managed by OpenGL? + Ubuntu 16.04 - GLFW + Memcheck:Leak + ... + fun:glfwInit + ... +} +{ + Ubuntu 16.04 - GLFW Memcheck:Cond ... - fun:_ZN4mbgl*Uniform* - ... - fun:_ZN8GLFWView10invalidateEv + fun:glfwInit ... } { - Buffer managed by OpenGL? + Ubuntu 16.04 - Qt + glib Memcheck:Cond - fun:_ZNSt7__equalILb0EE5equalIPKfS3_EEbT_S4_T0_ - ... - fun:_ZN4mbgl7Painter11renderLayerERKNS_10StyleLayerEPKNS_4Tile2IDEPKSt5arrayIfLm16EE -} -{ - Valgrind doesn't like our make_unique (C++14 polyfill) - Memcheck:Leak - match-leak-kinds: reachable - fun:malloc - ... - fun:_ZN4mbgl4util11make_unique* + fun:g_utf8_offset_to_pointer ... } { - dlopen doing its magic - Memcheck:Leak - match-leak-kinds: reachable + Ubuntu 16.04 - Qt + glib + Memcheck:Cond ... - fun:_dl_open + fun:g_signal_emit_valist + ... + fun:*QApplicationPrivate* ... } { - X11 false positive - Memcheck:Leak - match-leak-kinds: reachable + Ubuntu 16.04 - Qt + X11 + Memcheck:Param + writev(vector[...]) ... - obj:/usr/*/libX11.so.6.3.0 - ... - fun:_XrmInitParseInfo + obj:*/libxcb.* + fun:xcb_flush ... } { - OpenSSL false positive + Ubuntu 16.04 - Qt + X11 Memcheck:Leak ... - fun:CRYPTO_malloc + fun:_XmbTextListToTextProperty + ... + fun:*QWidget*setVisible* ... } { - OpenSSL false positive + Ubuntu 16.04 - Qt + Fontconfig Memcheck:Leak ... - fun:CRYPTO_realloc + obj:*/libfontconfig.* + obj:*/libfontconfig.* + ... + fun:FcFontRenderPrepare ... } { - Libcurl false positive + Ubuntu 16.04 - Qt + Fontconfig + Memcheck:Leak + ... + obj:*/libfontconfig.* + obj:*/libfontconfig.* + ... + fun:FcPatternAddInteger + ... +} +{ + Ubuntu 16.04 - Qt + Fontconfig + Memcheck:Leak + ... + obj:*/libfontconfig.* + obj:*/libfontconfig.* + ... + fun:FcConfigParseAndLoad + ... +} +{ + Ubuntu 16.04 - Qt + Dbus + Memcheck:Leak + ... + fun:dbus_connection_send_with_reply + ... + fun:*QWidget* +} +{ + Ubuntu 16.04 - Qt + Dbus + Memcheck:Leak + ... + fun:px_proxy_factory_get_proxies + obj:*/libQt5Network.* +} +{ + Ubuntu 16.04 - Qt + Memcheck:Leak + ... + fun:*QGuiApplicationPrivate*createEventDispatcher* + fun:*QCoreApplication*init* + ... +} +{ + Ubuntu 16.04 - Qt + Memcheck:Leak + ... + fun:*QWidget*setWindowTitle* + ... +} +{ + Ubuntu 16.04 - Qt + Memcheck:Leak + ... + fun:*QNetworkConfigurationManagerPrivate*updateConfigurations* + ... +} +{ + Ubuntu 16.04 - Mysterious leak when running utests + Memcheck:Leak + fun:calloc + obj:* + obj:* + obj:* + obj:* + obj:* + obj:* + obj:* + obj:* + obj:* + obj:* + obj:* +} +{ + Ubuntu 16.04 - Mysterious leak when running utests Memcheck:Leak fun:malloc - ... - obj:/usr/*/libcurl.so.4.3.0 - fun:curl_multi_socket_action + obj:* + obj:* + obj:* + obj:* + obj:* + obj:* + obj:* + obj:* + obj:* + obj:* + obj:* +} +{ + Ubuntu 14.04 - Travis CI bot using swrast + Memcheck:Cond + fun:do_stencil_test + fun:_swrast_stencil_and_ztest_span + fun:_swrast_write_rgba_span + fun:draw_wide_line ... } From c4e5ebbfee14bd3223ad77533b0d9cc01074902b Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Wed, 8 Jun 2016 18:18:14 +0300 Subject: [PATCH 30/31] [Qt][build] Run Qt valgrind test on the bots --- .travis.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5ae5baac6..eb7e2668f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,13 +18,13 @@ addons_shortcuts: addons_qt4: &qt4 apt: sources: [ 'ubuntu-toolchain-r-test' ] - packages: [ 'gdb', 'g++-5', 'gcc-5', + packages: [ 'g++-5', 'gcc-5', 'mesa-utils', 'qt4-default' ] addons_qt5: &qt5 apt: sources: [ 'ubuntu-toolchain-r-test' ] - packages: [ 'gdb', 'g++-5', 'gcc-5', - 'mesa-utils', 'qt5-default', 'libqt5opengl5-dev', 'qtdeclarative5-dev', 'qtpositioning5-dev', 'qtlocation5-dev' ] + packages: [ 'g++-5', 'gcc-5', + 'mesa-utils', 'libc6-dbg', 'qt5-default', 'libqt5opengl5-dev', 'qtdeclarative5-dev', 'qtpositioning5-dev', 'qtlocation5-dev' ] env: global: @@ -112,7 +112,8 @@ matrix: env: BUILDTYPE=Release _CXX=g++-5 _CC=gcc-5 addons: *qt4 script: - - make qt-app test-qt + - make qt-app + - make test-qt # Qt 5 - Release - os: linux @@ -123,7 +124,9 @@ matrix: env: BUILDTYPE=Release _CXX=g++-5 _CC=gcc-5 addons: *qt5 script: - - make qt-app qt-qml-app test-qt + - make qt-app + - make qt-qml-app + - make test-valgrind-qt cache: directories: From 40211abd9a6cb6a3b0eb8dbe61e1ccb605d19677 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Wed, 8 Jun 2016 19:10:09 +0300 Subject: [PATCH 31/31] [test] Rename Stress test to Load Too slow to run on valgrind. --- test/storage/asset_file_source.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/storage/asset_file_source.cpp b/test/storage/asset_file_source.cpp index 64f725480..ab214ff79 100644 --- a/test/storage/asset_file_source.cpp +++ b/test/storage/asset_file_source.cpp @@ -21,7 +21,7 @@ std::string getFileSourceRoot() { using namespace mbgl; -TEST(AssetFileSource, Stress) { +TEST(AssetFileSource, Load) { util::RunLoop loop; AssetFileSource fs(getFileSourceRoot());