From 73c3af4efeca769114e42b0641ca163693004058 Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Thu, 3 Sep 2015 16:12:53 +1000 Subject: [PATCH 001/156] Switch to TextureView Closes #2244 --- .../com/mapbox/mapboxgl/views/MapView.java | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java index 3718a567a..0d472e971 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java @@ -11,6 +11,7 @@ import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Matrix; import android.graphics.PointF; +import android.graphics.SurfaceTexture; import android.hardware.GeomagneticField; import android.hardware.Sensor; import android.hardware.SensorEvent; @@ -34,8 +35,8 @@ import android.util.AttributeSet; import android.view.InputDevice; import android.view.KeyEvent; import android.view.MotionEvent; -import android.view.SurfaceHolder; -import android.view.SurfaceView; +import android.view.Surface; +import android.view.TextureView; import android.view.View; import android.view.ViewConfiguration; import android.widget.FrameLayout; @@ -294,8 +295,8 @@ public class MapView extends FrameLayout implements LocationListener { // Save the context mContext = context; - SurfaceView surfaceView = new SurfaceView(mContext); - addView(surfaceView); + TextureView textureView = new TextureView(mContext); + addView(textureView); // Check if we are in Eclipse UI editor if (isInEditMode()) { @@ -328,8 +329,8 @@ public class MapView extends FrameLayout implements LocationListener { setFocusableInTouchMode(true); requestFocus(); - // Register the SurfaceHolder callbacks - surfaceView.getHolder().addCallback(new CallbacksHandler()); + // Register the TextureView callbacks + textureView.setSurfaceTextureListener(new SurfaceTextureListener()); // Touch gesture detectors mGestureDetector = new GestureDetectorCompat(context, new GestureListener()); @@ -843,37 +844,44 @@ public class MapView extends FrameLayout implements LocationListener { } } - // This class handles SurfaceHolder callbacks - private class CallbacksHandler implements SurfaceHolder.Callback, SurfaceHolder.Callback2 { + // This class handles TextureView callbacks + private class SurfaceTextureListener implements TextureView.SurfaceTextureListener { - // Called when the native surface buffer has been created + // Called when the native surface texture has been created // Must do all EGL/GL ES initialization here @Override - public void surfaceCreated(SurfaceHolder holder) { - mNativeMapView.createSurface(holder.getSurface()); + public void onSurfaceTextureAvailable (SurfaceTexture surface, int width, int height) { + mNativeMapView.createSurface(new Surface(surface)); + mNativeMapView.resizeFramebuffer(width, height); } - // Called when the native surface buffer has been destroyed + // Called when the native surface texture has been destroyed // Must do all EGL/GL ES destruction here @Override - public void surfaceDestroyed(SurfaceHolder holder) { + public boolean onSurfaceTextureDestroyed (SurfaceTexture surface) { mNativeMapView.destroySurface(); + return true; } - // Called when the format or size of the native surface buffer has been - // changed + // Called when the format or size of the native surface texture has been changed // Must handle window resizing here. @Override - public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { + public void onSurfaceTextureSizeChanged (SurfaceTexture surface, int width, int height) { mNativeMapView.resizeFramebuffer(width, height); } // Called when we need to redraw the view // This is called before our view is first visible to prevent an initial // flicker (see Android SDK documentation) - @Override + /*@Override public void surfaceRedrawNeeded(SurfaceHolder holder) { mNativeMapView.update(); + }*/ // TODO call update somewhere? + + // Not used + @Override + public void onSurfaceTextureUpdated (SurfaceTexture surface) { + // Do nothing } } From 71bfaec131d05ef360279cee83f5014febcd3d52 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Mon, 7 Sep 2015 14:43:26 -0700 Subject: [PATCH 002/156] bump podspec for ios-v2.1.0-pre.3 --- ios/Mapbox-iOS-SDK.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Mapbox-iOS-SDK.podspec b/ios/Mapbox-iOS-SDK.podspec index 099a84c8a..449d4ce1d 100644 --- a/ios/Mapbox-iOS-SDK.podspec +++ b/ios/Mapbox-iOS-SDK.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |m| m.name = 'Mapbox-iOS-SDK' - m.version = '2.0.0-symbols' + m.version = '2.1.0-pre.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 bindings.' From 72b75fab983f8b4064ffc22951dac0fbc8bbd87a Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Mon, 7 Sep 2015 14:44:02 -0700 Subject: [PATCH 003/156] [publish ios-v2.1.0-pre.3] From b29ef4011ef7f92af84d207aa5b005b8bb5c12e2 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Mon, 7 Sep 2015 14:45:11 -0700 Subject: [PATCH 004/156] fix typo in iOS script --- scripts/ios/publish.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ios/publish.sh b/scripts/ios/publish.sh index 61270fb45..c914fcacc 100755 --- a/scripts/ios/publish.sh +++ b/scripts/ios/publish.sh @@ -6,7 +6,7 @@ set -u # # iOS release tag format is `vX.Y.Z`; `X.Y.Z` gets passed in -# In the case of symbolicated builds, we also append the `style`. +# In the case of symbolicated builds, we also append the `-symbols`. # PUBLISH_VERSION="$1" From a9ef04e2189f2fc9947cb54c71732760e5c8e0db Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Mon, 7 Sep 2015 14:44:02 -0700 Subject: [PATCH 005/156] [publish ios-v2.1.0-pre.3] From 8f37502c719feb151e01cb31d89c2effaf1b91ad Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Tue, 8 Sep 2015 14:01:53 +1000 Subject: [PATCH 006/156] Use MapView as parent for InfoWindow See comment in #894 --- .../main/java/com/mapbox/mapboxgl/annotations/InfoWindow.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/InfoWindow.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/InfoWindow.java index c48227501..56eae1951 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/InfoWindow.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/InfoWindow.java @@ -28,11 +28,10 @@ public class InfoWindow { public InfoWindow(int layoutResId, MapView mapView) { mMapView = mapView; mIsVisible = false; - ViewGroup parent = (ViewGroup) mapView.getParent(); Context context = mapView.getContext(); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - mView = inflater.inflate(layoutResId, parent, false); + mView = inflater.inflate(layoutResId, (ViewGroup) mapView, false); if (mTitleId == 0) { setResIds(mapView.getContext()); From 9a55e9702915493ac34f58469674eaf9e77c019b Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Tue, 8 Sep 2015 11:43:55 -0400 Subject: [PATCH 007/156] Fix build, only ask for location permission on user's instigation Previously in #2265 we would ask for location permission at app startup if `!settings->showsUserLocation`. #2193 0a172a21fdc2a87473560fd7d45f4d495d95de91 changed the way we used `NSUserDefaults` and mostly removed the `settings` object, which broke #2265. Rather than fix our pestering location permissions ask at startup, this commit now only asks for location permissions when the user hits the locate-me button. Once a user grants permission, the user dot appears because a `userTrackingMode` is set, `showsUserLocation` is permanently set to `YES` in `NSUserDefaults` and is restored at launch. --- ios/app/MBXViewController.mm | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ios/app/MBXViewController.mm b/ios/app/MBXViewController.mm index b32371770..d94e41b5f 100644 --- a/ios/app/MBXViewController.mm +++ b/ios/app/MBXViewController.mm @@ -83,13 +83,6 @@ static NSUInteger const kStyleVersion = 8; action:@selector(locateUser)]; [self restoreState:nil]; - - if ( ! settings->showsUserLocation) - { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ - self.mapView.showsUserLocation = YES; - }); - } } - (void)saveState:(__unused NSNotification *)notification From 3f497ff9d23c8f01d36889d09ef5f3989960115f Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Tue, 8 Sep 2015 14:46:18 -0500 Subject: [PATCH 008/156] #2283 - Supporting custom InfoWindow touch listeners via Marker.setInfoWindowOnTouchListener(). Added Test to Custom Annotations in TestApp's MainActivity. --- .../mapbox/mapboxgl/annotations/Marker.java | 28 ++++++++++++++++--- .../com/mapbox/mapboxgl/views/MapView.java | 16 +++++++---- .../mapbox/mapboxgl/testapp/MainActivity.java | 12 +++++++- 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Marker.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Marker.java index 4776c37bf..17317bffb 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Marker.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Marker.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxgl.annotations; import android.graphics.Point; +import android.view.View; import com.mapbox.mapboxgl.geometry.LatLng; import com.mapbox.mapboxgl.views.R; @@ -145,13 +146,32 @@ public class Marker extends Annotation { return; } + getInfoWindow().open(this, getPosition(), (int) anchorU, (int) anchorV); + getInfoWindow().setBoundMarker(this); + infoWindowShown = true; + } + + /** + * Use to set a custom OnTouchListener for the InfoWindow. + * By default the InfoWindow will close on touch. + * @param listener Custom OnTouchListener + */ + public void setInfoWindowOnTouchListener(View.OnTouchListener listener) { + if (listener == null) { + return; + } + getInfoWindow().setOnTouchListener(listener); + } + + /** + * Common internal InfoWindow initialization method + * @return InfoWindow for Marker + */ + private InfoWindow getInfoWindow() { if (infoWindow == null) { infoWindow = new InfoWindow(R.layout.infowindow, mapView); } - - infoWindow.open(this, getPosition(), (int)anchorU, (int)anchorV); - infoWindow.setBoundMarker(this); - infoWindowShown = true; + return infoWindow; } @Override diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java index f5610f5d9..0c3429e00 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java @@ -8,10 +8,7 @@ import android.content.IntentFilter; import android.content.pm.PackageManager; import android.content.res.TypedArray; import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.Matrix; -import android.graphics.Paint; import android.graphics.PointF; import android.graphics.RectF; import android.hardware.GeomagneticField; @@ -29,7 +26,6 @@ import android.support.v4.content.ContextCompat; import android.support.v4.view.GestureDetectorCompat; import android.support.v4.view.ScaleGestureDetectorCompat; import android.text.TextUtils; -import android.util.Log; import android.view.GestureDetector; import android.view.Gravity; import android.view.ScaleGestureDetector; @@ -483,6 +479,9 @@ public class MapView extends FrameLayout implements LocationListener { private void removeAnnotationsWithId(long annotationId){ for (Iterator iterator = mAnnotations.iterator(); iterator.hasNext();) { Annotation annotation = iterator.next(); + if (annotation instanceof Marker) { + ((Marker)annotation).hideInfoWindow(); + } if (annotation.getId() == annotationId) { iterator.remove(); } @@ -490,6 +489,9 @@ public class MapView extends FrameLayout implements LocationListener { } public void removeAnnotation(Annotation annotation) { + if (annotation instanceof Marker) { + ((Marker)annotation).hideInfoWindow(); + } long id = annotation.getId(); mNativeMapView.removeAnnotation(id); mAnnotations.remove(annotation); @@ -503,8 +505,12 @@ public class MapView extends FrameLayout implements LocationListener { public void removeAnnotations() { long[] ids = new long[mAnnotations.size()]; for(int i = 0; i < mAnnotations.size(); i++) { - long id = mAnnotations.get(i).getId(); + Annotation annotation = mAnnotations.get(i); + long id = annotation.getId(); ids[i] = id; + if (annotation instanceof Marker) { + ((Marker)annotation).hideInfoWindow(); + } } mNativeMapView.removeAnnotations(ids); mAnnotations.clear(); diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java index ba521fc31..ed9b7ef06 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java @@ -22,7 +22,9 @@ import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.widget.TextView; +import android.widget.Toast; import com.crashlytics.android.Crashlytics; +import com.mapbox.mapboxgl.annotations.Marker; import com.mapbox.mapboxgl.annotations.MarkerOptions; import com.mapbox.mapboxgl.annotations.PolygonOptions; import com.mapbox.mapboxgl.annotations.PolylineOptions; @@ -395,10 +397,18 @@ public class MainActivity extends AppCompatActivity { private void addMarkers() { LatLng backLot = new LatLng(38.649441, -121.369064); - mMapView.addMarker(new MarkerOptions() + final Marker marker = mMapView.addMarker(new MarkerOptions() .position(backLot) .title("Back Lot") .snippet("The back lot behind my house")); + marker.setInfoWindowOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + Toast.makeText(getApplicationContext(), "Custom Info Touch Listener!!", Toast.LENGTH_SHORT).show(); + marker.hideInfoWindow(); + return true; + } + }); LatLng cheeseRoom = new LatLng(38.531577,-122.010646); mMapView.addMarker(new MarkerOptions() From 0d899df9ddc9a7a9a8bfbac2c4b077ce26da64e9 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Tue, 8 Sep 2015 18:03:10 -0700 Subject: [PATCH 009/156] fixes #1675: abstract annotation tile refresh check/render; trigger post-sprite/sprite store load --- src/mbgl/map/annotation.hpp | 1 + src/mbgl/map/map_context.cpp | 10 ++++++++-- src/mbgl/map/map_context.hpp | 2 ++ src/mbgl/style/style.cpp | 4 ++++ src/mbgl/style/style.hpp | 1 + test/style/resource_loading.cpp | 4 ++++ 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/mbgl/map/annotation.hpp b/src/mbgl/map/annotation.hpp index 745fc779c..5adec162f 100644 --- a/src/mbgl/map/annotation.hpp +++ b/src/mbgl/map/annotation.hpp @@ -52,6 +52,7 @@ public: ~AnnotationManager(); void markStaleTiles(std::unordered_set); + size_t getStaleTileCount() const { return staleTiles.size(); } std::unordered_set resetStaleTiles(); void setDefaultPointAnnotationSymbol(const std::string& symbol); diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp index 94aedb46d..0ebcd73f8 100644 --- a/src/mbgl/map/map_context.cpp +++ b/src/mbgl/map/map_context.cpp @@ -142,9 +142,11 @@ void MapContext::loadStyleJSON(const std::string& json, const std::string& base) updateFlags |= Update::DefaultTransition | Update::Classes | Update::Zoom; asyncUpdate->send(); +} - auto staleTiles = data.getAnnotationManager()->resetStaleTiles(); - if (!staleTiles.empty()) { +void MapContext::updateAnnotationTilesIfNeeded() { + if (data.getAnnotationManager()->getStaleTileCount()) { + auto staleTiles = data.getAnnotationManager()->resetStaleTiles(); updateAnnotationTiles(staleTiles); } } @@ -417,4 +419,8 @@ void MapContext::onResourceLoadingFailed(std::exception_ptr error) { } } +void MapContext::onSpriteStoreLoaded() { + updateAnnotationTilesIfNeeded(); +} + } diff --git a/src/mbgl/map/map_context.hpp b/src/mbgl/map/map_context.hpp index f1bfb01e4..449a0f1d1 100644 --- a/src/mbgl/map/map_context.hpp +++ b/src/mbgl/map/map_context.hpp @@ -54,6 +54,7 @@ public: bool isLoaded() const; double getTopOffsetPixelsForAnnotationSymbol(const std::string& symbol); + void updateAnnotationTilesIfNeeded(); void updateAnnotationTiles(const std::unordered_set&); void setSourceTileCacheSize(size_t size); @@ -66,6 +67,7 @@ public: // Style::Observer implementation. void onTileDataChanged() override; void onResourceLoadingFailed(std::exception_ptr error) override; + void onSpriteStoreLoaded() override; private: // Update the state indicated by the accumulated Update flags, then render. diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index 768621530..d4c9bd4e5 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -190,6 +190,10 @@ void Style::onSpriteLoaded(const Sprites& sprites) { // Add all sprite images to the SpriteStore object spriteStore->setSprites(sprites); + if (observer) { + observer->onSpriteStoreLoaded(); + } + shouldReparsePartialTiles = true; emitTileDataChanged(); } diff --git a/src/mbgl/style/style.hpp b/src/mbgl/style/style.hpp index cbc0ee2db..3f9696ffb 100644 --- a/src/mbgl/style/style.hpp +++ b/src/mbgl/style/style.hpp @@ -39,6 +39,7 @@ public: virtual ~Observer() = default; virtual void onTileDataChanged() = 0; + virtual void onSpriteStoreLoaded() = 0; virtual void onResourceLoadingFailed(std::exception_ptr error) = 0; }; diff --git a/test/style/resource_loading.cpp b/test/style/resource_loading.cpp index 056243458..5ed09065a 100644 --- a/test/style/resource_loading.cpp +++ b/test/style/resource_loading.cpp @@ -63,6 +63,10 @@ public: callback_(error); } + void onSpriteStoreLoaded() override { + // no-op + } + private: MapData data_; Transform transform_; From ea0992b72f3d70eb474a8c120e776032bfc57d01 Mon Sep 17 00:00:00 2001 From: tobrunvannuland Date: Tue, 1 Sep 2015 08:36:53 +0200 Subject: [PATCH 010/156] Added info icon and map box logo --- .../com/mapbox/mapboxgl/views/MapView.java | 133 +++++++++++++++++- .../main/res/color/material_bg_selector.xml | 8 ++ .../ic_info_outline_black_24dp.png | Bin 0 -> 487 bytes .../ic_info_outline_black_24dp.png | Bin 0 -> 323 bytes .../ic_info_outline_black_24dp.png | Bin 0 -> 640 bytes .../ic_info_outline_black_24dp.png | Bin 0 -> 940 bytes .../res/drawable-xxhdpi/ic_logo_mapbox.png | Bin 0 -> 7059 bytes .../ic_info_outline_black_24dp.png | Bin 0 -> 1256 bytes .../src/main/res/values/arrays.xml | 13 ++ .../src/main/res/values/attrs.xml | 62 +++++++- .../src/main/res/values/strings.xml | 3 + 11 files changed, 215 insertions(+), 4 deletions(-) create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/color/material_bg_selector.xml create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/ic_info_outline_black_24dp.png create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/ic_info_outline_black_24dp.png create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/ic_info_outline_black_24dp.png create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/ic_info_outline_black_24dp.png create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/ic_logo_mapbox.png create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/ic_info_outline_black_24dp.png create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/values/arrays.xml diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java index 0c3429e00..7bb9f4327 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java @@ -1,16 +1,22 @@ package com.mapbox.mapboxgl.views; import android.app.ActivityManager; +import android.app.AlertDialog; +import android.app.Dialog; import android.content.BroadcastReceiver; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; +import android.content.res.ColorStateList; import android.content.res.TypedArray; +import android.content.res.XmlResourceParser; import android.graphics.Bitmap; import android.graphics.Matrix; import android.graphics.PointF; import android.graphics.RectF; +import android.graphics.drawable.Drawable; import android.hardware.GeomagneticField; import android.hardware.Sensor; import android.hardware.SensorEvent; @@ -19,10 +25,12 @@ import android.hardware.SensorManager; import android.location.Location; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; +import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v4.view.GestureDetectorCompat; import android.support.v4.view.ScaleGestureDetectorCompat; import android.text.TextUtils; @@ -37,6 +45,8 @@ import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.view.ViewConfiguration; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ZoomButtonsController; @@ -94,6 +104,10 @@ public class MapView extends FrameLayout implements LocationListener { private static final String STATE_MY_LOCATION_ENABLED = "myLocationEnabled"; private static final String STATE_USER_LOCATION_TRACKING_MODE = "userLocationTrackingMode"; + // Used for positioning views + private static final float DIMENSION_SIXTEEN_DP = 16f; + private static final float DIMENSION_TEN_DP = 10f; + /** * Every annotation that has been added to the map. */ @@ -155,6 +169,12 @@ public class MapView extends FrameLayout implements LocationListener { private float mCompassBearing; private boolean mCompassValid = false; + // Used for MapboxLogo + private ImageView mLogoView; + + // Used for attributions control + private ImageView mAttributionsView; + // Used for map toggle mode private long t0 = new Date().getTime(); @@ -305,6 +325,8 @@ public class MapView extends FrameLayout implements LocationListener { // Get the screen's density mScreenDensity = context.getResources().getDisplayMetrics().density; + int tenDp = (int)(10 * mScreenDensity); + int sixteenDp = (int)(16 * mScreenDensity); // Get the cache path String cachePath = context.getCacheDir().getAbsolutePath(); @@ -372,13 +394,30 @@ public class MapView extends FrameLayout implements LocationListener { mCompassView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.compass)); mCompassView.setContentDescription(getResources().getString(R.string.compassContentDescription)); LayoutParams lp = new FrameLayout.LayoutParams((int)(48 * mScreenDensity), (int)(48 * mScreenDensity)); - lp.gravity = Gravity.TOP | Gravity.END; - int tenDp = (int)(10 * mScreenDensity); - lp.setMargins(tenDp, tenDp, tenDp, tenDp); mCompassView.setLayoutParams(lp); addView(mCompassView); mCompassView.setOnClickListener(new CompassOnClickListener()); + // Setup Mapbox logo + mLogoView = new ImageView(mContext); + mLogoView.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_logo_mapbox)); + mLogoView.setContentDescription(getResources().getString(R.string.mapboxIconContentDescription)); + LayoutParams logoParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + mLogoView.setLayoutParams(logoParams); + addView(mLogoView); + + // Setup Attributions control + mAttributionsView = new ImageView(mContext); + Drawable attrDrawable = ContextCompat.getDrawable(mContext, R.drawable.ic_info_outline_black_24dp); + attrDrawable = DrawableCompat.wrap(attrDrawable); + DrawableCompat.setTintList(attrDrawable, getResources().getColorStateList(R.color.material_bg_selector, mContext.getTheme())); + mAttributionsView.setImageDrawable(attrDrawable); + mAttributionsView.setContentDescription(getResources().getString(R.string.attributionsIconContentDescription)); + LayoutParams attrParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + mAttributionsView.setLayoutParams(attrParams); + addView(mAttributionsView); + mAttributionsView.setOnClickListener(new AttributionOnClickListener()); + // Setup Support For Listener Tracking // MapView's internal listener is setup in onCreate() mOnMapChangedListener = new ArrayList<>(); @@ -411,7 +450,29 @@ public class MapView extends FrameLayout implements LocationListener { } setStyleClasses(styleClasses); } + + // Compass setCompassEnabled(typedArray.getBoolean(R.styleable.MapView_compassEnabled, true)); + setCompassGravity(typedArray.getInt(R.styleable.MapView_compassGravity, Gravity.TOP | Gravity.END)); + setWidgetMargins(mCompassView, typedArray.getDimension(R.styleable.MapView_compassMarginLeft, DIMENSION_TEN_DP) + , typedArray.getDimension(R.styleable.MapView_compassMarginTop, DIMENSION_TEN_DP) + , typedArray.getDimension(R.styleable.MapView_compassMarginRight, DIMENSION_TEN_DP) + , typedArray.getDimension(R.styleable.MapView_compassMarginBottom, DIMENSION_TEN_DP)); + + // Logo + setLogoGravity(typedArray.getInt(R.styleable.MapView_logoGravity, Gravity.BOTTOM | Gravity.START)); + setWidgetMargins(mLogoView, typedArray.getDimension(R.styleable.MapView_logoMarginLeft, DIMENSION_SIXTEEN_DP) + , typedArray.getDimension(R.styleable.MapView_logoMarginTop, DIMENSION_SIXTEEN_DP) + , typedArray.getDimension(R.styleable.MapView_logoMarginRight, DIMENSION_SIXTEEN_DP) + , typedArray.getDimension(R.styleable.MapView_logoMarginBottom, DIMENSION_SIXTEEN_DP)); + + // Attribution + setAttributionGravity(typedArray.getInt(R.styleable.MapView_attributionGravity, Gravity.BOTTOM | Gravity.END)); + setWidgetMargins(mAttributionsView, typedArray.getDimension(R.styleable.MapView_attributionMarginLeft, DIMENSION_SIXTEEN_DP) + , typedArray.getDimension(R.styleable.MapView_attributionMarginTop, DIMENSION_SIXTEEN_DP) + , typedArray.getDimension(R.styleable.MapView_attributionMarginRight, DIMENSION_SIXTEEN_DP) + , typedArray.getDimension(R.styleable.MapView_attributionMarginBottom, DIMENSION_SIXTEEN_DP)); + setMyLocationEnabled(typedArray.getBoolean(R.styleable.MapView_myLocationEnabled, false)); } finally { typedArray.recycle(); @@ -1827,6 +1888,48 @@ public class MapView extends FrameLayout implements LocationListener { updateMap(MapChange.MapChangeNullChange); } + public void setCompassGravity(int gravity){ + setWidgetGravity(mCompassView, gravity); + } + + public void setCompassMargins(int left, int top, int right, int bottom){ + setWidgetMargins(mCompassView, left, top, right, bottom); + } + + public void setLogoGravity(int gravity){ + setWidgetGravity(mLogoView, gravity); + } + + public void setLogoMargins(int left, int top, int right, int bottom){ + setWidgetMargins(mLogoView, left, top, right, bottom); + } + + public void setAttributionGravity(int gravity){ + setWidgetGravity(mAttributionsView, gravity); + } + + public void setAttributionMargins(int left, int top, int right, int bottom) { + setWidgetMargins(mAttributionsView, left, top, right, bottom); + } + + private void setWidgetGravity(@NonNull final View view, int gravity){ + LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); + layoutParams.gravity = gravity; + view.setLayoutParams(layoutParams); + } + + private void setWidgetMargins(@NonNull final View view, int left, int top, int right, int bottom){ + LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); + layoutParams.setMargins(left,top,right,bottom); + view.setLayoutParams(layoutParams); + } + + private void setWidgetMargins(@NonNull final View view, float leftDp, float topDp, float rightDp, float bottomDp){ + LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); + layoutParams.setMargins((int)(leftDp*mScreenDensity),(int)(topDp*mScreenDensity),(int)(rightDp*mScreenDensity),(int)(bottomDp*mScreenDensity)); + view.setLayoutParams(layoutParams); + } + // This class handles sensor updates to calculate compass bearing private class CompassListener implements SensorEventListener { @@ -1881,6 +1984,30 @@ public class MapView extends FrameLayout implements LocationListener { } + private static class AttributionOnClickListener implements View.OnClickListener, DialogInterface.OnClickListener { + + // Called when someone presses the attribution icon + @Override + public void onClick(View v) { + Context context = v.getContext(); + String[] items = context.getResources().getStringArray(R.array.attribution_names); + AlertDialog.Builder builder = new AlertDialog.Builder(context); + builder.setTitle(R.string.attributionsDialogTitle); + builder.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, items), this); + builder.show(); + } + + // Called when someone selects an attribution + @Override + public void onClick(DialogInterface dialog, int which) { + Context context = ((Dialog)dialog).getContext(); + String[]links = context.getResources().getStringArray(R.array.attribution_links); + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse(links[which])); + context.startActivity(intent); + } + } + /** * LOST's LocationListener Callback * @param location New Location diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/color/material_bg_selector.xml b/android/java/MapboxGLAndroidSDK/src/main/res/color/material_bg_selector.xml new file mode 100644 index 000000000..0da674ac7 --- /dev/null +++ b/android/java/MapboxGLAndroidSDK/src/main/res/color/material_bg_selector.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/ic_info_outline_black_24dp.png b/android/java/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/ic_info_outline_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..4b5ab06e19d61515cf3a7395db43a81bb30a8203 GIT binary patch literal 487 zcmVS-P=?%O3jv@aJa6HGW<0ceyC!`rEoc~?j{U=`ic|b z9N*QPsMv*+MQv@1i8kR%)UIh1`=XoCqqIYBOKErvea{GWZ!y>;D~RpT`=%tUi9cM8 zjMJd-5IZXpx*;AQpQG66NVp4e3Hh{Q=T<@);yl@>u@F125nkF002ovPDHLkV1kFY-~<2w literal 0 HcmV?d00001 diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/ic_info_outline_black_24dp.png b/android/java/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/ic_info_outline_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..e0c9fe0eb8457013fbfa6e2efea61fca70bb9303 GIT binary patch literal 323 zcmV-J0lfZ+P)&s5ci5fY}sT-yed|rRg0)~VyRe(RxP5| ziKSu?+iDTDUGbuL5L2~?+LgFdoQk=|C}Pxj7RQRtyXcJ~MwepHsvL@iJ?s4SCH8$Y z6AQgYt#Ro~-1uQ)CSvZwj!tLSm1hyxCe}LeCL$stVz6(6)`@$smX==JIoA4R{{X3C VfQx`Hg^K_H002ovPDHLkV1oM>kN^Mx literal 0 HcmV?d00001 diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/ic_info_outline_black_24dp.png b/android/java/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/ic_info_outline_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..b706f0d06a9a1e5e2f6606c01e84094ee6a99b42 GIT binary patch literal 640 zcmV-`0)PF9P)o#88fEO5na|OlO{3G z*yIPEVO{WsIjnKnVT>2DMzkql!ApMPMO=L<#3I9oI}LubOO+CNvScYxqQ)LKcQkDr zB9h}Xp02N~GG)+JIYyNnkc)PDZOnzu*#; zB8R%~1(i4Rl0>e>Eb#WLtxfOV(#vvo;8MrfX8# zOJwj-6bRC^RW#U^^>`Uk%GqUlp=9>%y-#&$qZ(w=qV2=#%SNueJg~}R_Q4VL}5`+@9~aM z91c`Iph*TZkfp^?^`Dp^0y)$Ij}vN48)8+LhbiruA|j3sO47|fb;`I*GKou>Ivq)^ z4u=V1QQ;ad;<{u73-W9;3T-}Qiy5qW$_D4g=4Y%kOJdS2(WFCmdcfcOtJM6uO{+z8D@UxkKMBq1+Buz@6?P#P0jG1VJo zr4$sRhK5k2Z=fXRN~6nW@y^{1KD~XI=}gYdoFjX&pWp3sm>a@9yM-m0@&}6isAEB(Qj;>qRst`p9~=6q zAu7LO=u+TQ_K7Dd@dg8*_ZUX>5!&WBSSti4^<9Bi7`TY2+y<+KU=~psWnX%OzQeO# z$Y%%reeR=-{wJ-1^+Iq9eT6F#>jwG=^_&zcppV__#9BjN7F^M%z)NCy=&SoFTsf2ppC<<**2_ZI5@SJo9Db@pv9Dwel>@Q2Y|A^pR+ zXm)h0I4$&8t(hXy6*cz3S)t(J`aO{jqc{F(SB1>4AMjd@E;uWs|KhZ2{;};ky2AQ2 z)rxDxD$`NJH=PukQuA$!?4zc}-&3$&Xn>Du{t5dULsafqFEod!oWp?rpGSuiRtueB z&+LQNE+8tK3|cF6gtuz;3+FNP08y#Yj|~U-15sJR*io8@$}eQs#}cB_phN-_NT5>I zKj|$a=v*bC1q7WMgQRsN@Unzi63g)%L1&Ybq;ZC~2s(dqkQ990An0_M#V3gY=Ga5f z`5TXvN})=^4!0;^!e^R~NT^Pc418W7q3m*(v-Aa=K4XNz?fnc_RXp{J*(OZ^8ac7(2N>$@cY O0000!q0tf21(L7d_LUKmW<3(?>twY#jIyQY)1yO)`(73AgR#bf8_;AUaw zY{lc`YLmVTe*i%=B#JVUTHYBuMt+9>Y0uvh5iUzGV})?IlE+7J)Zf!+;L_9E`ckm= zJ*^>Cp|&FV8yo9ZWKxP?^;3OaR`*1Y)A7+7A^oPWNoje}92_pB?_Xh&e%zW}_qi30 z9?DoJ93Z3|I}3Pm_-e>)=sa`XXJ{{D;TSF&+xjir#_40=Fd3+EsSf;;dEY~Elk;?v)Rj5mhh21y`# z6fooIEctp19I;aCGbIU4pF+d2x9QS7IBkp&5?ZnT6&TNlxuTDN@%Op~P*H{%e~2MJ z{_t9{pSq2T#HHtc7o7(!5^d5N@4)-%%dtYDQ$x2`1@c86p;1``zVoi5fE-tQltD`YG>+6PKFWw`8MPVMB z{$y@aEkTE_1rxZh#UH%w?QI-z!`Q4RRzJ{x{`@gHzr1WM9!Aen2%Vhv5X|zia3%66Q~3FZ(0fiT=WFTf7u2~7 z{t?DDIMBzK7?tSA$OQH7P6_w;U?`l*7{O;2vV3;1y#89TT(l)I;3{N<{co)Ti|hF1$L^wfwIk4Vq0?95x!5~j)kZ(bi7h@5> zYAh8-)Kyc4&KVCWR~ejWqqeLY4??8*b*?;y`1J^}8UoGaQ&G#4qmn5CBlAW1nI+vy zx2glwAMlDOJ-I(xd{a6~t)jkn@9*s2)&4lg+4{=aoU>ObSI}n%X^cV@Wk8{xOZYB92tbT%@A`wl_UxGv;BYDX1u)g)D z@CG8QJ*9Hhzq)UXc4Gzy36+2Q_AHfLniO*%m*nnWOq4lR5PT(=F;VP65b@b?AMTtD zmiy5bCL>mxFiDhwQ-qH>39lzh&@0BqG*)K}J_-rp-VXC2DSLt^8}eR1=?MSGKfpg+ z%YyY*oB1qAW1O|aHBn+gpU@pzbB_j`SAQfe$Hc_Qx;Lb!zqYitUh~%6A)*!Lo9gbi zx^EP){5|G&;@2<3XNgS#PoBfP30EWy{IaFuap~`LFhV}_aeI3L`0@DD7T>}inyW5 zALnb9MMIQ-&7UxBbw}eNCVXh2EBrUD@uW>nO)`>_l7F&jvPh4J^hM+6=B5>34|}Cd z6F#y!<4m#b<+Zc~ltx7geiMQc$3}+AOWO5qbLb zNKsy1-szLV3SpaE@tBq}TU8;$8 z7b%p=wN>Z1?`8R9YBgUzE=y5GgLTCzE}2Qfvp`9#GUB@b3z z&(%~^RD^hqo4o&R6Q!%0o5}`0K17MZarXxcV|0h1qNauhrp-{s`PNeBhd4K9XXm== zYBx+MMsAEJrQgBoiT?aZzI>~aq9W&0mq73H)szprvkh)3NF=vY-Py%f#iUyLvmJ4* z13D6yVTGX zgKer|XlU4EfOIUZaCrLQJmb0B8v4?EHAy$1V%%Qaz4_$iWI8A)h!bKwU>k1od>mr0S zZX1ik28f@BzW&r?_;BWh>{8a%4zzejr+K_om-kC)X}?g4qo(FqZB0#$RnhJ`dL*Al zf9IFI$4ryYp)q>XXM4KV0lUXVtq)zG8$&6E7Dmw7#M>MUXNumNvB{nwp?V9jV8FrYQtZa8691hR29zm9uzZkUF zG%*QOWct*V=1W1wri>`p;@bNZFf7`yI-2 zXF7g2x|6oPu~D90JOIwk&tJ)2rp0DvVZofnXV$T`y1Lr8ySrP1S5QYqEmo0}!|3AT za^PoXX69zPnsIP^9P@~S$O+x8G_hA-px#^wo8QT=F(o>*4IrhtHeTZsb8 zpA86Ps<>(v{M=10@g>QpcwiRcMMZ2o>)C-VVJ?baotHXT@7%d_D{ZnUtXgL`R)n0( zZL}UtTRb~E^Lq2<4Qf@X5~Qy07P4+Wa4ppa_3I8QN}k@Q>u@Z&N? zg}*PS166n+UYJz-!E(>S@%}#A(>5AB(dSTH;uay>pN#ol2}w!g^?|oHae8m_^73xJ z+K+#cKwSZ^Q}gllRn6Pq(M4&%>?ED}Ouo#y<>|l9FPAi-~2Ma>hdH znwoAy{ry{X6x^}764@{OFPuQ~OcM5k@?vReX)$hZZzrRrqw`5rjLXQ#;I6E!#8oj8 z2kFrC`SWM&G6#`NRW~3Idj%RBsX%leG#HlO!Na4XB_}6e-P)pgbRR$UR98#u$ja81 z!>RHSFR#hc`uZuM(fq`O4mAZuvitRg2P-s?B{uVRp~XMD((?*@4HA5fiAJ{pMESGR z*gMJt=h_KqN9&mF)5vm5rKFeRPXn&Jv$o$v3^{}IMrAD^s$8O?eu;XIW6f$0|Nf0^ zbl=b@Dyg)xv}CECu5=HF;Sv>8ZEgng^YaUo8#SK9a2oiX?i%&k_k3xz>Q5FD&9Ai? z&hlDy_2Di>%H`X|MMXu~)G8?}XOxa@{3`RTb6QAdV`Cc`OYw#>DhTXlG|funb35R@MX)!Eztp!V#>dy$dl!5GFOzC>ZH45N1r7c+@*EP?q$v z@OJyl{OLmAZR(xsB7MNrRD9M02z~eGJucJH(b50a*Vi)_Df>T3RVJsWZ#it-Ynl0u z0$X!LiKL^90r6oA47_d467%z<+`6c-8>8TJl`QMHIzJp{VPR>SA06!w-~^&E?KIz% zYBP!xl=Miqe0&|)KcBJtgMiqwudc5bcppE$qFk<89M?5j-FXI_ zXQ$C~$ACCIkV{xtIAF5e=+)HJ)Nn&XL(D(9O-r6M3B0a|o~t3UE^0ra7J%By^s8@J zQ~I4!QS%@{Us!yPW}eHfH0um!-`U>w=2z1wao_6*BXAqsu=vvzfeXOsK+I_O&z~o* zeF>~D=BOEBdKd!X)nC4BVj1nC(ZcVpFOK0(O|`=AX!UCvr>07c{E>Z%w49urh0)lb zQ`I(&=VxbKKRwdZ(q4X#V`$969;Iu9ryDGVkd}%EOb7jP=7%nI%cq@__ zD-@1EAY61t?IGqiK4#|S2~ff}k|{IO(~-JJ1FHf8HdahTxfYkPS4k~ZMar7i1v9*m(lGeni|0UUP>oN4>hke&2F)NRJVY|f`{(3y)qkEez@>X7~|#;YHj<=%3{YoXT2Ap|3i;mJ)}%e zu7<~?W#BaG}&m|-|24_j(lCGW7O<>Tz;;^m2~3< zYP+s+W)IlIE(fS9Nq3Es|BN5LZl~0}pOYZrIN#LwT3?olRE?n$^MWO>u^uELxsf8r zeGx1yEcf*qk~YK!1|%pb2$!9npP%R8b8ZX5D0k1Ss(RuZ%|$X2C-=H%kEh(Qp`%e8 zpq|1dEg>lx+2Js7UPQDGSj!C;KmP$-yA0b*E~)QF+L}GkFJ_Oh{@U+j@ z&u>gotVk+32BBU${uhyu+{w-iGYkeRPD9bt&|LazXx#Ik&Y@cA zl8+im5tYW~7`$m%&k{|JkC#a2OZqA`4-1-|oux<~Hy=Ro*KBjQ``;rKHO1vx6@O_f50P0My2G(G_awt4$sp9_G(PNYGY3^|mVpE$hmNR*BYN zk#fy)PaK1A;LVk#?{@gt+FJ4oqejm#8K&HYRT4cH=(UL|p5VtTU&=CPSiGTjsp_r{ z$NdaLp7jlSKs1Gexl9NzXICc)!h{gpf|+P~u?rWJxu0L7VsUaR6=A}OFQuxg>Nk3N zdibHUv~(yba&67pIPI;eDWg*~6kPzFf>7{bB&IDv=VYsi{ic=9PUi zv|_-~JCv~wVVT73Hr%c!o>+KU1Q&S za7L_2VI^==V%zKLHF;N_0*vt?+qpR2f|tgnQeiK;#BcL47tK`Ls6_)1vl_YH?^7s|rO$#jLVRK>JJj2xu{iw*|4ivoq*+ zW>;&#N)_p%rS*$JLqo%ML;(*+(=+_?A(tUWpPaxf`H=`VuhX=~%KG{tTYP3_=5mYw zWx()fM`G6>p|5)?gof?NLskwRh`B|`m{$Yn64FO0sHzU>KeD@v$-F8kBI0Wb0>ETc zK5kE5Qc@yky+SAInSpKbhn0vb9)*|7@X4H%g z9xFS0_Nx*txQ&vGOxJ95G@*kSsu>eVT0KBgb6s8CEanQJ%JApU8*++mv9YiSf#3b) z^7He{dTgYj@%QeI_6z4l2_q}3RYg>JVxs0EXz%nINZ|hn^!#u=advLbXQ&f6{cPNe z3$%!lI5+p(Fm;X<&a?6H@#1X%ld0QuFpRO`=H`Y!8f^=P`Bzs}Q9KD>f(fX3v}V67 zz-M`rLn?OW5(A{CP>XA|`x_n>W_pUT@5VJ5yXpYC1ghUVpENtxV>T-tX zu9kHrK~hSU@6P`&QSum`{hpi4r2LWx0t*I0GyV3b^L~3)&a^#a3r)?<7Wf1N;_r59 zCzS()%r}3P@Br>F?da$T=&2t7#3z=?GcYt1YZLRTP(!fgXjF*-vum{0aSm1cc+cI| z7G3ss=GzEC)D2&7d1_rLJ~0yow}JaU;8{&NTH5Hp)BxY#16XvLZ}In&1HHou=!ByJ zuMT=H0AI2R5Yapv*d*fuJD*_^aBjtX0XQKRAgweLGjk6>2<58UTB|fR2M34Y;cW5S z{~Bt-@6tT$jZao!siNaIe-B#k-mm-n`|KZx=pGE-(}Wg}Hpa58tgQHt>;KuCY!t;# zY-HpgWPN#g`BHYkh23}2y(YJpTuE7+oSY?~zNbl<j!>^ioBGb0;;n=a?zkkEu>RIn@ zP_0P-Pf*Pi5#(fN|FBNAmE*MOP8jt{Tic_fr)T|oXcMH9q>s-z7cXyxqL^fLW#z$3 zuDk{Xh&jDvhB1 zuZ0xu*WYr!eVZs_;S5^gEiNu*zx+22;?^-XHqI+lN+~zB8UuxN&CJTWD*pxHmF8_| zIQt1aY}TFWp&`e`SUS;!FsX+~{Q8dfzCTkc75%ZZl)XXuCI9^S6Up1O-?8WB>iTVB zd|Z(nUsmjqPjOu?sNc75-)aLvGTEDN7M)sH2y_H@os2GEBhtai*vJKQA;6v$S>k~& zmgl?{jD)@S7sW>+9dQ3+WOGc4Xx%dh0ZNh%C)BTWUH#Do=30SI1qH8dy$7N|N9AB= z$Jy$8ym_ON{*2qj!^7WasUu8z-9SfYA}<(*doi;5Z&IixcC5wr4{S7yz0dMwqh4s0 zjyFk22np5oZg0PtHn4$_9nNcD8xXoasV%gHDPDZV8u|J&lc?%TCguUpWp30Zn14J2 zLa>%G@b-PR&G3T=qsQ16U@Q}8RBaveDP!*U@6Wq$W`u%pR=OKQMYzTWs?A;*7;p)( z3zD&%w358}P8RB2-S|%KU!*Z$ICxZfx@x&tr$3 zvxYtg>N7o*r_5foDhN4Y*)*f=GsJdXOcgW{6if|uia}@*3bei-4VH_)ucTyVH*G8$ z4a3-y^vtJ0H^c=Uu^shoQM#z{luHW9vXa?CsVi3Kiz(Z?-^b}5rQCEfC$~gBgKBo$ zg10l)wyVO=?pPZ0o5hT&5ShE|!y?xCJ>ZS^-ltoARkc}^=n#A-A?2!K^{zxRiKLJ+59#X60hNe|5azJ{F`vgfuOl{1(LLttNq8<&f%6t89aga3(BuB`%XtOO;JR zXQ7vHwh)rADkXgwUGER;Q9oaXw%|`&SB%TKrvg{eKU3CL1N4FetkI%J0-eLO*8@Mj z&^F=O&*^`V>>A^!$v@yTZBurbK3-lAyUA>KecCBv)uOu`dokjFw8n18po8wFQ+oW; zSMw-z@#?ZWFPpkdn(U*>+#RDHuiDVA8@)~L9eIZ3mUT?=MUv32-mgua1|-Fru#2Si ge?LbN-@9RW?OLDzX^j^T{D1~2%BsqgOPPlJ509$Xm;e9( literal 0 HcmV?d00001 diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/ic_info_outline_black_24dp.png b/android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/ic_info_outline_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..c1e2a03a4bc540419ce1165d5dedd8d5345fdec2 GIT binary patch literal 1256 zcmVP)W$LQv#I8j8T_{yf~=m$~;IXzu5?eh%l+bI*O5LnIQ3L?S-g zNEKIT<0XBJGshx}%rQL6n2^)65BytPpur(aAq3mzkx5L*!vp z0a@Ola>x)hq%a~$J)clM5drmH23z#q<|xU<0`*qKPGo7Si~n z%wqBU&0hSlj{%E?RDuuU7MJcXB=Jj%b`&x_e(Xp;ExUAT@Y|(jm(qjWZ(B;_Uor&Y z6!R#Nv*chaGsx+GPf(5^TbQOC&z>U}Plh0!MlPf-JUW9CsUc{WQ6klNkmN0L=W$Hb zI`=E``6_{H*O2>uGL!}iknh%)aH)U^vHJHyC=I|j;!5~HKCWcN1R5Z;2B2BgU%-W! zczBp#L#PcDi)Yo>;Taa!Y@Ptv;<}7l4r)8NeQGlwNF& zYb9ky8`z|cGKQ@=tt4)=frR*F&DNq;5;NLBOdDlk)i+CZzQKZh$R zK8n3)UuX^N7uDk=aj8xWGC(Sn1_~Jx)mdCiFf4{?52b-lQTv8C9#o@5E)leAD3OzR z)Fn^Gaf%@QAdedG1kbj}b8XCXgrFSb3rcL@n*sbhFEP*Qfd2Kr_;5}_cz_aF;&K3M ze+ebhM9$XHgOZ`06n-hB6D318YwImEMS(?`<%O>vfHEvXL&vNpLe#!|zDLp9b&_k9T z*x5;~c-Pf0-68_APCn*}yr+}vWZ1(d62yp+WD|SHaD&H;+SWI+mO!0l8Wm6`sU`&F zbfE&s6E+i?YKBohW{8u7EWu?ypnS+US>hOx&jq=;y2>EuNMckT2YAG1l*`QUkZ)PT z3X$L_jr@gjkUknXOq>;|goD)5%rkl!W0nOLm}QJ!o^qco2Ph^Ii9{k1-~0zqnGDmx SqDLYC0000 literal 0 HcmV?d00001 diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/values/arrays.xml b/android/java/MapboxGLAndroidSDK/src/main/res/values/arrays.xml new file mode 100644 index 000000000..3e937722c --- /dev/null +++ b/android/java/MapboxGLAndroidSDK/src/main/res/values/arrays.xml @@ -0,0 +1,13 @@ + + + + © Mapbox + © OpenStreetMap + Improve this map + + + https://www.mapbox.com/about/maps/ + http://www.openstreetmap.org/about/ + https://www.mapbox.com/map-feedback + + \ No newline at end of file diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/values/attrs.xml b/android/java/MapboxGLAndroidSDK/src/main/res/values/attrs.xml index 7148429db..901044375 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/res/values/attrs.xml +++ b/android/java/MapboxGLAndroidSDK/src/main/res/values/attrs.xml @@ -11,7 +11,67 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/values/strings.xml b/android/java/MapboxGLAndroidSDK/src/main/res/values/strings.xml index ff91a160d..455fdb026 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/res/values/strings.xml +++ b/android/java/MapboxGLAndroidSDK/src/main/res/values/strings.xml @@ -4,4 +4,7 @@ Title Description Address + Attribution icon. Click to show attribution dialog. + Mapbox for Android + Mapbox logo. From 75aefb7f9d98beb5c9d59587d4e47e377fda9b2d Mon Sep 17 00:00:00 2001 From: tobrunvannuland Date: Wed, 2 Sep 2015 20:49:54 +0200 Subject: [PATCH 011/156] Added save/restore state for CompassView, LogoView and AttributionView --- .../com/mapbox/mapboxgl/views/MapView.java | 66 ++++++++++++++++++- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java index 7bb9f4327..1dee4e217 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java @@ -100,9 +100,24 @@ public class MapView extends FrameLayout implements LocationListener { private static final String STATE_ACCESS_TOKEN = "accessToken"; private static final String STATE_STYLE_CLASSES = "styleClasses"; private static final String STATE_DEFAULT_TRANSITION_DURATION = "defaultTransitionDuration"; - private static final String STATE_COMPASS_ENABLED = "compassEnabled"; private static final String STATE_MY_LOCATION_ENABLED = "myLocationEnabled"; private static final String STATE_USER_LOCATION_TRACKING_MODE = "userLocationTrackingMode"; + private static final String STATE_COMPASS_ENABLED = "compassEnabled"; + private static final String STATE_COMPASS_GRAVITY = "compassGravity"; + private static final String STATE_COMPASS_MARGIN_LEFT = "compassMarginLeft"; + private static final String STATE_COMPASS_MARGIN_TOP = "compassMarginTop"; + private static final String STATE_COMPASS_MARGIN_RIGHT = "compassMarginRight"; + private static final String STATE_COMPASS_MARGIN_BOTTOM = "compassMarginBottom"; + private static final String STATE_LOGO_GRAVITY = "logoGravity"; + private static final String STATE_LOGO_MARGIN_LEFT = "logoMarginLeft"; + private static final String STATE_LOGO_MARGIN_TOP = "logoMarginTop"; + private static final String STATE_LOGO_MARGIN_RIGHT = "logoMarginRight"; + private static final String STATE_LOGO_MARGIN_BOTTOM = "logoMarginBottom"; + private static final String STATE_ATTRIBUTION_GRAVITY = "attrGravity"; + private static final String STATE_ATTRIBUTION_MARGIN_LEFT = "attrMarginLeft"; + private static final String STATE_ATTRIBUTION_MARGIN_TOP = "attrMarginTop"; + private static final String STATE_ATTRIBUTION_MARGIN_RIGHT = "attrMarginRight"; + private static final String STATE_ATTRIBUTION_MARGIN_BOTTOM = "atrrMarginBottom"; // Used for positioning views private static final float DIMENSION_SIXTEEN_DP = 16f; @@ -834,9 +849,30 @@ public class MapView extends FrameLayout implements LocationListener { setStyleClasses(appliedStyleClasses); } mNativeMapView.setDefaultTransitionDuration(savedInstanceState.getLong(STATE_DEFAULT_TRANSITION_DURATION)); - setCompassEnabled(savedInstanceState.getBoolean(STATE_COMPASS_ENABLED)); setMyLocationEnabled(savedInstanceState.getBoolean(STATE_MY_LOCATION_ENABLED)); setUserLocationTrackingMode((UserLocationTrackingMode) savedInstanceState.getSerializable(STATE_USER_LOCATION_TRACKING_MODE)); + + // Compass + setCompassEnabled(savedInstanceState.getBoolean(STATE_COMPASS_ENABLED)); + setCompassGravity(savedInstanceState.getInt(STATE_COMPASS_GRAVITY)); + setCompassMargins(savedInstanceState.getInt(STATE_COMPASS_MARGIN_LEFT) + , savedInstanceState.getInt(STATE_COMPASS_MARGIN_TOP) + , savedInstanceState.getInt(STATE_COMPASS_MARGIN_RIGHT) + , savedInstanceState.getInt(STATE_COMPASS_MARGIN_BOTTOM)); + + // Logo + setLogoGravity(savedInstanceState.getInt(STATE_LOGO_GRAVITY)); + setLogoMargins(savedInstanceState.getInt(STATE_LOGO_MARGIN_LEFT) + , savedInstanceState.getInt(STATE_LOGO_MARGIN_TOP) + , savedInstanceState.getInt(STATE_LOGO_MARGIN_RIGHT) + , savedInstanceState.getInt(STATE_LOGO_MARGIN_BOTTOM)); + + // Attribution + setAttributionGravity(savedInstanceState.getInt(STATE_ATTRIBUTION_GRAVITY)); + setAttributionMargins(savedInstanceState.getInt(STATE_ATTRIBUTION_MARGIN_LEFT) + , savedInstanceState.getInt(STATE_ATTRIBUTION_MARGIN_TOP) + , savedInstanceState.getInt(STATE_ATTRIBUTION_MARGIN_RIGHT) + , savedInstanceState.getInt(STATE_ATTRIBUTION_MARGIN_BOTTOM)); } // Force a check for an access token @@ -867,9 +903,33 @@ public class MapView extends FrameLayout implements LocationListener { outState.putString(STATE_ACCESS_TOKEN, getAccessToken()); outState.putStringArrayList(STATE_STYLE_CLASSES, new ArrayList<>(getStyleClasses())); outState.putLong(STATE_DEFAULT_TRANSITION_DURATION, mNativeMapView.getDefaultTransitionDuration()); - outState.putBoolean(STATE_COMPASS_ENABLED, isCompassEnabled()); outState.putBoolean(STATE_MY_LOCATION_ENABLED, isMyLocationEnabled()); outState.putSerializable(STATE_USER_LOCATION_TRACKING_MODE, getUserLocationTrackingMode()); + + // Compass + LayoutParams compassParams = (LayoutParams) mCompassView.getLayoutParams(); + outState.putBoolean(STATE_COMPASS_ENABLED, isCompassEnabled()); + outState.putInt(STATE_COMPASS_GRAVITY, compassParams.gravity ); + outState.putInt(STATE_COMPASS_MARGIN_LEFT, compassParams.leftMargin); + outState.putInt(STATE_COMPASS_MARGIN_TOP, compassParams.topMargin); + outState.putInt(STATE_COMPASS_MARGIN_BOTTOM, compassParams.bottomMargin); + outState.putInt(STATE_COMPASS_MARGIN_RIGHT, compassParams.rightMargin); + + // Logo + LayoutParams logoParams = (LayoutParams) mLogoView.getLayoutParams(); + outState.putInt(STATE_LOGO_GRAVITY, logoParams.gravity); + outState.putInt(STATE_LOGO_MARGIN_LEFT, logoParams.leftMargin); + outState.putInt(STATE_LOGO_MARGIN_TOP, logoParams.topMargin); + outState.putInt(STATE_LOGO_MARGIN_RIGHT, logoParams.rightMargin); + outState.putInt(STATE_LOGO_MARGIN_BOTTOM, logoParams.bottomMargin); + + // Attribution + LayoutParams attrParams = (LayoutParams) mAttributionsView.getLayoutParams(); + outState.putInt(STATE_ATTRIBUTION_GRAVITY, attrParams.gravity); + outState.putInt(STATE_ATTRIBUTION_MARGIN_LEFT, attrParams.leftMargin); + outState.putInt(STATE_ATTRIBUTION_MARGIN_TOP, attrParams.topMargin); + outState.putInt(STATE_ATTRIBUTION_MARGIN_RIGHT, attrParams.rightMargin); + outState.putInt(STATE_ATTRIBUTION_MARGIN_BOTTOM, attrParams.bottomMargin); } // Called when we need to clean up From f8b8ca72735237e91a2d215366a662fe0def6d89 Mon Sep 17 00:00:00 2001 From: tobrun Date: Sun, 6 Sep 2015 15:16:56 +0200 Subject: [PATCH 012/156] Refactored ColorStateList of attribution control to a Drawable selector, added images responding to different states. --- .../java/com/mapbox/mapboxgl/views/MapView.java | 8 +------- .../res/drawable-hdpi/ic_info_blue_normal.png | Bin 0 -> 2194 bytes .../res/drawable-hdpi/ic_info_blue_pressed.png | Bin 0 -> 2133 bytes .../drawable-hdpi/ic_info_outline_black_24dp.png | Bin 487 -> 0 bytes .../res/drawable-mdpi/ic_info_blue_normal.png | Bin 0 -> 1354 bytes .../res/drawable-mdpi/ic_info_blue_pressed.png | Bin 0 -> 1391 bytes .../drawable-mdpi/ic_info_outline_black_24dp.png | Bin 323 -> 0 bytes .../res/drawable-xhdpi/ic_info_blue_normal.png | Bin 0 -> 2710 bytes .../res/drawable-xhdpi/ic_info_blue_pressed.png | Bin 0 -> 2738 bytes .../ic_info_outline_black_24dp.png | Bin 640 -> 0 bytes .../res/drawable-xxhdpi/ic_info_blue_normal.png | Bin 0 -> 4256 bytes .../res/drawable-xxhdpi/ic_info_blue_pressed.png | Bin 0 -> 4240 bytes .../ic_info_outline_black_24dp.png | Bin 940 -> 0 bytes .../res/drawable-xxxhdpi/ic_info_blue_normal.png | Bin 0 -> 730 bytes .../drawable-xxxhdpi/ic_info_blue_pressed.png | Bin 0 -> 836 bytes .../ic_info_outline_black_24dp.png | Bin 1256 -> 0 bytes .../src/main/res/drawable/ic_info_selector.xml | 5 +++++ 17 files changed, 6 insertions(+), 7 deletions(-) create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/ic_info_blue_normal.png create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/ic_info_blue_pressed.png delete mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/ic_info_outline_black_24dp.png create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/ic_info_blue_normal.png create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/ic_info_blue_pressed.png delete mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/ic_info_outline_black_24dp.png create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/ic_info_blue_normal.png create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/ic_info_blue_pressed.png delete mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/ic_info_outline_black_24dp.png create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/ic_info_blue_normal.png create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/ic_info_blue_pressed.png delete mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/ic_info_outline_black_24dp.png create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/ic_info_blue_normal.png create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/ic_info_blue_pressed.png delete mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/ic_info_outline_black_24dp.png create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/drawable/ic_info_selector.xml diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java index 1dee4e217..dda11c8f5 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java @@ -9,9 +9,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; -import android.content.res.ColorStateList; import android.content.res.TypedArray; -import android.content.res.XmlResourceParser; import android.graphics.Bitmap; import android.graphics.Matrix; import android.graphics.PointF; @@ -30,7 +28,6 @@ import android.os.Build; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; -import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v4.view.GestureDetectorCompat; import android.support.v4.view.ScaleGestureDetectorCompat; import android.text.TextUtils; @@ -423,10 +420,7 @@ public class MapView extends FrameLayout implements LocationListener { // Setup Attributions control mAttributionsView = new ImageView(mContext); - Drawable attrDrawable = ContextCompat.getDrawable(mContext, R.drawable.ic_info_outline_black_24dp); - attrDrawable = DrawableCompat.wrap(attrDrawable); - DrawableCompat.setTintList(attrDrawable, getResources().getColorStateList(R.color.material_bg_selector, mContext.getTheme())); - mAttributionsView.setImageDrawable(attrDrawable); + mAttributionsView.setBackgroundResource(R.drawable.ic_info_selector); mAttributionsView.setContentDescription(getResources().getString(R.string.attributionsIconContentDescription)); LayoutParams attrParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); mAttributionsView.setLayoutParams(attrParams); diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/ic_info_blue_normal.png b/android/java/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/ic_info_blue_normal.png new file mode 100644 index 0000000000000000000000000000000000000000..de44e3ddc08a6ec2733d5f9a9aef169c0cf97805 GIT binary patch literal 2194 zcmY*b3pf*A8y_mn{g&MCwY31ypUcm1HvAEGXd(b0AhBy)fa@g(H~@4o%7f&AbbaimV{A`4GRq?!eSAsKM^pFzZ(XtD*uF#@Ca28q_eUmAquN( zq<2J5U)2<-tgLJj6^MhmTG{+g=j;%wXGo+77#K_@ll91l^$1ZxU;`)=3f4CS8ybQ* z2oNzYoP>!5g%j0&k^G0p3QG)#3XUKJ6T+2uc`^QkXc9tIbyw)m_*Ew<824YLaN_T_ zI1Pe#PrwFx`rtp@oK%zDDC|U3FqWgd%WrC6@)P-gvEMo-;9c?mDdtzFKck#hO@Suh zKi6gobm}~W1_1UA*jt&SJovjkkfErPlI_#&MKL(a&HcJ5X&DASDMpbzI>^n8f2<_- z3?t;wfS0+I^~)N1p;aofepIRSBgQvl#0Oi1m`i()i~skp zr^L2K`{jF9Sr`zcrSlCZWDpW%6gKbqLm&*Kf{!)pHf?-`nuXF{e;cAqXSN05%}=7? zz*FAmt7Vsw+y~!HeTlu1=OiD^vY;i{Xg7wThov}&2uuXTU{gFQ90BP zL?^haObHE}gOKdL6nNFPFxOf|GWKgx6#Gm=@{&$iuhNGKn^&EdG$y!Qex||m(c}KA z)oZ-A>pPM;=E5C1aV#`|*6Gv|pu3Dp*IjWsLv~!#n9YB1eJ)E9;hi^Z8YE$yA;Yld z797x6?%`_^N>m=E`p%kC9}X!tGrvxnN?lsgzraO<3{j;NaHYDPkhkswkaf7(%a{&p zk(ss(x8jBj9uNPEg-_!yPTvo&T?3a1DBR78cDNa}nOtjB+U8}AN&OdBrjzJYQ_EK6 za>;NB((t~RfkgblD<>JY)V#)1eJkHpcJd64^+p`opY<{1+90*Fo2{cI7YRBX5^o`l zm+$5#(`DNA9m3K;CgXan@A}XOKM$ho5z9698;WvjV4)r>c@_h2+ z{ZBq}tK8Sz87Yx>GG2_)AEiV?qx{R0Q z>pdb^+1!3Ta$-Y*qgnWk)Qz!6UTxWfX(sNp(=PbYE`{6psv0WX=!>F!a3|t0f}v8N zby~$sGH-P-(w4b`jWHsnh}l^}9v>VjuoXQDN|it11fR(CvY>mg?u@Cb%VE_9s_|(_ zlMo*k?kqP?XjT|R6D-VIqSa*HlfjgA5=po@H`!cAT=2U=;%c{0H$;+hrAl9bLdEZj z&y!`QExGEehDL|CqQwGl@bCw@ zr~SKUboD2(6!I1&v7_%6`p`4BgU5|y5}Q4c@mqx{Iod}T{OX{V)t4<9{IJ>HJ@Xg| z^AT~SpjhbDzL`nN1onK8y!7lIbDb5awgBCy7@F0#T%Q@r1ah8gKk^Jr|H&m_jJjs1 zZ^c)_*eyN9vZJlj(qvETwsYcXtM->qP`Cg!^?c(7ME zQ^+|{*pXu5ueL-uk!| J-NNtuzX40N*J=O& literal 0 HcmV?d00001 diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/ic_info_blue_pressed.png b/android/java/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/ic_info_blue_pressed.png new file mode 100644 index 0000000000000000000000000000000000000000..fa26786242c07a74e6de23c0e89703a50ad9b84f GIT binary patch literal 2133 zcmY*adpr~B8y_+EILtN8Z0Rg!bICPhTyn1nzo~xxe&_vsp7(v8=lwq4@AJI>yyx8yI>||ENCN->Ijpli zUU=@>GD)Ct9|IH?3J(z~-pLNY?$-P$45VV52~+?;Mrq4L09T9EgaAUgmk-Sc=V}>D zi9!a3P=ZKEdQ^-M4FFitEro6ri53WAzR|@9emfbC=l&>yI|d0an+fcgA9r$|B({p-sIJF>vHg2u-l)rF#>W zSblwYb*#lZ*LQDS>$clI`pS7CFOn7(l@r*g8=Xs?w_i2%hZ+&7bmOVN3erU8UB)X@ z(}33I^;p&$G4(0?q3RFDka>1%h0Sxf45R*=Bg2VZ1bEG?X#R}sIU*x@V|*m?1%Dbd zz;c?V!CawwHQ4n*vi*5o1{=`(vfA4$^QG!B7%Jd6ZO;{g^=2Q~-C!~OvMM)1UTaz` zS-adz3bNr?r^4zvdNrV=S2oCz;3>h89L+xxu>)ZKV&w7kx2(i{-~$q>6VjRLKpU(2 zr)npav>$Fy_#`o$=pL(D%4I)ztVtN=nHOS<7`nNv@aVMnrlQ|;=Q@E6{=91f-)^sw zLA3IeWCZpzoJqtpsvK9KcBQGL*(RJGtA@&dbwM!>=OsTIQv4t)#pzjPo?W73{_E_! z&r{5=o+F#SZd|DV?4VK$jStbvP=hfrixA@OeGabhZ}7+9_Uwe6?NJ_S3q7H(YU4p|Mro6MkBEnYG=|Ia zRx{+=vJos2fgwBXu2qERB@}#NUCS{_|6)G2t*v{eMKyB2Lh#uRx0jd3+!XoWY@3UG zyNg`(FUW$mk~-k)2qnD@Bu;A}&PV|QgQRihnePV0JWZ>1fG(FFQQI+IfWXOca*_Tg zi1a1QtzMiQ51(l=FQ{qVy&&=E+<~^xQM$>kNylUhiR{v$NRyiT_U10jq3Yn>OYbnmMPZe)B96#5ha&Vl0!0VCud&2+N4r-cMYGtTTBY# zolw}iFNQ}FC;7#?!uQF+buJ0cKd;o`eBI-0cxlF^&P24=;~_^W4-BntkD_GRNuBXV zIIaV@~YK5afQ1N*56|VR)|-|WxUzjS*wuE$yLWL->VBk!<04I;qGHFFVFSN z%CEWdZ3pQ-)Zm4=m^9hL6;gMcQsKFy5Gzz(?9QpbNuq(d#|)%w->Zc6doW8*mSJFx z_oEMFT%#IpGehHiH+(o3GD?7G2G98Gy6lN2N|_=^!fISa%%U_4#)XwU*vTu8EcSGi^SOSA9zP z8hhb1=&-Z9&4C*m`f~cd9w0x^;>C=drTn?;g~?YhZfwBDkHldcB{xyCy83m)(5CC7 z+;Hf_(TtP)uH&Ap?8JtS9uSBZ)hS3mTK7R~NA5#$!$!o+MLBh%HM_@i^Vu`QaIsF$ zu@j>UE(v$zTst_eeNjg#iw*ZWUKs?f+I+=+(pt@`T&^@FJlgu}u?`3A*>*(6e*pH= BzA^v+ literal 0 HcmV?d00001 diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/ic_info_outline_black_24dp.png b/android/java/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/ic_info_outline_black_24dp.png deleted file mode 100644 index 4b5ab06e19d61515cf3a7395db43a81bb30a8203..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 487 zcmVS-P=?%O3jv@aJa6HGW<0ceyC!`rEoc~?j{U=`ic|b z9N*QPsMv*+MQv@1i8kR%)UIh1`=XoCqqIYBOKErvea{GWZ!y>;D~RpT`=%tUi9cM8 zjMJd-5IZXpx*;AQpQG66NVp4e3Hh{Q=T<@);yl@>u@F125nkF002ovPDHLkV1kFY-~<2w diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/ic_info_blue_normal.png b/android/java/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/ic_info_blue_normal.png new file mode 100644 index 0000000000000000000000000000000000000000..dd50478ac143d77b36c6a74c5fdcf6183f8a3b89 GIT binary patch literal 1354 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|I14-?iy0WW zg+Z8+Vb&a=a>mHakcg59UmvUF{9L`nl>DSry^7odplSvNn+hu+GdHy)QK2F?C$HG5 z!d3~a!V1U+3F|8Y3;nDA{o-C@9zzrKDK}xwt{K19`Se z86_nJR{Hwo<>h+i#(Mch>H3D2mX`VkM*2oZx=P7{9O-#x!EwNQn0$BtH5O0c3d|4@L;p!@;Rg)$-uze<>}%W;=#K$ z^sK*dpuqf_x*Q^1xnv=J`8}9#k_O`h^|AQsZCa?wvhcdLd zC+<-Nk4a<8t5{Jkap>3j9fZpUtLB-_Sa{ugIqnRTF0 zr$9zEORD;=W6Dy2mt2o;ORo8SMrnDR+96h#`l{Lo&%&QtFOdG^ytDCL53jMOC8x@< z^!5o4CSEPL#&(B9c~{D{r5Su?66GKl5ht*C571JuOipnq7OJNc=Rl(rR#b)d%pNjwr}|dB_;$; zoqa6LKFQ>o=WW(|AJtc8{Z9OLZ|$CW?=Gkte$;BK-m2UXCV%bP=81nE{c^beRAAYh z#>NAlc}XS5HolT>|8b?p;Z@}8{U2iv3h8P;*A)9LIJwmB{+#w}?>YAFt=?p3{_h!| z;#+q!S3gMFeDwa~x$I)s zjaNSRzgiXXPm)&nUMpyEYtnAt$D7Y@ShlbK|D0Nn=~q6U$#u-WH7!^mO0!UdIqYdv z3jc#{?wNVLGO>&9*p^=oIVO>}NO{+(gE3s3JDODkzTWNS!%ZdJVJ*Szxrj z#k|N=VQcGwXC;ZL7Aq?jwk-{`v*}v*P{42E=XL{~nA5ZVWfZp+oqj5^;Io%}b875U zh8RAJqbGwi|8o0HVO^i5~@s2rKmsj1}_K5Y|uhT&n z1LkIn96fvY$1!>Dqt})#o@)BUbP0l+XkKQZzk) literal 0 HcmV?d00001 diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/ic_info_blue_pressed.png b/android/java/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/ic_info_blue_pressed.png new file mode 100644 index 0000000000000000000000000000000000000000..d377f3cb8c2fc5a059efd69f58ba5908ed76066c GIT binary patch literal 1391 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|I14-?iy0WW zg+Z8+Vb&a=a>mHakcg59UmvUF{9L`nl>DSry^7odplSvNn+hu+GdHy)QK2F?C$HG5 z!d3~a!V1U+3F|8Y3;nDA{o-C@9zzrKDK}xwt{K19`Se z86_nJR{Hwo<>h+i#(Mch>H3D2mX`VkM*2oZx=P7{9O-#x!EwNQn0$BtH5O0c3d|4@L;p!@;Rg)$-uz8-qXb~#DjNk zm~W0xporafzfAAt8Ox;XyVX=C-MYE5wX9u(GtErMGrUYm(@ZE%SI5Qm&6-`CW;!~% zs*0s9l+O0$NL+j+B-4HC)tS{b&-aw4Kl|GMMXmf^?f07R*7o1$d~VCwdN4<0t}jE< zw8mDWgKLb!#Mp8)4bIKKTUTDtJa=YlWx4e0vo~(8yC3J)z2RxC&NMB7?w-I!Yq!g9 zog&ut_Smf0Gk18lynB2-;mOU9?MHUanwbB*zh67^YUFyAbqlyI+$sOxkzCAi;OvIO zk1XHwyPl6y663FrI(+_O|Z3go{)-PKcd%v?)9L4 z&TZ!S+m08NY>w?T7vBGqk9DT~lbs4HK32$23lVz4Qslll=WIc8V%3M>3%23MLdD)k zHUE2l`J`{`u|jqAH}^s=&7G~V>*Y=ssVafkAdzV%Z|0Tye6NeK`swv^(}^V)P4e%5 zTjF=`_&%Ari?_{L=(9}aeRQ6UMFQ_!wrJZ!Q!f{|&e^f;L(o^J?xUv16#lGUl&zVU(b=aY30jX%io=|eDgSuPwBQ*w{I=~<+h&&NA|DLjy)fL zsz&sk)Tt*=n7k+HZeS2UHD6U{@}ZKgi(QrlhdmTXUga)e;Nc}AU@EqZjhpvmEypRo zbfMpj(gJzjJA0m4#oXjov{@q9yR${rC*0R}#sW{dncHl=((0EDW=UAs<4;UCX4rz zW!lv9DTxiQU1y4Jv$!(fRqsaYr5Fj>hOLE)M+1~YyjKLMW@LB!>Gwsn-m7+(Tb;i1 z+NRU}@ixZF9^GYYW<5AiE#vTeVOdDVT(OIbwzLSE8m$h^kX`uTiO&tIghht(qRnqM zP4Ug1|F?9>1QxSretQysL1(Gs2A|aiZER{)es9|NkBs_%D3O^Y?f2KVmE0#NThf_Uq#J=hN%E%(egLDo*80oBC0_>&pLf T$EjPVfl5J7S3j3^P6lN literal 0 HcmV?d00001 diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/ic_info_outline_black_24dp.png b/android/java/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/ic_info_outline_black_24dp.png deleted file mode 100644 index e0c9fe0eb8457013fbfa6e2efea61fca70bb9303..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 323 zcmV-J0lfZ+P)&s5ci5fY}sT-yed|rRg0)~VyRe(RxP5| ziKSu?+iDTDUGbuL5L2~?+LgFdoQk=|C}Pxj7RQRtyXcJ~MwepHsvL@iJ?s4SCH8$Y z6AQgYt#Ro~-1uQ)CSvZwj!tLSm1hyxCe}LeCL$stVz6(6)`@$smX==JIoA4R{{X3C VfQx`Hg^K_H002ovPDHLkV1oM>kN^Mx diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/ic_info_blue_normal.png b/android/java/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/ic_info_blue_normal.png new file mode 100644 index 0000000000000000000000000000000000000000..df7d7a88757135f8ae6c25f83f04e8d1340757b3 GIT binary patch literal 2710 zcmY*bdpr|rA0I1oX(6}8(i*vB%m`s)YI47X<6cNEJ8W~AjD*N#l@N*G!Ak%#SmvY=RNQHKA+F;`906~`99z8^ZWhvP@NsEz~YMH0001NV~ukW zWZmr$6%ouH!u$+D5{h=QItqB$3!M^d#3HP{q5%L2ne7k)+`I)55WMhio@7r4dy_yC zK_}o0>2#0|g%BZN0|01>iC{?xA_u@Igm7ZC2?YcH$uJSDw_zk4_LD*m!@xZqoMFdE zQ9&>Rox?i1a5Hfj42F(66KvvwJO0mg!43ltC6gmekjU8BSe;mX9a2;X5@l>`jMUXb z>gj0<7~0WsL~;N{n;5O~x5$5Va6!?5QTPZlojs=A#gH*@__oo%NOQ#SYO1j5#v|IyR4xs0Pr9b(2c9U(t5YDa5xpp=pJ?EK|FB0UqMR1P04J2b- zQ)TmH2n)nvOPVSbB&t)dUe3q6`$5me>Iz*`1<_O={@}j&sPPyXha9G9B(fZD%QK%G ze98nrAE~=tx!avX#oJ%H5l&_M%JlRlDXBEnzI!sjZ+~__e=^(hWPD?ikgcLgEU(ux zc_R()(2(%R4u)fQ?HrS`IZkjRMquSfe?1IqM9DZT`Y7dm#xSE|62-V6@2nqUIjX3- zyhJs=SM>Sd?*;zxZ&%JG=L*+R+pqm8t63T>A!YHHC#U0;iEG8AB;qcc@T zC3=zEeQ9|Wn%LvIDNpf+?_<_x=gxHo8C?%CP0CmBE7!~-K4NkTeF#ZC?8)XE;buM5 zr|jAGRmIX0i^jtHi};Z&6zL~h7eA6g67Xb4LW15V1^76t9YQn zx%zQBZ$1z~B45tlsw$qdD)|=FU@GXTOzH9^BIK225CWBzI2X1ks+CHhYy@DG>_$Z zhz0w}C|x)!?hrtfwHj%{)H2Sh&4|4yFSj%QoUBqr9PHddC~g<`0gPxz-UxBOyEo>X zAEU+@9BgcneAnZ(v-8928=Mo;o>S&~!{(@C;=-%>>sb)&e4j>6i`S0+GWy|H_gWTa zU!)%dckJiwDxlGUuiB<0mwmsCzWPjO-Z)#8-q+xBp1HB~!N{$)!mBI{8+OgxJvwHy z0fLN(>)3S}6NMlDT5A_m>1NNuFH(|odSOA_Nfm@9+)-p${k$o=c!7Rf>76?u8&F+4 zdLFU$nQo_VX1gW+v3E?L1h+j6tq%`*$w;+wSg$nbhpPq2>dM>yAq@E@b%eb@DU~*qbm99_idun1j|_@Z#>%#iCRBjG z?nL(Kp%|07I|ow~lstQ#llhjjJpc5A6a-XK5A3qQ`+BI!{Om0=tq7pkCp5%7=K=Gc z!Wtj4=*GFr$uXql6m-h(u(t1(mC)5Rd@5aCV=6ns6Lk!Yzu(cmD@({m1(7NX`c7=3 zkEK_eX&cVN@Qtm_6H%n~9!|-U6ian(PRjeeC9jgz=>hFMXHfMDegZ>EelR*1PEX zM+z-EjAUEaW|rt(gX&0Sn>HU5KmsMLggP{l+_a~=&?e5tNSgC{Vc)7-Z70qr?yibAlsa8JtEeKGi7g>L?tgq(@prPLxdH7+b=bu0 zopRtYCGhS{Jh>!g`QUSYw!(S}BQW%wc-xt=h=gyR7d-fDo3AQaVdkw` z!qv+{>FD0wle&3|pV40&X-25M1%XiEd!lX4U}c8``P}TTfv!J86uUdmjGd@&yWC2( z@W|oUt=>zHOjcEZ$V$aKESKD#_e)e-feUH1924r! z8gZtdY08$<-vxedcpsE-!5ER4PPFYhyLs!Nfg49Eox(sul!mdc_|*7zJHKSP2&ZOt ze1TTZ&A0CI*gD%Q0RxBXKWALpOT3Zy-E+;qS>e81d1K2?#_|lQTt#z9=+xvqO;Q)B zMsUzb5<5@0Xn;y`5?=qn%a~2KfsW)fVpvQdb|M7K4R* zq4MOj4{*doAQq_bT`jiM1``*WmC4r~=jopqCP#*VvwjIP~%mx27(|b;!>ER0uw7jwo$6agKdP&Zx1SSs$vP&7XXF(HQhd zg7K#LlukJQt>$Bq3Q0uFiNPq~O8m$(_ft-HK2jzgMb_qv`*f!@oEY>@B33xA>bf(9 z6ReYVVUNASYG&8eWxBSmWN2&4?LY HsDH{|I2Gyg literal 0 HcmV?d00001 diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/ic_info_blue_pressed.png b/android/java/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/ic_info_blue_pressed.png new file mode 100644 index 0000000000000000000000000000000000000000..f5b183364174112edbcd242539676f7ad7e83ffb GIT binary patch literal 2738 zcmY*bdpr|rAKzSOOi{T+%qWD-y*3->?&Q)T8M!TtwzkXTAoopfC{a^q90I|2Ta^Xka zoe2`*ukHft8TR&1@@DnkTod+2J5Z|*ifq*iG9G~DpJb|O&934>p5n*tA zK*Z@lI4z9CX9ECe8j8OS3#8zow6M@{GKz+Q{bZo{`yChogZ`vYLNG9#<8i2EL{uQu z2yO`1g_(k(P$)VofPiwbviavaKf}O+DHIY4fuK^UaH;`3A}R=>heRR~y7~xxeH}hS zha4MD!P9iY$*O;g{71(sknA5tBvFVF;m{pj{OO2j3I+z-G5UA>{Z0yz@L#8J@;_zq z3qnl9AMf_(f1wmqDT6Tj_2FO~ml?f4&hIL8L zSir3mm7L8%0xE&|QvjjeAW0IFm2Y7V+RcE99)&8!i6(5O(T2!EGpFM%Ni(#^YMrM4?vqr{!NFBWe z)kp$7?VT6(E<9_1)fgv_s^`ZOJ zs1e1oTi14qH1pjrD`9Xgju=36l2opL*4%2G9m7&PNd?O35rRVepPQAW`=YBpW_ZsX zw#kAH(J|cm!&aK9Q|?AzM_llbP(Mf~{9{KN9S|$g^`{`0XN);o6L)|F_jJo*Yb&>f zuwe?c8)(nO7#V0Ve)Ik6-PGl6VTWNqqmh={r}));?Ke-U1vzFOj~=Wff+xz{XyWG` zw)9DLqvK0XU*qV`SVk9NA1-xqvXG_KyX#%QHT#wHk}zn`t=L!NmVm|nFW6HvU%_dG z+nwyhM>GoO2I_;*OQRp*ArE+~H`Pc*gNG{3)-QVQotz&2T-^PGaF^)T3Og$u0#6vx zeud3^ldC;$KEYjIF6@ytr$N6`?@```=Vn_ zn#c;t9d!+BZxy{94)?0&Tzp&Bt?S`Cd#zjTi|#nG{OA^2kiC%SbU;RF>!v);-3wAy zTK;>(cSH7k(>Qdp<3L?>ZqD0!CSb<&riZ+dWWGTu0Ply?wU`_^Zq8 zrqc9Z%uN7I`veE1)ELRmPKDjA2i9%{gp&><_thh)gLym3q8@-|Grl#eGJ&_E$4yU z=(C6lhFmm0L_fYQY1m)>h?R4&AyoX7T6)R8&=}_$x;Jl=Ag(5sm9x}vb*yT4WW#m2 zuvR|^`dp*Y8cL=>GfF~>mxJWT9ph`w9V?_h~~=IT?JHFX=8R< z-?3E#<-O_(U*MUH2rQuxvz8K`dJZ*@IQ?~!gEKmZboEjfZ2DzgA?6#OOvDRiUhc;? zJXRFv7?Wn)d?+df=f8E_SE?7|LJ=!MT+A0hhk!$RoVNxyKp>I|0MHG)d!8n>QzxO9P*xu z`53lT+EO~85EKcb+bO(g>4>6`8T0fO9nsdMlA;62qOljY6^oPch%UYKliJ?%*ID6} zZTZB?45{FA$|pMeqrYZ!P&z9VUoIMJTOH(tW>kba{1|8cXx|JhEjgpad8-3HAjb*YbcwYrhZF?7xUij1s#5+ zjmL3pvIo2gYl!5Af=e4Sr)g-B{hmrTF}1=znh_fLIJq2#WSuYaRT?s0mvoY1F)7mR z@uV6M@}afoWetl%tu2tfP|-!V23X9?k1skuQL2~ik{};S3iu5xQ$CowM=le(Jr86A z;W{dMu`v!s%v5yG#0s>G*_%&|jH3irt2Ctpc)UYWS_IuuBnKK{ zvpO&4N=3$vcjYIX6}FQKS0O+PNtc98=!NW0+AQVE+>C5s3v)3R@VnQ|(JLtrZ`2)h zP1U?n%e@X!oU^W&%Y*D2Pd8DmDIDn8&b5K7hk%$$Wdkh7C!K0abBhTBACnzTMa(gV zp*~;m4{7f@_BQhLMBc={y$(`0%V_d^QVXJEjdF41&?| zu!1;+t=AEk?S!HgicIgsF=u^4R3y~M6$Q(U*N%6Z#V(r`_l3!*F*58YUTEEsI&TEB ziubbjG1=%m7o@+dM@vBNl+hNLSF+Z-wNYxcb~bX6xoN5!VyGa-N@N-p=BBPJPQ=9R@)v6)YTB9B}SJkq*TF`{;ju|Jnr$&v+WbpE_NwY@zps+buFoqANwmh+ zywS`pwDX*T>uEw^k(&O%y|oL_nW|`H&iH#)>2pGRvu5eD72X8vhyl^y=GHh2SlKdd zYx-;GiSCF;+ov0@SB8DHZO_>Qy{vXu1vIiTa7Sv0@;9rQBMWWX*cfM;l6 zia8s>Zvb=?=QwTy#cSVZ5o#88fEO5na|OlO{3G z*yIPEVO{WsIjnKnVT>2DMzkql!ApMPMO=L<#3I9oI}LubOO+CNvScYxqQ)LKcQkDr zB9h}Xp02N~GG)+JIYyNnkc)PDZOnzu*#; zB8R%~1(i4Rl0>e>Eb#WLtxfOV(#vvo;8MrfX8# zOJwj-6bRC^RW#U^^>`Uk%GqUlp=9>%y-#&$qZ(w=qV2=#%SNueJg~}R_Q4VL}5`+@9~aM z91c`Iph*TZkfp^?^`Dp^0y)$Ij}vN48)8+LhbiruA|j3sO47|fb;`I*GKou>Ivq)^ z4u=V1QQ;ad;<{u73-W9;3T-}Qiy5qW$_D4g=4Y%kOJdS2(WFC3|rs3Kj8 zqI8g=)F>bbTs-G|=eu{GXLe_1-+AAe{kgFQdK%OqHV^;+poVFx8eN>4e~g0sVmIBY z*SI)<0Y)0ifa+n6jf;TNSJN^80HC_|$AEzB=PVZhOLr5CKnq5T6&_fPvp=-dc;^XhkeMdw> zL=-F!;^yX-^>=cSF;Z3kr~D$41G@zV`pQ5cC=^NrB`)IQ?+SrROG`sU#UNs0!WRhP zfMD-Hc#yDn0Po)<|Hq^19N_5h?i=XttaC2pBo5NL=^Hb_eH7fpRA0&zq|8=@*jSAsO(?J|H=KMBMbQ>{$I`fJ?UTBi&5o4 zvXFnDO&+8}5U>OQXcl0qN+vMmjc=!HN%mau2M6Y;wTYb z0%z~hC|8kr)b`-^>?hWc^DmhL=5x89?xBWHhqFRP{G<)U;P2@wf?Wk7}rg zu@_CQIC+F|DR^g0@#n11Si4g@39uZzAWpUyHFXlIweA;#p85OFhZw8pa?#EdjxFhW z2y<6~o`p6#)|*9lS|`=b+8o);4=&&_`fFXUym5|h19Q7ymd2kD4&x`0u5$ww6-0GL zq@jU_(f|z-vu|H?dh72kquwwxa7k^rwvFr=~TCpz$!Ep%l$%s;ezphc*53aCG})VMlz! z6^zR7NCQFiq=x<@y3%n@r+hhF2-@_O?=oAtK2|Xp?J$yV%F1_KJ%#cemjfE^<;mq3 zN7KGHnL+Loc!~zE&VD`*p8c$W&j6|DMeChN3=l&p?q{un<+XPn;Pk^n19vP_yRyWC z5$guH`=EB?+HO)g@u-xA_lE58M1^C4 zdFZFlEvIL@#|*xU8xL;Ul_rr!9K8!^shRHsXj%^+#RA>pv`wZA2!gz+<%0`ww_IXV zQn~NfqPuOiI|XHq^SEk)TRD7aou|G977=^m{y`N<5jaFt|8^5C~s<8|@G5bnKt7o#$s189rq; z*I$H9*T`=Rv##+9*!_k{pp$}f$bD$z_PW)5mGUk13r8R&Q)=yfD=|#(h(m4a42Se#DfS73XsFF_e8W zR_SaDLWxiuI_Tt${t8uy7@15st~AtS$)dyiFnz_G>=lL3QXrzE8|KmwLsb2BP^l_W ze;SL$H=fu)4uaSqLf?+_&3yFw@S*Sz*)#ZJi1s+%w_2lYjE>2dN{bB@mjfkhznk={ zY~s4B?FMA{nVw?e*7UEAR-LksQti@J&?doRd-o2>G!9!$58RSilh(Zh+>j{#$%uQS zFILFJNXjImqd8bJl34F^ID9B;z<6b=n7Af)XRd%2L38YLj)8~TZz zqXY81lO~mA$-gQ1N`fw)-q*l;TD_aszvVv{4w48dEHAQ-vl zjqhTw4vA+&hQ0Jjum+WE9xigEB;xbZin%Oq^0i1AK3+N?a++CX0)RSzkFcvge(?>C%5^x2f|ExA z%Dkgo;kn``S7oO3`YfWVIxP2PiEk#lw^14ESr5&!>1kR$)#(IBi{oe&NkjFMXkC6} zF{7eztM6HcPDize1G~T^;@#|Xn1`Y#WAHEc1gi~C-8|NvSFd&_0pB99{LEwYnR!2iisShjc z*6(ZE*I^5|?R^6jwd5!4(ovvg&?>9jSE7_widxnrXC%6QuiHKs zs+W^4&*t@l(iuxB5NS#jwksA%Xz>&ZV?-o{kMhKRwz`70qVH~{pNk4pSlhFv5Lq+{ z+vCjTodChkv*p=o#wX6~Eu`|Sr=^8uZ`vrsK?+gT6r1CK8Y_(}Z@5xH)J(R-krRkV{YbL_64mvco`-apy|tj`;80=ZKes>Bv@EZi0FxJxsBbX~KcWecvV6 z1O=jk?(BDAoY~@Dp1c8s%)a!lt@L@+1(J+!{ z_Kw}{`jcBzQKq++>I&rfO%-~UW;W|=XPRcn%gc3V*M>aNlJ!U;=QF4iWYz0r$ z4XP&D^2V5n8J)QuEMKU{E=e%JsTw!p5zOCj@s_sc;tapFK%P#)E+d+)6|W+b;cN_; z*K1>|_fZxQlJfgBM$e+|^A#a@^Y3?`m(Ny%^BY_#wTb6V#c=)Qy50pX5<*^3`R&5d z-aWP_h=*o9GjvaRk}1MTS?BE0I#z^yosfVo0R|F`HW)aPyJdf7J$-|4>*F<9OU@yC zshCk8t+E=Ya$(RlexA6yd|OpWV?85-6ldtZ#Q3JgQsoD$oS!Hrct$@@?Pm!#)5dc! zr`?N7BP8-^N`sp1kDU7UjgmeUzw!fb9E~@oyS-pWJ!;=a*ntybI6%mEP=Cd)w$YA< zCQ$5CLIcn01FQ~tmhM0Vj6ow_%}~k_Bk_Y6k9vQ`jQ#nov0t4K1gpJ;;1ib7;=B%Wlh}u)RG`>rnE!?kAlFoaHWnp_LogvIR0Nc~r!N78vLKgp#@=Hk1=a-wW_9mP2K< zoJu0i`SB%AJ9j}b&7xQvP@%78BiZZ>dISIxYt3vk;kcQb;&KleC_D7v`h*`G-axz# z2dl#x93-tcuF%U}Le#|!N_pWUe@{Iu8IA}9e)@swx%qsBhj)@m_4_uTN}5iHiVJi2 zlZtCKDZhGqlW6r-cKbhu_uLhic8OvZtv zt^2huMbXAe*f)wEk}&0B7sxWnkl%Tn2FiM^UDDUXiw37m!P4J3*4af?vtm~?(TAzz zZTQ#~Gp*_rNn5pk7NhO=w?l6{{vb?rW~$4n-CAuMEc_XeZ(X*%;~JP=iL~9)X&VGj zp$L<8GSQIw%t-dJ1`@T)A!(SYov$UC+HW^vK6ou7ZkkK&y%wLHnxsOg1QmEUg+L~5 zM7a!xUF(~+T|S}7LvN*79TQ!d$vYZ%l9l|f)_~VX-ez!_IIrsjQyG}GWOAF+9&D6p z;ROHHV`I$DR4$7LyXL0>UmT2bGI>f2f zDVU``$jk`$&X7KS0id>Z;edsBZSAu<}!PeaQ5GvfW55~;Q xhz93Kv=biY(x2LAarfT`)JRx8_w{|6D6+y(#u literal 0 HcmV?d00001 diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/ic_info_blue_pressed.png b/android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/ic_info_blue_pressed.png new file mode 100644 index 0000000000000000000000000000000000000000..faaef0625d15ae837e23c270ce22d7d1b6ccdd48 GIT binary patch literal 4240 zcmY*d2UHU}+b+ngP{1lfRt03qDw_g@B3rhMBFNrbTJ}&tnabV*g6zGQRJJTDh)mfC zfH$w`c!jv6)aHV^;+P;00w8(dlSKbeB;sx-nk zs$Cf(l!2NOpk|b1>#9NNrEZD>0Iq}oWFkOz4&xQT)Y%Y;Mrv!pY(3qDtnEB)?1lW@ zy{^yzfSf<KmgnI3BlO?&&pgr24*#pj~Axv?QDOg{D&V7mHQj{|9t=I$O-=u|38!YC(^&YSE0gz za>D;zHaJkLm&X(U0Daa_Mi}}N;mx&QvZ&pv+5Vb)v0sDtp{)laIJiKxl*EI|UK~mq zv?FsCF}xPbjQzd;_bu;@ge=Sv(BQE-eB$#{b(lAe*Ua3BOyrDJ~m zgza49X8rtjW?^(}czkehUh^Iy)DipiIqfT;Ydp1MSV*Z9bDtP!{v2EzQ+YqtE?zDBtS6 zffY{S+%ofF=s^GF&0}iv${ki`WpQYU@bB;5+VVkd=}k}tOM~BXPKLF1Jk+-wTcRP3 zO7E<1w927;YxM(77_*xdx0tF6WmCtQdGGZD%#?45xoCOu8ElxB7Y*wB9*!hk5V+qm z9q?3(pFXHL%;F=Nc{oqpLWDl$+3YOhF#2+LpEP)x3|3J`Jv3L$KulU!3qYqCpBpTU@Fu zFJ)BmYU%pqvCVT&(!)vs&BIvD6F^7q@HZxbiEPly`IAq)w8cwtFWbvzB!z^G*-X>3 z*#@w=tQWXkNbTCz!>%_#7v?CALO413yXSfLp~Y1L(Gvqh%vA4<*M@p5TcM;)M2is% zF4e`{4b(dmn!kQ@T&uQ7h*W#?_J2-rZj(laR|v~b!g<=-nPuXJJkI^y10g@PL`UP+oaYk`j7=%QZ8N<`}Yk}2vLp?3^Z zUw6B+h`&)pp~%9d`|GU$`%aAG+kPjAV*Yxv8QjMfqW6l+Zp_)kowGb=^id<2_4X8vJ<_L`aZjT- zE~h>p9X)1+=UYc$y{&^-MprtpifyKaNpIl6L@@z-$wM?w$wxWPL}gQx)qv9-+x>Yt zem0X13*nmmD^YDi{*HSF5Z;QBO(p@Fyv-; zY=zAu4T&93bsfWLo)9A^o*t#_ z7mn{GgGzkkEMxXP*>e{aZ|%6wwc7Fk4z#s_k($fhg0kMbE{6z4k}(VUz0Y^=WOz5J zS4#{f^_}6Cfb-!d_erg1}KUupETfNi2Z1z)UMJ1diAm88FU1YX}pnSc!HcKerNU9!2P(rjDi z3U)j-cNfe#dDAEFjVgb%b(*p&lE^8oXW!6Q)#mS%-K^+?WIhv|nIs;vInYTGET!x! zlR)U;85;opxDn`$Vf8r`$g~r|n?H)L%65H@P`5J zKq)AT+S7-FzLi7-78p@^l6n*;;E>iZOdsi=gEe(Jx!unw3g!s=Wx=U;90_ielzskr zDZ47s)H9E$V(Er9)%6N%H$oJYcF#J`UOo#+)o1+(39<}NWVFJOhiHdsaWLDZn%QKn zoh|x_A;fP<%MK*o)f!oBRF++2Z9tpYE||3&HDJ+MzOt7Z;0Og|7yy}JW$AeAJG;D< zmZv4~^J{Y0*3%Y#q_YEkM`aIyE&Un==|khJ0KOn@iCg_MtJi!H5grjPHiI|}#)+mk zcQ(z$b=%V*V?N3vnOR%sdtvdf;k}Vwuq^_)T8a_fBl)->Zux@~*x@@%a!({8F_K=N zdxVTh#n{=Yrd%fSj%Z98f2=M$?elU?v6!&&^h2HJ0--2;huHOoT^#z+*ul38@o($z z!^7;i;_8GtBxM^#E+*Se>IqL79k9>xB<^i@8cf0L+@~B>BNWw0*)9*Ztl`;Vwi;*j zZduSA2?1(6dUVquLY?IkW(+bH4+T0{F)-bxeyBQ9@vBP5PVL3Ol%3jUY)%{dW43$q zo5q*?^k9a*qG%HC9--v+#gsmEY`+eZ$Po3y!87i65j3JIsn|qE@gYrF^V=V=W$jqq zyHuicQa*g^(KP(y?B7GkraJpHaW}}vS}G4!D@!pl@S!E`{<;~rhrCacI*7hB*6z*M zd)a7YELaHi1K%~hn>VisCQa&Pq17&%yD44O@3FS*++J06;@-r?+XYLVXamTe{fOd< z=WmK!H{_{M5D5&f2(5M~j1R=H=on@^!3RNx2l5uGW`HKv?S1^~MeTf;R}3B8W$tm0 zjq^7WSuziF^tee1@~H;%{i{E2kXgvjkW*ta!pW*lNs&4~_-7Mo_A?bK>W6PFbbin9 zXd}~Cl2aQ{9N)AivIZaU?5FlVZd~JqcPccGGLGC8Adye& z2hyqO>3NxS@aE90L~cGV`mCZxcuSQj1#YijdYekXbe$6QzE{udKhH8;r!iNNV~}Ep zoA){3ScFPyAK209cS-6?&reI9FslJc#p=$+^%eU&^KVwH1W;a5X03ETa3)^wr9AmK zQDoJD{bW)Y$_bS6*`t}Le(Uw>R7!gDZDIc$KTMN}&-GrB49V9DFLRRu1;Vqu4PKVf zO{yr@H)+{vv1(S89v*t_ecZ@^5?)~#@M^P%Ii>Zf&1)sb_3pAXu=pl}ttoEw51$tM z^YNqAIwExmwK6=AzW#m{Sby&-0t{vi7bD}K0IjkjyAlXn^ zU1^l8PjYJ$>bPFZ87MirFT*id6%s0Zg1FeqKu0-`8Ez4YK*MsiI9uY`rSnXpkoS?( zc){=-T|F4^m_A1ew&HA%(WW1cicouJ))ehnh{~hrpPCQ3CSaG3TEG1OuBVZHm>I1i zf(Ux~j@gwS-t)_xh~2P4UZnb%A%5&!DbShDY>X$`uZ?c~j{CaQMR`)dLFC$97eZc4 z0jGZ?oO}CgUzwP6WSs~J)V_)D>Np+y}$1(|=tn8JU1 zVL*F$aqDG{)!-d>w79jJR3|9eA4kp8VT}FEQ+&`LGZ2u|_UN^zDyaTukF&%+QD$<& zy8eKxyN72dPK1Kn3j7i-GpU!y-b>e0tVS~nu0x>&&z%2C->9jg4_mE}rG z3_gDWj}iCi1%=2(p|=F$Z01n-UE?my6Ttd z3c*``yO-e-zwupf?ROM2%XTuJ%+V}{hiv2U6kV(@7E+ui!g;<(-=r%~=);6I`=56Q z3z%IU3~mQYs-B+w)mL$HJs@|%2vow8>}=Du`qq5Ac<%#>rd;<@Mg4A!ZiPV{J9=n3 zVNwO92&$(AhuC{FxB=H!Qe#h1K3u1TseWE1`Lq4srYVWz6UZSxJ{KCFBhJnv*18J{ z6exru+Ev&rzMZfH*l1F7B_dqGl-~{Gzs6oYUrOz;eE>+Ll<@t)!54`p~Fsw#QFwyl-BobPH&q@*|fec7YXv z={ww zY3==8cy`G})KE9TGHL`A-3GuKVZ8g7k-gQ;F{x(U z#hCUD=xrvLwg$>8A1@X2iupaua5_3%r|megYR0YuH|?q?M4V}*W~M@LK*Sa=e?q5( gy{0->fc{c&!?StZ+oQVrO#lEiRCJVUl&r%413IYE761SM literal 0 HcmV?d00001 diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/ic_info_outline_black_24dp.png b/android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/ic_info_outline_black_24dp.png deleted file mode 100644 index 3847a9fe74774d3593dd694cff48ccca13cdec5a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 940 zcmV;d15^BoP)mdcfcOtJM6uO{+z8D@UxkKMBq1+Buz@6?P#P0jG1VJo zr4$sRhK5k2Z=fXRN~6nW@y^{1KD~XI=}gYdoFjX&pWp3sm>a@9yM-m0@&}6isAEB(Qj;>qRst`p9~=6q zAu7LO=u+TQ_K7Dd@dg8*_ZUX>5!&WBSSti4^<9Bi7`TY2+y<+KU=~psWnX%OzQeO# z$Y%%reeR=-{wJ-1^+Iq9eT6F#>jwG=^_&zcppV__#9BjN7F^M%z)NCy=&SoFTsf2ppC<<**2_ZI5@SJo9Db@pv9Dwel>@Q2Y|A^pR+ zXm)h0I4$&8t(hXy6*cz3S)t(J`aO{jqc{F(SB1>4AMjd@E;uWs|KhZ2{;};ky2AQ2 z)rxDxD$`NJH=PukQuA$!?4zc}-&3$&Xn>Du{t5dULsafqFEod!oWp?rpGSuiRtueB z&+LQNE+8tK3|cF6gtuz;3+FNP08y#Yj|~U-15sJR*io8@$}eQs#}cB_phN-_NT5>I zKj|$a=v*bC1q7WMgQRsN@Unzi63g)%L1&Ybq;ZC~2s(dqkQ990An0_M#V3gY=Ga5f z`5TXvN})=^4!0;^!e^R~NT^Pc418W7q3m*(v-Aa=K4XNz?fnc_RXp{J*(OZ^8ac7(2N>$@cY O0000WFU8GbZ8()Nlj27Z*CxAAWdOomE>Pr0006tNklnlcoicoy71mc7~=byUr8rH2l-DLmA!hR=qH<5hGk%LMzBi9` z_N{(xT)oHVt|OlEeR(flhWNhxQslCu5VIYTbB#~0!=tl8EVOu3>YB;TE7hzVfB}4Mh48b5t}&+ zD!5&m8^AbPj_djK=Gug3%z{!*dE0&uD?v3`Fp~*2Ty9?)X+G*JJ9CKBP;oUgL7Zv6DH0>0Uz;k9*fhg#A?xUb0wPr zirJ8JUd$}chujp5xUY6k;bjcyWrmXIvIZPw2(Q!t00000005Nm4{Jegp7QBMr~m)} M07*qoM6N<$g0ufBqyPW_ literal 0 HcmV?d00001 diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/ic_info_blue_pressed.png b/android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/ic_info_blue_pressed.png new file mode 100644 index 0000000000000000000000000000000000000000..781263f760abe2339a8df4f9aba5d04fa5b9eed1 GIT binary patch literal 836 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7OGoY)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP~CmS!L`er`8KA@0VW=KSdbAE1aYF-JD%fR4Vl$uzQ znxasiS(2gP?&%w#ke{cJsNkEJJoQO@Gy?6j(kYsC~VmFm{(&cgY?_QBh4X7}Ii<9G0M;9zkS0HX?K z9rkjId3HsA=4Z;>%W!Z#7;VH7=kmYjw+Y{RJ>CG3dm*6*c7M3#*6`@{EC#Oi*(@6S z)^RTQu*>bht{>5z(OpZs7%e%bpEB#-cu?qI)M|e3!b41&YkeoQ&RFPqfyW#N1 zFW=qr|DEJg$Y9__#SLsODwh}@bIv=;&@X>W=gFVc&5UyPIVW2`|9;HBO+nxJMzHj$ zlT$@6II%wYXEvk#P5dfJ?FHL=BhH6TIPf;QjCqGlY+t6#yO8#R{?H9mCZG8nu!dFj zU(V;lvwtYI6#V=9W$Nhw)e|=L{(q&Xoa?xj?w+}BgVYT6kE^#X5PRT4o?uX&}O7Mbt9_2-+d9A!l*H`D%_op0Fc6qV(mc(m)0xS>LMy?IH6xz`=@!;fE!9@WosPgTe~ HDWM4f2pMO@ literal 0 HcmV?d00001 diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/ic_info_outline_black_24dp.png b/android/java/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/ic_info_outline_black_24dp.png deleted file mode 100644 index c1e2a03a4bc540419ce1165d5dedd8d5345fdec2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1256 zcmVP)W$LQv#I8j8T_{yf~=m$~;IXzu5?eh%l+bI*O5LnIQ3L?S-g zNEKIT<0XBJGshx}%rQL6n2^)65BytPpur(aAq3mzkx5L*!vp z0a@Ola>x)hq%a~$J)clM5drmH23z#q<|xU<0`*qKPGo7Si~n z%wqBU&0hSlj{%E?RDuuU7MJcXB=Jj%b`&x_e(Xp;ExUAT@Y|(jm(qjWZ(B;_Uor&Y z6!R#Nv*chaGsx+GPf(5^TbQOC&z>U}Plh0!MlPf-JUW9CsUc{WQ6klNkmN0L=W$Hb zI`=E``6_{H*O2>uGL!}iknh%)aH)U^vHJHyC=I|j;!5~HKCWcN1R5Z;2B2BgU%-W! zczBp#L#PcDi)Yo>;Taa!Y@Ptv;<}7l4r)8NeQGlwNF& zYb9ky8`z|cGKQ@=tt4)=frR*F&DNq;5;NLBOdDlk)i+CZzQKZh$R zK8n3)UuX^N7uDk=aj8xWGC(Sn1_~Jx)mdCiFf4{?52b-lQTv8C9#o@5E)leAD3OzR z)Fn^Gaf%@QAdedG1kbj}b8XCXgrFSb3rcL@n*sbhFEP*Qfd2Kr_;5}_cz_aF;&K3M ze+ebhM9$XHgOZ`06n-hB6D318YwImEMS(?`<%O>vfHEvXL&vNpLe#!|zDLp9b&_k9T z*x5;~c-Pf0-68_APCn*}yr+}vWZ1(d62yp+WD|SHaD&H;+SWI+mO!0l8Wm6`sU`&F zbfE&s6E+i?YKBohW{8u7EWu?ypnS+US>hOx&jq=;y2>EuNMckT2YAG1l*`QUkZ)PT z3X$L_jr@gjkUknXOq>;|goD)5%rkl!W0nOLm}QJ!o^qco2Ph^Ii9{k1-~0zqnGDmx SqDLYC0000 diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/drawable/ic_info_selector.xml b/android/java/MapboxGLAndroidSDK/src/main/res/drawable/ic_info_selector.xml new file mode 100644 index 000000000..fdbabbae1 --- /dev/null +++ b/android/java/MapboxGLAndroidSDK/src/main/res/drawable/ic_info_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file From 9a6924435baa3f303311de305ba280a354364bfe Mon Sep 17 00:00:00 2001 From: tobrun Date: Sun, 6 Sep 2015 15:51:11 +0200 Subject: [PATCH 013/156] Added styling to the Attribution AlertDialog --- .../main/java/com/mapbox/mapboxgl/views/MapView.java | 4 ++-- .../src/main/res/layout/attribution_list_item.xml | 11 +++++++++++ .../MapboxGLAndroidSDK/src/main/res/values/colors.xml | 1 + .../MapboxGLAndroidSDK/src/main/res/values/styles.xml | 9 +++++++++ .../src/main/res/values/colors.xml | 2 +- 5 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/layout/attribution_list_item.xml create mode 100644 android/java/MapboxGLAndroidSDK/src/main/res/values/styles.xml diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java index dda11c8f5..5a07365c4 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java @@ -2045,9 +2045,9 @@ public class MapView extends FrameLayout implements LocationListener { public void onClick(View v) { Context context = v.getContext(); String[] items = context.getResources().getStringArray(R.array.attribution_names); - AlertDialog.Builder builder = new AlertDialog.Builder(context); + AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AttributionAlertDialogStyle); builder.setTitle(R.string.attributionsDialogTitle); - builder.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, items), this); + builder.setAdapter(new ArrayAdapter<>(context, R.layout.attribution_list_item, items), this); builder.show(); } diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/layout/attribution_list_item.xml b/android/java/MapboxGLAndroidSDK/src/main/res/layout/attribution_list_item.xml new file mode 100644 index 000000000..f0a912158 --- /dev/null +++ b/android/java/MapboxGLAndroidSDK/src/main/res/layout/attribution_list_item.xml @@ -0,0 +1,11 @@ + + diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/values/colors.xml b/android/java/MapboxGLAndroidSDK/src/main/res/values/colors.xml index bf3f48431..bb1c326a8 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/res/values/colors.xml +++ b/android/java/MapboxGLAndroidSDK/src/main/res/values/colors.xml @@ -2,4 +2,5 @@ #FFFFFF #000000 + #1E8CAB diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/values/styles.xml b/android/java/MapboxGLAndroidSDK/src/main/res/values/styles.xml new file mode 100644 index 000000000..a0859a998 --- /dev/null +++ b/android/java/MapboxGLAndroidSDK/src/main/res/values/styles.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/colors.xml b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/colors.xml index ac3b4fc30..af798515f 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/colors.xml +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/colors.xml @@ -1,6 +1,6 @@ - #1E8CAB + @color/mapbox_blue #166B83 #E55E5E #FFFFFF From e7398c16c133e74274ffeda4b5b2994816fcf121 Mon Sep 17 00:00:00 2001 From: tobrun Date: Sun, 6 Sep 2015 16:37:34 +0200 Subject: [PATCH 014/156] Added "Improve this map" functionality, current zoom level, center latitude and longitude will be parsed in to the url of improve this map. --- .../com/mapbox/mapboxgl/views/MapView.java | 22 ++++++++++++++----- .../src/main/res/values/arrays.xml | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java index 5a07365c4..71121b7aa 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java @@ -120,6 +120,8 @@ public class MapView extends FrameLayout implements LocationListener { private static final float DIMENSION_SIXTEEN_DP = 16f; private static final float DIMENSION_TEN_DP = 10f; + private static final int IMPROVE_THIS_MAP_INDEX = 2; + /** * Every annotation that has been added to the map. */ @@ -425,7 +427,7 @@ public class MapView extends FrameLayout implements LocationListener { LayoutParams attrParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); mAttributionsView.setLayoutParams(attrParams); addView(mAttributionsView); - mAttributionsView.setOnClickListener(new AttributionOnClickListener()); + mAttributionsView.setOnClickListener(new AttributionOnClickListener(this)); // Setup Support For Listener Tracking // MapView's internal listener is setup in onCreate() @@ -2040,6 +2042,12 @@ public class MapView extends FrameLayout implements LocationListener { private static class AttributionOnClickListener implements View.OnClickListener, DialogInterface.OnClickListener { + private MapView mMapView; + + public AttributionOnClickListener(MapView mapView) { + mMapView = mapView; + } + // Called when someone presses the attribution icon @Override public void onClick(View v) { @@ -2051,13 +2059,17 @@ public class MapView extends FrameLayout implements LocationListener { builder.show(); } - // Called when someone selects an attribution + // Called when someone selects an attribution, 'Improve this map' adds location data to the url @Override public void onClick(DialogInterface dialog, int which) { - Context context = ((Dialog)dialog).getContext(); - String[]links = context.getResources().getStringArray(R.array.attribution_links); + Context context = ((Dialog) dialog).getContext(); + String url = context.getResources().getStringArray(R.array.attribution_links)[which]; + if (which == IMPROVE_THIS_MAP_INDEX) { + LatLng latLng = mMapView.getCenterCoordinate(); + url = String.format(url, latLng.getLongitude(), latLng.getLatitude(), (int) mMapView.getZoomLevel()); + } Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse(links[which])); + intent.setData(Uri.parse(url)); context.startActivity(intent); } } diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/values/arrays.xml b/android/java/MapboxGLAndroidSDK/src/main/res/values/arrays.xml index 3e937722c..8a8e204b7 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/res/values/arrays.xml +++ b/android/java/MapboxGLAndroidSDK/src/main/res/values/arrays.xml @@ -8,6 +8,6 @@ https://www.mapbox.com/about/maps/ http://www.openstreetmap.org/about/ - https://www.mapbox.com/map-feedback + https://www.mapbox.com/map-feedback/#/%1$f/%2$f/%3$d \ No newline at end of file From 36a754a1fe20afeedd931d2b8dcd68d4ff16191f Mon Sep 17 00:00:00 2001 From: tobrun Date: Sun, 6 Sep 2015 19:20:05 +0200 Subject: [PATCH 015/156] Using AlertDialog from AppCompat instead of SDKs version --- .../src/main/java/com/mapbox/mapboxgl/views/MapView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java index 71121b7aa..b78db1736 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java @@ -1,7 +1,6 @@ package com.mapbox.mapboxgl.views; import android.app.ActivityManager; -import android.app.AlertDialog; import android.app.Dialog; import android.content.BroadcastReceiver; import android.content.Context; @@ -30,6 +29,7 @@ import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; import android.support.v4.view.GestureDetectorCompat; import android.support.v4.view.ScaleGestureDetectorCompat; +import android.support.v7.app.AlertDialog; import android.text.TextUtils; import android.view.GestureDetector; import android.view.Gravity; From 290a857b511f6500c8d376af78f5492c274c9bef Mon Sep 17 00:00:00 2001 From: tobrun Date: Wed, 9 Sep 2015 18:40:27 +0200 Subject: [PATCH 016/156] Moved icon to the right of Mapbox logo --- .../com/mapbox/mapboxgl/views/MapView.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java index b78db1736..d50fac6ee 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java @@ -117,10 +117,12 @@ public class MapView extends FrameLayout implements LocationListener { private static final String STATE_ATTRIBUTION_MARGIN_BOTTOM = "atrrMarginBottom"; // Used for positioning views - private static final float DIMENSION_SIXTEEN_DP = 16f; + private static final float DIMENSION_SEVEN_DP = 7f; private static final float DIMENSION_TEN_DP = 10f; + private static final float DIMENSION_SIXTEEN_DP = 16f; + private static final float DIMENSION_SEVENTYSIX_DP = 76f; - private static final int IMPROVE_THIS_MAP_INDEX = 2; + private static final int ATTRIBUTION_INDEX_IMPROVE_THIS_MAP = 2; /** * Every annotation that has been added to the map. @@ -422,7 +424,11 @@ public class MapView extends FrameLayout implements LocationListener { // Setup Attributions control mAttributionsView = new ImageView(mContext); - mAttributionsView.setBackgroundResource(R.drawable.ic_info_selector); + mAttributionsView.setClickable(true); + mAttributionsView.setImageResource(R.drawable.ic_info_selector); + int attrPadding = (int) (DIMENSION_SEVEN_DP * mScreenDensity); + mAttributionsView.setPadding(attrPadding, attrPadding, attrPadding, attrPadding); + mAttributionsView.setAdjustViewBounds(true); mAttributionsView.setContentDescription(getResources().getString(R.string.attributionsIconContentDescription)); LayoutParams attrParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); mAttributionsView.setLayoutParams(attrParams); @@ -478,11 +484,11 @@ public class MapView extends FrameLayout implements LocationListener { , typedArray.getDimension(R.styleable.MapView_logoMarginBottom, DIMENSION_SIXTEEN_DP)); // Attribution - setAttributionGravity(typedArray.getInt(R.styleable.MapView_attributionGravity, Gravity.BOTTOM | Gravity.END)); - setWidgetMargins(mAttributionsView, typedArray.getDimension(R.styleable.MapView_attributionMarginLeft, DIMENSION_SIXTEEN_DP) - , typedArray.getDimension(R.styleable.MapView_attributionMarginTop, DIMENSION_SIXTEEN_DP) - , typedArray.getDimension(R.styleable.MapView_attributionMarginRight, DIMENSION_SIXTEEN_DP) - , typedArray.getDimension(R.styleable.MapView_attributionMarginBottom, DIMENSION_SIXTEEN_DP)); + setAttributionGravity(typedArray.getInt(R.styleable.MapView_attributionGravity, Gravity.BOTTOM)); + setWidgetMargins(mAttributionsView, typedArray.getDimension(R.styleable.MapView_attributionMarginLeft, DIMENSION_SEVENTYSIX_DP) + , typedArray.getDimension(R.styleable.MapView_attributionMarginTop, DIMENSION_SEVEN_DP) + , typedArray.getDimension(R.styleable.MapView_attributionMarginRight, DIMENSION_SEVEN_DP) + , typedArray.getDimension(R.styleable.MapView_attributionMarginBottom, DIMENSION_SEVEN_DP)); setMyLocationEnabled(typedArray.getBoolean(R.styleable.MapView_myLocationEnabled, false)); } finally { @@ -2064,7 +2070,7 @@ public class MapView extends FrameLayout implements LocationListener { public void onClick(DialogInterface dialog, int which) { Context context = ((Dialog) dialog).getContext(); String url = context.getResources().getStringArray(R.array.attribution_links)[which]; - if (which == IMPROVE_THIS_MAP_INDEX) { + if (which == ATTRIBUTION_INDEX_IMPROVE_THIS_MAP) { LatLng latLng = mMapView.getCenterCoordinate(); url = String.format(url, latLng.getLongitude(), latLng.getLatitude(), (int) mMapView.getZoomLevel()); } From d371dd07cbe7093996ba2bf16dd5c33d4037e9f7 Mon Sep 17 00:00:00 2001 From: tobrun Date: Wed, 9 Sep 2015 18:55:17 +0200 Subject: [PATCH 017/156] Changed title dialog --- .../java/MapboxGLAndroidSDK/src/main/res/values/strings.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/values/strings.xml b/android/java/MapboxGLAndroidSDK/src/main/res/values/strings.xml index 455fdb026..be9a1d38c 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/res/values/strings.xml +++ b/android/java/MapboxGLAndroidSDK/src/main/res/values/strings.xml @@ -1,10 +1,10 @@ Map compass. Click to reset the map rotation to North. + Attribution icon. Click to show attribution dialog. + Mapbox Android SDK + Mapbox logo. Title Description Address - Attribution icon. Click to show attribution dialog. - Mapbox for Android - Mapbox logo. From aa001f07c315d89a43ef1c894ca11af236d607a5 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Wed, 9 Sep 2015 15:15:23 -0500 Subject: [PATCH 018/156] #2293 - Removing Drawable --- .../src/main/java/com/mapbox/mapboxgl/views/MapView.java | 1 - 1 file changed, 1 deletion(-) diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java index 823424be7..664268141 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java @@ -14,7 +14,6 @@ import android.graphics.Matrix; import android.graphics.PointF; import android.graphics.RectF; import android.graphics.SurfaceTexture; -import android.graphics.drawable.Drawable; import android.hardware.GeomagneticField; import android.hardware.Sensor; import android.hardware.SensorEvent; From 0531b38367eb23b787276b9b6ef1f6992b4b3bc2 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 3 Sep 2015 15:54:18 -0700 Subject: [PATCH 019/156] Nan 2.0 --- package.json | 2 +- platform/node/src/node_file_source.cpp | 49 ++---- platform/node/src/node_file_source.hpp | 12 +- platform/node/src/node_log.cpp | 39 +++-- platform/node/src/node_log.hpp | 5 +- platform/node/src/node_map.cpp | 180 ++++++++++---------- platform/node/src/node_map.hpp | 22 +-- platform/node/src/node_mapbox_gl_native.cpp | 67 +++++--- platform/node/src/node_request.cpp | 91 +++++----- platform/node/src/node_request.hpp | 14 +- 10 files changed, 239 insertions(+), 242 deletions(-) diff --git a/package.json b/package.json index 0fd6887ba..b8305af3e 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ } ], "dependencies": { - "nan": "^1.9.0", + "nan": "^2.0.8", "node-pre-gyp": "^0.6.9" }, "bundledDependencies": [ diff --git a/platform/node/src/node_file_source.cpp b/platform/node/src/node_file_source.cpp index 204e85a12..29a4748c5 100644 --- a/platform/node/src/node_file_source.cpp +++ b/platform/node/src/node_file_source.cpp @@ -11,7 +11,7 @@ struct NodeFileSource::Action { mbgl::Resource const resource; }; -NodeFileSource::NodeFileSource(v8::Handle options_) : +NodeFileSource::NodeFileSource(v8::Local options_) : queue(new Queue(uv_default_loop(), [this](Action &action) { if (action.type == Action::Add) { processAdd(action.resource); @@ -20,7 +20,7 @@ NodeFileSource::NodeFileSource(v8::Handle options_) : } })) { - NanAssignPersistent(options, options_->ToObject()); + options.Reset(options_); // Make sure that the queue doesn't block the loop from exiting. queue->unref(); @@ -30,7 +30,7 @@ NodeFileSource::~NodeFileSource() { queue->stop(); queue = nullptr; - NanDisposePersistent(options); + options.Reset(); } mbgl::Request* NodeFileSource::request(const mbgl::Resource& resource, uv_loop_t* loop, Callback callback) { @@ -68,44 +68,30 @@ void NodeFileSource::cancel(mbgl::Request* req) { } void NodeFileSource::processAdd(const mbgl::Resource& resource) { - NanScope(); + Nan::HandleScope scope; // Make sure the loop stays alive as long as request is pending. if (pending.empty()) { queue->ref(); } - auto requestHandle = NanNew(NodeRequest::Create(this, resource)); - - v8::Persistent requestPersistent; - NanAssignPersistent(requestPersistent, requestHandle); - pending.emplace(resource, std::move(requestPersistent)); - -#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION) - auto requestFunction = v8::Local::New(v8::Isolate::GetCurrent(), options)->Get(NanNew("request")).As(); -#else - auto requestFunction = options->Get(NanNew("request")).As(); -#endif + auto requestHandle = Nan::New(NodeRequest::Create(this, resource)); + pending.emplace(resource, requestHandle); v8::Local argv[] = { requestHandle }; - NanMakeCallback(NanGetCurrentContext()->Global(), requestFunction, 1, argv); + Nan::MakeCallback(Nan::New(options), "request", 1, argv); } void NodeFileSource::processCancel(const mbgl::Resource& resource) { - NanScope(); + Nan::HandleScope scope; auto it = pending.find(resource); if (it == pending.end()) { // The response callback was already fired. There is no point in calling the cancelation // callback because the request is already completed. } else { -#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION) - auto requestHandle = v8::Local::New(v8::Isolate::GetCurrent(), it->second); + v8::Local requestHandle = Nan::New(it->second); it->second.Reset(); -#else - auto requestHandle = NanNew(it->second); - NanDisposePersistent(it->second); -#endif pending.erase(it); // Make sure the the loop can exit when there are no pending requests. @@ -113,20 +99,13 @@ void NodeFileSource::processCancel(const mbgl::Resource& resource) { queue->unref(); } -#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION) - auto optionsObject = v8::Local::New(v8::Isolate::GetCurrent(), options); - if (optionsObject->Has(NanNew("cancel"))) { - auto cancelFunction = optionsObject->Get(NanNew("cancel")).As(); -#else - if (options->Has(NanNew("cancel"))) { - auto cancelFunction = options->Get(NanNew("cancel")).As(); -#endif + if (Nan::Has(Nan::New(options), Nan::New("cancel").ToLocalChecked()).FromJust()) { v8::Local argv[] = { requestHandle }; - NanMakeCallback(NanGetCurrentContext()->Global(), cancelFunction, 1, argv); + Nan::MakeCallback(Nan::New(options), "cancel", 1, argv); } // Set the request handle in the request wrapper handle to null - node::ObjectWrap::Unwrap(requestHandle)->cancel(); + Nan::ObjectWrap::Unwrap(requestHandle)->cancel(); } } @@ -134,11 +113,7 @@ void NodeFileSource::notify(const mbgl::Resource& resource, const std::shared_pt // First, remove the request, since it might be destructed at any point now. auto it = pending.find(resource); if (it != pending.end()) { -#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION) it->second.Reset(); -#else - NanDisposePersistent(it->second); -#endif pending.erase(it); // Make sure the the loop can exit when there are no pending requests. diff --git a/platform/node/src/node_file_source.hpp b/platform/node/src/node_file_source.hpp index f412bdee1..038765cb2 100644 --- a/platform/node/src/node_file_source.hpp +++ b/platform/node/src/node_file_source.hpp @@ -5,8 +5,6 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wshadow" -#include -#include #include #pragma GCC diagnostic pop @@ -20,7 +18,7 @@ namespace util { template class AsyncQueue; } class NodeFileSource : public mbgl::FileSource { public: - NodeFileSource(v8::Handle); + NodeFileSource(v8::Local); ~NodeFileSource(); mbgl::Request* request(const mbgl::Resource&, uv_loop_t*, Callback); @@ -36,14 +34,10 @@ private: void processAdd(const mbgl::Resource&); void processCancel(const mbgl::Resource&); - v8::Persistent options; + Nan::Persistent options; private: -#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION) - std::unordered_map>, mbgl::Resource::Hash> pending; -#else - std::unordered_map, mbgl::Resource::Hash> pending; -#endif + std::unordered_map, mbgl::Resource::Hash> pending; // The observers list will hold pointers to all the requests waiting // for a particular resource. The access must be guarded by a mutex diff --git a/platform/node/src/node_log.cpp b/platform/node/src/node_log.cpp index 637534807..8230bb36c 100644 --- a/platform/node/src/node_log.cpp +++ b/platform/node/src/node_log.cpp @@ -16,27 +16,35 @@ struct NodeLogObserver::LogMessage { text(text_) {} }; -NodeLogObserver::NodeLogObserver(v8::Handle target) +NodeLogObserver::NodeLogObserver(v8::Local target) : queue(new Queue(uv_default_loop(), [this](LogMessage &message) { - NanScope(); + Nan::HandleScope scope; + + auto msg = Nan::New(); + + Nan::Set(msg, Nan::New("class").ToLocalChecked(), + Nan::New(mbgl::EventClass(message.event).c_str()).ToLocalChecked()); + + Nan::Set(msg, Nan::New("severity").ToLocalChecked(), + Nan::New(mbgl::EventSeverityClass(message.severity).c_str()).ToLocalChecked()); - auto msg = NanNew(); - msg->Set(NanNew("class"), NanNew(mbgl::EventClass(message.event).c_str())); - msg->Set(NanNew("severity"), NanNew(mbgl::EventSeverityClass(message.severity).c_str())); if (message.code != -1) { - msg->Set(NanNew("code"), NanNew(message.code)); - } - if (!message.text.empty()) { - msg->Set(NanNew("text"), NanNew(message.text)); + Nan::Set(msg, Nan::New("code").ToLocalChecked(), + Nan::New(message.code)); } - v8::Local argv[] = { NanNew("message"), msg }; - auto handle = NanNew(module); - auto emit = handle->Get(NanNew("emit"))->ToObject(); - emit->CallAsFunction(handle, 2, argv); + if (!message.text.empty()) { + Nan::Set(msg, Nan::New("text").ToLocalChecked(), + Nan::New(message.text).ToLocalChecked()); + } + + v8::Local argv[] = { Nan::New("message").ToLocalChecked(), msg }; + auto handle = Nan::New(module); + auto emit = Nan::Get(handle, Nan::New("emit").ToLocalChecked()).ToLocalChecked()->ToObject(); + Nan::CallAsFunction(emit, handle, 2, argv); })) { - NanScope(); - NanAssignPersistent(module, target); + Nan::HandleScope scope; + module.Reset(target); // Don't keep the event loop alive. queue->unref(); @@ -44,6 +52,7 @@ NodeLogObserver::NodeLogObserver(v8::Handle target) NodeLogObserver::~NodeLogObserver() { queue->stop(); + module.Reset(); } bool NodeLogObserver::onRecord(mbgl::EventSeverity severity, mbgl::Event event, int64_t code, const std::string &text) { diff --git a/platform/node/src/node_log.hpp b/platform/node/src/node_log.hpp index 5c0048d26..d29e4e28e 100644 --- a/platform/node/src/node_log.hpp +++ b/platform/node/src/node_log.hpp @@ -5,7 +5,6 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wshadow" -#include #include #pragma GCC diagnostic pop @@ -15,14 +14,14 @@ namespace util { template class AsyncQueue; } class NodeLogObserver : public mbgl::Log::Observer { public: - NodeLogObserver(v8::Handle target); + NodeLogObserver(v8::Local target); ~NodeLogObserver(); // Log::Observer implementation virtual bool onRecord(mbgl::EventSeverity severity, mbgl::Event event, int64_t code, const std::string &msg) override; private: - v8::Persistent module; + Nan::Persistent module; struct LogMessage; using Queue = util::AsyncQueue; diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index b624e32e6..0133babc0 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -21,7 +21,7 @@ struct NodeMap::RenderOptions { //////////////////////////////////////////////////////////////////////////////////////////////// // Static Node Methods -v8::Persistent NodeMap::constructorTemplate; +Nan::Persistent NodeMap::constructor; static std::shared_ptr sharedDisplay() { static auto display = std::make_shared(); @@ -32,127 +32,137 @@ const static char* releasedMessage() { return "Map resources have already been released"; } -void NodeMap::Init(v8::Handle target) { - NanScope(); +NAN_MODULE_INIT(NodeMap::Init) { + v8::Local tpl = Nan::New(New); - v8::Local t = NanNew(New); + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(Nan::New("Map").ToLocalChecked()); - t->InstanceTemplate()->SetInternalFieldCount(1); - t->SetClassName(NanNew("Map")); + Nan::SetPrototypeMethod(tpl, "load", Load); + Nan::SetPrototypeMethod(tpl, "render", Render); + Nan::SetPrototypeMethod(tpl, "release", Release); - NODE_SET_PROTOTYPE_METHOD(t, "load", Load); - NODE_SET_PROTOTYPE_METHOD(t, "render", Render); - NODE_SET_PROTOTYPE_METHOD(t, "release", Release); - - NanAssignPersistent(constructorTemplate, t); - - target->Set(NanNew("Map"), t->GetFunction()); + constructor.Reset(tpl->GetFunction()); + Nan::Set(target, Nan::New("Map").ToLocalChecked(), tpl->GetFunction()); // Initialize display connection on module load. sharedDisplay(); } NAN_METHOD(NodeMap::New) { - NanScope(); - - if (!args.IsConstructCall()) { - return NanThrowTypeError("Use the new operator to create new Map objects"); + if (!info.IsConstructCall()) { + return Nan::ThrowTypeError("Use the new operator to create new Map objects"); } - if (args.Length() < 1 || !args[0]->IsObject()) { - return NanThrowTypeError("Requires an options object as first argument"); + if (info.Length() < 1 || !info[0]->IsObject()) { + return Nan::ThrowTypeError("Requires an options object as first argument"); } - auto options = args[0]->ToObject(); + auto options = info[0]->ToObject(); // Check that 'request', 'cancel' and 'ratio' are defined. - if (!options->Has(NanNew("request")) || !options->Get(NanNew("request"))->IsFunction()) { - return NanThrowError("Options object must have a 'request' method"); - } - if (options->Has(NanNew("cancel")) && !options->Get(NanNew("cancel"))->IsFunction()) { - return NanThrowError("Options object 'cancel' property must be a function"); + if (!Nan::Has(options, Nan::New("request").ToLocalChecked()).FromJust() + || !Nan::Get(options, Nan::New("request").ToLocalChecked()).ToLocalChecked()->IsFunction()) { + return Nan::ThrowError("Options object must have a 'request' method"); } - if (!options->Has(NanNew("ratio")) || !options->Get(NanNew("ratio"))->IsNumber()) { - return NanThrowError("Options object must have a numerical 'ratio' property"); + if ( Nan::Has(options, Nan::New("cancel").ToLocalChecked()).FromJust() + && !Nan::Get(options, Nan::New("cancel").ToLocalChecked()).ToLocalChecked()->IsFunction()) { + return Nan::ThrowError("Options object 'cancel' property must be a function"); + } + + if (!Nan::Has(options, Nan::New("ratio").ToLocalChecked()).FromJust() + || !Nan::Get(options, Nan::New("ratio").ToLocalChecked()).ToLocalChecked()->IsNumber()) { + return Nan::ThrowError("Options object must have a numerical 'ratio' property"); } try { auto nodeMap = new NodeMap(options); - nodeMap->Wrap(args.This()); + nodeMap->Wrap(info.This()); } catch(std::exception &ex) { - return NanThrowError(ex.what()); + return Nan::ThrowError(ex.what()); } - NanReturnValue(args.This()); + info.GetReturnValue().Set(info.This()); } -const std::string StringifyStyle(v8::Handle styleHandle) { - NanScope(); +const std::string StringifyStyle(v8::Local styleHandle) { + Nan::HandleScope scope; - auto JSON = NanGetCurrentContext()->Global()->Get(NanNew("JSON"))->ToObject(); - auto stringify = v8::Handle::Cast(JSON->Get(NanNew("stringify"))); + v8::Local JSON = Nan::Get( + Nan::GetCurrentContext()->Global(), + Nan::New("JSON").ToLocalChecked()).ToLocalChecked()->ToObject(); - return *NanUtf8String(stringify->Call(JSON, 1, &styleHandle)); + return *Nan::Utf8String(Nan::MakeCallback(JSON, "stringify", 1, &styleHandle)); } NAN_METHOD(NodeMap::Load) { - NanScope(); + auto nodeMap = Nan::ObjectWrap::Unwrap(info.Holder()); - auto nodeMap = node::ObjectWrap::Unwrap(args.Holder()); - - if (!nodeMap->isValid()) return NanThrowError(releasedMessage()); + if (!nodeMap->isValid()) return Nan::ThrowError(releasedMessage()); // Reset the flag as this could be the second time // we are calling this (being the previous successful). nodeMap->loaded = false; - if (args.Length() < 1) { - return NanThrowError("Requires a map style as first argument"); + if (info.Length() < 1) { + return Nan::ThrowError("Requires a map style as first argument"); } std::string style; - if (args[0]->IsObject()) { - style = StringifyStyle(args[0]); - } else if (args[0]->IsString()) { - style = *NanUtf8String(args[0]); + if (info[0]->IsObject()) { + style = StringifyStyle(info[0]); + } else if (info[0]->IsString()) { + style = *Nan::Utf8String(info[0]); } else { - return NanThrowTypeError("First argument must be a string or object"); + return Nan::ThrowTypeError("First argument must be a string or object"); } try { nodeMap->map->setStyleJSON(style, "."); } catch (const std::exception &ex) { - return NanThrowError(ex.what()); + return Nan::ThrowError(ex.what()); } nodeMap->loaded = true; - NanReturnUndefined(); + info.GetReturnValue().SetUndefined(); } std::unique_ptr NodeMap::ParseOptions(v8::Local obj) { - NanScope(); + Nan::HandleScope scope; auto options = std::make_unique(); - if (obj->Has(NanNew("zoom"))) { options->zoom = obj->Get(NanNew("zoom"))->NumberValue(); } - if (obj->Has(NanNew("bearing"))) { options->bearing = obj->Get(NanNew("bearing"))->NumberValue(); } - if (obj->Has(NanNew("center"))) { - auto center = obj->Get(NanNew("center")).As(); - if (center->Length() > 0) { options->latitude = center->Get(0)->NumberValue(); } - if (center->Length() > 1) { options->longitude = center->Get(1)->NumberValue(); } + if (Nan::Has(obj, Nan::New("zoom").ToLocalChecked()).FromJust()) { + options->zoom = Nan::Get(obj, Nan::New("zoom").ToLocalChecked()).ToLocalChecked()->NumberValue(); } - if (obj->Has(NanNew("width"))) { options->width = obj->Get(NanNew("width"))->IntegerValue(); } - if (obj->Has(NanNew("height"))) { options->height = obj->Get(NanNew("height"))->IntegerValue(); } - if (obj->Has(NanNew("classes"))) { - auto classes = obj->Get(NanNew("classes"))->ToObject().As(); + if (Nan::Has(obj, Nan::New("bearing").ToLocalChecked()).FromJust()) { + options->bearing = Nan::Get(obj, Nan::New("bearing").ToLocalChecked()).ToLocalChecked()->NumberValue(); + } + + if (Nan::Has(obj, Nan::New("center").ToLocalChecked()).FromJust()) { + auto center = Nan::Get(obj, Nan::New("center").ToLocalChecked()).ToLocalChecked().As(); + if (center->Length() > 0) { options->latitude = Nan::Get(center, 0).ToLocalChecked()->NumberValue(); } + if (center->Length() > 1) { options->longitude = Nan::Get(center, 1).ToLocalChecked()->NumberValue(); } + } + + if (Nan::Has(obj, Nan::New("width").ToLocalChecked()).FromJust()) { + options->width = Nan::Get(obj, Nan::New("width").ToLocalChecked()).ToLocalChecked()->IntegerValue(); + } + + if (Nan::Has(obj, Nan::New("height").ToLocalChecked()).FromJust()) { + options->height = Nan::Get(obj, Nan::New("height").ToLocalChecked()).ToLocalChecked()->IntegerValue(); + } + + if (Nan::Has(obj, Nan::New("classes").ToLocalChecked()).FromJust()) { + auto classes = Nan::Get(obj, Nan::New("classes").ToLocalChecked()).ToLocalChecked()->ToObject().As(); const int length = classes->Length(); options->classes.reserve(length); for (int i = 0; i < length; i++) { - options->classes.push_back(std::string { *NanUtf8String(classes->Get(i)->ToString()) }); + options->classes.push_back(std::string { *Nan::Utf8String(Nan::Get(classes, i).ToLocalChecked()->ToString()) }); } } @@ -160,37 +170,35 @@ std::unique_ptr NodeMap::ParseOptions(v8::Local(info.Holder()); - auto nodeMap = node::ObjectWrap::Unwrap(args.Holder()); + if (!nodeMap->isValid()) return Nan::ThrowError(releasedMessage()); - if (!nodeMap->isValid()) return NanThrowError(releasedMessage()); - - if (args.Length() <= 0 || !args[0]->IsObject()) { - return NanThrowTypeError("First argument must be an options object"); + if (info.Length() <= 0 || !info[0]->IsObject()) { + return Nan::ThrowTypeError("First argument must be an options object"); } - if (args.Length() <= 1 || !args[1]->IsFunction()) { - return NanThrowTypeError("Second argument must be a callback function"); + if (info.Length() <= 1 || !info[1]->IsFunction()) { + return Nan::ThrowTypeError("Second argument must be a callback function"); } if (!nodeMap->isLoaded()) { - return NanThrowTypeError("Style is not loaded"); + return Nan::ThrowTypeError("Style is not loaded"); } - auto options = ParseOptions(args[0]->ToObject()); + auto options = ParseOptions(info[0]->ToObject()); assert(!nodeMap->callback); assert(!nodeMap->image); - nodeMap->callback = std::unique_ptr(new NanCallback(args[1].As())); + nodeMap->callback = std::make_unique(info[1].As()); try { nodeMap->startRender(std::move(options)); } catch (mbgl::util::Exception &ex) { - return NanThrowError(ex.what()); + return Nan::ThrowError(ex.what()); } - NanReturnUndefined(); + info.GetReturnValue().SetUndefined(); } void NodeMap::startRender(std::unique_ptr options) { @@ -221,7 +229,7 @@ void NodeMap::startRender(std::unique_ptr options) { } void NodeMap::renderFinished() { - NanScope(); + Nan::HandleScope scope; // We're done with this render call, so we're unrefing so that the loop could close. uv_unref(reinterpret_cast(async)); @@ -249,7 +257,7 @@ void NodeMap::renderFinished() { } v8::Local argv[] = { - NanError(errorMessage.c_str()) + Nan::Error(errorMessage.c_str()) }; // This must be empty to be prepared for the next render call. @@ -258,7 +266,7 @@ void NodeMap::renderFinished() { cb->Call(1, argv); } else if (img) { - v8::Local pixels = NanNewBufferHandle( + v8::Local pixels = Nan::NewBuffer( reinterpret_cast(img->pixels.get()), size_t(img->width) * size_t(img->height) * sizeof(mbgl::StillImage::Pixel), @@ -267,36 +275,34 @@ void NodeMap::renderFinished() { delete reinterpret_cast(hint); }, const_cast(img.get()) - ); + ).ToLocalChecked(); img.release(); v8::Local argv[] = { - NanNull(), + Nan::Null(), pixels, }; cb->Call(2, argv); } else { v8::Local argv[] = { - NanError("Didn't get an image") + Nan::Error("Didn't get an image") }; cb->Call(1, argv); } } NAN_METHOD(NodeMap::Release) { - NanScope(); + auto nodeMap = Nan::ObjectWrap::Unwrap(info.Holder()); - auto nodeMap = node::ObjectWrap::Unwrap(args.Holder()); - - if (!nodeMap->isValid()) return NanThrowError(releasedMessage()); + if (!nodeMap->isValid()) return Nan::ThrowError(releasedMessage()); try { nodeMap->release(); } catch (const std::exception &ex) { - return NanThrowError(ex.what()); + return Nan::ThrowError(ex.what()); } - NanReturnUndefined(); + info.GetReturnValue().SetUndefined(); } void NodeMap::release() { @@ -315,8 +321,8 @@ void NodeMap::release() { //////////////////////////////////////////////////////////////////////////////////////////////// // Instance -NodeMap::NodeMap(v8::Handle options) : - view(sharedDisplay(), options->Get(NanNew("ratio"))->NumberValue()), +NodeMap::NodeMap(v8::Local options) : + view(sharedDisplay(), Nan::Get(options, Nan::New("ratio").ToLocalChecked()).ToLocalChecked()->NumberValue()), fs(options), map(std::make_unique(view, fs, mbgl::MapMode::Still)), async(new uv_async_t) { diff --git a/platform/node/src/node_map.hpp b/platform/node/src/node_map.hpp index 2c87900d4..90edf44f7 100644 --- a/platform/node/src/node_map.hpp +++ b/platform/node/src/node_map.hpp @@ -8,7 +8,6 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wshadow" -#include #include #pragma GCC diagnostic pop @@ -16,14 +15,13 @@ namespace node_mbgl { -class NodeMap : public node::ObjectWrap { +class NodeMap : public Nan::ObjectWrap { +public: struct RenderOptions; class RenderWorker; - //////////////////////////////////////////////////////////////////////////////////////////////// - // Static Node Methods -public: - static void Init(v8::Handle target); + static NAN_MODULE_INIT(Init); + static NAN_METHOD(New); static NAN_METHOD(Load); static NAN_METHOD(Render); @@ -37,24 +35,20 @@ public: inline bool isLoaded() { return loaded; } inline bool isValid() { return valid; } - static std::unique_ptr ParseOptions(v8::Local obj); + static std::unique_ptr ParseOptions(v8::Local); + static Nan::Persistent constructor; - static v8::Persistent constructorTemplate; - - //////////////////////////////////////////////////////////////////////////////////////////////// - // Instance private: - NodeMap(v8::Handle); + NodeMap(v8::Local); ~NodeMap(); -private: mbgl::HeadlessView view; NodeFileSource fs; std::unique_ptr map; std::exception_ptr error; std::unique_ptr image; - std::unique_ptr callback; + std::unique_ptr callback; // Async for delivering the notifications of render completion. uv_async_t *async; diff --git a/platform/node/src/node_mapbox_gl_native.cpp b/platform/node/src/node_mapbox_gl_native.cpp index 14a0c9ad2..b631b32c5 100644 --- a/platform/node/src/node_mapbox_gl_native.cpp +++ b/platform/node/src/node_mapbox_gl_native.cpp @@ -9,30 +9,57 @@ #include "node_log.hpp" #include "node_request.hpp" -void RegisterModule(v8::Handle exports) { - NanScope(); - - node_mbgl::NodeMap::Init(exports); - node_mbgl::NodeRequest::Init(exports); +NAN_MODULE_INIT(RegisterModule) { + node_mbgl::NodeMap::Init(target); + node_mbgl::NodeRequest::Init(target); // Exports Resource constants. - auto ConstantProperty = static_cast(v8::ReadOnly | v8::DontDelete); - auto resource = NanNew(); - resource->ForceSet(NanNew("Unknown"), NanNew(mbgl::Resource::Unknown), ConstantProperty); - resource->ForceSet(NanNew("Style"), NanNew(mbgl::Resource::Style), ConstantProperty); - resource->ForceSet(NanNew("Source"), NanNew(mbgl::Resource::Source), ConstantProperty); - resource->ForceSet(NanNew("Tile"), NanNew(mbgl::Resource::Tile), ConstantProperty); - resource->ForceSet(NanNew("Glyphs"), NanNew(mbgl::Resource::Glyphs), ConstantProperty); - resource->ForceSet(NanNew("SpriteImage"), NanNew(mbgl::Resource::SpriteImage), ConstantProperty); - resource->ForceSet(NanNew("SpriteJSON"), NanNew(mbgl::Resource::SpriteJSON), ConstantProperty); - exports->ForceSet(NanNew("Resource"), resource, ConstantProperty); + v8::Local resource = Nan::New(); - // Make the exported object inerhit from process.EventEmitter - auto process = NanGetCurrentContext()->Global()->Get(NanNew("process"))->ToObject(); - auto EventEmitter = process->Get(NanNew("EventEmitter"))->ToObject(); - exports->SetPrototype(EventEmitter->Get(NanNew("prototype"))); + Nan::Set(resource, + Nan::New("Unknown").ToLocalChecked(), + Nan::New(mbgl::Resource::Unknown)); - mbgl::Log::setObserver(std::make_unique(exports)); + Nan::Set(resource, + Nan::New("Style").ToLocalChecked(), + Nan::New(mbgl::Resource::Style)); + + Nan::Set(resource, + Nan::New("Source").ToLocalChecked(), + Nan::New(mbgl::Resource::Source)); + + Nan::Set(resource, + Nan::New("Tile").ToLocalChecked(), + Nan::New(mbgl::Resource::Tile)); + + Nan::Set(resource, + Nan::New("Glyphs").ToLocalChecked(), + Nan::New(mbgl::Resource::Glyphs)); + + Nan::Set(resource, + Nan::New("SpriteImage").ToLocalChecked(), + Nan::New(mbgl::Resource::SpriteImage)); + + Nan::Set(resource, + Nan::New("SpriteJSON").ToLocalChecked(), + Nan::New(mbgl::Resource::SpriteJSON)); + + Nan::Set(target, + Nan::New("Resource").ToLocalChecked(), + resource); + + // Make the exported object inherit from process.EventEmitter + v8::Local process = Nan::Get( + Nan::GetCurrentContext()->Global(), + Nan::New("process").ToLocalChecked()).ToLocalChecked()->ToObject(); + + v8::Local EventEmitter = Nan::Get(process, + Nan::New("EventEmitter").ToLocalChecked()).ToLocalChecked()->ToObject(); + + Nan::SetPrototype(target, + Nan::Get(EventEmitter, Nan::New("prototype").ToLocalChecked()).ToLocalChecked()); + + mbgl::Log::setObserver(std::make_unique(Nan::New(target))); } NODE_MODULE(mapbox_gl_native, RegisterModule) diff --git a/platform/node/src/node_request.cpp b/platform/node/src/node_request.cpp index ea9fc4d73..09d7bf798 100644 --- a/platform/node/src/node_request.cpp +++ b/platform/node/src/node_request.cpp @@ -11,112 +11,111 @@ namespace node_mbgl { //////////////////////////////////////////////////////////////////////////////////////////////// // Static Node Methods -v8::Persistent NodeRequest::constructorTemplate; +Nan::Persistent NodeRequest::constructor; -void NodeRequest::Init(v8::Handle target) { - NanScope(); +NAN_MODULE_INIT(NodeRequest::Init) { + v8::Local tpl = Nan::New(New); - v8::Local t = NanNew(New); + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(Nan::New("Request").ToLocalChecked()); - t->InstanceTemplate()->SetInternalFieldCount(1); - t->SetClassName(NanNew("Request")); + Nan::SetPrototypeMethod(tpl, "respond", Respond); - NODE_SET_PROTOTYPE_METHOD(t, "respond", Respond); - - NanAssignPersistent(constructorTemplate, t); - - target->Set(NanNew("Request"), t->GetFunction()); + constructor.Reset(tpl->GetFunction()); + Nan::Set(target, Nan::New("Request").ToLocalChecked(), tpl->GetFunction()); } NAN_METHOD(NodeRequest::New) { - NanScope(); - // Extract the pointer from the first argument - if (args.Length() < 2 || !args[0]->IsExternal() || !args[1]->IsExternal()) { - return NanThrowTypeError("Cannot create Request objects explicitly"); + if (info.Length() < 2 || !info[0]->IsExternal() || !info[1]->IsExternal()) { + return Nan::ThrowTypeError("Cannot create Request objects explicitly"); } - auto source = reinterpret_cast(args[0].As()->Value()); - auto resource = reinterpret_cast(args[1].As()->Value()); + auto source = reinterpret_cast(info[0].As()->Value()); + auto resource = reinterpret_cast(info[1].As()->Value()); auto req = new NodeRequest(source, *resource); - req->Wrap(args.This()); + req->Wrap(info.This()); - NanReturnValue(args.This()); + info.GetReturnValue().Set(info.This()); } v8::Handle NodeRequest::Create(NodeFileSource* source, const mbgl::Resource& resource) { - NanEscapableScope(); + Nan::EscapableHandleScope scope; - v8::Local argv[] = { NanNew(const_cast(source)), - NanNew(const_cast(&resource)) }; - auto instance = NanNew(constructorTemplate)->GetFunction()->NewInstance(2, argv); + v8::Local argv[] = { + Nan::New(const_cast(source)), + Nan::New(const_cast(&resource)) + }; + auto instance = Nan::New(constructor)->NewInstance(2, argv); - instance->ForceSet(NanNew("url"), NanNew(resource.url), v8::ReadOnly); - instance->ForceSet(NanNew("kind"), NanNew(int(resource.kind)), v8::ReadOnly); + Nan::Set(instance, Nan::New("url").ToLocalChecked(), Nan::New(resource.url).ToLocalChecked()); + Nan::Set(instance, Nan::New("kind").ToLocalChecked(), Nan::New(int(resource.kind))); - return NanEscapeScope(instance); + return scope.Escape(instance); } NAN_METHOD(NodeRequest::Respond) { - auto nodeRequest = ObjectWrap::Unwrap(args.Holder()); + auto nodeRequest = Nan::ObjectWrap::Unwrap(info.Holder()); // Request has already been responded to, or was canceled, fail silently. - if (!nodeRequest->resource) NanReturnUndefined(); + if (!nodeRequest->resource) { + return info.GetReturnValue().SetUndefined(); + } auto source = nodeRequest->source; auto resource = std::move(nodeRequest->resource); - if (args.Length() < 1) { - return NanThrowTypeError("First argument must be an error object"); - } else if (args[0]->BooleanValue()) { + if (info.Length() < 1) { + return Nan::ThrowTypeError("First argument must be an error object"); + } else if (info[0]->BooleanValue()) { auto response = std::make_shared(); response->status = mbgl::Response::Error; // Store the error string. - const NanUtf8String message { args[0]->ToString() }; + const Nan::Utf8String message { info[0]->ToString() }; response->message = std::string { *message, size_t(message.length()) }; source->notify(*resource, response); - } else if (args.Length() < 2 || !args[1]->IsObject()) { - return NanThrowTypeError("Second argument must be a response object"); + } else if (info.Length() < 2 || !info[1]->IsObject()) { + return Nan::ThrowTypeError("Second argument must be a response object"); } else { auto response = std::make_shared(); - auto res = args[1]->ToObject(); + auto res = info[1]->ToObject(); response->status = mbgl::Response::Successful; - if (res->Has(NanNew("modified"))) { - const double modified = res->Get(NanNew("modified"))->ToNumber()->Value(); + if (Nan::Has(res, Nan::New("modified").ToLocalChecked()).FromJust()) { + const double modified = Nan::Get(res, Nan::New("modified").ToLocalChecked()).ToLocalChecked()->ToNumber()->Value(); if (!std::isnan(modified)) { response->modified = modified / 1000; // JS timestamps are milliseconds } } - if (res->Has(NanNew("expires"))) { - const double expires = res->Get(NanNew("expires"))->ToNumber()->Value(); + if (Nan::Has(res, Nan::New("expires").ToLocalChecked()).FromJust()) { + const double expires = Nan::Get(res, Nan::New("expires").ToLocalChecked()).ToLocalChecked()->ToNumber()->Value(); if (!std::isnan(expires)) { response->expires = expires / 1000; // JS timestamps are milliseconds } } - if (res->Has(NanNew("etag"))) { - auto etagHandle = res->Get(NanNew("etag")); + if (Nan::Has(res, Nan::New("etag").ToLocalChecked()).FromJust()) { + auto etagHandle = Nan::Get(res, Nan::New("etag").ToLocalChecked()).ToLocalChecked(); if (etagHandle->BooleanValue()) { - const NanUtf8String etag { etagHandle->ToString() }; + const Nan::Utf8String etag { etagHandle->ToString() }; response->etag = std::string { *etag, size_t(etag.length()) }; } } - if (res->Has(NanNew("data"))) { - auto dataHandle = res->Get(NanNew("data")); + if (Nan::Has(res, Nan::New("data").ToLocalChecked()).FromJust()) { + auto dataHandle = Nan::Get(res, Nan::New("data").ToLocalChecked()).ToLocalChecked(); if (node::Buffer::HasInstance(dataHandle)) { response->data = std::string { node::Buffer::Data(dataHandle), node::Buffer::Length(dataHandle) }; } else { - return NanThrowTypeError("Response data must be a Buffer"); + return Nan::ThrowTypeError("Response data must be a Buffer"); } } @@ -124,7 +123,7 @@ NAN_METHOD(NodeRequest::Respond) { source->notify(*resource, response); } - NanReturnUndefined(); + info.GetReturnValue().SetUndefined(); } //////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/platform/node/src/node_request.hpp b/platform/node/src/node_request.hpp index a690904ef..35bb8e520 100644 --- a/platform/node/src/node_request.hpp +++ b/platform/node/src/node_request.hpp @@ -3,7 +3,6 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wshadow" -#include #include #pragma GCC diagnostic pop @@ -15,21 +14,16 @@ namespace node_mbgl { class NodeFileSource; -class NodeRequest : public node::ObjectWrap { - //////////////////////////////////////////////////////////////////////////////////////////////// - // Static Node Methods +class NodeRequest : public Nan::ObjectWrap { public: - static void Init(v8::Handle target); + static NAN_MODULE_INIT(Init); + static NAN_METHOD(New); static NAN_METHOD(Respond); static v8::Handle Create(NodeFileSource*, const mbgl::Resource&); + static Nan::Persistent constructor; - static v8::Persistent constructorTemplate; - - //////////////////////////////////////////////////////////////////////////////////////////////// - // Instance -public: NodeRequest(NodeFileSource* source, const mbgl::Resource& resource); ~NodeRequest(); From 627623edbcc0fa8812bfc345b3e338eff229626b Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 8 Sep 2015 17:14:39 -0400 Subject: [PATCH 020/156] Use nan with https://github.com/nodejs/nan/pull/443 fixed --- package.json | 2 +- platform/node/src/node_map.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b8305af3e..4284fccfd 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ } ], "dependencies": { - "nan": "^2.0.8", + "nan": "nodejs/nan#a71301e0f62877ca017c4ebec7fbac9f4359038e", "node-pre-gyp": "^0.6.9" }, "bundledDependencies": [ diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index 0133babc0..121265f4f 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -280,7 +280,7 @@ void NodeMap::renderFinished() { v8::Local argv[] = { Nan::Null(), - pixels, + pixels }; cb->Call(2, argv); } else { From 3d48147f2f8d2ef3ed3a9b8848ba0304d27c3403 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 8 Sep 2015 15:17:49 -0400 Subject: [PATCH 021/156] add io.js v3.x support --- .travis.yml | 4 ++-- platform/node/CHANGELOG.md | 1 + platform/node/src/node_file_source.cpp | 2 +- platform/node/src/node_mapbox_gl_native.cpp | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2e300c568..d16643364 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,7 +59,7 @@ matrix: apt: packages: [ 'lib32stdc++6' ] - os: linux - env: FLAVOR=node CXX=clang++-3.5 BUILDTYPE=Release NODE_VERSION=iojs-v2 + env: FLAVOR=node CXX=clang++-3.5 BUILDTYPE=Release NODE_VERSION=iojs-v3 addons: apt: sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5' ] @@ -79,7 +79,7 @@ matrix: - os: osx osx_image: xcode6.4 compiler: clang - env: FLAVOR=node NODE_VERSION=iojs-v2 + env: FLAVOR=node NODE_VERSION=iojs-v3 - os: osx osx_image: xcode6.4 compiler: clang diff --git a/platform/node/CHANGELOG.md b/platform/node/CHANGELOG.md index 6d6486bd2..927cc5ece 100644 --- a/platform/node/CHANGELOG.md +++ b/platform/node/CHANGELOG.md @@ -9,6 +9,7 @@ render options. - Adds support for rendering v8 styles. - No longer load resources before a render request is made. +- Adds io.js v3.x support. # 1.1.3 diff --git a/platform/node/src/node_file_source.cpp b/platform/node/src/node_file_source.cpp index 29a4748c5..622584846 100644 --- a/platform/node/src/node_file_source.cpp +++ b/platform/node/src/node_file_source.cpp @@ -75,7 +75,7 @@ void NodeFileSource::processAdd(const mbgl::Resource& resource) { queue->ref(); } - auto requestHandle = Nan::New(NodeRequest::Create(this, resource)); + v8::Local requestHandle = NodeRequest::Create(this, resource)->ToObject(); pending.emplace(resource, requestHandle); v8::Local argv[] = { requestHandle }; diff --git a/platform/node/src/node_mapbox_gl_native.cpp b/platform/node/src/node_mapbox_gl_native.cpp index b631b32c5..c0fb47d14 100644 --- a/platform/node/src/node_mapbox_gl_native.cpp +++ b/platform/node/src/node_mapbox_gl_native.cpp @@ -59,7 +59,7 @@ NAN_MODULE_INIT(RegisterModule) { Nan::SetPrototype(target, Nan::Get(EventEmitter, Nan::New("prototype").ToLocalChecked()).ToLocalChecked()); - mbgl::Log::setObserver(std::make_unique(Nan::New(target))); + mbgl::Log::setObserver(std::make_unique(target->ToObject())); } NODE_MODULE(mapbox_gl_native, RegisterModule) From 532bbd54845d78749983b9c5410f506d7dc64a66 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 9 Sep 2015 15:06:54 -0700 Subject: [PATCH 022/156] Add anonymous lambda for HandleScope --- platform/node/src/node_map.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index 121265f4f..5b2a83916 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -322,7 +322,10 @@ void NodeMap::release() { // Instance NodeMap::NodeMap(v8::Local options) : - view(sharedDisplay(), Nan::Get(options, Nan::New("ratio").ToLocalChecked()).ToLocalChecked()->NumberValue()), + view(sharedDisplay(), [&] { + Nan::HandleScope scope; + return Nan::Get(options, Nan::New("ratio").ToLocalChecked()).ToLocalChecked()->NumberValue(); + }()), fs(options), map(std::make_unique(view, fs, mbgl::MapMode::Still)), async(new uv_async_t) { From 1296f91c828b9a9a7b0d261637c15e3ba7db3868 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Thu, 10 Sep 2015 15:54:06 -0400 Subject: [PATCH 023/156] [node] change request semantics Passes a second, callback argument to the request implementation instead of needing to call req.respond. --- package.json | 2 +- platform/node/CHANGELOG.md | 4 +++- platform/node/README.md | 24 ++++++++++++------------ platform/node/src/node_file_source.cpp | 9 ++++++--- platform/node/src/node_request.cpp | 4 +--- platform/node/test/js/map.test.js | 4 ++-- platform/node/test/render.test.js | 4 ++-- 7 files changed, 27 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 4284fccfd..8491a4851 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ } ], "dependencies": { - "nan": "nodejs/nan#a71301e0f62877ca017c4ebec7fbac9f4359038e", + "nan": "^2.0.9", "node-pre-gyp": "^0.6.9" }, "bundledDependencies": [ diff --git a/platform/node/CHANGELOG.md b/platform/node/CHANGELOG.md index 927cc5ece..dfa5ad33e 100644 --- a/platform/node/CHANGELOG.md +++ b/platform/node/CHANGELOG.md @@ -4,11 +4,13 @@ - Requires an options object argument to `new mbgl.Map()` (with required `request` and optional `cancel` methods), drops `mbgl.FileSource`. +- Changes `request` semantics to pass a second, callback argument instead + of needing to call `req.respond`. - Requires numerical `ratio` in `mbgl.Map` options argument. Map pixel ratio is now immutable and can no longer be set with render options. - Adds support for rendering v8 styles. -- No longer load resources before a render request is made. +- No longer loads resources before a render request is made. - Adds io.js v3.x support. # 1.1.3 diff --git a/platform/node/README.md b/platform/node/README.md index 72a08e853..dfe5d909f 100644 --- a/platform/node/README.md +++ b/platform/node/README.md @@ -92,22 +92,22 @@ The `kind` is an enum and defined in [`mbgl.Resource`](https://github.com/mapbox It has no significance for anything but serves as a hint to your implemention as to what sort of resource to expect. E.g., your implementation could choose caching strategies based on the expected file type. -THe `request` implementation should pass uncompressed data to `req.respond`. If you are downloading assets from a source that applies gzip transport encoding, the implementation must decompress the results before passing them on. +The `request` implementation should pass uncompressed data to `callback`. If you are downloading assets from a source that applies gzip transport encoding, the implementation must decompress the results before passing them on. A sample implementation that reads files from disk would look like the following: ```js var map = new mbgl.Map({ - request: function(req) { + request: function(req, callback) { fs.readFile(path.join('base/path', req.url), function(err, data) { - req.respond(err, { data: data }); + callback(err, { data: data }); }); }, ratio: 1.0 }); ``` -This is a very barebones implementation and you'll probably want a better implementation. E.g. it passes the url verbatim to the file system, but you'd want add some logic that normalizes `http` URLs. You'll notice that once your implementation has obtained the requested file, you have to deliver it to the requestee by calling `req.respond()`, which takes either an error object or `null` and an object with several settings: +This is a very barebones implementation and you'll probably want a better implementation. E.g. it passes the url verbatim to the file system, but you'd want add some logic that normalizes `http` URLs. You'll notice that once your implementation has obtained the requested file, you have to deliver it to the requestee by calling `callback()`, which takes either an error object or `null` and an object with several settings: ```js { @@ -125,14 +125,14 @@ var mbgl = require('mapbox-gl-native'); var request = require('request'); var map = new mbgl.Map({ - request: function(req) { + request: function(req, callback) { request({ url: req.url, encoding: null, gzip: true }, function (err, res, body) { if (err) { - req.respond(err); + callback(err); } else if (res.statusCode == 200) { var response = {}; @@ -142,9 +142,9 @@ var map = new mbgl.Map({ response.data = body; - req.respond(null, response); + callback(null, response); } else { - req.respond(new Error(JSON.parse(body).message)); + callback(new Error(JSON.parse(body).message)); } }); }, @@ -164,7 +164,7 @@ var request = require('request'); var url = require('url'); var map = new mbgl.Map({ - request: function(req) { + request: function(req, callback) { var opts = { url: req.url, encoding: null, @@ -177,7 +177,7 @@ var map = new mbgl.Map({ request(opts, function (err, res, body) { if (err) { - req.respond(err); + callback(err); } else if (res.statusCode == 200) { var response = {}; @@ -187,9 +187,9 @@ var map = new mbgl.Map({ response.data = body; - req.respond(null, response); + callback(null, response); } else { - req.respond(new Error(JSON.parse(body).message)); + callback(new Error(JSON.parse(body).message)); } }); }, diff --git a/platform/node/src/node_file_source.cpp b/platform/node/src/node_file_source.cpp index 622584846..b4828e768 100644 --- a/platform/node/src/node_file_source.cpp +++ b/platform/node/src/node_file_source.cpp @@ -75,11 +75,14 @@ void NodeFileSource::processAdd(const mbgl::Resource& resource) { queue->ref(); } - v8::Local requestHandle = NodeRequest::Create(this, resource)->ToObject(); + auto requestHandle = NodeRequest::Create(this, resource)->ToObject(); pending.emplace(resource, requestHandle); - v8::Local argv[] = { requestHandle }; - Nan::MakeCallback(Nan::New(options), "request", 1, argv); + auto callback = Nan::GetFunction(Nan::New(NodeRequest::Respond, requestHandle)).ToLocalChecked(); + callback->SetName(Nan::New("respond").ToLocalChecked()); + + v8::Local argv[] = { requestHandle, callback }; + Nan::MakeCallback(Nan::New(options), "request", 2, argv); } void NodeFileSource::processCancel(const mbgl::Resource& resource) { diff --git a/platform/node/src/node_request.cpp b/platform/node/src/node_request.cpp index 09d7bf798..76cafacbd 100644 --- a/platform/node/src/node_request.cpp +++ b/platform/node/src/node_request.cpp @@ -19,8 +19,6 @@ NAN_MODULE_INIT(NodeRequest::Init) { tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(Nan::New("Request").ToLocalChecked()); - Nan::SetPrototypeMethod(tpl, "respond", Respond); - constructor.Reset(tpl->GetFunction()); Nan::Set(target, Nan::New("Request").ToLocalChecked(), tpl->GetFunction()); } @@ -55,7 +53,7 @@ v8::Handle NodeRequest::Create(NodeFileSource* source, const mbgl::R } NAN_METHOD(NodeRequest::Respond) { - auto nodeRequest = Nan::ObjectWrap::Unwrap(info.Holder()); + auto nodeRequest = Nan::ObjectWrap::Unwrap(info.Data().As()); // Request has already been responded to, or was canceled, fail silently. if (!nodeRequest->resource) { diff --git a/platform/node/test/js/map.test.js b/platform/node/test/js/map.test.js index b3934e4fd..295fec693 100644 --- a/platform/node/test/js/map.test.js +++ b/platform/node/test/js/map.test.js @@ -147,9 +147,9 @@ test('Map', function(t) { t.test('.render', function(t) { var options = { - request: function(req) { + request: function(req, callback) { fs.readFile(path.join(__dirname, '..', req.url), function(err, data) { - req.respond(err, { data: data }); + callback(err, { data: data }); }); }, ratio: 1 diff --git a/platform/node/test/render.test.js b/platform/node/test/render.test.js index 2050677e9..c36600157 100644 --- a/platform/node/test/render.test.js +++ b/platform/node/test/render.test.js @@ -13,9 +13,9 @@ if (process.argv[1] === __filename && process.argv.length > 2) { suite.run('native', {tests: tests}, function (style, options, callback) { var map = new mbgl.Map({ ratio: options.pixelRatio, - request: function (req) { + request: function(req, callback) { request(req.url, {encoding: null}, function (err, response, body) { - req.respond(err, {data: body}); + callback(err, {data: body}); }); } }); From f6648f585e40bda82613c65dcfc03d4618f15007 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Thu, 10 Sep 2015 16:49:26 -0400 Subject: [PATCH 024/156] node-v2.0.0-pre.4 [publish binary] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8491a4851..33ffb3288 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mapbox-gl-native", - "version": "2.0.0-pre.3", + "version": "2.0.0-pre.4", "description": "Renders map tiles with Mapbox GL", "keywords": [ "mapbox", From 5a5a5ef4f05169ac3147f15f3063649f4e587a20 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Thu, 10 Sep 2015 19:28:47 -0400 Subject: [PATCH 025/156] [node] update CHANGELOG.md [skip ci] --- platform/node/CHANGELOG.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/platform/node/CHANGELOG.md b/platform/node/CHANGELOG.md index dfa5ad33e..6a5f5f2dd 100644 --- a/platform/node/CHANGELOG.md +++ b/platform/node/CHANGELOG.md @@ -1,14 +1,16 @@ # 2.0.0 -- Integrates Node.js bindings into core mapbox-gl-native project. +- Integrates Node.js bindings into core mapbox-gl-native project. (#2179) - Requires an options object argument to `new mbgl.Map()` (with required `request` and optional `cancel` methods), - drops `mbgl.FileSource`. + drops `mbgl.FileSource`. (https://github.com/mapbox/node-mapbox-gl-native/pull/143) - Changes `request` semantics to pass a second, callback argument instead - of needing to call `req.respond`. + of needing to call `req.respond`. (#2299) - Requires numerical `ratio` in `mbgl.Map` options argument. Map pixel ratio is now immutable and can no longer be set with - render options. + render options. (https://github.com/mapbox/mapbox-gl-native/commit/a8d9b921d71a91d7f8eff82e5a584aaab8b7d1c6, #1799) +- `map.render` now returns a raw image buffer instead of an object with + `width`, `height` and `pixels` properties. (#2262) - Adds support for rendering v8 styles. - No longer loads resources before a render request is made. - Adds io.js v3.x support. From 7cc0ef019a2b9681b110c4968fcba8b16159d6e8 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Thu, 10 Sep 2015 19:33:07 -0400 Subject: [PATCH 026/156] [node] update platform/node/CHANGELOG.md [skip ci] --- platform/node/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/node/CHANGELOG.md b/platform/node/CHANGELOG.md index 6a5f5f2dd..0fb8f3d38 100644 --- a/platform/node/CHANGELOG.md +++ b/platform/node/CHANGELOG.md @@ -3,12 +3,12 @@ - Integrates Node.js bindings into core mapbox-gl-native project. (#2179) - Requires an options object argument to `new mbgl.Map()` (with required `request` and optional `cancel` methods), - drops `mbgl.FileSource`. (https://github.com/mapbox/node-mapbox-gl-native/pull/143) + drops `mbgl.FileSource`. (mapbox/node-mapbox-gl-native#143) - Changes `request` semantics to pass a second, callback argument instead of needing to call `req.respond`. (#2299) - Requires numerical `ratio` in `mbgl.Map` options argument. Map pixel ratio is now immutable and can no longer be set with - render options. (https://github.com/mapbox/mapbox-gl-native/commit/a8d9b921d71a91d7f8eff82e5a584aaab8b7d1c6, #1799) + render options. (a8d9b921d71a91d7f8eff82e5a584aaab8b7d1c6, #1799) - `map.render` now returns a raw image buffer instead of an object with `width`, `height` and `pixels` properties. (#2262) - Adds support for rendering v8 styles. From f9f43fd1506b9bc7d45ffd55fb788ff7672a45b5 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Thu, 10 Sep 2015 19:40:16 -0400 Subject: [PATCH 027/156] [node] fix links in CHANGELOG.md [skip ci] --- platform/node/CHANGELOG.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/platform/node/CHANGELOG.md b/platform/node/CHANGELOG.md index 0fb8f3d38..158d4958e 100644 --- a/platform/node/CHANGELOG.md +++ b/platform/node/CHANGELOG.md @@ -1,19 +1,19 @@ # 2.0.0 -- Integrates Node.js bindings into core mapbox-gl-native project. (#2179) +- Integrates Node.js bindings into core mapbox-gl-native project. ([#2179](https://github.com/mapbox/mapbox-gl-native/pull/2179)) - Requires an options object argument to `new mbgl.Map()` (with required `request` and optional `cancel` methods), - drops `mbgl.FileSource`. (mapbox/node-mapbox-gl-native#143) + drops `mbgl.FileSource`. ([mapbox/node-mapbox-gl-native#143](https://github.com/mapbox/node-mapbox-gl-native/pull/143)) - Changes `request` semantics to pass a second, callback argument instead - of needing to call `req.respond`. (#2299) + of needing to call `req.respond`. ([#2299](https://github.com/mapbox/mapbox-gl-native/pull/2299)) - Requires numerical `ratio` in `mbgl.Map` options argument. Map pixel ratio is now immutable and can no longer be set with - render options. (a8d9b921d71a91d7f8eff82e5a584aaab8b7d1c6, #1799) + render options. ([`a8d9b92`](https://github.com/mapbox/mapbox-gl-native/commit/a8d9b921d71a91d7f8eff82e5a584aaab8b7d1c6), [#1799](https://github.com/mapbox/mapbox-gl-native/pull/1799)) - `map.render` now returns a raw image buffer instead of an object with - `width`, `height` and `pixels` properties. (#2262) + `width`, `height` and `pixels` properties. ([#2262](https://github.com/mapbox/mapbox-gl-native/pull/2262)) - Adds support for rendering v8 styles. - No longer loads resources before a render request is made. -- Adds io.js v3.x support. +- Adds io.js v3.x support. ([#2261](https://github.com/mapbox/mapbox-gl-native/pull/2261)) # 1.1.3 From a9b163fadcf24d7e9754044e10789f42969c7638 Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Fri, 11 Sep 2015 11:34:04 +1000 Subject: [PATCH 028/156] Call cancelTransitions when setting map position, zoom level, or direction. Fixes # 2296 --- .../src/main/java/com/mapbox/mapboxgl/views/MapView.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java index 664268141..614ccdb11 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java @@ -628,6 +628,7 @@ public class MapView extends FrameLayout implements LocationListener { public void setCenterCoordinate(LatLng centerCoordinate, boolean animated) { long duration = animated ? ANIMATION_DURATION : 0; + mNativeMapView.cancelTransitions(); mNativeMapView.setLatLng(centerCoordinate, duration); } @@ -638,6 +639,7 @@ public class MapView extends FrameLayout implements LocationListener { public void setCenterCoordinate(LatLngZoom centerCoordinate, boolean animated) { long duration = animated ? ANIMATION_DURATION : 0; + mNativeMapView.cancelTransitions(); mNativeMapView.setLatLngZoom(centerCoordinate, duration); } @@ -660,14 +662,17 @@ public class MapView extends FrameLayout implements LocationListener { public void setDirection(double direction, boolean animated) { long duration = animated ? ANIMATION_DURATION : 0; + mNativeMapView.cancelTransitions(); mNativeMapView.setBearing(-direction, duration); } public void resetPosition() { + mNativeMapView.cancelTransitions(); mNativeMapView.resetPosition(); } public void resetNorth() { + mNativeMapView.cancelTransitions(); mNativeMapView.resetNorth(); } @@ -681,6 +686,7 @@ public class MapView extends FrameLayout implements LocationListener { public void setZoomLevel(double zoomLevel, boolean animated) { long duration = animated ? ANIMATION_DURATION : 0; + mNativeMapView.cancelTransitions(); mNativeMapView.setZoom(zoomLevel, duration); } From 344a7b2ffdd449642ce2a78b0d438611dd0773dd Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Fri, 11 Sep 2015 12:12:03 +1000 Subject: [PATCH 029/156] Update to Android build tools 23.0.1 Closes #2303 --- .travis.yml | 8 ++++---- android/java/MapboxGLAndroidSDK/gradle.properties | 2 +- android/java/MapboxGLAndroidSDKTestApp/build.gradle | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index d16643364..f3a830849 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,28 +33,28 @@ matrix: - os: linux env: FLAVOR=android ANDROID_ABI=arm-v7 BUILDTYPE=Release android: - components: [ 'build-tools-23', 'android-23', 'extra-android-m2repository', 'extra-android-support', 'extra-google-m2repository' ] + components: [ 'build-tools-23.0.1', 'android-23', 'extra-android-m2repository', 'extra-android-support', 'extra-google-m2repository' ] addons: apt: packages: [ 'lib32stdc++6' ] - os: linux env: FLAVOR=android ANDROID_ABI=arm-v7 BUILDTYPE=Debug android: - components: [ 'build-tools-23', 'android-23', 'extra-android-m2repository', 'extra-android-support', 'extra-google-m2repository' ] + components: [ 'build-tools-23.0.1', 'android-23', 'extra-android-m2repository', 'extra-android-support', 'extra-google-m2repository' ] addons: apt: packages: [ 'lib32stdc++6' ] - os: linux env: FLAVOR=android ANDROID_ABI=arm-v8 BUILDTYPE=Release android: - components: [ 'build-tools-23', 'android-23', 'extra-android-m2repository', 'extra-android-support', 'extra-google-m2repository' ] + components: [ 'build-tools-23.0.1', 'android-23', 'extra-android-m2repository', 'extra-android-support', 'extra-google-m2repository' ] addons: apt: packages: [ 'lib32stdc++6' ] - os: linux env: FLAVOR=android ANDROID_ABI=x86 BUILDTYPE=Release android: - components: [ 'build-tools-23', 'android-23', 'extra-android-m2repository', 'extra-android-support', 'extra-google-m2repository' ] + components: [ 'build-tools-23.0.1', 'android-23', 'extra-android-m2repository', 'extra-android-support', 'extra-google-m2repository' ] addons: apt: packages: [ 'lib32stdc++6' ] diff --git a/android/java/MapboxGLAndroidSDK/gradle.properties b/android/java/MapboxGLAndroidSDK/gradle.properties index 5d862987b..680aad376 100644 --- a/android/java/MapboxGLAndroidSDK/gradle.properties +++ b/android/java/MapboxGLAndroidSDK/gradle.properties @@ -14,7 +14,7 @@ POM_DEVELOPER_NAME=Mapbox ANDROID_MIN_SDK=15 ANDROID_BUILD_TARGET_SDK_VERSION=23 -ANDROID_BUILD_TOOLS_VERSION=23 +ANDROID_BUILD_TOOLS_VERSION=23.0.1 ANDROID_BUILD_SDK_VERSION=23 POM_NAME=Mapbox GL Android SDK diff --git a/android/java/MapboxGLAndroidSDKTestApp/build.gradle b/android/java/MapboxGLAndroidSDKTestApp/build.gradle index 84f627d9e..172f31d0f 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/build.gradle +++ b/android/java/MapboxGLAndroidSDKTestApp/build.gradle @@ -39,7 +39,7 @@ gradle.projectsEvaluated { android { compileSdkVersion 23 - buildToolsVersion "23" + buildToolsVersion "23.0.1" repositories { mavenCentral() From cdafaf49cf7a87cea9b4a72f6c8c4326ca7b03da Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Fri, 11 Sep 2015 15:47:28 +1000 Subject: [PATCH 030/156] Add missing support libs --- .../src/main/res/layout/activity_main.xml | 2 -- .../MapboxGLAndroidSDKTestApp/src/main/res/values/colors.xml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_main.xml b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_main.xml index 2d22dcce7..0e569b770 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_main.xml +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_main.xml @@ -53,8 +53,6 @@ android:layout_gravity="end|bottom" android:layout_margin="@dimen/fab_margin" app:backgroundTint="@color/white" - app:borderWidth="0dp" - app:elevation="0dp" /> diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/colors.xml b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/colors.xml index af798515f..ac3b4fc30 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/colors.xml +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/colors.xml @@ -1,6 +1,6 @@ - @color/mapbox_blue + #1E8CAB #166B83 #E55E5E #FFFFFF From 169f580519367105ca626f158964910295ee73c1 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Fri, 11 Sep 2015 14:16:42 -0400 Subject: [PATCH 031/156] [node] update platform/node/CHANGELOG.md [skip ci] --- platform/node/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/node/CHANGELOG.md b/platform/node/CHANGELOG.md index 158d4958e..d4b0abd49 100644 --- a/platform/node/CHANGELOG.md +++ b/platform/node/CHANGELOG.md @@ -12,7 +12,7 @@ - `map.render` now returns a raw image buffer instead of an object with `width`, `height` and `pixels` properties. ([#2262](https://github.com/mapbox/mapbox-gl-native/pull/2262)) - Adds support for rendering v8 styles. -- No longer loads resources before a render request is made. +- No longer loads resources before a render request is made. ([`55d25a8`](https://github.com/mapbox/mapbox-gl-native/commit/55d25a80a77c06ef5e66acc0d8518867b03fe8a4)) - Adds io.js v3.x support. ([#2261](https://github.com/mapbox/mapbox-gl-native/pull/2261)) # 1.1.3 From c8e80595d854c79f4c16ef4237f7a4ca9d18ddd9 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Tue, 1 Sep 2015 23:30:54 -0400 Subject: [PATCH 032/156] [iOS] Initial user location puck --- platform/ios/MGLUserLocationAnnotationView.m | 480 ++++++++++++------- 1 file changed, 296 insertions(+), 184 deletions(-) diff --git a/platform/ios/MGLUserLocationAnnotationView.m b/platform/ios/MGLUserLocationAnnotationView.m index 7733674e6..301e3c4b2 100644 --- a/platform/ios/MGLUserLocationAnnotationView.m +++ b/platform/ios/MGLUserLocationAnnotationView.m @@ -8,6 +8,9 @@ const CGFloat MGLUserLocationAnnotationDotSize = 22.0; const CGFloat MGLUserLocationAnnotationHaloSize = 115.0; +const CGFloat MGLUserLocationAnnotationPuckSize = 35.0; +const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuckSize * 0.6; + @interface MGLUserLocationAnnotationView () @property (nonatomic, readwrite) CALayer *haloLayer; @@ -18,12 +21,17 @@ const CGFloat MGLUserLocationAnnotationHaloSize = 115.0; @implementation MGLUserLocationAnnotationView { + BOOL _puckModeActivated; + + CALayer *_puckDot; + CAShapeLayer *_puckArrow; + CALayer *_headingIndicatorLayer; CAShapeLayer *_headingIndicatorMaskLayer; CALayer *_accuracyRingLayer; CALayer *_dotBorderLayer; CALayer *_dotLayer; - + double _oldHeadingAccuracy; CLLocationAccuracy _oldHorizontalAccuracy; double _oldZoom; @@ -37,7 +45,9 @@ const CGFloat MGLUserLocationAnnotationHaloSize = 115.0; - (instancetype)initInMapView:(MGLMapView *)mapView { - if (self = [super initWithFrame:CGRectMake(0, 0, MGLUserLocationAnnotationDotSize, MGLUserLocationAnnotationDotSize)]) + CGFloat frameSize = (mapView.userTrackingMode == MGLUserTrackingModeFollowWithCourse) ? MGLUserLocationAnnotationPuckSize : MGLUserLocationAnnotationDotSize; + + if (self = [super initWithFrame:CGRectMake(0, 0, frameSize, frameSize)]) { self.annotation = [[MGLUserLocation alloc] initWithMapView:mapView]; _mapView = mapView; @@ -55,189 +65,291 @@ const CGFloat MGLUserLocationAnnotationHaloSize = 115.0; - (void)setTintColor:(UIColor *)tintColor { - if (_accuracyRingLayer) + if (_puckModeActivated) { - _accuracyRingLayer.backgroundColor = [tintColor CGColor]; + _puckArrow.fillColor = [tintColor CGColor]; + } + else + { + if (_accuracyRingLayer) + { + _accuracyRingLayer.backgroundColor = [tintColor CGColor]; + } + + _haloLayer.backgroundColor = [tintColor CGColor]; + _dotLayer.backgroundColor = [tintColor CGColor]; + + _headingIndicatorLayer.contents = (__bridge id)[[self headingIndicatorTintedGradientImage] CGImage]; } - - _haloLayer.backgroundColor = [tintColor CGColor]; - _dotLayer.backgroundColor = [tintColor CGColor]; - - _headingIndicatorLayer.contents = (__bridge id)[[self headingIndicatorTintedGradientImage] CGImage]; } - (void)setupLayers { if (CLLocationCoordinate2DIsValid(self.annotation.coordinate)) { - // update heading indicator - // - if (_headingIndicatorLayer) - { - _headingIndicatorLayer.hidden = !(_mapView.userTrackingMode == MGLUserTrackingModeFollowWithHeading || - _mapView.userTrackingMode == MGLUserTrackingModeFollowWithCourse); - - if (_oldHeadingAccuracy != self.annotation.heading.headingAccuracy) - { - // recalculate the clipping mask based on updated accuracy - _headingIndicatorMaskLayer.path = [[self headingIndicatorClippingMask] CGPath]; + (_mapView.userTrackingMode == MGLUserTrackingModeFollowWithCourse) ? [self drawPuck] : [self drawDot]; + } +} - _oldHeadingAccuracy = self.annotation.heading.headingAccuracy; - } - } - - // heading indicator (tinted, semi-circle) - // - if ( ! _headingIndicatorLayer && self.annotation.heading.headingAccuracy) +- (void)drawPuck +{ + if ( ! _puckModeActivated) + { + self.layer.sublayers = nil; + + _headingIndicatorLayer = nil; + _headingIndicatorMaskLayer = nil; + _accuracyRingLayer = nil; + _haloLayer = nil; + _dotBorderLayer = nil; + _dotLayer = nil; + + _puckModeActivated = YES; + } + + // background dot (white with black shadow) + // + if ( ! _puckDot) + { + _puckDot = [self circleLayerWithSize:MGLUserLocationAnnotationPuckSize]; + _puckDot.backgroundColor = [[UIColor whiteColor] CGColor]; + _puckDot.shadowColor = [[UIColor blackColor] CGColor]; + _puckDot.shadowOffset = CGSizeMake(0, 1); + _puckDot.shadowRadius = 1; + _puckDot.shadowOpacity = 0.1; + + [self.layer addSublayer:_puckDot]; + } + + // arrow + // + if ( ! _puckArrow) + { + _puckArrow = [CAShapeLayer layer]; + _puckArrow.path = [[self puckArrow] CGPath]; + _puckArrow.fillColor = [_mapView.tintColor CGColor]; + _puckArrow.bounds = CGRectMake(0, 0, MGLUserLocationAnnotationArrowSize, MGLUserLocationAnnotationArrowSize); + _puckArrow.position = CGPointMake(super.bounds.size.width / 2.0, super.bounds.size.height / 2.0); + _puckArrow.shouldRasterize = YES; + _puckArrow.rasterizationScale = [UIScreen mainScreen].scale; + _puckArrow.drawsAsynchronously = YES; + + [self.layer addSublayer:_puckArrow]; + } + + if (self.mapView.pitch) + { + CATransform3D t = CATransform3DRotate(CATransform3DIdentity, MGLRadiansFromDegrees(self.mapView.pitch), 1.0, 0, 0); + self.layer.sublayerTransform = t; + } +} + +CGFloat MGLRadiansFromDegrees(CLLocationDegrees degrees) +{ + return degrees * M_PI / 180; +} + +CLLocationDegrees MGLDegreesFromRadians(CGFloat radians) +{ + return radians * 180 / M_PI; +} + +- (UIBezierPath *)puckArrow +{ + CGFloat max = MGLUserLocationAnnotationArrowSize; + + UIBezierPath *bezierPath = UIBezierPath.bezierPath; + [bezierPath moveToPoint: CGPointMake(max * 0.5, 0)]; + [bezierPath addLineToPoint: CGPointMake(max * 0.1, max)]; + [bezierPath addLineToPoint: CGPointMake(max * 0.5, max * 0.65)]; + [bezierPath addLineToPoint: CGPointMake(max * 0.9, max)]; + [bezierPath addLineToPoint: CGPointMake(max * 0.5, 0)]; + [bezierPath closePath]; + + return bezierPath; +} + +- (void)drawDot +{ + if (_puckModeActivated) + { + self.layer.sublayers = nil; + + _puckDot = nil; + _puckArrow = nil; + + _puckModeActivated = NO; + + self.layer.sublayerTransform = CATransform3DIdentity; + } + + // update heading indicator + // + if (_headingIndicatorLayer) + { + _headingIndicatorLayer.hidden = !(_mapView.userTrackingMode == MGLUserTrackingModeFollowWithHeading || + _mapView.userTrackingMode == MGLUserTrackingModeFollowWithCourse); + + if (_oldHeadingAccuracy != self.annotation.heading.headingAccuracy) { - CGFloat headingIndicatorSize = MGLUserLocationAnnotationHaloSize; - - _headingIndicatorLayer = [CALayer layer]; - _headingIndicatorLayer.bounds = CGRectMake(0, 0, headingIndicatorSize, headingIndicatorSize); - _headingIndicatorLayer.position = CGPointMake(super.bounds.size.width / 2.0, super.bounds.size.height / 2.0); - _headingIndicatorLayer.contents = (__bridge id)[[self headingIndicatorTintedGradientImage] CGImage]; - _headingIndicatorLayer.contentsGravity = kCAGravityBottom; - _headingIndicatorLayer.contentsScale = [UIScreen mainScreen].scale; - _headingIndicatorLayer.opacity = 0.4; - _headingIndicatorLayer.shouldRasterize = YES; - _headingIndicatorLayer.rasterizationScale = [UIScreen mainScreen].scale; - _headingIndicatorLayer.drawsAsynchronously = YES; - - [self.layer insertSublayer:_headingIndicatorLayer below:_dotBorderLayer]; - } - - // heading indicator accuracy mask (fan-shaped) - // - if ( ! _headingIndicatorMaskLayer && self.annotation.heading.headingAccuracy) - { - _headingIndicatorMaskLayer = [CAShapeLayer layer]; - _headingIndicatorMaskLayer.frame = _headingIndicatorLayer.bounds; + // recalculate the clipping mask based on updated accuracy _headingIndicatorMaskLayer.path = [[self headingIndicatorClippingMask] CGPath]; - // apply the mask to the halo-radius-sized gradient layer - _headingIndicatorLayer.mask = _headingIndicatorMaskLayer; - _oldHeadingAccuracy = self.annotation.heading.headingAccuracy; } + } + + // heading indicator (tinted, semi-circle) + // + if ( ! _headingIndicatorLayer && self.annotation.heading.headingAccuracy) + { + CGFloat headingIndicatorSize = MGLUserLocationAnnotationHaloSize; + + _headingIndicatorLayer = [CALayer layer]; + _headingIndicatorLayer.bounds = CGRectMake(0, 0, headingIndicatorSize, headingIndicatorSize); + _headingIndicatorLayer.position = CGPointMake(super.bounds.size.width / 2.0, super.bounds.size.height / 2.0); + _headingIndicatorLayer.contents = (__bridge id)[[self headingIndicatorTintedGradientImage] CGImage]; + _headingIndicatorLayer.contentsGravity = kCAGravityBottom; + _headingIndicatorLayer.contentsScale = [UIScreen mainScreen].scale; + _headingIndicatorLayer.opacity = 0.4; + _headingIndicatorLayer.shouldRasterize = YES; + _headingIndicatorLayer.rasterizationScale = [UIScreen mainScreen].scale; + _headingIndicatorLayer.drawsAsynchronously = YES; + + [self.layer insertSublayer:_headingIndicatorLayer below:_dotBorderLayer]; + } + + // heading indicator accuracy mask (fan-shaped) + // + if ( ! _headingIndicatorMaskLayer && self.annotation.heading.headingAccuracy) + { + _headingIndicatorMaskLayer = [CAShapeLayer layer]; + _headingIndicatorMaskLayer.frame = _headingIndicatorLayer.bounds; + _headingIndicatorMaskLayer.path = [[self headingIndicatorClippingMask] CGPath]; + + // apply the mask to the halo-radius-sized gradient layer + _headingIndicatorLayer.mask = _headingIndicatorMaskLayer; + + _oldHeadingAccuracy = self.annotation.heading.headingAccuracy; + } + + // update accuracy ring (if zoom or horizontal accuracy have changed) + // + if (_accuracyRingLayer && (_oldZoom != self.mapView.zoomLevel || _oldHorizontalAccuracy != self.annotation.location.horizontalAccuracy)) + { + CGFloat accuracyRingSize = [self calculateAccuracyRingSize]; - // update accuracy ring (if zoom or horizontal accuracy have changed) - // - if (_accuracyRingLayer && (_oldZoom != self.mapView.zoomLevel || _oldHorizontalAccuracy != self.annotation.location.horizontalAccuracy)) + // only show the accuracy ring if it won't be obscured by the location dot + if (accuracyRingSize > MGLUserLocationAnnotationDotSize + 15) { - CGFloat accuracyRingSize = [self calculateAccuracyRingSize]; - - // only show the accuracy ring if it won't be obscured by the location dot - if (accuracyRingSize > MGLUserLocationAnnotationDotSize + 15) - { - _accuracyRingLayer.hidden = NO; - _accuracyRingLayer.bounds = CGRectMake(0, 0, accuracyRingSize, accuracyRingSize); - _accuracyRingLayer.cornerRadius = accuracyRingSize / 2; - - // match the halo to the accuracy ring - _haloLayer.bounds = _accuracyRingLayer.bounds; - _haloLayer.cornerRadius = _accuracyRingLayer.cornerRadius; - _haloLayer.shouldRasterize = NO; - } - else - { - _accuracyRingLayer.hidden = YES; - - _haloLayer.bounds = CGRectMake(0, 0, MGLUserLocationAnnotationHaloSize, MGLUserLocationAnnotationHaloSize); - _haloLayer.cornerRadius = MGLUserLocationAnnotationHaloSize / 2.0; - _haloLayer.shouldRasterize = YES; - _haloLayer.rasterizationScale = [UIScreen mainScreen].scale; - } - - // store accuracy and zoom so we're not redrawing unchanged location updates - _oldHorizontalAccuracy = self.annotation.location.horizontalAccuracy; - _oldZoom = self.mapView.zoomLevel; + _accuracyRingLayer.hidden = NO; + _accuracyRingLayer.bounds = CGRectMake(0, 0, accuracyRingSize, accuracyRingSize); + _accuracyRingLayer.cornerRadius = accuracyRingSize / 2; + + // match the halo to the accuracy ring + _haloLayer.bounds = _accuracyRingLayer.bounds; + _haloLayer.cornerRadius = _accuracyRingLayer.cornerRadius; + _haloLayer.shouldRasterize = NO; } + else + { + _accuracyRingLayer.hidden = YES; + + _haloLayer.bounds = CGRectMake(0, 0, MGLUserLocationAnnotationHaloSize, MGLUserLocationAnnotationHaloSize); + _haloLayer.cornerRadius = MGLUserLocationAnnotationHaloSize / 2.0; + _haloLayer.shouldRasterize = YES; + _haloLayer.rasterizationScale = [UIScreen mainScreen].scale; + } + + // store accuracy and zoom so we're not redrawing unchanged location updates + _oldHorizontalAccuracy = self.annotation.location.horizontalAccuracy; + _oldZoom = self.mapView.zoomLevel; + } + + // accuracy ring (circular, tinted, mostly-transparent) + // + if ( ! _accuracyRingLayer && self.annotation.location.horizontalAccuracy) + { + CGFloat accuracyRingSize = [self calculateAccuracyRingSize]; + _accuracyRingLayer = [self circleLayerWithSize:accuracyRingSize]; + _accuracyRingLayer.backgroundColor = [_mapView.tintColor CGColor]; + _accuracyRingLayer.opacity = 0.1; + _accuracyRingLayer.shouldRasterize = NO; + _accuracyRingLayer.allowsGroupOpacity = NO; - // accuracy ring (circular, tinted, mostly-transparent) - // - if ( ! _accuracyRingLayer && self.annotation.location.horizontalAccuracy) - { - CGFloat accuracyRingSize = [self calculateAccuracyRingSize]; - _accuracyRingLayer = [self circleLayerWithSize:accuracyRingSize]; - _accuracyRingLayer.backgroundColor = [_mapView.tintColor CGColor]; - _accuracyRingLayer.opacity = 0.1; - _accuracyRingLayer.shouldRasterize = NO; - _accuracyRingLayer.allowsGroupOpacity = NO; - - [self.layer addSublayer:_accuracyRingLayer]; - } + [self.layer addSublayer:_accuracyRingLayer]; + } + + // expanding sonar-like pulse (circular, tinted, fades out) + // + if ( ! _haloLayer) + { + _haloLayer = [self circleLayerWithSize:MGLUserLocationAnnotationHaloSize]; + _haloLayer.backgroundColor = [_mapView.tintColor CGColor]; + _haloLayer.allowsGroupOpacity = NO; + + // set defaults for the animations + CAAnimationGroup *animationGroup = [self loopingAnimationGroupWithDuration:3.0]; + + // scale out radially with initial acceleration + CAKeyframeAnimation *boundsAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale.xy"]; + boundsAnimation.values = @[@0, @0.35, @1]; + boundsAnimation.keyTimes = @[@0, @0.2, @1]; + + // go transparent as scaled out, start semi-opaque + CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"]; + opacityAnimation.values = @[@0.4, @0.4, @0]; + opacityAnimation.keyTimes = @[@0, @0.2, @1]; + + animationGroup.animations = @[boundsAnimation, opacityAnimation]; + + [_haloLayer addAnimation:animationGroup forKey:@"animateTransformAndOpacity"]; + + [self.layer addSublayer:_haloLayer]; + } + + // background dot (white with black shadow) + // + if ( ! _dotBorderLayer) + { + _dotBorderLayer = [self circleLayerWithSize:MGLUserLocationAnnotationDotSize]; + _dotBorderLayer.backgroundColor = [[UIColor whiteColor] CGColor]; + _dotBorderLayer.shadowColor = [[UIColor blackColor] CGColor]; + _dotBorderLayer.shadowOffset = CGSizeMake(0, 0); + _dotBorderLayer.shadowRadius = 3; + _dotBorderLayer.shadowOpacity = 0.25; - // expanding sonar-like pulse (circular, tinted, fades out) - // - if ( ! _haloLayer) - { - _haloLayer = [self circleLayerWithSize:MGLUserLocationAnnotationHaloSize]; - _haloLayer.backgroundColor = [_mapView.tintColor CGColor]; - _haloLayer.allowsGroupOpacity = NO; - - // set defaults for the animations - CAAnimationGroup *animationGroup = [self loopingAnimationGroupWithDuration:3.0]; - - // scale out radially with initial acceleration - CAKeyframeAnimation *boundsAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale.xy"]; - boundsAnimation.values = @[@0, @0.35, @1]; - boundsAnimation.keyTimes = @[@0, @0.2, @1]; - - // go transparent as scaled out, start semi-opaque - CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"]; - opacityAnimation.values = @[@0.4, @0.4, @0]; - opacityAnimation.keyTimes = @[@0, @0.2, @1]; - - animationGroup.animations = @[boundsAnimation, opacityAnimation]; - - [_haloLayer addAnimation:animationGroup forKey:@"animateTransformAndOpacity"]; - - [self.layer addSublayer:_haloLayer]; - } - - // background dot (white with black shadow) - // - if ( ! _dotBorderLayer) - { - _dotBorderLayer = [self circleLayerWithSize:MGLUserLocationAnnotationDotSize]; - _dotBorderLayer.backgroundColor = [[UIColor whiteColor] CGColor]; - _dotBorderLayer.shadowColor = [[UIColor blackColor] CGColor]; - _dotBorderLayer.shadowOffset = CGSizeMake(0, 0); - _dotBorderLayer.shadowRadius = 3; - _dotBorderLayer.shadowOpacity = 0.25; - - [self.layer addSublayer:_dotBorderLayer]; - } - - // inner dot (pulsing, tinted) - // - if ( ! _dotLayer) - { - _dotLayer = [self circleLayerWithSize:MGLUserLocationAnnotationDotSize * 0.75]; - _dotLayer.backgroundColor = [_mapView.tintColor CGColor]; - _dotLayer.shouldRasterize = NO; - - // set defaults for the animations - CAAnimationGroup *animationGroup = [self loopingAnimationGroupWithDuration:1.5]; - animationGroup.autoreverses = YES; - animationGroup.fillMode = kCAFillModeBoth; - - // scale the dot up and down - CABasicAnimation *pulseAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale.xy"]; - pulseAnimation.fromValue = @0.8; - pulseAnimation.toValue = @1; - - // fade opacity in and out, subtly - CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"]; - opacityAnimation.fromValue = @0.8; - opacityAnimation.toValue = @1; - - animationGroup.animations = @[pulseAnimation, opacityAnimation]; - - [_dotLayer addAnimation:animationGroup forKey:@"animateTransformAndOpacity"]; - - [self.layer addSublayer:_dotLayer]; - } + [self.layer addSublayer:_dotBorderLayer]; + } + + // inner dot (pulsing, tinted) + // + if ( ! _dotLayer) + { + _dotLayer = [self circleLayerWithSize:MGLUserLocationAnnotationDotSize * 0.75]; + _dotLayer.backgroundColor = [_mapView.tintColor CGColor]; + _dotLayer.shouldRasterize = NO; + + // set defaults for the animations + CAAnimationGroup *animationGroup = [self loopingAnimationGroupWithDuration:1.5]; + animationGroup.autoreverses = YES; + animationGroup.fillMode = kCAFillModeBoth; + + // scale the dot up and down + CABasicAnimation *pulseAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale.xy"]; + pulseAnimation.fromValue = @0.8; + pulseAnimation.toValue = @1; + + // fade opacity in and out, subtly + CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"]; + opacityAnimation.fromValue = @0.8; + opacityAnimation.toValue = @1; + + animationGroup.animations = @[pulseAnimation, opacityAnimation]; + + [_dotLayer addAnimation:animationGroup forKey:@"animateTransformAndOpacity"]; + + [self.layer addSublayer:_dotLayer]; } } @@ -250,7 +362,7 @@ const CGFloat MGLUserLocationAnnotationHaloSize = 115.0; circleLayer.shouldRasterize = YES; circleLayer.rasterizationScale = [UIScreen mainScreen].scale; circleLayer.drawsAsynchronously = YES; - + return circleLayer; } @@ -261,7 +373,7 @@ const CGFloat MGLUserLocationAnnotationHaloSize = 115.0; animationGroup.repeatCount = INFINITY; animationGroup.removedOnCompletion = NO; animationGroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]; - + return animationGroup; } @@ -269,65 +381,65 @@ const CGFloat MGLUserLocationAnnotationHaloSize = 115.0; { CGFloat latRadians = self.annotation.coordinate.latitude * M_PI / 180.0f; CGFloat pixelRadius = self.annotation.location.horizontalAccuracy / cos(latRadians) / [self.mapView metersPerPixelAtLatitude:self.annotation.coordinate.latitude]; - + return pixelRadius * 2; } - (UIImage *)headingIndicatorTintedGradientImage { UIImage *image; - + CGFloat haloRadius = MGLUserLocationAnnotationHaloSize / 2.0; - + UIGraphicsBeginImageContextWithOptions(CGSizeMake(MGLUserLocationAnnotationHaloSize, haloRadius), NO, 0); - + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = UIGraphicsGetCurrentContext(); - + // gradient from the tint color to no-alpha tint color CGFloat gradientLocations[] = {0.0, 1.0}; CGGradientRef gradient = CGGradientCreateWithColors( - colorSpace, (__bridge CFArrayRef)@[(id)[_mapView.tintColor CGColor], - (id)[[_mapView.tintColor colorWithAlphaComponent:0] CGColor]], gradientLocations); - + colorSpace, (__bridge CFArrayRef)@[(id)[_mapView.tintColor CGColor], + (id)[[_mapView.tintColor colorWithAlphaComponent:0] CGColor]], gradientLocations); + // draw the gradient from the center point to the edge (full halo radius) CGPoint centerPoint = CGPointMake(haloRadius, haloRadius); CGContextDrawRadialGradient(context, gradient, centerPoint, 0.0, centerPoint, haloRadius, nil); - + image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); - + CGGradientRelease(gradient); CGColorSpaceRelease(colorSpace); - + return image; } - (UIBezierPath *)headingIndicatorClippingMask { CGFloat accuracy = self.annotation.heading.headingAccuracy; - + // size the mask using exagerated accuracy, but keep within a good display range CGFloat clippingDegrees = 90 - (accuracy * 1.5); clippingDegrees = fmin(clippingDegrees, 55); clippingDegrees = fmax(clippingDegrees, 10); - + CGRect ovalRect = CGRectMake(0, 0, MGLUserLocationAnnotationHaloSize, MGLUserLocationAnnotationHaloSize); UIBezierPath *ovalPath = UIBezierPath.bezierPath; - + // clip the oval to ± incoming accuracy degrees (converted to radians), from the top [ovalPath addArcWithCenter:CGPointMake(CGRectGetMidX(ovalRect), CGRectGetMidY(ovalRect)) radius:CGRectGetWidth(ovalRect) / 2.0 startAngle:(-180 + clippingDegrees) * M_PI / 180 endAngle:-clippingDegrees * M_PI / 180 clockwise:YES]; - + [ovalPath addLineToPoint:CGPointMake(CGRectGetMidX(ovalRect), CGRectGetMidY(ovalRect))]; [ovalPath closePath]; - + return ovalPath; } From c34d62aca29f207bbd68b48ee13063c9e4fed82a Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Fri, 4 Sep 2015 00:00:28 -0400 Subject: [PATCH 033/156] [iOS] Move radians/degrees conversion functions to MGLGeometry.h --- include/mbgl/ios/MGLGeometry.h | 11 +++++++++++ platform/ios/MGLMapView.mm | 10 ---------- platform/ios/MGLUserLocationAnnotationView.m | 10 ---------- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/include/mbgl/ios/MGLGeometry.h b/include/mbgl/ios/MGLGeometry.h index 6226af1d0..2dee7c76c 100644 --- a/include/mbgl/ios/MGLGeometry.h +++ b/include/mbgl/ios/MGLGeometry.h @@ -3,6 +3,7 @@ #import "MGLTypes.h" #import +#import NS_ASSUME_NONNULL_BEGIN @@ -82,4 +83,14 @@ NS_INLINE NSString *MGLStringFromCoordinateBounds(MGLCoordinateBounds bounds) { bounds.ne.latitude, bounds.ne.longitude]; } +NS_INLINE CGFloat MGLRadiansFromDegrees(CLLocationDegrees degrees) +{ + return degrees * M_PI / 180; +} + +NS_INLINE CLLocationDegrees MGLDegreesFromRadians(CGFloat radians) +{ + return radians * 180 / M_PI; +} + NS_ASSUME_NONNULL_END diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index e509b5c8d..705627663 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -60,16 +60,6 @@ static NSURL *MGLURLForBundledStyleNamed(NSString *styleName) return [NSURL URLWithString:[NSString stringWithFormat:@"asset://styles/%@.json", styleName]]; } -CGFloat MGLRadiansFromDegrees(CLLocationDegrees degrees) -{ - return degrees * M_PI / 180; -} - -CLLocationDegrees MGLDegreesFromRadians(CGFloat radians) -{ - return radians * 180 / M_PI; -} - mbgl::util::UnitBezier MGLUnitBezierForMediaTimingFunction(CAMediaTimingFunction *function) { if ( ! function) diff --git a/platform/ios/MGLUserLocationAnnotationView.m b/platform/ios/MGLUserLocationAnnotationView.m index 301e3c4b2..06da8a998 100644 --- a/platform/ios/MGLUserLocationAnnotationView.m +++ b/platform/ios/MGLUserLocationAnnotationView.m @@ -144,16 +144,6 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck } } -CGFloat MGLRadiansFromDegrees(CLLocationDegrees degrees) -{ - return degrees * M_PI / 180; -} - -CLLocationDegrees MGLDegreesFromRadians(CGFloat radians) -{ - return radians * 180 / M_PI; -} - - (UIBezierPath *)puckArrow { CGFloat max = MGLUserLocationAnnotationArrowSize; From 2a300bd425cfed1a8494a0efd4790976ae2f5aa5 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Fri, 4 Sep 2015 00:41:43 -0400 Subject: [PATCH 034/156] =?UTF-8?q?[iOS]=20Pitch=20the=20dot,=20add=20faux?= =?UTF-8?q?=203D=20effect=20to=20tilted=20dot=20and=20puck=20This=20expose?= =?UTF-8?q?s=20the=20na=C3=AFvet=C3=A9=20of=20the=20current=20pitch=20tran?= =?UTF-8?q?sform:=20accuracy=20ring=20sizing=20stays=20constant,=20despite?= =?UTF-8?q?=20vertical=20screen=20movement.=20Still,=20it=20looks=20better?= =?UTF-8?q?=20pitched=20than=20not.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform/ios/MGLUserLocationAnnotationView.m | 88 ++++++++++++++++---- 1 file changed, 72 insertions(+), 16 deletions(-) diff --git a/platform/ios/MGLUserLocationAnnotationView.m b/platform/ios/MGLUserLocationAnnotationView.m index 06da8a998..22c1d00f1 100644 --- a/platform/ios/MGLUserLocationAnnotationView.m +++ b/platform/ios/MGLUserLocationAnnotationView.m @@ -8,7 +8,7 @@ const CGFloat MGLUserLocationAnnotationDotSize = 22.0; const CGFloat MGLUserLocationAnnotationHaloSize = 115.0; -const CGFloat MGLUserLocationAnnotationPuckSize = 35.0; +const CGFloat MGLUserLocationAnnotationPuckSize = 45.0; const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuckSize * 0.6; @interface MGLUserLocationAnnotationView () @@ -35,6 +35,7 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck double _oldHeadingAccuracy; CLLocationAccuracy _oldHorizontalAccuracy; double _oldZoom; + double _oldPitch; } - (instancetype)initWithFrame:(CGRect)frame @@ -88,6 +89,42 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck if (CLLocationCoordinate2DIsValid(self.annotation.coordinate)) { (_mapView.userTrackingMode == MGLUserTrackingModeFollowWithCourse) ? [self drawPuck] : [self drawDot]; + [self updatePitch]; + } +} + +- (void)updatePitch +{ + if (self.mapView.camera.pitch && (self.mapView.camera.pitch != _oldPitch)) + { + CATransform3D t = CATransform3DRotate(CATransform3DIdentity, MGLRadiansFromDegrees(self.mapView.camera.pitch), 1.0, 0, 0); + self.layer.sublayerTransform = t; + + [self updateFaux3DEffect]; + + _oldPitch = self.mapView.camera.pitch; + } +} + +- (void)updateFaux3DEffect +{ + CGFloat pitch = MGLRadiansFromDegrees(self.mapView.camera.pitch); + + if (_puckDot) + { + _puckDot.shadowOffset = CGSizeMake(0, fmaxf(pitch * 10.f, 1.f)); + _puckDot.shadowRadius = fmaxf(pitch * 5.f, 0.75f); + } + + if (_dotBorderLayer) + { + _dotBorderLayer.shadowOffset = CGSizeMake(0.f, pitch * 10.f); + _dotBorderLayer.shadowRadius = fmaxf(pitch * 5.f, 3.f); + } + + if (_dotLayer) + { + _dotLayer.zPosition = pitch * 2.f; } } @@ -103,8 +140,6 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck _haloLayer = nil; _dotBorderLayer = nil; _dotLayer = nil; - - _puckModeActivated = YES; } // background dot (white with black shadow) @@ -114,9 +149,17 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck _puckDot = [self circleLayerWithSize:MGLUserLocationAnnotationPuckSize]; _puckDot.backgroundColor = [[UIColor whiteColor] CGColor]; _puckDot.shadowColor = [[UIColor blackColor] CGColor]; - _puckDot.shadowOffset = CGSizeMake(0, 1); - _puckDot.shadowRadius = 1; - _puckDot.shadowOpacity = 0.1; + _puckDot.shadowOpacity = 0.25; + + if (self.mapView.camera.pitch) + { + [self updateFaux3DEffect]; + } + else + { + _puckDot.shadowOffset = CGSizeMake(0, 1); + _puckDot.shadowRadius = 0.75; + } [self.layer addSublayer:_puckDot]; } @@ -137,10 +180,11 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck [self.layer addSublayer:_puckArrow]; } - if (self.mapView.pitch) + if ( ! _puckModeActivated) { - CATransform3D t = CATransform3DRotate(CATransform3DIdentity, MGLRadiansFromDegrees(self.mapView.pitch), 1.0, 0, 0); - self.layer.sublayerTransform = t; + _puckModeActivated = YES; + + [self updateFaux3DEffect]; } } @@ -167,10 +211,6 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck _puckDot = nil; _puckArrow = nil; - - _puckModeActivated = NO; - - self.layer.sublayerTransform = CATransform3DIdentity; } // update heading indicator @@ -277,6 +317,7 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck _haloLayer = [self circleLayerWithSize:MGLUserLocationAnnotationHaloSize]; _haloLayer.backgroundColor = [_mapView.tintColor CGColor]; _haloLayer.allowsGroupOpacity = NO; + _haloLayer.zPosition = -0.1f; // set defaults for the animations CAAnimationGroup *animationGroup = [self loopingAnimationGroupWithDuration:3.0]; @@ -305,10 +346,18 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck _dotBorderLayer = [self circleLayerWithSize:MGLUserLocationAnnotationDotSize]; _dotBorderLayer.backgroundColor = [[UIColor whiteColor] CGColor]; _dotBorderLayer.shadowColor = [[UIColor blackColor] CGColor]; - _dotBorderLayer.shadowOffset = CGSizeMake(0, 0); - _dotBorderLayer.shadowRadius = 3; _dotBorderLayer.shadowOpacity = 0.25; - + + if (self.mapView.camera.pitch) + { + [self updateFaux3DEffect]; + } + else + { + _dotBorderLayer.shadowOffset = CGSizeMake(0, 0); + _dotBorderLayer.shadowRadius = 3; + } + [self.layer addSublayer:_dotBorderLayer]; } @@ -341,6 +390,13 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck [self.layer addSublayer:_dotLayer]; } + + if (_puckModeActivated) + { + _puckModeActivated = NO; + + [self updateFaux3DEffect]; + } } - (CALayer *)circleLayerWithSize:(CGFloat)layerSize From 7782802f3741ddff15ae9753ca484d13543a65cd Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Thu, 10 Sep 2015 19:29:13 -0400 Subject: [PATCH 035/156] [iOS] Remove unneccessary pitch check Fix case where moving the tilted dot off-screen, changing the pitch to 0, and then moving the dot back on screen would not reset the pitch of the dot. --- platform/ios/MGLUserLocationAnnotationView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/ios/MGLUserLocationAnnotationView.m b/platform/ios/MGLUserLocationAnnotationView.m index 22c1d00f1..b477b1088 100644 --- a/platform/ios/MGLUserLocationAnnotationView.m +++ b/platform/ios/MGLUserLocationAnnotationView.m @@ -95,7 +95,7 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck - (void)updatePitch { - if (self.mapView.camera.pitch && (self.mapView.camera.pitch != _oldPitch)) + if (self.mapView.camera.pitch != _oldPitch) { CATransform3D t = CATransform3DRotate(CATransform3DIdentity, MGLRadiansFromDegrees(self.mapView.camera.pitch), 1.0, 0, 0); self.layer.sublayerTransform = t; From b4b56c951e55bc47d7877e90b219ece4b656300a Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Wed, 26 Aug 2015 11:14:08 -0400 Subject: [PATCH 036/156] increase precision for coordinate conversions This fixes the earthquakes while panning at high zoom levels. Cherry-picked from 9607171612c4a40e41eddaff5230ad571571a5b9 on the perspective-improved-gestures branch. --- src/mbgl/map/transform_state.cpp | 31 +++++++++++++++---------------- src/mbgl/map/transform_state.hpp | 8 ++++---- src/mbgl/util/mat4.cpp | 2 +- src/mbgl/util/tile_coordinate.hpp | 12 ++++++------ src/mbgl/util/vec4.cpp | 2 +- 5 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index c672ca5de..e37f10dc6 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -157,21 +157,21 @@ float TransformState::getPitch() const { #pragma mark - Projection -float TransformState::lngX(float lng) const { +double TransformState::lngX(double lng) const { return (180.0f + lng) * worldSize() / 360.0f; } -float TransformState::latY(float lat) const { - float y_ = 180.0f / M_PI * std::log(std::tan(M_PI / 4 + lat * M_PI / 360.0f)); +double TransformState::latY(double lat) const { + double y_ = 180.0f / M_PI * std::log(std::tan(M_PI / 4 + lat * M_PI / 360.0f)); return (180.0f - y_) * worldSize() / 360.0f; } -float TransformState::xLng(float x_, float worldSize_) const { +double TransformState::xLng(double x_, double worldSize_) const { return x_ * 360.0f / worldSize_ - 180.0f; } -float TransformState::yLat(float y_, float worldSize_) const { - float y2 = 180.0f - y_ * 360.0f / worldSize_; +double TransformState::yLat(double y_, double worldSize_) const { + double y2 = 180.0f - y_ * 360.0f / worldSize_; return 360.0f / M_PI * std::atan(std::exp(y2 * M_PI / 180.0f)) - 90.0f; } @@ -245,17 +245,16 @@ TileCoordinate TransformState::pointToCoordinate(const vec2 point) const matrix::transformMat4(coord0, point0, inverted); matrix::transformMat4(coord1, point1, inverted); - float w0 = coord0[3]; - float w1 = coord1[3]; - float x0 = coord0[0] / w0; - float x1 = coord1[0] / w1; - float y0 = coord0[1] / w0; - float y1 = coord1[1] / w1; - float z0 = coord0[2] / w0; - float z1 = coord1[2] / w1; + double w0 = coord0[3]; + double w1 = coord1[3]; + double x0 = coord0[0] / w0; + double x1 = coord1[0] / w1; + double y0 = coord0[1] / w0; + double y1 = coord1[1] / w1; + double z0 = coord0[2] / w0; + double z1 = coord1[2] / w1; - - float t = z0 == z1 ? 0 : (targetZ - z0) / (z1 - z0); + double t = z0 == z1 ? 0 : (targetZ - z0) / (z1 - z0); return { util::interpolate(x0, x1, t), util::interpolate(y0, y1, t), tileZoom }; } diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp index d4b46f04b..c3e1072c9 100644 --- a/src/mbgl/map/transform_state.hpp +++ b/src/mbgl/map/transform_state.hpp @@ -79,10 +79,10 @@ private: // logical dimensions uint16_t width = 0, height = 0; - float xLng(float x, float worldSize) const; - float yLat(float y, float worldSize) const; - float lngX(float lon) const; - float latY(float lat) const; + double xLng(double x, double worldSize) const; + double yLat(double y, double worldSize) const; + double lngX(double lon) const; + double latY(double lat) const; float zoomScale(float zoom) const; float worldSize() const; diff --git a/src/mbgl/util/mat4.cpp b/src/mbgl/util/mat4.cpp index 123c8464f..0934cd081 100644 --- a/src/mbgl/util/mat4.cpp +++ b/src/mbgl/util/mat4.cpp @@ -46,7 +46,7 @@ void matrix::identity(mat4& out) { } bool matrix::invert(mat4& out, mat4& a) { - float a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3], + double a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3], a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7], a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11], a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15], diff --git a/src/mbgl/util/tile_coordinate.hpp b/src/mbgl/util/tile_coordinate.hpp index 0f5f0dcb8..836539b5b 100644 --- a/src/mbgl/util/tile_coordinate.hpp +++ b/src/mbgl/util/tile_coordinate.hpp @@ -6,15 +6,15 @@ namespace mbgl { struct TileCoordinate { - float column; - float row; - float zoom; + double column; + double row; + double zoom; - TileCoordinate(float column_, float row_, float zoom_) : + TileCoordinate(double column_, double row_, double zoom_) : column(column_), row(row_), zoom(zoom_) {} - TileCoordinate zoomTo(float targetZoom) { - float scale = std::pow(2, targetZoom - zoom); + TileCoordinate zoomTo(double targetZoom) { + double scale = std::pow(2, targetZoom - zoom); return { column * scale, row * scale, targetZoom }; } diff --git a/src/mbgl/util/vec4.cpp b/src/mbgl/util/vec4.cpp index 415b15d80..bee4eaf97 100644 --- a/src/mbgl/util/vec4.cpp +++ b/src/mbgl/util/vec4.cpp @@ -25,7 +25,7 @@ using namespace mbgl; void matrix::transformMat4(vec4& out, vec4& a, mat4& m) { - float x = a[0], y = a[1], z = a[2], w = a[3]; + double x = a[0], y = a[1], z = a[2], w = a[3]; out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w; out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w; out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w; From 60d0db0d2d0eb046df26c5a76c3144ff01e2e0b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Thu, 10 Sep 2015 13:39:47 -0700 Subject: [PATCH 037/156] Increased precision of coordinate conversion methods Fixes #2230. --- src/mbgl/map/transform_state.cpp | 16 ++++++++-------- src/mbgl/map/transform_state.hpp | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index e37f10dc6..ac3988dc5 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -175,7 +175,7 @@ double TransformState::yLat(double y_, double worldSize_) const { return 360.0f / M_PI * std::atan(std::exp(y2 * M_PI / 180.0f)) - 90.0f; } -float TransformState::zoomScale(float zoom) const { +double TransformState::zoomScale(double zoom) const { return std::pow(2.0f, zoom); } @@ -192,8 +192,8 @@ LatLng TransformState::pointToLatLng(const vec2 point) const { } TileCoordinate TransformState::latLngToCoordinate(const LatLng& latLng) const { - const float tileZoom = getIntegerZoom(); - const float k = zoomScale(tileZoom) / worldSize(); + const double tileZoom = getZoom(); + const double k = zoomScale(tileZoom) / worldSize(); return { lngX(latLng.longitude) * k, latY(latLng.latitude) * k, @@ -202,12 +202,12 @@ TileCoordinate TransformState::latLngToCoordinate(const LatLng& latLng) const { } LatLng TransformState::coordinateToLatLng(const TileCoordinate& coord) const { - const float worldSize_ = zoomScale(coord.zoom); + const double worldSize_ = zoomScale(coord.zoom); LatLng latLng = { yLat(coord.row, worldSize_), xLng(coord.column, worldSize_) }; - while (latLng.longitude < 180.0f) latLng.longitude += 360.0f; + while (latLng.longitude < -180.0f) latLng.longitude += 360.0f; while (latLng.longitude > 180.0f) latLng.longitude -= 360.0f; return latLng; } @@ -223,7 +223,7 @@ vec2 TransformState::coordinateToPoint(const TileCoordinate& coord) cons TileCoordinate TransformState::pointToCoordinate(const vec2 point) const { float targetZ = 0; - const float tileZoom = getIntegerZoom(); + const double tileZoom = getZoom(); mat4 mat = coordinatePointMatrix(tileZoom); @@ -259,11 +259,11 @@ TileCoordinate TransformState::pointToCoordinate(const vec2 point) const return { util::interpolate(x0, x1, t), util::interpolate(y0, y1, t), tileZoom }; } -mat4 TransformState::coordinatePointMatrix(float z) const { +mat4 TransformState::coordinatePointMatrix(double z) const { mat4 proj; getProjMatrix(proj); float s = util::tileSize * scale / std::pow(2, z); - matrix::scale(proj, proj, s , s, 1); + matrix::scale(proj, proj, s, s, 1); matrix::multiply(proj, getPixelMatrix(), proj); return proj; } diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp index c3e1072c9..6fcd35ffa 100644 --- a/src/mbgl/map/transform_state.hpp +++ b/src/mbgl/map/transform_state.hpp @@ -83,10 +83,10 @@ private: double yLat(double y, double worldSize) const; double lngX(double lon) const; double latY(double lat) const; - float zoomScale(float zoom) const; + double zoomScale(double zoom) const; float worldSize() const; - mat4 coordinatePointMatrix(float z) const; + mat4 coordinatePointMatrix(double z) const; mat4 getPixelMatrix() const; private: From d9c7fdc5655d48a6e7c54016c0efd94710431430 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Fri, 11 Sep 2015 16:34:10 -0400 Subject: [PATCH 038/156] [iOS] Fix MGLPolyline documentation typo --- include/mbgl/ios/MGLPolyline.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mbgl/ios/MGLPolyline.h b/include/mbgl/ios/MGLPolyline.h index 7cbbadeca..07c5286c8 100644 --- a/include/mbgl/ios/MGLPolyline.h +++ b/include/mbgl/ios/MGLPolyline.h @@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN /** The `MGLPolyline` class represents a shape consisting of one or more points that define connecting line segments. The points are connected end-to-end in the order they are provided. The first and last points are not connected to each other. */ @interface MGLPolyline : MGLMultiPoint -/** Creates and returns an `MGLPolygon` object from the specified set of coordinates. +/** Creates and returns an `MGLPolyline` object from the specified set of coordinates. * @param coords The array of coordinates defining the shape. The data in this array is copied to the new object. * @param count The number of items in the _`coords`_ array. * @return A new polyline object. */ From 7127cfebb5949e2bdb4ef86f8c192c7bdc04caed Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Tue, 8 Sep 2015 11:43:55 -0400 Subject: [PATCH 039/156] Fix build, only ask for location permission on user's instigation Previously in #2265 we would ask for location permission at app startup if `!settings->showsUserLocation`. #2193 0a172a21fdc2a87473560fd7d45f4d495d95de91 changed the way we used `NSUserDefaults` and mostly removed the `settings` object, which broke #2265. Rather than fix our pestering location permissions ask at startup, this commit now only asks for location permissions when the user hits the locate-me button. Once a user grants permission, the user dot appears because a `userTrackingMode` is set, `showsUserLocation` is permanently set to `YES` in `NSUserDefaults` and is restored at launch. --- ios/app/MBXViewController.mm | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ios/app/MBXViewController.mm b/ios/app/MBXViewController.mm index b32371770..d94e41b5f 100644 --- a/ios/app/MBXViewController.mm +++ b/ios/app/MBXViewController.mm @@ -83,13 +83,6 @@ static NSUInteger const kStyleVersion = 8; action:@selector(locateUser)]; [self restoreState:nil]; - - if ( ! settings->showsUserLocation) - { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ - self.mapView.showsUserLocation = YES; - }); - } } - (void)saveState:(__unused NSNotification *)notification From db28ef37dbabd3e8f53289e843def4a3a68cdf06 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Tue, 8 Sep 2015 18:03:10 -0700 Subject: [PATCH 040/156] fixes #1675: abstract annotation tile refresh check/render; trigger post-sprite/sprite store load --- src/mbgl/map/annotation.hpp | 1 + src/mbgl/map/map_context.cpp | 10 ++++++++-- src/mbgl/map/map_context.hpp | 2 ++ src/mbgl/style/style.cpp | 4 ++++ src/mbgl/style/style.hpp | 1 + test/style/resource_loading.cpp | 4 ++++ 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/mbgl/map/annotation.hpp b/src/mbgl/map/annotation.hpp index 745fc779c..5adec162f 100644 --- a/src/mbgl/map/annotation.hpp +++ b/src/mbgl/map/annotation.hpp @@ -52,6 +52,7 @@ public: ~AnnotationManager(); void markStaleTiles(std::unordered_set); + size_t getStaleTileCount() const { return staleTiles.size(); } std::unordered_set resetStaleTiles(); void setDefaultPointAnnotationSymbol(const std::string& symbol); diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp index 94aedb46d..0ebcd73f8 100644 --- a/src/mbgl/map/map_context.cpp +++ b/src/mbgl/map/map_context.cpp @@ -142,9 +142,11 @@ void MapContext::loadStyleJSON(const std::string& json, const std::string& base) updateFlags |= Update::DefaultTransition | Update::Classes | Update::Zoom; asyncUpdate->send(); +} - auto staleTiles = data.getAnnotationManager()->resetStaleTiles(); - if (!staleTiles.empty()) { +void MapContext::updateAnnotationTilesIfNeeded() { + if (data.getAnnotationManager()->getStaleTileCount()) { + auto staleTiles = data.getAnnotationManager()->resetStaleTiles(); updateAnnotationTiles(staleTiles); } } @@ -417,4 +419,8 @@ void MapContext::onResourceLoadingFailed(std::exception_ptr error) { } } +void MapContext::onSpriteStoreLoaded() { + updateAnnotationTilesIfNeeded(); +} + } diff --git a/src/mbgl/map/map_context.hpp b/src/mbgl/map/map_context.hpp index f1bfb01e4..449a0f1d1 100644 --- a/src/mbgl/map/map_context.hpp +++ b/src/mbgl/map/map_context.hpp @@ -54,6 +54,7 @@ public: bool isLoaded() const; double getTopOffsetPixelsForAnnotationSymbol(const std::string& symbol); + void updateAnnotationTilesIfNeeded(); void updateAnnotationTiles(const std::unordered_set&); void setSourceTileCacheSize(size_t size); @@ -66,6 +67,7 @@ public: // Style::Observer implementation. void onTileDataChanged() override; void onResourceLoadingFailed(std::exception_ptr error) override; + void onSpriteStoreLoaded() override; private: // Update the state indicated by the accumulated Update flags, then render. diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index 768621530..d4c9bd4e5 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -190,6 +190,10 @@ void Style::onSpriteLoaded(const Sprites& sprites) { // Add all sprite images to the SpriteStore object spriteStore->setSprites(sprites); + if (observer) { + observer->onSpriteStoreLoaded(); + } + shouldReparsePartialTiles = true; emitTileDataChanged(); } diff --git a/src/mbgl/style/style.hpp b/src/mbgl/style/style.hpp index cbc0ee2db..3f9696ffb 100644 --- a/src/mbgl/style/style.hpp +++ b/src/mbgl/style/style.hpp @@ -39,6 +39,7 @@ public: virtual ~Observer() = default; virtual void onTileDataChanged() = 0; + virtual void onSpriteStoreLoaded() = 0; virtual void onResourceLoadingFailed(std::exception_ptr error) = 0; }; diff --git a/test/style/resource_loading.cpp b/test/style/resource_loading.cpp index 056243458..5ed09065a 100644 --- a/test/style/resource_loading.cpp +++ b/test/style/resource_loading.cpp @@ -63,6 +63,10 @@ public: callback_(error); } + void onSpriteStoreLoaded() override { + // no-op + } + private: MapData data_; Transform transform_; From 182bd9723e4b13161a2139db4c33f124a95d9c4b Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Tue, 1 Sep 2015 23:30:54 -0400 Subject: [PATCH 041/156] [iOS] Initial user location puck --- platform/ios/MGLUserLocationAnnotationView.m | 480 ++++++++++++------- 1 file changed, 296 insertions(+), 184 deletions(-) diff --git a/platform/ios/MGLUserLocationAnnotationView.m b/platform/ios/MGLUserLocationAnnotationView.m index 7733674e6..301e3c4b2 100644 --- a/platform/ios/MGLUserLocationAnnotationView.m +++ b/platform/ios/MGLUserLocationAnnotationView.m @@ -8,6 +8,9 @@ const CGFloat MGLUserLocationAnnotationDotSize = 22.0; const CGFloat MGLUserLocationAnnotationHaloSize = 115.0; +const CGFloat MGLUserLocationAnnotationPuckSize = 35.0; +const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuckSize * 0.6; + @interface MGLUserLocationAnnotationView () @property (nonatomic, readwrite) CALayer *haloLayer; @@ -18,12 +21,17 @@ const CGFloat MGLUserLocationAnnotationHaloSize = 115.0; @implementation MGLUserLocationAnnotationView { + BOOL _puckModeActivated; + + CALayer *_puckDot; + CAShapeLayer *_puckArrow; + CALayer *_headingIndicatorLayer; CAShapeLayer *_headingIndicatorMaskLayer; CALayer *_accuracyRingLayer; CALayer *_dotBorderLayer; CALayer *_dotLayer; - + double _oldHeadingAccuracy; CLLocationAccuracy _oldHorizontalAccuracy; double _oldZoom; @@ -37,7 +45,9 @@ const CGFloat MGLUserLocationAnnotationHaloSize = 115.0; - (instancetype)initInMapView:(MGLMapView *)mapView { - if (self = [super initWithFrame:CGRectMake(0, 0, MGLUserLocationAnnotationDotSize, MGLUserLocationAnnotationDotSize)]) + CGFloat frameSize = (mapView.userTrackingMode == MGLUserTrackingModeFollowWithCourse) ? MGLUserLocationAnnotationPuckSize : MGLUserLocationAnnotationDotSize; + + if (self = [super initWithFrame:CGRectMake(0, 0, frameSize, frameSize)]) { self.annotation = [[MGLUserLocation alloc] initWithMapView:mapView]; _mapView = mapView; @@ -55,189 +65,291 @@ const CGFloat MGLUserLocationAnnotationHaloSize = 115.0; - (void)setTintColor:(UIColor *)tintColor { - if (_accuracyRingLayer) + if (_puckModeActivated) { - _accuracyRingLayer.backgroundColor = [tintColor CGColor]; + _puckArrow.fillColor = [tintColor CGColor]; + } + else + { + if (_accuracyRingLayer) + { + _accuracyRingLayer.backgroundColor = [tintColor CGColor]; + } + + _haloLayer.backgroundColor = [tintColor CGColor]; + _dotLayer.backgroundColor = [tintColor CGColor]; + + _headingIndicatorLayer.contents = (__bridge id)[[self headingIndicatorTintedGradientImage] CGImage]; } - - _haloLayer.backgroundColor = [tintColor CGColor]; - _dotLayer.backgroundColor = [tintColor CGColor]; - - _headingIndicatorLayer.contents = (__bridge id)[[self headingIndicatorTintedGradientImage] CGImage]; } - (void)setupLayers { if (CLLocationCoordinate2DIsValid(self.annotation.coordinate)) { - // update heading indicator - // - if (_headingIndicatorLayer) - { - _headingIndicatorLayer.hidden = !(_mapView.userTrackingMode == MGLUserTrackingModeFollowWithHeading || - _mapView.userTrackingMode == MGLUserTrackingModeFollowWithCourse); - - if (_oldHeadingAccuracy != self.annotation.heading.headingAccuracy) - { - // recalculate the clipping mask based on updated accuracy - _headingIndicatorMaskLayer.path = [[self headingIndicatorClippingMask] CGPath]; + (_mapView.userTrackingMode == MGLUserTrackingModeFollowWithCourse) ? [self drawPuck] : [self drawDot]; + } +} - _oldHeadingAccuracy = self.annotation.heading.headingAccuracy; - } - } - - // heading indicator (tinted, semi-circle) - // - if ( ! _headingIndicatorLayer && self.annotation.heading.headingAccuracy) +- (void)drawPuck +{ + if ( ! _puckModeActivated) + { + self.layer.sublayers = nil; + + _headingIndicatorLayer = nil; + _headingIndicatorMaskLayer = nil; + _accuracyRingLayer = nil; + _haloLayer = nil; + _dotBorderLayer = nil; + _dotLayer = nil; + + _puckModeActivated = YES; + } + + // background dot (white with black shadow) + // + if ( ! _puckDot) + { + _puckDot = [self circleLayerWithSize:MGLUserLocationAnnotationPuckSize]; + _puckDot.backgroundColor = [[UIColor whiteColor] CGColor]; + _puckDot.shadowColor = [[UIColor blackColor] CGColor]; + _puckDot.shadowOffset = CGSizeMake(0, 1); + _puckDot.shadowRadius = 1; + _puckDot.shadowOpacity = 0.1; + + [self.layer addSublayer:_puckDot]; + } + + // arrow + // + if ( ! _puckArrow) + { + _puckArrow = [CAShapeLayer layer]; + _puckArrow.path = [[self puckArrow] CGPath]; + _puckArrow.fillColor = [_mapView.tintColor CGColor]; + _puckArrow.bounds = CGRectMake(0, 0, MGLUserLocationAnnotationArrowSize, MGLUserLocationAnnotationArrowSize); + _puckArrow.position = CGPointMake(super.bounds.size.width / 2.0, super.bounds.size.height / 2.0); + _puckArrow.shouldRasterize = YES; + _puckArrow.rasterizationScale = [UIScreen mainScreen].scale; + _puckArrow.drawsAsynchronously = YES; + + [self.layer addSublayer:_puckArrow]; + } + + if (self.mapView.pitch) + { + CATransform3D t = CATransform3DRotate(CATransform3DIdentity, MGLRadiansFromDegrees(self.mapView.pitch), 1.0, 0, 0); + self.layer.sublayerTransform = t; + } +} + +CGFloat MGLRadiansFromDegrees(CLLocationDegrees degrees) +{ + return degrees * M_PI / 180; +} + +CLLocationDegrees MGLDegreesFromRadians(CGFloat radians) +{ + return radians * 180 / M_PI; +} + +- (UIBezierPath *)puckArrow +{ + CGFloat max = MGLUserLocationAnnotationArrowSize; + + UIBezierPath *bezierPath = UIBezierPath.bezierPath; + [bezierPath moveToPoint: CGPointMake(max * 0.5, 0)]; + [bezierPath addLineToPoint: CGPointMake(max * 0.1, max)]; + [bezierPath addLineToPoint: CGPointMake(max * 0.5, max * 0.65)]; + [bezierPath addLineToPoint: CGPointMake(max * 0.9, max)]; + [bezierPath addLineToPoint: CGPointMake(max * 0.5, 0)]; + [bezierPath closePath]; + + return bezierPath; +} + +- (void)drawDot +{ + if (_puckModeActivated) + { + self.layer.sublayers = nil; + + _puckDot = nil; + _puckArrow = nil; + + _puckModeActivated = NO; + + self.layer.sublayerTransform = CATransform3DIdentity; + } + + // update heading indicator + // + if (_headingIndicatorLayer) + { + _headingIndicatorLayer.hidden = !(_mapView.userTrackingMode == MGLUserTrackingModeFollowWithHeading || + _mapView.userTrackingMode == MGLUserTrackingModeFollowWithCourse); + + if (_oldHeadingAccuracy != self.annotation.heading.headingAccuracy) { - CGFloat headingIndicatorSize = MGLUserLocationAnnotationHaloSize; - - _headingIndicatorLayer = [CALayer layer]; - _headingIndicatorLayer.bounds = CGRectMake(0, 0, headingIndicatorSize, headingIndicatorSize); - _headingIndicatorLayer.position = CGPointMake(super.bounds.size.width / 2.0, super.bounds.size.height / 2.0); - _headingIndicatorLayer.contents = (__bridge id)[[self headingIndicatorTintedGradientImage] CGImage]; - _headingIndicatorLayer.contentsGravity = kCAGravityBottom; - _headingIndicatorLayer.contentsScale = [UIScreen mainScreen].scale; - _headingIndicatorLayer.opacity = 0.4; - _headingIndicatorLayer.shouldRasterize = YES; - _headingIndicatorLayer.rasterizationScale = [UIScreen mainScreen].scale; - _headingIndicatorLayer.drawsAsynchronously = YES; - - [self.layer insertSublayer:_headingIndicatorLayer below:_dotBorderLayer]; - } - - // heading indicator accuracy mask (fan-shaped) - // - if ( ! _headingIndicatorMaskLayer && self.annotation.heading.headingAccuracy) - { - _headingIndicatorMaskLayer = [CAShapeLayer layer]; - _headingIndicatorMaskLayer.frame = _headingIndicatorLayer.bounds; + // recalculate the clipping mask based on updated accuracy _headingIndicatorMaskLayer.path = [[self headingIndicatorClippingMask] CGPath]; - // apply the mask to the halo-radius-sized gradient layer - _headingIndicatorLayer.mask = _headingIndicatorMaskLayer; - _oldHeadingAccuracy = self.annotation.heading.headingAccuracy; } + } + + // heading indicator (tinted, semi-circle) + // + if ( ! _headingIndicatorLayer && self.annotation.heading.headingAccuracy) + { + CGFloat headingIndicatorSize = MGLUserLocationAnnotationHaloSize; + + _headingIndicatorLayer = [CALayer layer]; + _headingIndicatorLayer.bounds = CGRectMake(0, 0, headingIndicatorSize, headingIndicatorSize); + _headingIndicatorLayer.position = CGPointMake(super.bounds.size.width / 2.0, super.bounds.size.height / 2.0); + _headingIndicatorLayer.contents = (__bridge id)[[self headingIndicatorTintedGradientImage] CGImage]; + _headingIndicatorLayer.contentsGravity = kCAGravityBottom; + _headingIndicatorLayer.contentsScale = [UIScreen mainScreen].scale; + _headingIndicatorLayer.opacity = 0.4; + _headingIndicatorLayer.shouldRasterize = YES; + _headingIndicatorLayer.rasterizationScale = [UIScreen mainScreen].scale; + _headingIndicatorLayer.drawsAsynchronously = YES; + + [self.layer insertSublayer:_headingIndicatorLayer below:_dotBorderLayer]; + } + + // heading indicator accuracy mask (fan-shaped) + // + if ( ! _headingIndicatorMaskLayer && self.annotation.heading.headingAccuracy) + { + _headingIndicatorMaskLayer = [CAShapeLayer layer]; + _headingIndicatorMaskLayer.frame = _headingIndicatorLayer.bounds; + _headingIndicatorMaskLayer.path = [[self headingIndicatorClippingMask] CGPath]; + + // apply the mask to the halo-radius-sized gradient layer + _headingIndicatorLayer.mask = _headingIndicatorMaskLayer; + + _oldHeadingAccuracy = self.annotation.heading.headingAccuracy; + } + + // update accuracy ring (if zoom or horizontal accuracy have changed) + // + if (_accuracyRingLayer && (_oldZoom != self.mapView.zoomLevel || _oldHorizontalAccuracy != self.annotation.location.horizontalAccuracy)) + { + CGFloat accuracyRingSize = [self calculateAccuracyRingSize]; - // update accuracy ring (if zoom or horizontal accuracy have changed) - // - if (_accuracyRingLayer && (_oldZoom != self.mapView.zoomLevel || _oldHorizontalAccuracy != self.annotation.location.horizontalAccuracy)) + // only show the accuracy ring if it won't be obscured by the location dot + if (accuracyRingSize > MGLUserLocationAnnotationDotSize + 15) { - CGFloat accuracyRingSize = [self calculateAccuracyRingSize]; - - // only show the accuracy ring if it won't be obscured by the location dot - if (accuracyRingSize > MGLUserLocationAnnotationDotSize + 15) - { - _accuracyRingLayer.hidden = NO; - _accuracyRingLayer.bounds = CGRectMake(0, 0, accuracyRingSize, accuracyRingSize); - _accuracyRingLayer.cornerRadius = accuracyRingSize / 2; - - // match the halo to the accuracy ring - _haloLayer.bounds = _accuracyRingLayer.bounds; - _haloLayer.cornerRadius = _accuracyRingLayer.cornerRadius; - _haloLayer.shouldRasterize = NO; - } - else - { - _accuracyRingLayer.hidden = YES; - - _haloLayer.bounds = CGRectMake(0, 0, MGLUserLocationAnnotationHaloSize, MGLUserLocationAnnotationHaloSize); - _haloLayer.cornerRadius = MGLUserLocationAnnotationHaloSize / 2.0; - _haloLayer.shouldRasterize = YES; - _haloLayer.rasterizationScale = [UIScreen mainScreen].scale; - } - - // store accuracy and zoom so we're not redrawing unchanged location updates - _oldHorizontalAccuracy = self.annotation.location.horizontalAccuracy; - _oldZoom = self.mapView.zoomLevel; + _accuracyRingLayer.hidden = NO; + _accuracyRingLayer.bounds = CGRectMake(0, 0, accuracyRingSize, accuracyRingSize); + _accuracyRingLayer.cornerRadius = accuracyRingSize / 2; + + // match the halo to the accuracy ring + _haloLayer.bounds = _accuracyRingLayer.bounds; + _haloLayer.cornerRadius = _accuracyRingLayer.cornerRadius; + _haloLayer.shouldRasterize = NO; } + else + { + _accuracyRingLayer.hidden = YES; + + _haloLayer.bounds = CGRectMake(0, 0, MGLUserLocationAnnotationHaloSize, MGLUserLocationAnnotationHaloSize); + _haloLayer.cornerRadius = MGLUserLocationAnnotationHaloSize / 2.0; + _haloLayer.shouldRasterize = YES; + _haloLayer.rasterizationScale = [UIScreen mainScreen].scale; + } + + // store accuracy and zoom so we're not redrawing unchanged location updates + _oldHorizontalAccuracy = self.annotation.location.horizontalAccuracy; + _oldZoom = self.mapView.zoomLevel; + } + + // accuracy ring (circular, tinted, mostly-transparent) + // + if ( ! _accuracyRingLayer && self.annotation.location.horizontalAccuracy) + { + CGFloat accuracyRingSize = [self calculateAccuracyRingSize]; + _accuracyRingLayer = [self circleLayerWithSize:accuracyRingSize]; + _accuracyRingLayer.backgroundColor = [_mapView.tintColor CGColor]; + _accuracyRingLayer.opacity = 0.1; + _accuracyRingLayer.shouldRasterize = NO; + _accuracyRingLayer.allowsGroupOpacity = NO; - // accuracy ring (circular, tinted, mostly-transparent) - // - if ( ! _accuracyRingLayer && self.annotation.location.horizontalAccuracy) - { - CGFloat accuracyRingSize = [self calculateAccuracyRingSize]; - _accuracyRingLayer = [self circleLayerWithSize:accuracyRingSize]; - _accuracyRingLayer.backgroundColor = [_mapView.tintColor CGColor]; - _accuracyRingLayer.opacity = 0.1; - _accuracyRingLayer.shouldRasterize = NO; - _accuracyRingLayer.allowsGroupOpacity = NO; - - [self.layer addSublayer:_accuracyRingLayer]; - } + [self.layer addSublayer:_accuracyRingLayer]; + } + + // expanding sonar-like pulse (circular, tinted, fades out) + // + if ( ! _haloLayer) + { + _haloLayer = [self circleLayerWithSize:MGLUserLocationAnnotationHaloSize]; + _haloLayer.backgroundColor = [_mapView.tintColor CGColor]; + _haloLayer.allowsGroupOpacity = NO; + + // set defaults for the animations + CAAnimationGroup *animationGroup = [self loopingAnimationGroupWithDuration:3.0]; + + // scale out radially with initial acceleration + CAKeyframeAnimation *boundsAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale.xy"]; + boundsAnimation.values = @[@0, @0.35, @1]; + boundsAnimation.keyTimes = @[@0, @0.2, @1]; + + // go transparent as scaled out, start semi-opaque + CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"]; + opacityAnimation.values = @[@0.4, @0.4, @0]; + opacityAnimation.keyTimes = @[@0, @0.2, @1]; + + animationGroup.animations = @[boundsAnimation, opacityAnimation]; + + [_haloLayer addAnimation:animationGroup forKey:@"animateTransformAndOpacity"]; + + [self.layer addSublayer:_haloLayer]; + } + + // background dot (white with black shadow) + // + if ( ! _dotBorderLayer) + { + _dotBorderLayer = [self circleLayerWithSize:MGLUserLocationAnnotationDotSize]; + _dotBorderLayer.backgroundColor = [[UIColor whiteColor] CGColor]; + _dotBorderLayer.shadowColor = [[UIColor blackColor] CGColor]; + _dotBorderLayer.shadowOffset = CGSizeMake(0, 0); + _dotBorderLayer.shadowRadius = 3; + _dotBorderLayer.shadowOpacity = 0.25; - // expanding sonar-like pulse (circular, tinted, fades out) - // - if ( ! _haloLayer) - { - _haloLayer = [self circleLayerWithSize:MGLUserLocationAnnotationHaloSize]; - _haloLayer.backgroundColor = [_mapView.tintColor CGColor]; - _haloLayer.allowsGroupOpacity = NO; - - // set defaults for the animations - CAAnimationGroup *animationGroup = [self loopingAnimationGroupWithDuration:3.0]; - - // scale out radially with initial acceleration - CAKeyframeAnimation *boundsAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale.xy"]; - boundsAnimation.values = @[@0, @0.35, @1]; - boundsAnimation.keyTimes = @[@0, @0.2, @1]; - - // go transparent as scaled out, start semi-opaque - CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"]; - opacityAnimation.values = @[@0.4, @0.4, @0]; - opacityAnimation.keyTimes = @[@0, @0.2, @1]; - - animationGroup.animations = @[boundsAnimation, opacityAnimation]; - - [_haloLayer addAnimation:animationGroup forKey:@"animateTransformAndOpacity"]; - - [self.layer addSublayer:_haloLayer]; - } - - // background dot (white with black shadow) - // - if ( ! _dotBorderLayer) - { - _dotBorderLayer = [self circleLayerWithSize:MGLUserLocationAnnotationDotSize]; - _dotBorderLayer.backgroundColor = [[UIColor whiteColor] CGColor]; - _dotBorderLayer.shadowColor = [[UIColor blackColor] CGColor]; - _dotBorderLayer.shadowOffset = CGSizeMake(0, 0); - _dotBorderLayer.shadowRadius = 3; - _dotBorderLayer.shadowOpacity = 0.25; - - [self.layer addSublayer:_dotBorderLayer]; - } - - // inner dot (pulsing, tinted) - // - if ( ! _dotLayer) - { - _dotLayer = [self circleLayerWithSize:MGLUserLocationAnnotationDotSize * 0.75]; - _dotLayer.backgroundColor = [_mapView.tintColor CGColor]; - _dotLayer.shouldRasterize = NO; - - // set defaults for the animations - CAAnimationGroup *animationGroup = [self loopingAnimationGroupWithDuration:1.5]; - animationGroup.autoreverses = YES; - animationGroup.fillMode = kCAFillModeBoth; - - // scale the dot up and down - CABasicAnimation *pulseAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale.xy"]; - pulseAnimation.fromValue = @0.8; - pulseAnimation.toValue = @1; - - // fade opacity in and out, subtly - CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"]; - opacityAnimation.fromValue = @0.8; - opacityAnimation.toValue = @1; - - animationGroup.animations = @[pulseAnimation, opacityAnimation]; - - [_dotLayer addAnimation:animationGroup forKey:@"animateTransformAndOpacity"]; - - [self.layer addSublayer:_dotLayer]; - } + [self.layer addSublayer:_dotBorderLayer]; + } + + // inner dot (pulsing, tinted) + // + if ( ! _dotLayer) + { + _dotLayer = [self circleLayerWithSize:MGLUserLocationAnnotationDotSize * 0.75]; + _dotLayer.backgroundColor = [_mapView.tintColor CGColor]; + _dotLayer.shouldRasterize = NO; + + // set defaults for the animations + CAAnimationGroup *animationGroup = [self loopingAnimationGroupWithDuration:1.5]; + animationGroup.autoreverses = YES; + animationGroup.fillMode = kCAFillModeBoth; + + // scale the dot up and down + CABasicAnimation *pulseAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale.xy"]; + pulseAnimation.fromValue = @0.8; + pulseAnimation.toValue = @1; + + // fade opacity in and out, subtly + CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"]; + opacityAnimation.fromValue = @0.8; + opacityAnimation.toValue = @1; + + animationGroup.animations = @[pulseAnimation, opacityAnimation]; + + [_dotLayer addAnimation:animationGroup forKey:@"animateTransformAndOpacity"]; + + [self.layer addSublayer:_dotLayer]; } } @@ -250,7 +362,7 @@ const CGFloat MGLUserLocationAnnotationHaloSize = 115.0; circleLayer.shouldRasterize = YES; circleLayer.rasterizationScale = [UIScreen mainScreen].scale; circleLayer.drawsAsynchronously = YES; - + return circleLayer; } @@ -261,7 +373,7 @@ const CGFloat MGLUserLocationAnnotationHaloSize = 115.0; animationGroup.repeatCount = INFINITY; animationGroup.removedOnCompletion = NO; animationGroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]; - + return animationGroup; } @@ -269,65 +381,65 @@ const CGFloat MGLUserLocationAnnotationHaloSize = 115.0; { CGFloat latRadians = self.annotation.coordinate.latitude * M_PI / 180.0f; CGFloat pixelRadius = self.annotation.location.horizontalAccuracy / cos(latRadians) / [self.mapView metersPerPixelAtLatitude:self.annotation.coordinate.latitude]; - + return pixelRadius * 2; } - (UIImage *)headingIndicatorTintedGradientImage { UIImage *image; - + CGFloat haloRadius = MGLUserLocationAnnotationHaloSize / 2.0; - + UIGraphicsBeginImageContextWithOptions(CGSizeMake(MGLUserLocationAnnotationHaloSize, haloRadius), NO, 0); - + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = UIGraphicsGetCurrentContext(); - + // gradient from the tint color to no-alpha tint color CGFloat gradientLocations[] = {0.0, 1.0}; CGGradientRef gradient = CGGradientCreateWithColors( - colorSpace, (__bridge CFArrayRef)@[(id)[_mapView.tintColor CGColor], - (id)[[_mapView.tintColor colorWithAlphaComponent:0] CGColor]], gradientLocations); - + colorSpace, (__bridge CFArrayRef)@[(id)[_mapView.tintColor CGColor], + (id)[[_mapView.tintColor colorWithAlphaComponent:0] CGColor]], gradientLocations); + // draw the gradient from the center point to the edge (full halo radius) CGPoint centerPoint = CGPointMake(haloRadius, haloRadius); CGContextDrawRadialGradient(context, gradient, centerPoint, 0.0, centerPoint, haloRadius, nil); - + image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); - + CGGradientRelease(gradient); CGColorSpaceRelease(colorSpace); - + return image; } - (UIBezierPath *)headingIndicatorClippingMask { CGFloat accuracy = self.annotation.heading.headingAccuracy; - + // size the mask using exagerated accuracy, but keep within a good display range CGFloat clippingDegrees = 90 - (accuracy * 1.5); clippingDegrees = fmin(clippingDegrees, 55); clippingDegrees = fmax(clippingDegrees, 10); - + CGRect ovalRect = CGRectMake(0, 0, MGLUserLocationAnnotationHaloSize, MGLUserLocationAnnotationHaloSize); UIBezierPath *ovalPath = UIBezierPath.bezierPath; - + // clip the oval to ± incoming accuracy degrees (converted to radians), from the top [ovalPath addArcWithCenter:CGPointMake(CGRectGetMidX(ovalRect), CGRectGetMidY(ovalRect)) radius:CGRectGetWidth(ovalRect) / 2.0 startAngle:(-180 + clippingDegrees) * M_PI / 180 endAngle:-clippingDegrees * M_PI / 180 clockwise:YES]; - + [ovalPath addLineToPoint:CGPointMake(CGRectGetMidX(ovalRect), CGRectGetMidY(ovalRect))]; [ovalPath closePath]; - + return ovalPath; } From b611c9bb7bc6fa807ddb03922f1ffa26df9765e6 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Fri, 4 Sep 2015 00:00:28 -0400 Subject: [PATCH 042/156] [iOS] Move radians/degrees conversion functions to MGLGeometry.h --- include/mbgl/ios/MGLGeometry.h | 11 +++++++++++ platform/ios/MGLMapView.mm | 10 ---------- platform/ios/MGLUserLocationAnnotationView.m | 10 ---------- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/include/mbgl/ios/MGLGeometry.h b/include/mbgl/ios/MGLGeometry.h index 6226af1d0..2dee7c76c 100644 --- a/include/mbgl/ios/MGLGeometry.h +++ b/include/mbgl/ios/MGLGeometry.h @@ -3,6 +3,7 @@ #import "MGLTypes.h" #import +#import NS_ASSUME_NONNULL_BEGIN @@ -82,4 +83,14 @@ NS_INLINE NSString *MGLStringFromCoordinateBounds(MGLCoordinateBounds bounds) { bounds.ne.latitude, bounds.ne.longitude]; } +NS_INLINE CGFloat MGLRadiansFromDegrees(CLLocationDegrees degrees) +{ + return degrees * M_PI / 180; +} + +NS_INLINE CLLocationDegrees MGLDegreesFromRadians(CGFloat radians) +{ + return radians * 180 / M_PI; +} + NS_ASSUME_NONNULL_END diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index e509b5c8d..705627663 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -60,16 +60,6 @@ static NSURL *MGLURLForBundledStyleNamed(NSString *styleName) return [NSURL URLWithString:[NSString stringWithFormat:@"asset://styles/%@.json", styleName]]; } -CGFloat MGLRadiansFromDegrees(CLLocationDegrees degrees) -{ - return degrees * M_PI / 180; -} - -CLLocationDegrees MGLDegreesFromRadians(CGFloat radians) -{ - return radians * 180 / M_PI; -} - mbgl::util::UnitBezier MGLUnitBezierForMediaTimingFunction(CAMediaTimingFunction *function) { if ( ! function) diff --git a/platform/ios/MGLUserLocationAnnotationView.m b/platform/ios/MGLUserLocationAnnotationView.m index 301e3c4b2..06da8a998 100644 --- a/platform/ios/MGLUserLocationAnnotationView.m +++ b/platform/ios/MGLUserLocationAnnotationView.m @@ -144,16 +144,6 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck } } -CGFloat MGLRadiansFromDegrees(CLLocationDegrees degrees) -{ - return degrees * M_PI / 180; -} - -CLLocationDegrees MGLDegreesFromRadians(CGFloat radians) -{ - return radians * 180 / M_PI; -} - - (UIBezierPath *)puckArrow { CGFloat max = MGLUserLocationAnnotationArrowSize; From 60d68158a3be7830f52e90e149999631883e8461 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Fri, 4 Sep 2015 00:41:43 -0400 Subject: [PATCH 043/156] =?UTF-8?q?[iOS]=20Pitch=20the=20dot,=20add=20faux?= =?UTF-8?q?=203D=20effect=20to=20tilted=20dot=20and=20puck=20This=20expose?= =?UTF-8?q?s=20the=20na=C3=AFvet=C3=A9=20of=20the=20current=20pitch=20tran?= =?UTF-8?q?sform:=20accuracy=20ring=20sizing=20stays=20constant,=20despite?= =?UTF-8?q?=20vertical=20screen=20movement.=20Still,=20it=20looks=20better?= =?UTF-8?q?=20pitched=20than=20not.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform/ios/MGLUserLocationAnnotationView.m | 88 ++++++++++++++++---- 1 file changed, 72 insertions(+), 16 deletions(-) diff --git a/platform/ios/MGLUserLocationAnnotationView.m b/platform/ios/MGLUserLocationAnnotationView.m index 06da8a998..22c1d00f1 100644 --- a/platform/ios/MGLUserLocationAnnotationView.m +++ b/platform/ios/MGLUserLocationAnnotationView.m @@ -8,7 +8,7 @@ const CGFloat MGLUserLocationAnnotationDotSize = 22.0; const CGFloat MGLUserLocationAnnotationHaloSize = 115.0; -const CGFloat MGLUserLocationAnnotationPuckSize = 35.0; +const CGFloat MGLUserLocationAnnotationPuckSize = 45.0; const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuckSize * 0.6; @interface MGLUserLocationAnnotationView () @@ -35,6 +35,7 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck double _oldHeadingAccuracy; CLLocationAccuracy _oldHorizontalAccuracy; double _oldZoom; + double _oldPitch; } - (instancetype)initWithFrame:(CGRect)frame @@ -88,6 +89,42 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck if (CLLocationCoordinate2DIsValid(self.annotation.coordinate)) { (_mapView.userTrackingMode == MGLUserTrackingModeFollowWithCourse) ? [self drawPuck] : [self drawDot]; + [self updatePitch]; + } +} + +- (void)updatePitch +{ + if (self.mapView.camera.pitch && (self.mapView.camera.pitch != _oldPitch)) + { + CATransform3D t = CATransform3DRotate(CATransform3DIdentity, MGLRadiansFromDegrees(self.mapView.camera.pitch), 1.0, 0, 0); + self.layer.sublayerTransform = t; + + [self updateFaux3DEffect]; + + _oldPitch = self.mapView.camera.pitch; + } +} + +- (void)updateFaux3DEffect +{ + CGFloat pitch = MGLRadiansFromDegrees(self.mapView.camera.pitch); + + if (_puckDot) + { + _puckDot.shadowOffset = CGSizeMake(0, fmaxf(pitch * 10.f, 1.f)); + _puckDot.shadowRadius = fmaxf(pitch * 5.f, 0.75f); + } + + if (_dotBorderLayer) + { + _dotBorderLayer.shadowOffset = CGSizeMake(0.f, pitch * 10.f); + _dotBorderLayer.shadowRadius = fmaxf(pitch * 5.f, 3.f); + } + + if (_dotLayer) + { + _dotLayer.zPosition = pitch * 2.f; } } @@ -103,8 +140,6 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck _haloLayer = nil; _dotBorderLayer = nil; _dotLayer = nil; - - _puckModeActivated = YES; } // background dot (white with black shadow) @@ -114,9 +149,17 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck _puckDot = [self circleLayerWithSize:MGLUserLocationAnnotationPuckSize]; _puckDot.backgroundColor = [[UIColor whiteColor] CGColor]; _puckDot.shadowColor = [[UIColor blackColor] CGColor]; - _puckDot.shadowOffset = CGSizeMake(0, 1); - _puckDot.shadowRadius = 1; - _puckDot.shadowOpacity = 0.1; + _puckDot.shadowOpacity = 0.25; + + if (self.mapView.camera.pitch) + { + [self updateFaux3DEffect]; + } + else + { + _puckDot.shadowOffset = CGSizeMake(0, 1); + _puckDot.shadowRadius = 0.75; + } [self.layer addSublayer:_puckDot]; } @@ -137,10 +180,11 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck [self.layer addSublayer:_puckArrow]; } - if (self.mapView.pitch) + if ( ! _puckModeActivated) { - CATransform3D t = CATransform3DRotate(CATransform3DIdentity, MGLRadiansFromDegrees(self.mapView.pitch), 1.0, 0, 0); - self.layer.sublayerTransform = t; + _puckModeActivated = YES; + + [self updateFaux3DEffect]; } } @@ -167,10 +211,6 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck _puckDot = nil; _puckArrow = nil; - - _puckModeActivated = NO; - - self.layer.sublayerTransform = CATransform3DIdentity; } // update heading indicator @@ -277,6 +317,7 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck _haloLayer = [self circleLayerWithSize:MGLUserLocationAnnotationHaloSize]; _haloLayer.backgroundColor = [_mapView.tintColor CGColor]; _haloLayer.allowsGroupOpacity = NO; + _haloLayer.zPosition = -0.1f; // set defaults for the animations CAAnimationGroup *animationGroup = [self loopingAnimationGroupWithDuration:3.0]; @@ -305,10 +346,18 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck _dotBorderLayer = [self circleLayerWithSize:MGLUserLocationAnnotationDotSize]; _dotBorderLayer.backgroundColor = [[UIColor whiteColor] CGColor]; _dotBorderLayer.shadowColor = [[UIColor blackColor] CGColor]; - _dotBorderLayer.shadowOffset = CGSizeMake(0, 0); - _dotBorderLayer.shadowRadius = 3; _dotBorderLayer.shadowOpacity = 0.25; - + + if (self.mapView.camera.pitch) + { + [self updateFaux3DEffect]; + } + else + { + _dotBorderLayer.shadowOffset = CGSizeMake(0, 0); + _dotBorderLayer.shadowRadius = 3; + } + [self.layer addSublayer:_dotBorderLayer]; } @@ -341,6 +390,13 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck [self.layer addSublayer:_dotLayer]; } + + if (_puckModeActivated) + { + _puckModeActivated = NO; + + [self updateFaux3DEffect]; + } } - (CALayer *)circleLayerWithSize:(CGFloat)layerSize From b162d2cafab89f43bddd5289c5be3815b3abb0f0 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Thu, 10 Sep 2015 19:29:13 -0400 Subject: [PATCH 044/156] [iOS] Remove unneccessary pitch check Fix case where moving the tilted dot off-screen, changing the pitch to 0, and then moving the dot back on screen would not reset the pitch of the dot. --- platform/ios/MGLUserLocationAnnotationView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/ios/MGLUserLocationAnnotationView.m b/platform/ios/MGLUserLocationAnnotationView.m index 22c1d00f1..b477b1088 100644 --- a/platform/ios/MGLUserLocationAnnotationView.m +++ b/platform/ios/MGLUserLocationAnnotationView.m @@ -95,7 +95,7 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck - (void)updatePitch { - if (self.mapView.camera.pitch && (self.mapView.camera.pitch != _oldPitch)) + if (self.mapView.camera.pitch != _oldPitch) { CATransform3D t = CATransform3DRotate(CATransform3DIdentity, MGLRadiansFromDegrees(self.mapView.camera.pitch), 1.0, 0, 0); self.layer.sublayerTransform = t; From 26a5d128b46febc1ca2ed41e468c59c66d90af1d Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Wed, 26 Aug 2015 11:14:08 -0400 Subject: [PATCH 045/156] increase precision for coordinate conversions This fixes the earthquakes while panning at high zoom levels. Cherry-picked from 9607171612c4a40e41eddaff5230ad571571a5b9 on the perspective-improved-gestures branch. --- src/mbgl/map/transform_state.cpp | 31 +++++++++++++++---------------- src/mbgl/map/transform_state.hpp | 8 ++++---- src/mbgl/util/mat4.cpp | 2 +- src/mbgl/util/tile_coordinate.hpp | 12 ++++++------ src/mbgl/util/vec4.cpp | 2 +- 5 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index c672ca5de..e37f10dc6 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -157,21 +157,21 @@ float TransformState::getPitch() const { #pragma mark - Projection -float TransformState::lngX(float lng) const { +double TransformState::lngX(double lng) const { return (180.0f + lng) * worldSize() / 360.0f; } -float TransformState::latY(float lat) const { - float y_ = 180.0f / M_PI * std::log(std::tan(M_PI / 4 + lat * M_PI / 360.0f)); +double TransformState::latY(double lat) const { + double y_ = 180.0f / M_PI * std::log(std::tan(M_PI / 4 + lat * M_PI / 360.0f)); return (180.0f - y_) * worldSize() / 360.0f; } -float TransformState::xLng(float x_, float worldSize_) const { +double TransformState::xLng(double x_, double worldSize_) const { return x_ * 360.0f / worldSize_ - 180.0f; } -float TransformState::yLat(float y_, float worldSize_) const { - float y2 = 180.0f - y_ * 360.0f / worldSize_; +double TransformState::yLat(double y_, double worldSize_) const { + double y2 = 180.0f - y_ * 360.0f / worldSize_; return 360.0f / M_PI * std::atan(std::exp(y2 * M_PI / 180.0f)) - 90.0f; } @@ -245,17 +245,16 @@ TileCoordinate TransformState::pointToCoordinate(const vec2 point) const matrix::transformMat4(coord0, point0, inverted); matrix::transformMat4(coord1, point1, inverted); - float w0 = coord0[3]; - float w1 = coord1[3]; - float x0 = coord0[0] / w0; - float x1 = coord1[0] / w1; - float y0 = coord0[1] / w0; - float y1 = coord1[1] / w1; - float z0 = coord0[2] / w0; - float z1 = coord1[2] / w1; + double w0 = coord0[3]; + double w1 = coord1[3]; + double x0 = coord0[0] / w0; + double x1 = coord1[0] / w1; + double y0 = coord0[1] / w0; + double y1 = coord1[1] / w1; + double z0 = coord0[2] / w0; + double z1 = coord1[2] / w1; - - float t = z0 == z1 ? 0 : (targetZ - z0) / (z1 - z0); + double t = z0 == z1 ? 0 : (targetZ - z0) / (z1 - z0); return { util::interpolate(x0, x1, t), util::interpolate(y0, y1, t), tileZoom }; } diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp index d4b46f04b..c3e1072c9 100644 --- a/src/mbgl/map/transform_state.hpp +++ b/src/mbgl/map/transform_state.hpp @@ -79,10 +79,10 @@ private: // logical dimensions uint16_t width = 0, height = 0; - float xLng(float x, float worldSize) const; - float yLat(float y, float worldSize) const; - float lngX(float lon) const; - float latY(float lat) const; + double xLng(double x, double worldSize) const; + double yLat(double y, double worldSize) const; + double lngX(double lon) const; + double latY(double lat) const; float zoomScale(float zoom) const; float worldSize() const; diff --git a/src/mbgl/util/mat4.cpp b/src/mbgl/util/mat4.cpp index 123c8464f..0934cd081 100644 --- a/src/mbgl/util/mat4.cpp +++ b/src/mbgl/util/mat4.cpp @@ -46,7 +46,7 @@ void matrix::identity(mat4& out) { } bool matrix::invert(mat4& out, mat4& a) { - float a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3], + double a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3], a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7], a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11], a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15], diff --git a/src/mbgl/util/tile_coordinate.hpp b/src/mbgl/util/tile_coordinate.hpp index 0f5f0dcb8..836539b5b 100644 --- a/src/mbgl/util/tile_coordinate.hpp +++ b/src/mbgl/util/tile_coordinate.hpp @@ -6,15 +6,15 @@ namespace mbgl { struct TileCoordinate { - float column; - float row; - float zoom; + double column; + double row; + double zoom; - TileCoordinate(float column_, float row_, float zoom_) : + TileCoordinate(double column_, double row_, double zoom_) : column(column_), row(row_), zoom(zoom_) {} - TileCoordinate zoomTo(float targetZoom) { - float scale = std::pow(2, targetZoom - zoom); + TileCoordinate zoomTo(double targetZoom) { + double scale = std::pow(2, targetZoom - zoom); return { column * scale, row * scale, targetZoom }; } diff --git a/src/mbgl/util/vec4.cpp b/src/mbgl/util/vec4.cpp index 415b15d80..bee4eaf97 100644 --- a/src/mbgl/util/vec4.cpp +++ b/src/mbgl/util/vec4.cpp @@ -25,7 +25,7 @@ using namespace mbgl; void matrix::transformMat4(vec4& out, vec4& a, mat4& m) { - float x = a[0], y = a[1], z = a[2], w = a[3]; + double x = a[0], y = a[1], z = a[2], w = a[3]; out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w; out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w; out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w; From f8ed28cca0ba160d658958f7b0f8a3312fa62d23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Thu, 10 Sep 2015 13:39:47 -0700 Subject: [PATCH 046/156] Increased precision of coordinate conversion methods Fixes #2230. --- src/mbgl/map/transform_state.cpp | 16 ++++++++-------- src/mbgl/map/transform_state.hpp | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index e37f10dc6..ac3988dc5 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -175,7 +175,7 @@ double TransformState::yLat(double y_, double worldSize_) const { return 360.0f / M_PI * std::atan(std::exp(y2 * M_PI / 180.0f)) - 90.0f; } -float TransformState::zoomScale(float zoom) const { +double TransformState::zoomScale(double zoom) const { return std::pow(2.0f, zoom); } @@ -192,8 +192,8 @@ LatLng TransformState::pointToLatLng(const vec2 point) const { } TileCoordinate TransformState::latLngToCoordinate(const LatLng& latLng) const { - const float tileZoom = getIntegerZoom(); - const float k = zoomScale(tileZoom) / worldSize(); + const double tileZoom = getZoom(); + const double k = zoomScale(tileZoom) / worldSize(); return { lngX(latLng.longitude) * k, latY(latLng.latitude) * k, @@ -202,12 +202,12 @@ TileCoordinate TransformState::latLngToCoordinate(const LatLng& latLng) const { } LatLng TransformState::coordinateToLatLng(const TileCoordinate& coord) const { - const float worldSize_ = zoomScale(coord.zoom); + const double worldSize_ = zoomScale(coord.zoom); LatLng latLng = { yLat(coord.row, worldSize_), xLng(coord.column, worldSize_) }; - while (latLng.longitude < 180.0f) latLng.longitude += 360.0f; + while (latLng.longitude < -180.0f) latLng.longitude += 360.0f; while (latLng.longitude > 180.0f) latLng.longitude -= 360.0f; return latLng; } @@ -223,7 +223,7 @@ vec2 TransformState::coordinateToPoint(const TileCoordinate& coord) cons TileCoordinate TransformState::pointToCoordinate(const vec2 point) const { float targetZ = 0; - const float tileZoom = getIntegerZoom(); + const double tileZoom = getZoom(); mat4 mat = coordinatePointMatrix(tileZoom); @@ -259,11 +259,11 @@ TileCoordinate TransformState::pointToCoordinate(const vec2 point) const return { util::interpolate(x0, x1, t), util::interpolate(y0, y1, t), tileZoom }; } -mat4 TransformState::coordinatePointMatrix(float z) const { +mat4 TransformState::coordinatePointMatrix(double z) const { mat4 proj; getProjMatrix(proj); float s = util::tileSize * scale / std::pow(2, z); - matrix::scale(proj, proj, s , s, 1); + matrix::scale(proj, proj, s, s, 1); matrix::multiply(proj, getPixelMatrix(), proj); return proj; } diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp index c3e1072c9..6fcd35ffa 100644 --- a/src/mbgl/map/transform_state.hpp +++ b/src/mbgl/map/transform_state.hpp @@ -83,10 +83,10 @@ private: double yLat(double y, double worldSize) const; double lngX(double lon) const; double latY(double lat) const; - float zoomScale(float zoom) const; + double zoomScale(double zoom) const; float worldSize() const; - mat4 coordinatePointMatrix(float z) const; + mat4 coordinatePointMatrix(double z) const; mat4 getPixelMatrix() const; private: From b10ae77765795a216ff6633d19cb8a184a9f1301 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Fri, 11 Sep 2015 16:34:10 -0400 Subject: [PATCH 047/156] [iOS] Fix MGLPolyline documentation typo --- include/mbgl/ios/MGLPolyline.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mbgl/ios/MGLPolyline.h b/include/mbgl/ios/MGLPolyline.h index 7cbbadeca..07c5286c8 100644 --- a/include/mbgl/ios/MGLPolyline.h +++ b/include/mbgl/ios/MGLPolyline.h @@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN /** The `MGLPolyline` class represents a shape consisting of one or more points that define connecting line segments. The points are connected end-to-end in the order they are provided. The first and last points are not connected to each other. */ @interface MGLPolyline : MGLMultiPoint -/** Creates and returns an `MGLPolygon` object from the specified set of coordinates. +/** Creates and returns an `MGLPolyline` object from the specified set of coordinates. * @param coords The array of coordinates defining the shape. The data in this array is copied to the new object. * @param count The number of items in the _`coords`_ array. * @return A new polyline object. */ From b72acf5dc5e92369e7b33b12c7e41c2515c3ff94 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Fri, 11 Sep 2015 15:33:17 -0700 Subject: [PATCH 048/156] bump podspec to 2.1.0-pre.4 --- ios/Mapbox-iOS-SDK.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Mapbox-iOS-SDK.podspec b/ios/Mapbox-iOS-SDK.podspec index 449d4ce1d..fce1a602d 100644 --- a/ios/Mapbox-iOS-SDK.podspec +++ b/ios/Mapbox-iOS-SDK.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |m| m.name = 'Mapbox-iOS-SDK' - m.version = '2.1.0-pre.3-symbols' + m.version = '2.1.0-pre.4-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 bindings.' From be29ad1c101b848054167ad60901694abd68bdcb Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Fri, 11 Sep 2015 15:34:43 -0700 Subject: [PATCH 049/156] [publish ios-v2.1.0-pre.4] From 8d6b9696bf3cea0cf8c3beaf9dfb48c7d376d925 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Thu, 10 Sep 2015 14:05:16 +0300 Subject: [PATCH 050/156] [shader] Moved 'a_pos' GL attribute to Shader Avoids duplicated code in all derived classes. --- src/mbgl/shader/box_shader.cpp | 1 - src/mbgl/shader/box_shader.hpp | 1 - src/mbgl/shader/circle_shader.cpp | 1 - src/mbgl/shader/circle_shader.hpp | 3 --- src/mbgl/shader/dot_shader.cpp | 1 - src/mbgl/shader/dot_shader.hpp | 3 --- src/mbgl/shader/icon_shader.cpp | 1 - src/mbgl/shader/icon_shader.hpp | 1 - src/mbgl/shader/line_shader.cpp | 1 - src/mbgl/shader/line_shader.hpp | 1 - src/mbgl/shader/linepattern_shader.cpp | 1 - src/mbgl/shader/linepattern_shader.hpp | 1 - src/mbgl/shader/linesdf_shader.cpp | 1 - src/mbgl/shader/linesdf_shader.hpp | 1 - src/mbgl/shader/outline_shader.cpp | 1 - src/mbgl/shader/outline_shader.hpp | 3 --- src/mbgl/shader/pattern_shader.cpp | 1 - src/mbgl/shader/pattern_shader.hpp | 3 --- src/mbgl/shader/plain_shader.cpp | 1 - src/mbgl/shader/plain_shader.hpp | 3 --- src/mbgl/shader/raster_shader.cpp | 1 - src/mbgl/shader/raster_shader.hpp | 3 --- src/mbgl/shader/sdf_shader.cpp | 1 - src/mbgl/shader/sdf_shader.hpp | 1 - src/mbgl/shader/shader.cpp | 2 ++ src/mbgl/shader/shader.hpp | 7 ++++++- 26 files changed, 8 insertions(+), 37 deletions(-) diff --git a/src/mbgl/shader/box_shader.cpp b/src/mbgl/shader/box_shader.cpp index 2676223a9..5c290718e 100644 --- a/src/mbgl/shader/box_shader.cpp +++ b/src/mbgl/shader/box_shader.cpp @@ -12,7 +12,6 @@ CollisionBoxShader::CollisionBoxShader() shaders[BOX_SHADER].vertex, shaders[BOX_SHADER].fragment ) { - a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos")); a_extrude = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_extrude")); a_data = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data")); } diff --git a/src/mbgl/shader/box_shader.hpp b/src/mbgl/shader/box_shader.hpp index 5c84d8906..832d3e1c0 100644 --- a/src/mbgl/shader/box_shader.hpp +++ b/src/mbgl/shader/box_shader.hpp @@ -18,7 +18,6 @@ public: Uniform u_maxzoom = {"u_maxzoom", *this}; protected: - int32_t a_pos = -1; int32_t a_extrude = -1; int32_t a_data = -1; }; diff --git a/src/mbgl/shader/circle_shader.cpp b/src/mbgl/shader/circle_shader.cpp index 074f92d68..dc8558d10 100644 --- a/src/mbgl/shader/circle_shader.cpp +++ b/src/mbgl/shader/circle_shader.cpp @@ -12,7 +12,6 @@ CircleShader::CircleShader() shaders[CIRCLE_SHADER].vertex, shaders[CIRCLE_SHADER].fragment ) { - a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos")); } void CircleShader::bind(char *offset) { diff --git a/src/mbgl/shader/circle_shader.hpp b/src/mbgl/shader/circle_shader.hpp index 545a0baad..ce7bb2d20 100644 --- a/src/mbgl/shader/circle_shader.hpp +++ b/src/mbgl/shader/circle_shader.hpp @@ -17,9 +17,6 @@ public: Uniform> u_color = {"u_color", *this}; Uniform u_size = {"u_size", *this}; Uniform u_blur = {"u_blur", *this}; - -private: - int32_t a_pos = -1; }; } diff --git a/src/mbgl/shader/dot_shader.cpp b/src/mbgl/shader/dot_shader.cpp index 57a60cc51..67c463944 100644 --- a/src/mbgl/shader/dot_shader.cpp +++ b/src/mbgl/shader/dot_shader.cpp @@ -12,7 +12,6 @@ DotShader::DotShader() shaders[DOT_SHADER].vertex, shaders[DOT_SHADER].fragment ) { - a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos")); } void DotShader::bind(char *offset) { diff --git a/src/mbgl/shader/dot_shader.hpp b/src/mbgl/shader/dot_shader.hpp index 2c4176f36..51263a731 100644 --- a/src/mbgl/shader/dot_shader.hpp +++ b/src/mbgl/shader/dot_shader.hpp @@ -16,9 +16,6 @@ public: Uniform> u_color = {"u_color", *this}; Uniform u_size = {"u_size", *this}; Uniform u_blur = {"u_blur", *this}; - -private: - int32_t a_pos = -1; }; } diff --git a/src/mbgl/shader/icon_shader.cpp b/src/mbgl/shader/icon_shader.cpp index 0f626ec9e..1084ab308 100644 --- a/src/mbgl/shader/icon_shader.cpp +++ b/src/mbgl/shader/icon_shader.cpp @@ -12,7 +12,6 @@ IconShader::IconShader() shaders[ICON_SHADER].vertex, shaders[ICON_SHADER].fragment ) { - a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos")); a_offset = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_offset")); a_data1 = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data1")); a_data2 = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data2")); diff --git a/src/mbgl/shader/icon_shader.hpp b/src/mbgl/shader/icon_shader.hpp index 18b0fce37..20d3ebf5c 100644 --- a/src/mbgl/shader/icon_shader.hpp +++ b/src/mbgl/shader/icon_shader.hpp @@ -25,7 +25,6 @@ public: Uniform u_extra = {"u_extra", *this}; private: - int32_t a_pos = -1; int32_t a_offset = -1; int32_t a_data1 = -1; int32_t a_data2 = -1; diff --git a/src/mbgl/shader/line_shader.cpp b/src/mbgl/shader/line_shader.cpp index c2364c9be..66dff81c9 100644 --- a/src/mbgl/shader/line_shader.cpp +++ b/src/mbgl/shader/line_shader.cpp @@ -12,7 +12,6 @@ LineShader::LineShader() shaders[LINE_SHADER].vertex, shaders[LINE_SHADER].fragment ) { - a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos")); a_data = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data")); } diff --git a/src/mbgl/shader/line_shader.hpp b/src/mbgl/shader/line_shader.hpp index 0572cac88..1a4289ded 100644 --- a/src/mbgl/shader/line_shader.hpp +++ b/src/mbgl/shader/line_shader.hpp @@ -22,7 +22,6 @@ public: UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this}; private: - int32_t a_pos = -1; int32_t a_data = -1; }; diff --git a/src/mbgl/shader/linepattern_shader.cpp b/src/mbgl/shader/linepattern_shader.cpp index 7bfd1412d..65404cb11 100644 --- a/src/mbgl/shader/linepattern_shader.cpp +++ b/src/mbgl/shader/linepattern_shader.cpp @@ -12,7 +12,6 @@ LinepatternShader::LinepatternShader() shaders[LINEPATTERN_SHADER].vertex, shaders[LINEPATTERN_SHADER].fragment ) { - a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos")); a_data = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data")); } diff --git a/src/mbgl/shader/linepattern_shader.hpp b/src/mbgl/shader/linepattern_shader.hpp index dce065a0d..a06135180 100644 --- a/src/mbgl/shader/linepattern_shader.hpp +++ b/src/mbgl/shader/linepattern_shader.hpp @@ -30,7 +30,6 @@ public: UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this}; private: - int32_t a_pos = -1; int32_t a_data = -1; }; } diff --git a/src/mbgl/shader/linesdf_shader.cpp b/src/mbgl/shader/linesdf_shader.cpp index bd2137de3..a08c99c74 100644 --- a/src/mbgl/shader/linesdf_shader.cpp +++ b/src/mbgl/shader/linesdf_shader.cpp @@ -12,7 +12,6 @@ LineSDFShader::LineSDFShader() shaders[LINESDF_SHADER].vertex, shaders[LINESDF_SHADER].fragment ) { - a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos")); a_data = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data")); } diff --git a/src/mbgl/shader/linesdf_shader.hpp b/src/mbgl/shader/linesdf_shader.hpp index 9928d5b30..4d08916cd 100644 --- a/src/mbgl/shader/linesdf_shader.hpp +++ b/src/mbgl/shader/linesdf_shader.hpp @@ -29,7 +29,6 @@ public: UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this}; private: - int32_t a_pos = -1; int32_t a_data = -1; }; diff --git a/src/mbgl/shader/outline_shader.cpp b/src/mbgl/shader/outline_shader.cpp index ee2a6bcd4..1d2c3667f 100644 --- a/src/mbgl/shader/outline_shader.cpp +++ b/src/mbgl/shader/outline_shader.cpp @@ -12,7 +12,6 @@ OutlineShader::OutlineShader() shaders[OUTLINE_SHADER].vertex, shaders[OUTLINE_SHADER].fragment ) { - a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos")); } void OutlineShader::bind(char *offset) { diff --git a/src/mbgl/shader/outline_shader.hpp b/src/mbgl/shader/outline_shader.hpp index f3e8175fd..9b086594b 100644 --- a/src/mbgl/shader/outline_shader.hpp +++ b/src/mbgl/shader/outline_shader.hpp @@ -15,9 +15,6 @@ public: UniformMatrix<4> u_matrix = {"u_matrix", *this}; Uniform> u_color = {"u_color", *this}; Uniform> u_world = {"u_world", *this}; - -private: - int32_t a_pos = -1; }; } diff --git a/src/mbgl/shader/pattern_shader.cpp b/src/mbgl/shader/pattern_shader.cpp index 66369d528..b5883b956 100644 --- a/src/mbgl/shader/pattern_shader.cpp +++ b/src/mbgl/shader/pattern_shader.cpp @@ -12,7 +12,6 @@ PatternShader::PatternShader() shaders[PATTERN_SHADER].vertex, shaders[PATTERN_SHADER].fragment ) { - a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos")); } void PatternShader::bind(char *offset) { diff --git a/src/mbgl/shader/pattern_shader.hpp b/src/mbgl/shader/pattern_shader.hpp index 9fc8dcfa0..5090a453e 100644 --- a/src/mbgl/shader/pattern_shader.hpp +++ b/src/mbgl/shader/pattern_shader.hpp @@ -22,9 +22,6 @@ public: Uniform u_image = {"u_image", *this}; UniformMatrix<3> u_patternmatrix_a = {"u_patternmatrix_a", *this}; UniformMatrix<3> u_patternmatrix_b = {"u_patternmatrix_b", *this}; - -private: - int32_t a_pos = -1; }; } diff --git a/src/mbgl/shader/plain_shader.cpp b/src/mbgl/shader/plain_shader.cpp index 93dbb42a5..bb719f47d 100644 --- a/src/mbgl/shader/plain_shader.cpp +++ b/src/mbgl/shader/plain_shader.cpp @@ -12,7 +12,6 @@ PlainShader::PlainShader() shaders[PLAIN_SHADER].vertex, shaders[PLAIN_SHADER].fragment ) { - a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos")); } void PlainShader::bind(char *offset) { diff --git a/src/mbgl/shader/plain_shader.hpp b/src/mbgl/shader/plain_shader.hpp index 051501c3c..266600024 100644 --- a/src/mbgl/shader/plain_shader.hpp +++ b/src/mbgl/shader/plain_shader.hpp @@ -14,9 +14,6 @@ public: UniformMatrix<4> u_matrix = {"u_matrix", *this}; Uniform> u_color = {"u_color", *this}; - -private: - int32_t a_pos = -1; }; } diff --git a/src/mbgl/shader/raster_shader.cpp b/src/mbgl/shader/raster_shader.cpp index 2d6954920..ce03488ac 100644 --- a/src/mbgl/shader/raster_shader.cpp +++ b/src/mbgl/shader/raster_shader.cpp @@ -12,7 +12,6 @@ RasterShader::RasterShader() shaders[RASTER_SHADER].vertex, shaders[RASTER_SHADER].fragment ) { - a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos")); } void RasterShader::bind(char *offset) { diff --git a/src/mbgl/shader/raster_shader.hpp b/src/mbgl/shader/raster_shader.hpp index 8cf97055a..e869fb741 100644 --- a/src/mbgl/shader/raster_shader.hpp +++ b/src/mbgl/shader/raster_shader.hpp @@ -21,9 +21,6 @@ public: Uniform u_saturation_factor = {"u_saturation_factor", *this}; Uniform u_contrast_factor = {"u_contrast_factor", *this}; Uniform> u_spin_weights = {"u_spin_weights", *this}; - -private: - int32_t a_pos = -1; }; } diff --git a/src/mbgl/shader/sdf_shader.cpp b/src/mbgl/shader/sdf_shader.cpp index ca1dab58d..7b729a458 100644 --- a/src/mbgl/shader/sdf_shader.cpp +++ b/src/mbgl/shader/sdf_shader.cpp @@ -12,7 +12,6 @@ SDFShader::SDFShader() shaders[SDF_SHADER].vertex, shaders[SDF_SHADER].fragment ) { - a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos")); a_offset = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_offset")); a_data1 = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data1")); a_data2 = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data2")); diff --git a/src/mbgl/shader/sdf_shader.hpp b/src/mbgl/shader/sdf_shader.hpp index 181788ab1..f8e0aef2b 100644 --- a/src/mbgl/shader/sdf_shader.hpp +++ b/src/mbgl/shader/sdf_shader.hpp @@ -27,7 +27,6 @@ public: Uniform u_extra = {"u_extra", *this}; protected: - int32_t a_pos = -1; int32_t a_offset = -1; int32_t a_data1 = -1; int32_t a_data2 = -1; diff --git a/src/mbgl/shader/shader.cpp b/src/mbgl/shader/shader.cpp index 6210c1c32..1e3df1bbc 100644 --- a/src/mbgl/shader/shader.cpp +++ b/src/mbgl/shader/shader.cpp @@ -97,6 +97,8 @@ Shader::Shader(const char *name_, const GLchar *vertSource, const GLchar *fragSo MBGL_CHECK_ERROR(glDeleteShader(vertShader)); MBGL_CHECK_ERROR(glDetachShader(program, fragShader)); MBGL_CHECK_ERROR(glDeleteShader(fragShader)); + + a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos")); } diff --git a/src/mbgl/shader/shader.hpp b/src/mbgl/shader/shader.hpp index b3d9b4e46..2a1cf39fe 100644 --- a/src/mbgl/shader/shader.hpp +++ b/src/mbgl/shader/shader.hpp @@ -1,10 +1,12 @@ #ifndef MBGL_RENDERER_SHADER #define MBGL_RENDERER_SHADER +#include +#include + #include #include #include -#include namespace mbgl { @@ -19,6 +21,9 @@ public: return program; } +protected: + GLint a_pos = -1; + private: bool compileShader(uint32_t *shader, uint32_t type, const char *source); }; From 2156aa35ca96f9dd05166fd6b012f09eaaa5b934 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Thu, 10 Sep 2015 14:46:38 +0300 Subject: [PATCH 051/156] [shader] bind() is now a pure virtual - Shader::bind() now receives a GLbyte* - BUFFER_OFFSET now uses GLbyte --- src/mbgl/geometry/vao.cpp | 4 ++-- src/mbgl/geometry/vao.hpp | 10 +++++----- src/mbgl/renderer/bucket.hpp | 4 +++- src/mbgl/renderer/circle_bucket.cpp | 4 ++-- src/mbgl/renderer/debug_bucket.cpp | 4 ++-- src/mbgl/renderer/fill_bucket.cpp | 12 ++++++------ src/mbgl/renderer/line_bucket.cpp | 12 ++++++------ src/mbgl/renderer/painter_clipping.cpp | 2 +- src/mbgl/renderer/painter_debug.cpp | 2 +- src/mbgl/renderer/raster_bucket.cpp | 2 +- src/mbgl/renderer/symbol_bucket.cpp | 14 +++++++------- src/mbgl/shader/box_shader.cpp | 2 +- src/mbgl/shader/box_shader.hpp | 3 ++- src/mbgl/shader/circle_shader.cpp | 2 +- src/mbgl/shader/circle_shader.hpp | 2 +- src/mbgl/shader/dot_shader.cpp | 2 +- src/mbgl/shader/dot_shader.hpp | 2 +- src/mbgl/shader/icon_shader.cpp | 2 +- src/mbgl/shader/icon_shader.hpp | 2 +- src/mbgl/shader/line_shader.cpp | 2 +- src/mbgl/shader/line_shader.hpp | 2 +- src/mbgl/shader/linepattern_shader.cpp | 2 +- src/mbgl/shader/linepattern_shader.hpp | 2 +- src/mbgl/shader/linesdf_shader.cpp | 2 +- src/mbgl/shader/linesdf_shader.hpp | 2 +- src/mbgl/shader/outline_shader.cpp | 2 +- src/mbgl/shader/outline_shader.hpp | 2 +- src/mbgl/shader/pattern_shader.cpp | 2 +- src/mbgl/shader/pattern_shader.hpp | 2 +- src/mbgl/shader/plain_shader.cpp | 2 +- src/mbgl/shader/plain_shader.hpp | 2 +- src/mbgl/shader/raster_shader.cpp | 2 +- src/mbgl/shader/raster_shader.hpp | 2 +- src/mbgl/shader/sdf_shader.cpp | 4 ++-- src/mbgl/shader/sdf_shader.hpp | 6 ++---- src/mbgl/shader/shader.hpp | 2 ++ 36 files changed, 65 insertions(+), 62 deletions(-) diff --git a/src/mbgl/geometry/vao.cpp b/src/mbgl/geometry/vao.cpp index ef4cb26db..1330a057f 100644 --- a/src/mbgl/geometry/vao.cpp +++ b/src/mbgl/geometry/vao.cpp @@ -69,7 +69,7 @@ void VertexArrayObject::bindVertexArrayObject() { } void VertexArrayObject::verifyBinding(Shader &shader, GLuint vertexBuffer, GLuint elementsBuffer, - char *offset) { + GLbyte *offset) { if (bound_shader != shader.getID()) { throw std::runtime_error(std::string("trying to rebind VAO to another shader from " + util::toString(bound_shader) + "(" + bound_shader_name + ") to " + @@ -84,7 +84,7 @@ void VertexArrayObject::verifyBinding(Shader &shader, GLuint vertexBuffer, GLuin } void VertexArrayObject::storeBinding(Shader &shader, GLuint vertexBuffer, GLuint elementsBuffer, - char *offset) { + GLbyte *offset) { bound_shader = shader.getID(); bound_shader_name = shader.name; bound_offset = offset; diff --git a/src/mbgl/geometry/vao.hpp b/src/mbgl/geometry/vao.hpp index e512a3e48..bd845b1e3 100644 --- a/src/mbgl/geometry/vao.hpp +++ b/src/mbgl/geometry/vao.hpp @@ -18,7 +18,7 @@ public: ~VertexArrayObject(); template - inline void bind(Shader& shader, VertexBuffer &vertexBuffer, char *offset) { + inline void bind(Shader& shader, VertexBuffer &vertexBuffer, GLbyte *offset) { bindVertexArrayObject(); if (bound_shader == 0) { vertexBuffer.bind(); @@ -32,7 +32,7 @@ public: } template - inline void bind(Shader& shader, VertexBuffer &vertexBuffer, ElementsBuffer &elementsBuffer, char *offset) { + inline void bind(Shader& shader, VertexBuffer &vertexBuffer, ElementsBuffer &elementsBuffer, GLbyte *offset) { bindVertexArrayObject(); if (bound_shader == 0) { vertexBuffer.bind(); @@ -52,8 +52,8 @@ public: private: void bindVertexArrayObject(); - void storeBinding(Shader &shader, GLuint vertexBuffer, GLuint elementsBuffer, char *offset); - void verifyBinding(Shader &shader, GLuint vertexBuffer, GLuint elementsBuffer, char *offset); + void storeBinding(Shader &shader, GLuint vertexBuffer, GLuint elementsBuffer, GLbyte *offset); + void verifyBinding(Shader &shader, GLuint vertexBuffer, GLuint elementsBuffer, GLbyte *offset); GLuint vao = 0; @@ -63,7 +63,7 @@ private: const char *bound_shader_name = ""; GLuint bound_vertex_buffer = 0; GLuint bound_elements_buffer = 0; - char *bound_offset = 0; + GLbyte *bound_offset = 0; }; } diff --git a/src/mbgl/renderer/bucket.hpp b/src/mbgl/renderer/bucket.hpp index eb02f32eb..a1dbdeeed 100644 --- a/src/mbgl/renderer/bucket.hpp +++ b/src/mbgl/renderer/bucket.hpp @@ -1,13 +1,15 @@ #ifndef MBGL_RENDERER_BUCKET #define MBGL_RENDERER_BUCKET +#include #include #include #include #include -#define BUFFER_OFFSET(i) ((char*)nullptr + (i)) +#define BUFFER_OFFSET_0 ((GLbyte*)nullptr) +#define BUFFER_OFFSET(i) ((BUFFER_OFFSET_0) + (i)) namespace mbgl { diff --git a/src/mbgl/renderer/circle_bucket.cpp b/src/mbgl/renderer/circle_bucket.cpp index fde04df29..a6a439d86 100644 --- a/src/mbgl/renderer/circle_bucket.cpp +++ b/src/mbgl/renderer/circle_bucket.cpp @@ -74,8 +74,8 @@ void CircleBucket::addGeometry(const GeometryCollection& geometryCollection) { } void CircleBucket::drawCircles(CircleShader& shader) { - char* vertexIndex = BUFFER_OFFSET(vertexStart_ * vertexBuffer_.itemSize); - char* elementsIndex = BUFFER_OFFSET(elementsStart_ * elementsBuffer_.itemSize); + GLbyte *vertexIndex = BUFFER_OFFSET(vertexStart_ * vertexBuffer_.itemSize); + GLbyte *elementsIndex = BUFFER_OFFSET(elementsStart_ * elementsBuffer_.itemSize); for (auto& group : triangleGroups_) { assert(group); diff --git a/src/mbgl/renderer/debug_bucket.cpp b/src/mbgl/renderer/debug_bucket.cpp index 1d9b9fb6d..161412f0d 100644 --- a/src/mbgl/renderer/debug_bucket.cpp +++ b/src/mbgl/renderer/debug_bucket.cpp @@ -23,11 +23,11 @@ void DebugBucket::render(Painter& painter, const StyleLayer&, const TileID&, con } void DebugBucket::drawLines(PlainShader& shader) { - array.bind(shader, fontBuffer, BUFFER_OFFSET(0)); + array.bind(shader, fontBuffer, BUFFER_OFFSET_0); MBGL_CHECK_ERROR(glDrawArrays(GL_LINES, 0, (GLsizei)(fontBuffer.index()))); } void DebugBucket::drawPoints(PlainShader& shader) { - array.bind(shader, fontBuffer, BUFFER_OFFSET(0)); + array.bind(shader, fontBuffer, BUFFER_OFFSET_0); MBGL_CHECK_ERROR(glDrawArrays(GL_POINTS, 0, (GLsizei)(fontBuffer.index()))); } diff --git a/src/mbgl/renderer/fill_bucket.cpp b/src/mbgl/renderer/fill_bucket.cpp index 151e4c4a4..1828ae0a2 100644 --- a/src/mbgl/renderer/fill_bucket.cpp +++ b/src/mbgl/renderer/fill_bucket.cpp @@ -216,8 +216,8 @@ bool FillBucket::hasData() const { } void FillBucket::drawElements(PlainShader& shader) { - char *vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize); - char *elements_index = BUFFER_OFFSET(triangle_elements_start * triangleElementsBuffer.itemSize); + GLbyte *vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize); + GLbyte *elements_index = BUFFER_OFFSET(triangle_elements_start * triangleElementsBuffer.itemSize); for (auto& group : triangleGroups) { assert(group); group->array[0].bind(shader, vertexBuffer, triangleElementsBuffer, vertex_index); @@ -228,8 +228,8 @@ void FillBucket::drawElements(PlainShader& shader) { } void FillBucket::drawElements(PatternShader& shader) { - char *vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize); - char *elements_index = BUFFER_OFFSET(triangle_elements_start * triangleElementsBuffer.itemSize); + GLbyte *vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize); + GLbyte *elements_index = BUFFER_OFFSET(triangle_elements_start * triangleElementsBuffer.itemSize); for (auto& group : triangleGroups) { assert(group); group->array[1].bind(shader, vertexBuffer, triangleElementsBuffer, vertex_index); @@ -240,8 +240,8 @@ void FillBucket::drawElements(PatternShader& shader) { } void FillBucket::drawVertices(OutlineShader& shader) { - char *vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize); - char *elements_index = BUFFER_OFFSET(line_elements_start * lineElementsBuffer.itemSize); + GLbyte *vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize); + GLbyte *elements_index = BUFFER_OFFSET(line_elements_start * lineElementsBuffer.itemSize); for (auto& group : lineGroups) { assert(group); group->array[0].bind(shader, vertexBuffer, lineElementsBuffer, vertex_index); diff --git a/src/mbgl/renderer/line_bucket.cpp b/src/mbgl/renderer/line_bucket.cpp index 24bda6d0a..f0d52fa51 100644 --- a/src/mbgl/renderer/line_bucket.cpp +++ b/src/mbgl/renderer/line_bucket.cpp @@ -405,8 +405,8 @@ bool LineBucket::hasData() const { } void LineBucket::drawLines(LineShader& shader) { - char* vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize); - char* elements_index = BUFFER_OFFSET(triangle_elements_start * triangleElementsBuffer.itemSize); + GLbyte* vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize); + GLbyte* elements_index = BUFFER_OFFSET(triangle_elements_start * triangleElementsBuffer.itemSize); for (auto& group : triangleGroups) { assert(group); if (!group->elements_length) { @@ -421,8 +421,8 @@ void LineBucket::drawLines(LineShader& shader) { } void LineBucket::drawLineSDF(LineSDFShader& shader) { - char* vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize); - char* elements_index = BUFFER_OFFSET(triangle_elements_start * triangleElementsBuffer.itemSize); + GLbyte* vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize); + GLbyte* elements_index = BUFFER_OFFSET(triangle_elements_start * triangleElementsBuffer.itemSize); for (auto& group : triangleGroups) { assert(group); if (!group->elements_length) { @@ -437,8 +437,8 @@ void LineBucket::drawLineSDF(LineSDFShader& shader) { } void LineBucket::drawLinePatterns(LinepatternShader& shader) { - char* vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize); - char* elements_index = BUFFER_OFFSET(triangle_elements_start * triangleElementsBuffer.itemSize); + GLbyte* vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize); + GLbyte* elements_index = BUFFER_OFFSET(triangle_elements_start * triangleElementsBuffer.itemSize); for (auto& group : triangleGroups) { assert(group); if (!group->elements_length) { diff --git a/src/mbgl/renderer/painter_clipping.cpp b/src/mbgl/renderer/painter_clipping.cpp index 332d2876f..59e40fefe 100644 --- a/src/mbgl/renderer/painter_clipping.cpp +++ b/src/mbgl/renderer/painter_clipping.cpp @@ -16,7 +16,7 @@ void Painter::drawClippingMasks(const std::set& sources) { config.colorMask = { false, false, false, false }; config.depthRange = { 1.0f, 1.0f }; - coveringPlainArray.bind(*plainShader, tileStencilBuffer, BUFFER_OFFSET(0)); + coveringPlainArray.bind(*plainShader, tileStencilBuffer, BUFFER_OFFSET_0); for (const auto& source : sources) { source->drawClippingMasks(*this); diff --git a/src/mbgl/renderer/painter_debug.cpp b/src/mbgl/renderer/painter_debug.cpp index f4f3a19cb..bc4055324 100644 --- a/src/mbgl/renderer/painter_debug.cpp +++ b/src/mbgl/renderer/painter_debug.cpp @@ -59,7 +59,7 @@ void Painter::renderDebugFrame(const mat4 &matrix) { plainShader->u_matrix = matrix; // draw tile outline - tileBorderArray.bind(*plainShader, tileBorderBuffer, BUFFER_OFFSET(0)); + tileBorderArray.bind(*plainShader, tileBorderBuffer, BUFFER_OFFSET_0); plainShader->u_color = {{ 1.0f, 0.0f, 0.0f, 1.0f }}; lineWidth(4.0f * data.pixelRatio); MBGL_CHECK_ERROR(glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)tileBorderBuffer.index())); diff --git a/src/mbgl/renderer/raster_bucket.cpp b/src/mbgl/renderer/raster_bucket.cpp index 70cc1065d..cf72f860a 100644 --- a/src/mbgl/renderer/raster_bucket.cpp +++ b/src/mbgl/renderer/raster_bucket.cpp @@ -30,7 +30,7 @@ bool RasterBucket::setImage(std::unique_ptr image) { void RasterBucket::drawRaster(RasterShader& shader, StaticVertexBuffer &vertices, VertexArrayObject &array) { raster.bind(true); shader.u_image = 0; - array.bind(shader, vertices, BUFFER_OFFSET(0)); + array.bind(shader, vertices, BUFFER_OFFSET_0); MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLES, 0, (GLsizei)vertices.index())); } diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp index 7665fd9a6..11b3bf3d0 100644 --- a/src/mbgl/renderer/symbol_bucket.cpp +++ b/src/mbgl/renderer/symbol_bucket.cpp @@ -565,8 +565,8 @@ void SymbolBucket::swapRenderData() { } void SymbolBucket::drawGlyphs(SDFShader &shader) { - char *vertex_index = BUFFER_OFFSET(0); - char *elements_index = BUFFER_OFFSET(0); + GLbyte *vertex_index = BUFFER_OFFSET_0; + GLbyte *elements_index = BUFFER_OFFSET_0; auto& text = renderData->text; for (auto &group : text.groups) { assert(group); @@ -578,8 +578,8 @@ void SymbolBucket::drawGlyphs(SDFShader &shader) { } void SymbolBucket::drawIcons(SDFShader &shader) { - char *vertex_index = BUFFER_OFFSET(0); - char *elements_index = BUFFER_OFFSET(0); + GLbyte *vertex_index = BUFFER_OFFSET_0; + GLbyte *elements_index = BUFFER_OFFSET_0; auto& icon = renderData->icon; for (auto &group : icon.groups) { assert(group); @@ -591,8 +591,8 @@ void SymbolBucket::drawIcons(SDFShader &shader) { } void SymbolBucket::drawIcons(IconShader &shader) { - char *vertex_index = BUFFER_OFFSET(0); - char *elements_index = BUFFER_OFFSET(0); + GLbyte *vertex_index = BUFFER_OFFSET_0; + GLbyte *elements_index = BUFFER_OFFSET_0; auto& icon = renderData->icon; for (auto &group : icon.groups) { assert(group); @@ -604,7 +604,7 @@ void SymbolBucket::drawIcons(IconShader &shader) { } void SymbolBucket::drawCollisionBoxes(CollisionBoxShader &shader) { - char *vertex_index = BUFFER_OFFSET(0); + GLbyte *vertex_index = BUFFER_OFFSET_0; auto& collisionBox = renderData->collisionBox; for (auto &group : collisionBox.groups) { group->array[0].bind(shader, collisionBox.vertices, vertex_index); diff --git a/src/mbgl/shader/box_shader.cpp b/src/mbgl/shader/box_shader.cpp index 5c290718e..ffcce815f 100644 --- a/src/mbgl/shader/box_shader.cpp +++ b/src/mbgl/shader/box_shader.cpp @@ -16,7 +16,7 @@ CollisionBoxShader::CollisionBoxShader() a_data = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data")); } -void CollisionBoxShader::bind(char *offset) { +void CollisionBoxShader::bind(GLbyte *offset) { const int stride = 12; MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos)); diff --git a/src/mbgl/shader/box_shader.hpp b/src/mbgl/shader/box_shader.hpp index 832d3e1c0..20d1deec6 100644 --- a/src/mbgl/shader/box_shader.hpp +++ b/src/mbgl/shader/box_shader.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace mbgl { @@ -10,7 +11,7 @@ class CollisionBoxShader : public Shader { public: CollisionBoxShader(); - void bind(char *offset); + void bind(GLbyte *offset) final; UniformMatrix<4> u_matrix = {"u_matrix", *this}; Uniform u_scale = {"u_scale", *this}; diff --git a/src/mbgl/shader/circle_shader.cpp b/src/mbgl/shader/circle_shader.cpp index dc8558d10..8fa10191b 100644 --- a/src/mbgl/shader/circle_shader.cpp +++ b/src/mbgl/shader/circle_shader.cpp @@ -14,7 +14,7 @@ CircleShader::CircleShader() ) { } -void CircleShader::bind(char *offset) { +void CircleShader::bind(GLbyte *offset) { MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos)); MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 4, offset)); } diff --git a/src/mbgl/shader/circle_shader.hpp b/src/mbgl/shader/circle_shader.hpp index ce7bb2d20..58314e837 100644 --- a/src/mbgl/shader/circle_shader.hpp +++ b/src/mbgl/shader/circle_shader.hpp @@ -10,7 +10,7 @@ class CircleShader : public Shader { public: CircleShader(); - void bind(char *offset); + void bind(GLbyte *offset) final; UniformMatrix<4> u_matrix = {"u_matrix", *this}; UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this}; diff --git a/src/mbgl/shader/dot_shader.cpp b/src/mbgl/shader/dot_shader.cpp index 67c463944..baec3678b 100644 --- a/src/mbgl/shader/dot_shader.cpp +++ b/src/mbgl/shader/dot_shader.cpp @@ -14,7 +14,7 @@ DotShader::DotShader() ) { } -void DotShader::bind(char *offset) { +void DotShader::bind(GLbyte *offset) { MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos)); MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 8, offset)); } diff --git a/src/mbgl/shader/dot_shader.hpp b/src/mbgl/shader/dot_shader.hpp index 51263a731..45ac1c26c 100644 --- a/src/mbgl/shader/dot_shader.hpp +++ b/src/mbgl/shader/dot_shader.hpp @@ -10,7 +10,7 @@ class DotShader : public Shader { public: DotShader(); - void bind(char *offset); + void bind(GLbyte *offset) final; UniformMatrix<4> u_matrix = {"u_matrix", *this}; Uniform> u_color = {"u_color", *this}; diff --git a/src/mbgl/shader/icon_shader.cpp b/src/mbgl/shader/icon_shader.cpp index 1084ab308..736bb47e7 100644 --- a/src/mbgl/shader/icon_shader.cpp +++ b/src/mbgl/shader/icon_shader.cpp @@ -17,7 +17,7 @@ IconShader::IconShader() a_data2 = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data2")); } -void IconShader::bind(char *offset) { +void IconShader::bind(GLbyte *offset) { const int stride = 16; MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos)); diff --git a/src/mbgl/shader/icon_shader.hpp b/src/mbgl/shader/icon_shader.hpp index 20d3ebf5c..a0e9397f0 100644 --- a/src/mbgl/shader/icon_shader.hpp +++ b/src/mbgl/shader/icon_shader.hpp @@ -10,7 +10,7 @@ class IconShader : public Shader { public: IconShader(); - void bind(char *offset); + void bind(GLbyte *offset) final; UniformMatrix<4> u_matrix = {"u_matrix", *this}; UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this}; diff --git a/src/mbgl/shader/line_shader.cpp b/src/mbgl/shader/line_shader.cpp index 66dff81c9..1e2306939 100644 --- a/src/mbgl/shader/line_shader.cpp +++ b/src/mbgl/shader/line_shader.cpp @@ -15,7 +15,7 @@ LineShader::LineShader() a_data = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data")); } -void LineShader::bind(char *offset) { +void LineShader::bind(GLbyte *offset) { MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos)); MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 8, offset + 0)); diff --git a/src/mbgl/shader/line_shader.hpp b/src/mbgl/shader/line_shader.hpp index 1a4289ded..77866e89d 100644 --- a/src/mbgl/shader/line_shader.hpp +++ b/src/mbgl/shader/line_shader.hpp @@ -10,7 +10,7 @@ class LineShader : public Shader { public: LineShader(); - void bind(char *offset); + void bind(GLbyte *offset) final; UniformMatrix<4> u_matrix = {"u_matrix", *this}; UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this}; diff --git a/src/mbgl/shader/linepattern_shader.cpp b/src/mbgl/shader/linepattern_shader.cpp index 65404cb11..4d416d506 100644 --- a/src/mbgl/shader/linepattern_shader.cpp +++ b/src/mbgl/shader/linepattern_shader.cpp @@ -15,7 +15,7 @@ LinepatternShader::LinepatternShader() a_data = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data")); } -void LinepatternShader::bind(char *offset) { +void LinepatternShader::bind(GLbyte *offset) { MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos)); MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 8, offset + 0)); diff --git a/src/mbgl/shader/linepattern_shader.hpp b/src/mbgl/shader/linepattern_shader.hpp index a06135180..335281c19 100644 --- a/src/mbgl/shader/linepattern_shader.hpp +++ b/src/mbgl/shader/linepattern_shader.hpp @@ -10,7 +10,7 @@ class LinepatternShader : public Shader { public: LinepatternShader(); - void bind(char *offset); + void bind(GLbyte *offset) final; UniformMatrix<4> u_matrix = {"u_matrix", *this}; UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this}; diff --git a/src/mbgl/shader/linesdf_shader.cpp b/src/mbgl/shader/linesdf_shader.cpp index a08c99c74..1a56bb106 100644 --- a/src/mbgl/shader/linesdf_shader.cpp +++ b/src/mbgl/shader/linesdf_shader.cpp @@ -15,7 +15,7 @@ LineSDFShader::LineSDFShader() a_data = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data")); } -void LineSDFShader::bind(char *offset) { +void LineSDFShader::bind(GLbyte *offset) { MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos)); MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 8, offset + 0)); diff --git a/src/mbgl/shader/linesdf_shader.hpp b/src/mbgl/shader/linesdf_shader.hpp index 4d08916cd..1996d16f1 100644 --- a/src/mbgl/shader/linesdf_shader.hpp +++ b/src/mbgl/shader/linesdf_shader.hpp @@ -10,7 +10,7 @@ class LineSDFShader : public Shader { public: LineSDFShader(); - void bind(char *offset); + void bind(GLbyte *offset) final; UniformMatrix<4> u_matrix = {"u_matrix", *this}; UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this}; diff --git a/src/mbgl/shader/outline_shader.cpp b/src/mbgl/shader/outline_shader.cpp index 1d2c3667f..74453468b 100644 --- a/src/mbgl/shader/outline_shader.cpp +++ b/src/mbgl/shader/outline_shader.cpp @@ -14,7 +14,7 @@ OutlineShader::OutlineShader() ) { } -void OutlineShader::bind(char *offset) { +void OutlineShader::bind(GLbyte *offset) { MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos)); MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 0, offset)); } diff --git a/src/mbgl/shader/outline_shader.hpp b/src/mbgl/shader/outline_shader.hpp index 9b086594b..9de01e214 100644 --- a/src/mbgl/shader/outline_shader.hpp +++ b/src/mbgl/shader/outline_shader.hpp @@ -10,7 +10,7 @@ class OutlineShader : public Shader { public: OutlineShader(); - void bind(char *offset); + void bind(GLbyte *offset) final; UniformMatrix<4> u_matrix = {"u_matrix", *this}; Uniform> u_color = {"u_color", *this}; diff --git a/src/mbgl/shader/pattern_shader.cpp b/src/mbgl/shader/pattern_shader.cpp index b5883b956..d6ddab8e2 100644 --- a/src/mbgl/shader/pattern_shader.cpp +++ b/src/mbgl/shader/pattern_shader.cpp @@ -14,7 +14,7 @@ PatternShader::PatternShader() ) { } -void PatternShader::bind(char *offset) { +void PatternShader::bind(GLbyte *offset) { MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos)); MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 0, offset)); } diff --git a/src/mbgl/shader/pattern_shader.hpp b/src/mbgl/shader/pattern_shader.hpp index 5090a453e..28cd341d8 100644 --- a/src/mbgl/shader/pattern_shader.hpp +++ b/src/mbgl/shader/pattern_shader.hpp @@ -10,7 +10,7 @@ class PatternShader : public Shader { public: PatternShader(); - void bind(char *offset); + void bind(GLbyte *offset) final; UniformMatrix<4> u_matrix = {"u_matrix", *this}; Uniform> u_pattern_tl_a = {"u_pattern_tl_a", *this}; diff --git a/src/mbgl/shader/plain_shader.cpp b/src/mbgl/shader/plain_shader.cpp index bb719f47d..52fef07c0 100644 --- a/src/mbgl/shader/plain_shader.cpp +++ b/src/mbgl/shader/plain_shader.cpp @@ -14,7 +14,7 @@ PlainShader::PlainShader() ) { } -void PlainShader::bind(char *offset) { +void PlainShader::bind(GLbyte *offset) { MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos)); MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 0, offset)); } diff --git a/src/mbgl/shader/plain_shader.hpp b/src/mbgl/shader/plain_shader.hpp index 266600024..cf2bcc38c 100644 --- a/src/mbgl/shader/plain_shader.hpp +++ b/src/mbgl/shader/plain_shader.hpp @@ -10,7 +10,7 @@ class PlainShader : public Shader { public: PlainShader(); - void bind(char *offset); + void bind(GLbyte *offset) final; UniformMatrix<4> u_matrix = {"u_matrix", *this}; Uniform> u_color = {"u_color", *this}; diff --git a/src/mbgl/shader/raster_shader.cpp b/src/mbgl/shader/raster_shader.cpp index ce03488ac..b8496230b 100644 --- a/src/mbgl/shader/raster_shader.cpp +++ b/src/mbgl/shader/raster_shader.cpp @@ -14,7 +14,7 @@ RasterShader::RasterShader() ) { } -void RasterShader::bind(char *offset) { +void RasterShader::bind(GLbyte *offset) { MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos)); MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 0, offset)); } diff --git a/src/mbgl/shader/raster_shader.hpp b/src/mbgl/shader/raster_shader.hpp index e869fb741..705efec99 100644 --- a/src/mbgl/shader/raster_shader.hpp +++ b/src/mbgl/shader/raster_shader.hpp @@ -10,7 +10,7 @@ class RasterShader : public Shader { public: RasterShader(); - void bind(char *offset); + void bind(GLbyte *offset) final; UniformMatrix<4> u_matrix = {"u_matrix", *this}; Uniform u_image = {"u_image", *this}; diff --git a/src/mbgl/shader/sdf_shader.cpp b/src/mbgl/shader/sdf_shader.cpp index 7b729a458..144ba6c47 100644 --- a/src/mbgl/shader/sdf_shader.cpp +++ b/src/mbgl/shader/sdf_shader.cpp @@ -17,7 +17,7 @@ SDFShader::SDFShader() a_data2 = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data2")); } -void SDFGlyphShader::bind(char *offset) { +void SDFGlyphShader::bind(GLbyte *offset) { const int stride = 16; MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos)); @@ -33,7 +33,7 @@ void SDFGlyphShader::bind(char *offset) { MBGL_CHECK_ERROR(glVertexAttribPointer(a_data2, 4, GL_UNSIGNED_BYTE, false, stride, offset + 12)); } -void SDFIconShader::bind(char *offset) { +void SDFIconShader::bind(GLbyte *offset) { const int stride = 16; MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos)); diff --git a/src/mbgl/shader/sdf_shader.hpp b/src/mbgl/shader/sdf_shader.hpp index f8e0aef2b..a56f3b2eb 100644 --- a/src/mbgl/shader/sdf_shader.hpp +++ b/src/mbgl/shader/sdf_shader.hpp @@ -10,8 +10,6 @@ class SDFShader : public Shader { public: SDFShader(); - virtual void bind(char *offset) = 0; - UniformMatrix<4> u_matrix = {"u_matrix", *this}; UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this}; Uniform> u_color = {"u_color", *this}; @@ -34,12 +32,12 @@ protected: class SDFGlyphShader : public SDFShader { public: - void bind(char *offset); + void bind(GLbyte *offset) final; }; class SDFIconShader : public SDFShader { public: - void bind(char *offset); + void bind(GLbyte *offset) final; }; } diff --git a/src/mbgl/shader/shader.hpp b/src/mbgl/shader/shader.hpp index 2a1cf39fe..9b150c37e 100644 --- a/src/mbgl/shader/shader.hpp +++ b/src/mbgl/shader/shader.hpp @@ -21,6 +21,8 @@ public: return program; } + virtual void bind(GLbyte *offset) = 0; + protected: GLint a_pos = -1; From 9ff66acf61c33c4b073ea44d0932807e9c7632be Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Mon, 14 Sep 2015 14:54:54 +0300 Subject: [PATCH 052/156] Typo fix in README.md Fixed URL typo for react-native-mapbox-gl. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c54afa28f..00432f17c 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ An OpenGL ES-based renderer for [Mapbox Vector Tiles](https://www.mapbox.com/blo If you want to use products _based on_ Mapbox GL, check out: - [Mapbox Mobile](http://mapbox.com/mobile) — iOS and Android native development libraries for vector maps in apps -- [`react-native-mapbox-gl`](https://github.com/mapbox/react-native-mapbox-gl`) — React Native library for vector maps in apps +- [`react-native-mapbox-gl`](https://github.com/mapbox/react-native-mapbox-gl) — React Native library for vector maps in apps - [`qmapboxgl`](https://github.com/tmpsantos/qmapboxgl) — Qt library for vector map rendering -- From 6db8e65394838e3269351cf393a8820cea1326a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Fri, 21 Aug 2015 14:33:17 -0400 Subject: [PATCH 053/156] don't validate the program it's not in a state where validation always succeeds with all drivers, e.g. because textures might not be attached yet --- src/mbgl/shader/shader.cpp | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/src/mbgl/shader/shader.cpp b/src/mbgl/shader/shader.cpp index 1e3df1bbc..ed4cb729b 100644 --- a/src/mbgl/shader/shader.cpp +++ b/src/mbgl/shader/shader.cpp @@ -67,31 +67,6 @@ Shader::Shader(const char *name_, const GLchar *vertSource, const GLchar *fragSo } } - { - // Validate program - GLint status; - MBGL_CHECK_ERROR(glValidateProgram(program)); - - MBGL_CHECK_ERROR(glGetProgramiv(program, GL_VALIDATE_STATUS, &status)); - if (status == 0) { - GLint logLength; - MBGL_CHECK_ERROR(glGetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength)); - const auto log = std::make_unique(logLength); - if (logLength > 0) { - MBGL_CHECK_ERROR(glGetProgramInfoLog(program, logLength, &logLength, log.get())); - Log::Error(Event::Shader, "Program failed to validate: %s", log.get()); - } - - MBGL_CHECK_ERROR(glDeleteShader(vertShader)); - vertShader = 0; - MBGL_CHECK_ERROR(glDeleteShader(fragShader)); - fragShader = 0; - MBGL_CHECK_ERROR(glDeleteProgram(program)); - program = 0; - throw util::ShaderException(std::string { "Program " } + name + " failed to link: " + log.get()); - } - } - // Remove the compiled shaders; they are now part of the program. MBGL_CHECK_ERROR(glDetachShader(program, vertShader)); MBGL_CHECK_ERROR(glDeleteShader(vertShader)); From 5ef7011089e761dda0a26782c04dad9f61e65d34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Fri, 21 Aug 2015 14:34:06 -0400 Subject: [PATCH 054/156] don't delete the shaders before the program some GPU drivers have issues with deleting shader objects that are attached to programs. while this is allowed by the spec, it seems that some drivers are crashing nonetheless. --- src/mbgl/shader/shader.cpp | 14 ++++++-------- src/mbgl/shader/shader.hpp | 3 +++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/mbgl/shader/shader.cpp b/src/mbgl/shader/shader.cpp index ed4cb729b..c69518c8c 100644 --- a/src/mbgl/shader/shader.cpp +++ b/src/mbgl/shader/shader.cpp @@ -20,8 +20,6 @@ Shader::Shader(const char *name_, const GLchar *vertSource, const GLchar *fragSo program = MBGL_CHECK_ERROR(glCreateProgram()); - GLuint vertShader = 0; - GLuint fragShader = 0; if (!compileShader(&vertShader, GL_VERTEX_SHADER, vertSource)) { Log::Error(Event::Shader, "Vertex shader %s failed to compile: %s", name, vertSource); MBGL_CHECK_ERROR(glDeleteProgram(program)); @@ -67,12 +65,6 @@ Shader::Shader(const char *name_, const GLchar *vertSource, const GLchar *fragSo } } - // Remove the compiled shaders; they are now part of the program. - MBGL_CHECK_ERROR(glDetachShader(program, vertShader)); - MBGL_CHECK_ERROR(glDeleteShader(vertShader)); - MBGL_CHECK_ERROR(glDetachShader(program, fragShader)); - MBGL_CHECK_ERROR(glDeleteShader(fragShader)); - a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos")); } @@ -115,7 +107,13 @@ bool Shader::compileShader(GLuint *shader, GLenum type, const GLchar *source) { Shader::~Shader() { if (program) { + MBGL_CHECK_ERROR(glDetachShader(program, vertShader)); + MBGL_CHECK_ERROR(glDetachShader(program, fragShader)); MBGL_CHECK_ERROR(glDeleteProgram(program)); program = 0; + MBGL_CHECK_ERROR(glDeleteShader(vertShader)); + vertShader = 0; + MBGL_CHECK_ERROR(glDeleteShader(fragShader)); + fragShader = 0; } } diff --git a/src/mbgl/shader/shader.hpp b/src/mbgl/shader/shader.hpp index 9b150c37e..329022479 100644 --- a/src/mbgl/shader/shader.hpp +++ b/src/mbgl/shader/shader.hpp @@ -28,6 +28,9 @@ protected: private: bool compileShader(uint32_t *shader, uint32_t type, const char *source); + + uint32_t vertShader = 0; + uint32_t fragShader = 0; }; } From b9d34b55e2281ca151e187d67b1d546cfad0c6dd Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Mon, 14 Sep 2015 12:45:59 -0400 Subject: [PATCH 055/156] #2317 - README to set up and run Espresso testing --- android/java/MapboxGLAndroidSDKTestApp/README.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 android/java/MapboxGLAndroidSDKTestApp/README.md diff --git a/android/java/MapboxGLAndroidSDKTestApp/README.md b/android/java/MapboxGLAndroidSDKTestApp/README.md new file mode 100644 index 000000000..007a8b1d4 --- /dev/null +++ b/android/java/MapboxGLAndroidSDKTestApp/README.md @@ -0,0 +1,5 @@ +# Mapbox GL Test App + +## Testing + +TBD. From 4a11c312757fecf8609b858b54c58f4c2fe24b33 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Mon, 14 Sep 2015 12:51:40 -0400 Subject: [PATCH 056/156] #2317 - added testing dependencies --- android/java/MapboxGLAndroidSDKTestApp/build.gradle | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/android/java/MapboxGLAndroidSDKTestApp/build.gradle b/android/java/MapboxGLAndroidSDKTestApp/build.gradle index 46c95c21e..d39fdfbbe 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/build.gradle +++ b/android/java/MapboxGLAndroidSDKTestApp/build.gradle @@ -78,6 +78,11 @@ dependencies { compile 'com.android.support:support-v4:22.1.1' compile 'com.android.support:appcompat-v7:22.1.1' compile 'com.mapzen.android:lost:1.0.0' + + // Testing dependencies + androidTestCompile 'com.android.support.test:runner:0.3' + androidTestCompile 'com.android.support.test:rules:0.3' + androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2' } checkstyle { From 6d18a2dd6e2d7f040fdb2c6c13e67e98ecfbca80 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Mon, 14 Sep 2015 16:01:13 -0400 Subject: [PATCH 057/156] Bumped version to remove conflict with com.android.support:support-annotations versions for app (22.1.1) and test app (22.2.0). --- android/java/MapboxGLAndroidSDKTestApp/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/build.gradle b/android/java/MapboxGLAndroidSDKTestApp/build.gradle index d39fdfbbe..be49cff90 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/build.gradle +++ b/android/java/MapboxGLAndroidSDKTestApp/build.gradle @@ -74,9 +74,9 @@ dependencies { compile(project(':MapboxGLAndroidSDK')) { transitive = true } - compile 'com.android.support:support-annotations:22.1.1' - compile 'com.android.support:support-v4:22.1.1' - compile 'com.android.support:appcompat-v7:22.1.1' + compile 'com.android.support:support-annotations:22.2.0' + compile 'com.android.support:support-v4:22.2.0' + compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.mapzen.android:lost:1.0.0' // Testing dependencies From 67586c13fc5672aff4665cf1f66eab97deb9fae0 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Mon, 14 Sep 2015 16:08:00 -0400 Subject: [PATCH 058/156] Specify AndroidJUnitRunner as the default test instrumentation runner --- android/java/MapboxGLAndroidSDKTestApp/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/android/java/MapboxGLAndroidSDKTestApp/build.gradle b/android/java/MapboxGLAndroidSDKTestApp/build.gradle index be49cff90..48c17d1fe 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/build.gradle +++ b/android/java/MapboxGLAndroidSDKTestApp/build.gradle @@ -43,6 +43,9 @@ android { targetSdkVersion 22 versionCode 4 versionName "0.1.3" + + // Specify AndroidJUnitRunner as the default test instrumentation runner + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } compileOptions { From e95d0e030315a35aa0ec6d42597c1be99adf3307 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Mon, 14 Sep 2015 17:03:46 -0400 Subject: [PATCH 059/156] tests documentation --- .../java/MapboxGLAndroidSDKTestApp/README.md | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/README.md b/android/java/MapboxGLAndroidSDKTestApp/README.md index 007a8b1d4..87ea2eb13 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/README.md +++ b/android/java/MapboxGLAndroidSDKTestApp/README.md @@ -2,4 +2,43 @@ ## Testing -TBD. +### Run Espresso tests on a device + +This test project comes with all the required Android Testing Support Library dependencies +in the Gradle file. Tests are under the `app/src/androidTest` folder. + +Note that before running your tests, you might want to turn off animations on your test device. +It's a known issue that leaving system animations turned on in a test device +(window animation scale, transition animation scale, animator duration scale) +might cause unexpected results, or may lead tests to fail. + +To create a new run configuration: +* Click on Run -> Edit Configurations... +* Click on the plus sign and then on "Android Tests" +* Give a name to the configuration, e.g. `TestAppTests` +* Choose the `MapboxGLAndroidSDKTestApp` module +* Choose `android.support.test.runner.AndroidJUnitRunner` as the instrumentation runner +* Click OK to save the new configuration + +You can now run this configuration from the main toolbar dropdown menu. + +# Run Espresso tests on AWS Device Farm + +On a terminal, within `mapbox-gl-native/android/java`, +run the tests (`cC` stands for `connectedCheck`): + +``` +$ ./gradlew cC -p MapboxGLAndroidSDKTestApp +``` + +Then: +* Go to your AWS Console and choose Device Farm. +* Create a new project, e.g. `MapboxGLAndroidSDKTestApp` +* On step 1, upload the APK in `mapbox-gl-native/android/java/MapboxGLAndroidSDKTestApp/build/outputs/apk/MapboxGLAndroidSDKTestApp-debug-unaligned.apk` +* On step 2, choose Instrumentation, test filter is `com.mapbox.mapboxgl.testapp.MainActivityTest` and upload the APK in `mapbox-gl-native/android/java/MapboxGLAndroidSDKTestApp/build/outputs/apk/MapboxGLAndroidSDKTestApp-debug-androidTest-unaligned.apk` +* On step 3, choose a device pool. E.g. Top Devices +* On step 4, customize your device state (if needed) +* Finally, confirm the configuration and run the tests. + +If you have no tests for your app, or want to test some random user behaviour, +you can just choose "Built-in: Fuzz" in step 2. From 6f7aa10609258dfe34d1844d89cdb5dafaa24ea9 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Mon, 14 Sep 2015 17:04:10 -0400 Subject: [PATCH 060/156] one more exclude required for testing --- android/java/MapboxGLAndroidSDKTestApp/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/android/java/MapboxGLAndroidSDKTestApp/build.gradle b/android/java/MapboxGLAndroidSDKTestApp/build.gradle index 48c17d1fe..89b9ac90a 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/build.gradle +++ b/android/java/MapboxGLAndroidSDKTestApp/build.gradle @@ -56,6 +56,7 @@ android { packagingOptions { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' + exclude 'LICENSE.txt' } lintOptions { From 9a0d12e1422a82670300abcd6afeeaa2a8d216d5 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Mon, 14 Sep 2015 17:04:55 -0400 Subject: [PATCH 061/156] basic espresso testSanity() working locally and on was device farm --- .../com/mapbox/mapboxgl/testapp/BaseTest.java | 27 +++++++++++++++++++ .../mapboxgl/testapp/MainActivityTest.java | 27 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java create mode 100644 android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java new file mode 100644 index 000000000..d9801cf1e --- /dev/null +++ b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java @@ -0,0 +1,27 @@ +package com.mapbox.mapboxgl.testapp; + +import android.support.test.InstrumentationRegistry; +import android.test.ActivityInstrumentationTestCase2; + +import org.junit.Before; + +/** + * Base Espresso class for all tests, helps working with ActivityInstrumentationTestCase2 + */ +public class BaseTest + extends ActivityInstrumentationTestCase2 { + + private MainActivity mActivity; + + public BaseTest() { + super(MainActivity.class); + } + + @Before + public void setUp() throws Exception { + super.setUp(); + injectInstrumentation(InstrumentationRegistry.getInstrumentation()); + mActivity = getActivity(); + } + +} diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java new file mode 100644 index 000000000..07485875d --- /dev/null +++ b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java @@ -0,0 +1,27 @@ +package com.mapbox.mapboxgl.testapp; + +import org.junit.Test; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; + +/** + * Tests MainActivity + */ +public class MainActivityTest extends BaseTest { + + /* + * Note that we need to keep the `test` prefix if we want to be able to run these + * tests on AWS Device Farm, annotations are not enough: + * https://github.com/awslabs/aws-device-farm-sample-app-for-android/issues/5#issuecomment-138258444 + */ + + @Test + public void testSanity() { + onView(withId(R.id.layout_map)) + .check(matches(isDisplayed())); + } + +} From 5c74d202d3e0b603ce842c9e60eecc617a9cdbdd Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Mon, 14 Sep 2015 17:18:52 -0400 Subject: [PATCH 062/156] added info about Monkey --- .../java/MapboxGLAndroidSDKTestApp/README.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/README.md b/android/java/MapboxGLAndroidSDKTestApp/README.md index 87ea2eb13..6748b42c6 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/README.md +++ b/android/java/MapboxGLAndroidSDKTestApp/README.md @@ -2,7 +2,7 @@ ## Testing -### Run Espresso tests on a device +### Running Espresso tests on a device This test project comes with all the required Android Testing Support Library dependencies in the Gradle file. Tests are under the `app/src/androidTest` folder. @@ -22,7 +22,7 @@ To create a new run configuration: You can now run this configuration from the main toolbar dropdown menu. -# Run Espresso tests on AWS Device Farm +### Running Espresso tests on AWS Device Farm On a terminal, within `mapbox-gl-native/android/java`, run the tests (`cC` stands for `connectedCheck`): @@ -42,3 +42,17 @@ Then: If you have no tests for your app, or want to test some random user behaviour, you can just choose "Built-in: Fuzz" in step 2. + +### Running the UI/Application Exerciser Monkey + +Similar to the "Built-in: Fuzz" test mentioned above, Android provides +[Monkey](http://developer.android.com/tools/help/monkey.html), +"a program that runs on your emulator or device and generates pseudo-random streams of user events +such as clicks, touches, or gestures, as well as a number of system-level events." + +To exercise Monkey on the test app, install the package on the device (e.g. via Android Studio) +and then: + +``` +$ adb shell monkey -p com.mapbox.mapboxgl.testapp -v 500 +``` From 7d2f060887697b0ea4163672e438e997fedad048 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Mon, 14 Sep 2015 17:27:08 -0400 Subject: [PATCH 063/156] match the new annotations version --- android/java/MapboxGLAndroidSDKTestApp/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/android/java/MapboxGLAndroidSDKTestApp/build.gradle b/android/java/MapboxGLAndroidSDKTestApp/build.gradle index fea7691d2..69a068713 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/build.gradle +++ b/android/java/MapboxGLAndroidSDKTestApp/build.gradle @@ -95,6 +95,7 @@ dependencies { } // Testing dependencies + androidTestCompile 'com.android.support:support-annotations:23.0.1' androidTestCompile 'com.android.support.test:runner:0.3' androidTestCompile 'com.android.support.test:rules:0.3' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2' From 8dd8e019615e1ed36eddd328a99ee95b2391d350 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Mon, 14 Sep 2015 17:48:43 -0400 Subject: [PATCH 064/156] switch id to new layout mainMapView --- .../java/com/mapbox/mapboxgl/testapp/MainActivityTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java index 07485875d..1f786affd 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java @@ -20,7 +20,7 @@ public class MainActivityTest extends BaseTest { @Test public void testSanity() { - onView(withId(R.id.layout_map)) + onView(withId(R.id.mainMapView)) .check(matches(isDisplayed())); } From 0fa2461371741a1c35ec7c85b30cfbd94ed8556b Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Mon, 14 Sep 2015 18:20:47 -0700 Subject: [PATCH 065/156] update podspec for 2.1.0 final and no symbols --- ios/Mapbox-iOS-SDK.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Mapbox-iOS-SDK.podspec b/ios/Mapbox-iOS-SDK.podspec index fce1a602d..3fad85cf1 100644 --- a/ios/Mapbox-iOS-SDK.podspec +++ b/ios/Mapbox-iOS-SDK.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |m| m.name = 'Mapbox-iOS-SDK' - m.version = '2.1.0-pre.4-symbols' + m.version = '2.1.0' 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 bindings.' From ab1daf85ba3184c0c9308f21b3d8e496894b0373 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Mon, 14 Sep 2015 18:21:29 -0700 Subject: [PATCH 066/156] [publish ios-v2.1.0] From 6bfb18f075f5d7bbb05a01aa9519c0c553e2c5f2 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Mon, 14 Sep 2015 18:40:42 -0700 Subject: [PATCH 067/156] update changelog for ios-v2.1.0 --- CHANGELOG.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1b3e3003..f7ecd8cd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## iOS 2.1.0 + +- A two-finger vertical swipe now tilts the map into perspective mode. ([#2116](https://github.com/mapbox/mapbox-gl-native/pull/2116)) +- A new `MGLMapCamera` API allows you to transition multiple viewpoint properties, including rotation and pitch, simultaneously with an optional custom duration and timing function. ([#2193](https://github.com/mapbox/mapbox-gl-native/pull/2193)) +- A new user tracking mode, `MGLUserTrackingModeFollowWithCourse`, has been added for indicating the current direction of travel. ([#2068](https://github.com/mapbox/mapbox-gl-native/pull/2068)) +- Version 8 (`v8`) of the [Mapbox GL style spec](https://www.mapbox.com/mapbox-gl-style-spec/) is now required. If you are using a custom `v7` style, it needs to be upgraded using [this migrator script](https://github.com/mapbox/mapbox-gl-style-spec/blob/mb-pages/migrations/v7.js). ([#2052](https://github.com/mapbox/mapbox-gl-native/pull/2052)) +- Applications built with Mapbox GL no longer crash when Location Services launches them in background mode. ([#1821](https://github.com/mapbox/mapbox-gl-native/pull/1821), [#1869](https://github.com/mapbox/mapbox-gl-native/pull/1869)) +- Fixed a crash when adding annotations to an `MGLMapView` inside `-viewDidLoad`. ([#1874](https://github.com/mapbox/mapbox-gl-native/pull/1874)) +- The user location annotation view now indicates the location reading’s accuracy and the device’s heading. ([#2010](https://github.com/mapbox/mapbox-gl-native/pull/2010)) +- Eliminated linker warnings and errors when building against the iOS 9.0 SDK in Xcode 7. ([#1962](https://github.com/mapbox/mapbox-gl-native/pull/1962)) +- Worked around a bug in the iOS 9.0 SDK that caused a crash on launch. ([#1958](https://github.com/mapbox/mapbox-gl-native/pull/1958)) +- User location tracking no longer sends `MGLMapView` into an invalid region on iOS 9. ([#1925](https://github.com/mapbox/mapbox-gl-native/pull/1925)) +- Eliminated console spew in the iOS demo application that was related to Mapbox Metrics HTTP requests. ([#1937](https://github.com/mapbox/mapbox-gl-native/issues/1937)) +- Implemented `-[MGLMapView showAnnotations:animated:]`. ([#2050](https://github.com/mapbox/mapbox-gl-native/pull/2050)) +- Fixed a crash adding a shape annotation with zero points. ([#2098](https://github.com/mapbox/mapbox-gl-native/pull/2098)) +- Debug mode now displays information useful for debugging the label collision algorithm. ([#1808](https://github.com/mapbox/mapbox-gl-native/pull/1808)) +- Minor style updates. ([#1910](https://github.com/mapbox/mapbox-gl-native/pull/1910)) +- The CocoaPods pod now contains a `README.md` file. ([#1886](https://github.com/mapbox/mapbox-gl-native/pull/1886)) + ## iOS 2.0.0 Repackaging 2.0.0-pre.1 as it contained no issues. From 1f1b3fbbc213d5725d4bdbe5271de8fca617a05b Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Thu, 10 Sep 2015 15:16:19 +0300 Subject: [PATCH 068/156] [shader] Shaders vertex and fragments are now GLchar* --- scripts/build-shaders.py | 6 ++++-- src/mbgl/shader/shader.cpp | 16 ++++++++-------- src/mbgl/shader/shader.hpp | 11 ++++++----- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/scripts/build-shaders.py b/scripts/build-shaders.py index c1d7f7f28..3f3b77671 100755 --- a/scripts/build-shaders.py +++ b/scripts/build-shaders.py @@ -34,11 +34,13 @@ def write_header(): #ifndef MBGL_SHADER_SHADERS #define MBGL_SHADER_SHADERS +#include + namespace mbgl { struct shader_source { - const char *vertex; - const char *fragment; + const GLchar *vertex; + const GLchar *fragment; }; enum { diff --git a/src/mbgl/shader/shader.cpp b/src/mbgl/shader/shader.cpp index c69518c8c..e8deefc8f 100644 --- a/src/mbgl/shader/shader.cpp +++ b/src/mbgl/shader/shader.cpp @@ -14,20 +14,21 @@ using namespace mbgl; Shader::Shader(const char *name_, const GLchar *vertSource, const GLchar *fragSource) - : name(name_), - program(0) { + : name(name_) + , program(0) +{ util::stopwatch stopwatch("shader compilation", Event::Shader); program = MBGL_CHECK_ERROR(glCreateProgram()); - if (!compileShader(&vertShader, GL_VERTEX_SHADER, vertSource)) { + if (!compileShader(&vertShader, GL_VERTEX_SHADER, &vertSource)) { Log::Error(Event::Shader, "Vertex shader %s failed to compile: %s", name, vertSource); MBGL_CHECK_ERROR(glDeleteProgram(program)); program = 0; throw util::ShaderException(std::string { "Vertex shader " } + name + " failed to compile"); } - if (!compileShader(&fragShader, GL_FRAGMENT_SHADER, fragSource)) { + if (!compileShader(&fragShader, GL_FRAGMENT_SHADER, &fragSource)) { Log::Error(Event::Shader, "Fragment shader %s failed to compile: %s", name, fragSource); MBGL_CHECK_ERROR(glDeleteShader(vertShader)); vertShader = 0; @@ -69,13 +70,12 @@ Shader::Shader(const char *name_, const GLchar *vertSource, const GLchar *fragSo } -bool Shader::compileShader(GLuint *shader, GLenum type, const GLchar *source) { +bool Shader::compileShader(GLuint *shader, GLenum type, const GLchar *source[]) { GLint status; *shader = MBGL_CHECK_ERROR(glCreateShader(type)); - const GLchar *strings[] = { source }; - const GLsizei lengths[] = { static_cast(std::strlen(source)) }; - MBGL_CHECK_ERROR(glShaderSource(*shader, 1, strings, lengths)); + const GLsizei lengths = static_cast(std::strlen(*source)); + MBGL_CHECK_ERROR(glShaderSource(*shader, 1, source, &lengths)); MBGL_CHECK_ERROR(glCompileShader(*shader)); diff --git a/src/mbgl/shader/shader.hpp b/src/mbgl/shader/shader.hpp index 329022479..dab7cd852 100644 --- a/src/mbgl/shader/shader.hpp +++ b/src/mbgl/shader/shader.hpp @@ -12,9 +12,10 @@ namespace mbgl { class Shader : private util::noncopyable { public: - Shader(const char *name, const char *vertex, const char *fragment); + Shader(const GLchar *name, const GLchar *vertex, const GLchar *fragment); + ~Shader(); - const char *name; + const GLchar *name; uint32_t program; inline uint32_t getID() const { @@ -27,10 +28,10 @@ protected: GLint a_pos = -1; private: - bool compileShader(uint32_t *shader, uint32_t type, const char *source); + bool compileShader(GLuint *shader, GLenum type, const GLchar *source[]); - uint32_t vertShader = 0; - uint32_t fragShader = 0; + GLuint vertShader = 0; + GLuint fragShader = 0; }; } From b2fcde5e8b098cedfd6f772740ebdac56678d828 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Thu, 10 Sep 2015 17:45:02 +0300 Subject: [PATCH 069/156] [shader] GL types for all Shader attributes --- src/mbgl/shader/box_shader.cpp | 2 +- src/mbgl/shader/box_shader.hpp | 14 +++++------ src/mbgl/shader/circle_shader.hpp | 10 ++++---- src/mbgl/shader/dot_shader.hpp | 8 +++--- src/mbgl/shader/icon_shader.cpp | 2 +- src/mbgl/shader/icon_shader.hpp | 30 +++++++++++------------ src/mbgl/shader/line_shader.hpp | 18 +++++++------- src/mbgl/shader/linepattern_shader.hpp | 34 +++++++++++++------------- src/mbgl/shader/linesdf_shader.hpp | 32 ++++++++++++------------ src/mbgl/shader/outline_shader.hpp | 6 ++--- src/mbgl/shader/pattern_shader.hpp | 20 +++++++-------- src/mbgl/shader/plain_shader.hpp | 4 +-- src/mbgl/shader/raster_shader.hpp | 18 +++++++------- src/mbgl/shader/sdf_shader.hpp | 32 ++++++++++++------------ src/mbgl/shader/shader.hpp | 4 +-- src/mbgl/shader/uniform.cpp | 16 ++++++------ 16 files changed, 125 insertions(+), 125 deletions(-) diff --git a/src/mbgl/shader/box_shader.cpp b/src/mbgl/shader/box_shader.cpp index ffcce815f..beb5e15f9 100644 --- a/src/mbgl/shader/box_shader.cpp +++ b/src/mbgl/shader/box_shader.cpp @@ -17,7 +17,7 @@ CollisionBoxShader::CollisionBoxShader() } void CollisionBoxShader::bind(GLbyte *offset) { - const int stride = 12; + const GLint stride = 12; MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos)); MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, stride, offset + 0)); diff --git a/src/mbgl/shader/box_shader.hpp b/src/mbgl/shader/box_shader.hpp index 20d1deec6..19df2ca82 100644 --- a/src/mbgl/shader/box_shader.hpp +++ b/src/mbgl/shader/box_shader.hpp @@ -14,15 +14,15 @@ public: void bind(GLbyte *offset) final; UniformMatrix<4> u_matrix = {"u_matrix", *this}; - Uniform u_scale = {"u_scale", *this}; - Uniform u_zoom = {"u_zoom", *this}; - Uniform u_maxzoom = {"u_maxzoom", *this}; + Uniform u_scale = {"u_scale", *this}; + Uniform u_zoom = {"u_zoom", *this}; + Uniform u_maxzoom = {"u_maxzoom", *this}; protected: - int32_t a_extrude = -1; - int32_t a_data = -1; + GLint a_extrude = -1; + GLint a_data = -1; }; -} +} // namespace mbgl -#endif +#endif // MBGL_SHADER_BOX_SHADER diff --git a/src/mbgl/shader/circle_shader.hpp b/src/mbgl/shader/circle_shader.hpp index 58314e837..84f4ef99a 100644 --- a/src/mbgl/shader/circle_shader.hpp +++ b/src/mbgl/shader/circle_shader.hpp @@ -12,11 +12,11 @@ public: void bind(GLbyte *offset) final; - UniformMatrix<4> u_matrix = {"u_matrix", *this}; - UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this}; - Uniform> u_color = {"u_color", *this}; - Uniform u_size = {"u_size", *this}; - Uniform u_blur = {"u_blur", *this}; + UniformMatrix<4> u_matrix = {"u_matrix", *this}; + UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this}; + Uniform> u_color = {"u_color", *this}; + Uniform u_size = {"u_size", *this}; + Uniform u_blur = {"u_blur", *this}; }; } diff --git a/src/mbgl/shader/dot_shader.hpp b/src/mbgl/shader/dot_shader.hpp index 45ac1c26c..fe1541cf7 100644 --- a/src/mbgl/shader/dot_shader.hpp +++ b/src/mbgl/shader/dot_shader.hpp @@ -12,10 +12,10 @@ public: void bind(GLbyte *offset) final; - UniformMatrix<4> u_matrix = {"u_matrix", *this}; - Uniform> u_color = {"u_color", *this}; - Uniform u_size = {"u_size", *this}; - Uniform u_blur = {"u_blur", *this}; + UniformMatrix<4> u_matrix = {"u_matrix", *this}; + Uniform> u_color = {"u_color", *this}; + Uniform u_size = {"u_size", *this}; + Uniform u_blur = {"u_blur", *this}; }; } diff --git a/src/mbgl/shader/icon_shader.cpp b/src/mbgl/shader/icon_shader.cpp index 736bb47e7..a9b4be23e 100644 --- a/src/mbgl/shader/icon_shader.cpp +++ b/src/mbgl/shader/icon_shader.cpp @@ -18,7 +18,7 @@ IconShader::IconShader() } void IconShader::bind(GLbyte *offset) { - const int stride = 16; + const GLsizei stride = 16; MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos)); MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, stride, offset + 0)); diff --git a/src/mbgl/shader/icon_shader.hpp b/src/mbgl/shader/icon_shader.hpp index a0e9397f0..437fd859b 100644 --- a/src/mbgl/shader/icon_shader.hpp +++ b/src/mbgl/shader/icon_shader.hpp @@ -12,22 +12,22 @@ public: void bind(GLbyte *offset) final; - UniformMatrix<4> u_matrix = {"u_matrix", *this}; - UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this}; - Uniform u_zoom = {"u_zoom", *this}; - Uniform u_fadedist = {"u_fadedist", *this}; - Uniform u_minfadezoom = {"u_minfadezoom", *this}; - Uniform u_maxfadezoom = {"u_maxfadezoom", *this}; - Uniform u_fadezoom = {"u_fadezoom", *this}; - Uniform u_opacity = {"u_opacity", *this}; - Uniform> u_texsize = {"u_texsize", *this}; - Uniform u_skewed = {"u_skewed", *this}; - Uniform u_extra = {"u_extra", *this}; + UniformMatrix<4> u_matrix = {"u_matrix", *this}; + UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this}; + Uniform u_zoom = {"u_zoom", *this}; + Uniform u_fadedist = {"u_fadedist", *this}; + Uniform u_minfadezoom = {"u_minfadezoom", *this}; + Uniform u_maxfadezoom = {"u_maxfadezoom", *this}; + Uniform u_fadezoom = {"u_fadezoom", *this}; + Uniform u_opacity = {"u_opacity", *this}; + Uniform> u_texsize = {"u_texsize", *this}; + Uniform u_skewed = {"u_skewed", *this}; + Uniform u_extra = {"u_extra", *this}; -private: - int32_t a_offset = -1; - int32_t a_data1 = -1; - int32_t a_data2 = -1; +protected: + GLint a_offset = -1; + GLint a_data1 = -1; + GLint a_data2 = -1; }; } diff --git a/src/mbgl/shader/line_shader.hpp b/src/mbgl/shader/line_shader.hpp index 77866e89d..580035a07 100644 --- a/src/mbgl/shader/line_shader.hpp +++ b/src/mbgl/shader/line_shader.hpp @@ -12,17 +12,17 @@ public: void bind(GLbyte *offset) final; - UniformMatrix<4> u_matrix = {"u_matrix", *this}; - UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this}; - Uniform> u_color = {"u_color", *this}; - Uniform> u_linewidth = {"u_linewidth", *this}; - Uniform u_ratio = {"u_ratio", *this}; - Uniform u_blur = {"u_blur", *this}; - Uniform u_extra = {"u_extra", *this}; - UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this}; + UniformMatrix<4> u_matrix = {"u_matrix", *this}; + UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this}; + Uniform> u_color = {"u_color", *this}; + Uniform> u_linewidth = {"u_linewidth", *this}; + Uniform u_ratio = {"u_ratio", *this}; + Uniform u_blur = {"u_blur", *this}; + Uniform u_extra = {"u_extra", *this}; + UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this}; private: - int32_t a_data = -1; + GLint a_data = -1; }; diff --git a/src/mbgl/shader/linepattern_shader.hpp b/src/mbgl/shader/linepattern_shader.hpp index 335281c19..f2189d471 100644 --- a/src/mbgl/shader/linepattern_shader.hpp +++ b/src/mbgl/shader/linepattern_shader.hpp @@ -12,25 +12,25 @@ public: void bind(GLbyte *offset) final; - UniformMatrix<4> u_matrix = {"u_matrix", *this}; - UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this}; - Uniform> u_linewidth = {"u_linewidth", *this}; - Uniform> u_pattern_size_a = {"u_pattern_size_a", *this}; - Uniform> u_pattern_tl_a = {"u_pattern_tl_a", *this}; - Uniform> u_pattern_br_a = {"u_pattern_br_a", *this}; - Uniform> u_pattern_size_b = {"u_pattern_size_b", *this}; - Uniform> u_pattern_tl_b = {"u_pattern_tl_b", *this}; - Uniform> u_pattern_br_b = {"u_pattern_br_b", *this}; - Uniform u_ratio = {"u_ratio", *this}; - Uniform u_point = {"u_point", *this}; - Uniform u_blur = {"u_blur", *this}; - Uniform u_fade = {"u_fade", *this}; - Uniform u_opacity = {"u_opacity", *this}; - Uniform u_extra = {"u_extra", *this}; - UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this}; + UniformMatrix<4> u_matrix = {"u_matrix", *this}; + UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this}; + Uniform> u_linewidth = {"u_linewidth", *this}; + Uniform> u_pattern_size_a = {"u_pattern_size_a", *this}; + Uniform> u_pattern_tl_a = {"u_pattern_tl_a", *this}; + Uniform> u_pattern_br_a = {"u_pattern_br_a", *this}; + Uniform> u_pattern_size_b = {"u_pattern_size_b", *this}; + Uniform> u_pattern_tl_b = {"u_pattern_tl_b", *this}; + Uniform> u_pattern_br_b = {"u_pattern_br_b", *this}; + Uniform u_ratio = {"u_ratio", *this}; + Uniform u_point = {"u_point", *this}; + Uniform u_blur = {"u_blur", *this}; + Uniform u_fade = {"u_fade", *this}; + Uniform u_opacity = {"u_opacity", *this}; + Uniform u_extra = {"u_extra", *this}; + UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this}; private: - int32_t a_data = -1; + GLint a_data = -1; }; } diff --git a/src/mbgl/shader/linesdf_shader.hpp b/src/mbgl/shader/linesdf_shader.hpp index 1996d16f1..839494f79 100644 --- a/src/mbgl/shader/linesdf_shader.hpp +++ b/src/mbgl/shader/linesdf_shader.hpp @@ -12,24 +12,24 @@ public: void bind(GLbyte *offset) final; - UniformMatrix<4> u_matrix = {"u_matrix", *this}; - UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this}; - Uniform> u_color = {"u_color", *this}; - Uniform> u_linewidth = {"u_linewidth", *this}; - Uniform u_ratio = {"u_ratio", *this}; - Uniform u_blur = {"u_blur", *this}; - Uniform> u_patternscale_a = { "u_patternscale_a", *this }; - Uniform u_tex_y_a = {"u_tex_y_a", *this}; - Uniform> u_patternscale_b = { "u_patternscale_b", *this }; - Uniform u_tex_y_b = {"u_tex_y_b", *this}; - Uniform u_image = {"u_image", *this}; - Uniform u_sdfgamma = {"u_sdfgamma", *this}; - Uniform u_mix = {"u_mix", *this}; - Uniform u_extra = {"u_extra", *this}; - UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this}; + UniformMatrix<4> u_matrix = {"u_matrix", *this}; + UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this}; + Uniform> u_color = {"u_color", *this}; + Uniform> u_linewidth = {"u_linewidth", *this}; + Uniform u_ratio = {"u_ratio", *this}; + Uniform u_blur = {"u_blur", *this}; + Uniform> u_patternscale_a = { "u_patternscale_a", *this}; + Uniform u_tex_y_a = {"u_tex_y_a", *this}; + Uniform> u_patternscale_b = { "u_patternscale_b", *this}; + Uniform u_tex_y_b = {"u_tex_y_b", *this}; + Uniform u_image = {"u_image", *this}; + Uniform u_sdfgamma = {"u_sdfgamma", *this}; + Uniform u_mix = {"u_mix", *this}; + Uniform u_extra = {"u_extra", *this}; + UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this}; private: - int32_t a_data = -1; + GLint a_data = -1; }; diff --git a/src/mbgl/shader/outline_shader.hpp b/src/mbgl/shader/outline_shader.hpp index 9de01e214..2cd4b1dc3 100644 --- a/src/mbgl/shader/outline_shader.hpp +++ b/src/mbgl/shader/outline_shader.hpp @@ -12,9 +12,9 @@ public: void bind(GLbyte *offset) final; - UniformMatrix<4> u_matrix = {"u_matrix", *this}; - Uniform> u_color = {"u_color", *this}; - Uniform> u_world = {"u_world", *this}; + UniformMatrix<4> u_matrix = {"u_matrix", *this}; + Uniform> u_color = {"u_color", *this}; + Uniform> u_world = {"u_world", *this}; }; } diff --git a/src/mbgl/shader/pattern_shader.hpp b/src/mbgl/shader/pattern_shader.hpp index 28cd341d8..3dd3daa46 100644 --- a/src/mbgl/shader/pattern_shader.hpp +++ b/src/mbgl/shader/pattern_shader.hpp @@ -12,16 +12,16 @@ public: void bind(GLbyte *offset) final; - UniformMatrix<4> u_matrix = {"u_matrix", *this}; - Uniform> u_pattern_tl_a = {"u_pattern_tl_a", *this}; - Uniform> u_pattern_br_a = {"u_pattern_br_a", *this}; - Uniform> u_pattern_tl_b = {"u_pattern_tl_b", *this}; - Uniform> u_pattern_br_b = {"u_pattern_br_b", *this}; - Uniform u_opacity = {"u_opacity", *this}; - Uniform u_mix = {"u_mix", *this}; - Uniform u_image = {"u_image", *this}; - UniformMatrix<3> u_patternmatrix_a = {"u_patternmatrix_a", *this}; - UniformMatrix<3> u_patternmatrix_b = {"u_patternmatrix_b", *this}; + UniformMatrix<4> u_matrix = {"u_matrix", *this}; + Uniform> u_pattern_tl_a = {"u_pattern_tl_a", *this}; + Uniform> u_pattern_br_a = {"u_pattern_br_a", *this}; + Uniform> u_pattern_tl_b = {"u_pattern_tl_b", *this}; + Uniform> u_pattern_br_b = {"u_pattern_br_b", *this}; + Uniform u_opacity = {"u_opacity", *this}; + Uniform u_mix = {"u_mix", *this}; + Uniform u_image = {"u_image", *this}; + UniformMatrix<3> u_patternmatrix_a = {"u_patternmatrix_a", *this}; + UniformMatrix<3> u_patternmatrix_b = {"u_patternmatrix_b", *this}; }; } diff --git a/src/mbgl/shader/plain_shader.hpp b/src/mbgl/shader/plain_shader.hpp index cf2bcc38c..ee0528e9e 100644 --- a/src/mbgl/shader/plain_shader.hpp +++ b/src/mbgl/shader/plain_shader.hpp @@ -12,8 +12,8 @@ public: void bind(GLbyte *offset) final; - UniformMatrix<4> u_matrix = {"u_matrix", *this}; - Uniform> u_color = {"u_color", *this}; + UniformMatrix<4> u_matrix = {"u_matrix", *this}; + Uniform> u_color = {"u_color", *this}; }; } diff --git a/src/mbgl/shader/raster_shader.hpp b/src/mbgl/shader/raster_shader.hpp index 705efec99..af51b4ba4 100644 --- a/src/mbgl/shader/raster_shader.hpp +++ b/src/mbgl/shader/raster_shader.hpp @@ -12,15 +12,15 @@ public: void bind(GLbyte *offset) final; - UniformMatrix<4> u_matrix = {"u_matrix", *this}; - Uniform u_image = {"u_image", *this}; - Uniform u_opacity = {"u_opacity", *this}; - Uniform u_buffer = {"u_buffer", *this}; - Uniform u_brightness_low = {"u_brightness_low", *this}; - Uniform u_brightness_high = {"u_brightness_high", *this}; - Uniform u_saturation_factor = {"u_saturation_factor", *this}; - Uniform u_contrast_factor = {"u_contrast_factor", *this}; - Uniform> u_spin_weights = {"u_spin_weights", *this}; + UniformMatrix<4> u_matrix = {"u_matrix", *this}; + Uniform u_image = {"u_image", *this}; + Uniform u_opacity = {"u_opacity", *this}; + Uniform u_buffer = {"u_buffer", *this}; + Uniform u_brightness_low = {"u_brightness_low", *this}; + Uniform u_brightness_high = {"u_brightness_high", *this}; + Uniform u_saturation_factor = {"u_saturation_factor", *this}; + Uniform u_contrast_factor = {"u_contrast_factor", *this}; + Uniform> u_spin_weights = {"u_spin_weights", *this}; }; } diff --git a/src/mbgl/shader/sdf_shader.hpp b/src/mbgl/shader/sdf_shader.hpp index a56f3b2eb..fcb2e15d1 100644 --- a/src/mbgl/shader/sdf_shader.hpp +++ b/src/mbgl/shader/sdf_shader.hpp @@ -10,24 +10,24 @@ class SDFShader : public Shader { public: SDFShader(); - UniformMatrix<4> u_matrix = {"u_matrix", *this}; - UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this}; - Uniform> u_color = {"u_color", *this}; - Uniform> u_texsize = {"u_texsize", *this}; - Uniform u_buffer = {"u_buffer", *this}; - Uniform u_gamma = {"u_gamma", *this}; - Uniform u_zoom = {"u_zoom", *this}; - Uniform u_fadedist = {"u_fadedist", *this}; - Uniform u_minfadezoom = {"u_minfadezoom", *this}; - Uniform u_maxfadezoom = {"u_maxfadezoom", *this}; - Uniform u_fadezoom = {"u_fadezoom", *this}; - Uniform u_skewed = {"u_skewed", *this}; - Uniform u_extra = {"u_extra", *this}; + UniformMatrix<4> u_matrix = {"u_matrix", *this}; + UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this}; + Uniform> u_color = {"u_color", *this}; + Uniform> u_texsize = {"u_texsize", *this}; + Uniform u_buffer = {"u_buffer", *this}; + Uniform u_gamma = {"u_gamma", *this}; + Uniform u_zoom = {"u_zoom", *this}; + Uniform u_fadedist = {"u_fadedist", *this}; + Uniform u_minfadezoom = {"u_minfadezoom", *this}; + Uniform u_maxfadezoom = {"u_maxfadezoom", *this}; + Uniform u_fadezoom = {"u_fadezoom", *this}; + Uniform u_skewed = {"u_skewed", *this}; + Uniform u_extra = {"u_extra", *this}; protected: - int32_t a_offset = -1; - int32_t a_data1 = -1; - int32_t a_data2 = -1; + GLint a_offset = -1; + GLint a_data1 = -1; + GLint a_data2 = -1; }; class SDFGlyphShader : public SDFShader { diff --git a/src/mbgl/shader/shader.hpp b/src/mbgl/shader/shader.hpp index dab7cd852..1de56da87 100644 --- a/src/mbgl/shader/shader.hpp +++ b/src/mbgl/shader/shader.hpp @@ -16,9 +16,9 @@ public: ~Shader(); const GLchar *name; - uint32_t program; + GLuint program; - inline uint32_t getID() const { + inline GLuint getID() const { return program; } diff --git a/src/mbgl/shader/uniform.cpp b/src/mbgl/shader/uniform.cpp index c013699bf..eca1a99d1 100644 --- a/src/mbgl/shader/uniform.cpp +++ b/src/mbgl/shader/uniform.cpp @@ -3,42 +3,42 @@ namespace mbgl { template <> -void Uniform::bind(const float& t) { +void Uniform::bind(const GLfloat& t) { MBGL_CHECK_ERROR(glUniform1f(location, t)); } template <> -void Uniform::bind(const int32_t& t) { +void Uniform::bind(const GLint& t) { MBGL_CHECK_ERROR(glUniform1i(location, t)); } template <> -void Uniform>::bind(const std::array& t) { +void Uniform>::bind(const std::array& t) { MBGL_CHECK_ERROR(glUniform2fv(location, 1, t.data())); } template <> -void Uniform>::bind(const std::array& t) { +void Uniform>::bind(const std::array& t) { MBGL_CHECK_ERROR(glUniform3fv(location, 1, t.data())); } template <> -void Uniform>::bind(const std::array& t) { +void Uniform>::bind(const std::array& t) { MBGL_CHECK_ERROR(glUniform4fv(location, 1, t.data())); } template <> -void UniformMatrix<2>::bind(const std::array& t) { +void UniformMatrix<2>::bind(const std::array& t) { MBGL_CHECK_ERROR(glUniformMatrix2fv(location, 1, GL_FALSE, t.data())); } template <> -void UniformMatrix<3>::bind(const std::array& t) { +void UniformMatrix<3>::bind(const std::array& t) { MBGL_CHECK_ERROR(glUniformMatrix3fv(location, 1, GL_FALSE, t.data())); } template <> -void UniformMatrix<4>::bind(const std::array& t) { +void UniformMatrix<4>::bind(const std::array& t) { MBGL_CHECK_ERROR(glUniformMatrix4fv(location, 1, GL_FALSE, t.data())); } From 05d01194b7864673b412fbd80487973859d2dd9f Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Thu, 10 Sep 2015 15:33:32 +0300 Subject: [PATCH 070/156] [core] GLObjectStore now uses GLuint --- src/mbgl/util/gl_object_store.cpp | 6 +++--- src/mbgl/util/gl_object_store.hpp | 13 +++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/mbgl/util/gl_object_store.cpp b/src/mbgl/util/gl_object_store.cpp index 269004f89..28a36e663 100644 --- a/src/mbgl/util/gl_object_store.cpp +++ b/src/mbgl/util/gl_object_store.cpp @@ -7,17 +7,17 @@ namespace mbgl { namespace util { -void GLObjectStore::abandonVAO(uint32_t vao) { +void GLObjectStore::abandonVAO(GLuint vao) { assert(ThreadContext::currentlyOn(ThreadType::Map)); abandonedVAOs.emplace_back(vao); } -void GLObjectStore::abandonBuffer(uint32_t buffer) { +void GLObjectStore::abandonBuffer(GLuint buffer) { assert(ThreadContext::currentlyOn(ThreadType::Map)); abandonedBuffers.emplace_back(buffer); } -void GLObjectStore::abandonTexture(uint32_t texture) { +void GLObjectStore::abandonTexture(GLuint texture) { assert(ThreadContext::currentlyOn(ThreadType::Map)); abandonedTextures.emplace_back(texture); } diff --git a/src/mbgl/util/gl_object_store.hpp b/src/mbgl/util/gl_object_store.hpp index 925ac1c05..d2929b518 100644 --- a/src/mbgl/util/gl_object_store.hpp +++ b/src/mbgl/util/gl_object_store.hpp @@ -1,6 +1,7 @@ #ifndef MBGL_MAP_UTIL_GL_OBJECT_STORE #define MBGL_MAP_UTIL_GL_OBJECT_STORE +#include #include #include @@ -14,18 +15,18 @@ public: GLObjectStore() = default; // Mark OpenGL objects for deletion - void abandonVAO(uint32_t vao); - void abandonBuffer(uint32_t buffer); - void abandonTexture(uint32_t texture); + void abandonVAO(GLuint vao); + void abandonBuffer(GLuint buffer); + void abandonTexture(GLuint texture); // Actually remove the objects we marked as abandoned with the above methods. // Only call this while the OpenGL context is exclusive to this thread. void performCleanup(); private: - std::vector abandonedVAOs; - std::vector abandonedBuffers; - std::vector abandonedTextures; + std::vector abandonedVAOs; + std::vector abandonedBuffers; + std::vector abandonedTextures; }; } From c33a6bddc66efd18159b111796cce65ad78950f2 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Thu, 10 Sep 2015 17:59:58 +0300 Subject: [PATCH 071/156] [core] GL types for buckets, textures, buffers --- src/mbgl/geometry/buffer.hpp | 10 +++++----- src/mbgl/geometry/elements_buffer.hpp | 14 +++++++------- src/mbgl/geometry/glyph_atlas.hpp | 3 ++- src/mbgl/geometry/line_atlas.cpp | 4 ++-- src/mbgl/geometry/line_atlas.hpp | 12 +++++++----- src/mbgl/geometry/sprite_atlas.hpp | 4 ++-- src/mbgl/renderer/fill_bucket.cpp | 4 ++-- src/mbgl/renderer/line_bucket.cpp | 20 +++++++++----------- src/mbgl/renderer/line_bucket.hpp | 10 +++++----- src/mbgl/renderer/painter.cpp | 4 ++-- src/mbgl/renderer/painter.hpp | 8 ++++---- src/mbgl/renderer/symbol_bucket.cpp | 2 +- src/mbgl/util/raster.cpp | 2 +- src/mbgl/util/raster.hpp | 8 +++++--- src/mbgl/util/texture_pool.cpp | 4 ++-- 15 files changed, 56 insertions(+), 53 deletions(-) diff --git a/src/mbgl/geometry/buffer.hpp b/src/mbgl/geometry/buffer.hpp index c696b5b86..620315d49 100644 --- a/src/mbgl/geometry/buffer.hpp +++ b/src/mbgl/geometry/buffer.hpp @@ -14,9 +14,9 @@ namespace mbgl { template < - size_t item_size, - int bufferType = GL_ARRAY_BUFFER, - size_t defaultLength = 8192, + GLsizei item_size, + GLenum bufferType = GL_ARRAY_BUFFER, + GLsizei defaultLength = 8192, bool retainAfterUpload = false > class Buffer : private util::noncopyable { @@ -31,8 +31,8 @@ public: // Returns the number of elements in this buffer. This is not the number of // bytes, but rather the number of coordinates with associated information. - inline size_t index() const { - return pos / itemSize; + inline GLsizei index() const { + return static_cast(pos / itemSize); } inline bool empty() const { diff --git a/src/mbgl/geometry/elements_buffer.hpp b/src/mbgl/geometry/elements_buffer.hpp index 24753ebaf..5e642f06d 100644 --- a/src/mbgl/geometry/elements_buffer.hpp +++ b/src/mbgl/geometry/elements_buffer.hpp @@ -10,16 +10,16 @@ namespace mbgl { -template +template struct ElementGroup : public util::noncopyable { std::array array; - uint32_t vertex_length; - uint32_t elements_length; + GLsizei vertex_length; + GLsizei elements_length; - ElementGroup() : vertex_length(0), elements_length(0) {} - ElementGroup(uint32_t vertex_length_, uint32_t elements_length_) - : vertex_length(vertex_length_), - elements_length(elements_length_) { + ElementGroup(GLsizei vertex_length_ = 0, GLsizei elements_length_ = 0) + : vertex_length(vertex_length_) + , elements_length(elements_length_) + { } }; diff --git a/src/mbgl/geometry/glyph_atlas.hpp b/src/mbgl/geometry/glyph_atlas.hpp index 8bc21da09..f499859d7 100644 --- a/src/mbgl/geometry/glyph_atlas.hpp +++ b/src/mbgl/geometry/glyph_atlas.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -51,7 +52,7 @@ private: std::map> index; const std::unique_ptr data; std::atomic dirty; - uint32_t texture = 0; + GLuint texture = 0; }; }; diff --git a/src/mbgl/geometry/line_atlas.cpp b/src/mbgl/geometry/line_atlas.cpp index aeac3067e..bbda2dce6 100644 --- a/src/mbgl/geometry/line_atlas.cpp +++ b/src/mbgl/geometry/line_atlas.cpp @@ -12,10 +12,10 @@ using namespace mbgl; -LineAtlas::LineAtlas(uint16_t w, uint16_t h) +LineAtlas::LineAtlas(GLsizei w, GLsizei h) : width(w), height(h), - data(std::make_unique(w * h)), + data(std::make_unique(w * h)), dirty(true) { } diff --git a/src/mbgl/geometry/line_atlas.hpp b/src/mbgl/geometry/line_atlas.hpp index 3c3b90f75..a8663cb82 100644 --- a/src/mbgl/geometry/line_atlas.hpp +++ b/src/mbgl/geometry/line_atlas.hpp @@ -1,6 +1,8 @@ #ifndef MBGL_GEOMETRY_LINE_ATLAS #define MBGL_GEOMETRY_LINE_ATLAS +#include + #include #include #include @@ -15,7 +17,7 @@ typedef struct { class LineAtlas { public: - LineAtlas(uint16_t width, uint16_t height); + LineAtlas(GLsizei width, GLsizei height); ~LineAtlas(); // Binds the atlas texture to the GPU, and uploads data if it is out of date. @@ -28,13 +30,13 @@ public: LinePatternPos getDashPosition(const std::vector&, bool); LinePatternPos addDash(const std::vector &dasharray, bool round); - const int width; - const int height; + const GLsizei width; + const GLsizei height; private: - const std::unique_ptr data; + const std::unique_ptr data; bool dirty; - uint32_t texture = 0; + GLuint texture = 0; int nextRow = 0; std::map positions; }; diff --git a/src/mbgl/geometry/sprite_atlas.hpp b/src/mbgl/geometry/sprite_atlas.hpp index bfe4f843d..4a8c3fefa 100644 --- a/src/mbgl/geometry/sprite_atlas.hpp +++ b/src/mbgl/geometry/sprite_atlas.hpp @@ -2,7 +2,7 @@ #define MBGL_GEOMETRY_SPRITE_ATLAS #include - +#include #include #include @@ -93,7 +93,7 @@ private: const std::unique_ptr data; std::atomic dirty; bool fullUploadRequired = true; - uint32_t texture = 0; + GLuint texture = 0; uint32_t filter = 0; static const int buffer = 1; }; diff --git a/src/mbgl/renderer/fill_bucket.cpp b/src/mbgl/renderer/fill_bucket.cpp index 1828ae0a2..7fb25d9a8 100644 --- a/src/mbgl/renderer/fill_bucket.cpp +++ b/src/mbgl/renderer/fill_bucket.cpp @@ -107,7 +107,7 @@ void FillBucket::tessellate() { assert(lineGroups.back()); LineGroup& lineGroup = *lineGroups.back(); - uint32_t lineIndex = lineGroup.vertex_length; + GLsizei lineIndex = lineGroup.vertex_length; for (const auto& polygon : polygons) { const size_t group_count = polygon.size(); @@ -156,7 +156,7 @@ void FillBucket::tessellate() { // coordinate in this polygon. assert(triangleGroups.back()); TriangleGroup& triangleGroup = *triangleGroups.back(); - uint32_t triangleIndex = triangleGroup.vertex_length; + GLsizei triangleIndex = triangleGroup.vertex_length; for (int i = 0; i < triangle_count; ++i) { const TESSindex *element_group = &elements[i * vertices_per_group]; diff --git a/src/mbgl/renderer/line_bucket.cpp b/src/mbgl/renderer/line_bucket.cpp index f0d52fa51..9769cac33 100644 --- a/src/mbgl/renderer/line_bucket.cpp +++ b/src/mbgl/renderer/line_bucket.cpp @@ -75,7 +75,7 @@ void LineBucket::addGeometry(const std::vector& vertices) { nextNormal = util::perp(util::unit(vec2(firstVertex - currentVertex))); } - const int32_t startVertex = (int32_t)vertexBuffer.index(); + const GLint startVertex = vertexBuffer.index(); std::vector triangleStore; for (size_t i = 0; i < len; ++i) { @@ -333,16 +333,15 @@ void LineBucket::addCurrentVertex(const Coordinate& currentVertex, float endLeft, float endRight, bool round, - int32_t startVertex, + GLint startVertex, std::vector& triangleStore) { int8_t tx = round ? 1 : 0; vec2 extrude = normal * flip; if (endLeft) extrude = extrude - (util::perp(normal) * endLeft); - e3 = (int32_t)vertexBuffer.add(currentVertex.x, currentVertex.y, extrude.x, extrude.y, tx, 0, - distance) - - startVertex; + e3 = vertexBuffer.add(currentVertex.x, currentVertex.y, extrude.x, extrude.y, tx, 0, distance) + - startVertex; if (e1 >= 0 && e2 >= 0) { triangleStore.emplace_back(e1, e2, e3); } @@ -352,9 +351,8 @@ void LineBucket::addCurrentVertex(const Coordinate& currentVertex, extrude = normal * (-flip); if (endRight) extrude = extrude - (util::perp(normal) * endRight); - e3 = (int32_t)vertexBuffer.add(currentVertex.x, currentVertex.y, extrude.x, extrude.y, tx, 1, - distance) - - startVertex; + e3 = vertexBuffer.add(currentVertex.x, currentVertex.y, extrude.x, extrude.y, tx, 1, distance) + - startVertex; if (e1 >= 0 && e2 >= 0) { triangleStore.emplace_back(e1, e2, e3); } @@ -367,13 +365,13 @@ void LineBucket::addPieSliceVertex(const Coordinate& currentVertex, double distance, const vec2& extrude, bool lineTurnsLeft, - int32_t startVertex, + GLint startVertex, std::vector& triangleStore) { int8_t ty = lineTurnsLeft; auto flippedExtrude = extrude * (flip * (lineTurnsLeft ? -1 : 1)); - e3 = (int32_t)vertexBuffer.add(currentVertex.x, currentVertex.y, flippedExtrude.x, flippedExtrude.y, 0, ty, - distance) - startVertex; + e3 = vertexBuffer.add(currentVertex.x, currentVertex.y, flippedExtrude.x, flippedExtrude.y, 0, ty, distance) + - startVertex; if (e1 >= 0 && e2 >= 0) { triangleStore.emplace_back(e1, e2, e3); } diff --git a/src/mbgl/renderer/line_bucket.hpp b/src/mbgl/renderer/line_bucket.hpp index cd5fce3cb..ea12a1d84 100644 --- a/src/mbgl/renderer/line_bucket.hpp +++ b/src/mbgl/renderer/line_bucket.hpp @@ -46,9 +46,9 @@ private: }; void addCurrentVertex(const Coordinate& currentVertex, float flip, double distance, const vec2& normal, float endLeft, float endRight, bool round, - int32_t startVertex, std::vector& triangleStore); + GLint startVertex, std::vector& triangleStore); void addPieSliceVertex(const Coordinate& currentVertex, float flip, double distance, - const vec2& extrude, bool lineTurnsLeft, int32_t startVertex, + const vec2& extrude, bool lineTurnsLeft, GLint startVertex, std::vector& triangleStore); public: @@ -61,9 +61,9 @@ private: const size_t vertex_start; const size_t triangle_elements_start; - int32_t e1; - int32_t e2; - int32_t e3; + GLint e1; + GLint e2; + GLint e3; std::vector> triangleGroups; }; diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp index e757d682a..a1b5566f2 100644 --- a/src/mbgl/renderer/painter.cpp +++ b/src/mbgl/renderer/painter.cpp @@ -117,14 +117,14 @@ void Painter::setDebug(bool enabled) { debug = enabled; } -void Painter::useProgram(uint32_t program) { +void Painter::useProgram(GLuint program) { if (gl_program != program) { MBGL_CHECK_ERROR(glUseProgram(program)); gl_program = program; } } -void Painter::lineWidth(float line_width) { +void Painter::lineWidth(GLfloat line_width) { if (gl_lineWidth != line_width) { MBGL_CHECK_ERROR(glLineWidth(line_width)); gl_lineWidth = line_width; diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp index 9c0f5db8c..ce42b59d1 100644 --- a/src/mbgl/renderer/painter.hpp +++ b/src/mbgl/renderer/painter.hpp @@ -161,8 +161,8 @@ private: void setDepthSublayer(int n); public: - void useProgram(uint32_t program); - void lineWidth(float lineWidth); + void useProgram(GLuint program); + void lineWidth(GLfloat lineWidth); public: mat4 projMatrix; @@ -194,8 +194,8 @@ private: gl::Config config; - uint32_t gl_program = 0; - float gl_lineWidth = 0; + GLuint gl_program = 0; + GLfloat gl_lineWidth = 0; std::array gl_viewport = {{ 0, 0 }}; RenderPass pass = RenderPass::Opaque; Color background = {{ 0, 0, 0, 0 }}; diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp index 11b3bf3d0..9b1deef91 100644 --- a/src/mbgl/renderer/symbol_bucket.cpp +++ b/src/mbgl/renderer/symbol_bucket.cpp @@ -488,7 +488,7 @@ void SymbolBucket::addSymbols(Buffer &buffer, const SymbolQuads &symbols, float // coordinate in this polygon. assert(buffer.groups.back()); auto &triangleGroup = *buffer.groups.back(); - uint32_t triangleIndex = triangleGroup.vertex_length; + GLsizei triangleIndex = triangleGroup.vertex_length; // coordinates (2 triangles) buffer.vertices.add(anchorPoint.x, anchorPoint.y, tl.x, tl.y, tex.x, tex.y, minZoom, diff --git a/src/mbgl/util/raster.cpp b/src/mbgl/util/raster.cpp index 9b8254089..1c277040c 100644 --- a/src/mbgl/util/raster.cpp +++ b/src/mbgl/util/raster.cpp @@ -50,7 +50,7 @@ void Raster::bind(bool linear) { MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, texture)); } - GLuint new_filter = linear ? GL_LINEAR : GL_NEAREST; + GLint new_filter = linear ? GL_LINEAR : GL_NEAREST; if (new_filter != this->filter) { MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, new_filter)); MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, new_filter)); diff --git a/src/mbgl/util/raster.hpp b/src/mbgl/util/raster.hpp index 39ab26ffc..adf3b2cbf 100644 --- a/src/mbgl/util/raster.hpp +++ b/src/mbgl/util/raster.hpp @@ -1,6 +1,7 @@ #ifndef MBGL_UTIL_RASTER #define MBGL_UTIL_RASTER +#include #include #include #include @@ -32,13 +33,14 @@ public: public: // loaded image dimensions - uint32_t width = 0, height = 0; + GLsizei width = 0; + GLsizei height = 0; // has been uploaded to texture bool textured = false; // the uploaded texture - uint32_t texture = 0; + GLuint texture = 0; // texture opacity double opacity = 0; @@ -53,7 +55,7 @@ private: TexturePool& texturePool; // min/mag filter - uint32_t filter = 0; + GLint filter = 0; // the raw pixels std::unique_ptr img; diff --git a/src/mbgl/util/texture_pool.cpp b/src/mbgl/util/texture_pool.cpp index 84d24ac77..d4afb1f86 100644 --- a/src/mbgl/util/texture_pool.cpp +++ b/src/mbgl/util/texture_pool.cpp @@ -5,7 +5,7 @@ #include -const int TextureMax = 64; +const GLsizei TextureMax = 64; using namespace mbgl; @@ -13,7 +13,7 @@ GLuint TexturePool::getTextureID() { if (texture_ids.empty()) { GLuint new_texture_ids[TextureMax]; MBGL_CHECK_ERROR(glGenTextures(TextureMax, new_texture_ids)); - for (uint32_t id = 0; id < TextureMax; id++) { + for (GLuint id = 0; id < TextureMax; id++) { texture_ids.insert(new_texture_ids[id]); } } From a3ea4acb7cb4d57ca2f5808b9b600d7c1b7b3cc7 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Fri, 11 Sep 2015 15:08:54 +0300 Subject: [PATCH 072/156] [core] convert remaining types to use OpenGL header defined variants --- src/mbgl/geometry/buffer.hpp | 4 ++-- src/mbgl/geometry/glyph_atlas.hpp | 4 ++-- src/mbgl/geometry/line_buffer.cpp | 4 ++-- src/mbgl/geometry/line_buffer.hpp | 2 +- src/mbgl/geometry/sprite_atlas.hpp | 2 +- src/mbgl/renderer/circle_bucket.hpp | 4 ++-- src/mbgl/renderer/fill_bucket.cpp | 12 ++++++------ src/mbgl/renderer/fill_bucket.hpp | 6 +++--- src/mbgl/renderer/line_bucket.cpp | 10 +++++----- src/mbgl/renderer/line_bucket.hpp | 4 ++-- src/mbgl/renderer/painter.cpp | 4 ++-- src/mbgl/renderer/painter.hpp | 4 ++-- src/mbgl/renderer/symbol_bucket.cpp | 3 ++- 13 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/mbgl/geometry/buffer.hpp b/src/mbgl/geometry/buffer.hpp index 620315d49..d54ee18c7 100644 --- a/src/mbgl/geometry/buffer.hpp +++ b/src/mbgl/geometry/buffer.hpp @@ -110,10 +110,10 @@ public: private: // CPU buffer - void *array = nullptr; + GLvoid *array = nullptr; // Byte position where we are writing. - size_t pos = 0; + GLsizeiptr pos = 0; // Number of bytes that are valid in this buffer. size_t length = 0; diff --git a/src/mbgl/geometry/glyph_atlas.hpp b/src/mbgl/geometry/glyph_atlas.hpp index f499859d7..c5c785994 100644 --- a/src/mbgl/geometry/glyph_atlas.hpp +++ b/src/mbgl/geometry/glyph_atlas.hpp @@ -32,8 +32,8 @@ public: // the texture is only bound when the data is out of date (=dirty). void upload(); - const uint16_t width = 0; - const uint16_t height = 0; + const GLsizei width; + const GLsizei height; private: struct GlyphValue { diff --git a/src/mbgl/geometry/line_buffer.cpp b/src/mbgl/geometry/line_buffer.cpp index f475c63b2..77a134b46 100644 --- a/src/mbgl/geometry/line_buffer.cpp +++ b/src/mbgl/geometry/line_buffer.cpp @@ -5,8 +5,8 @@ using namespace mbgl; -size_t LineVertexBuffer::add(vertex_type x, vertex_type y, float ex, float ey, int8_t tx, int8_t ty, int32_t linesofar) { - size_t idx = index(); +GLsizei LineVertexBuffer::add(vertex_type x, vertex_type y, float ex, float ey, int8_t tx, int8_t ty, int32_t linesofar) { + GLsizei idx = index(); void *data = addElement(); int16_t *coords = static_cast(data); diff --git a/src/mbgl/geometry/line_buffer.hpp b/src/mbgl/geometry/line_buffer.hpp index 1c217b59d..7174fa291 100644 --- a/src/mbgl/geometry/line_buffer.hpp +++ b/src/mbgl/geometry/line_buffer.hpp @@ -30,7 +30,7 @@ public: * @param {number} tx texture normal * @param {number} ty texture normal */ - size_t add(vertex_type x, vertex_type y, float ex, float ey, int8_t tx, int8_t ty, int32_t linesofar = 0); + GLsizei add(vertex_type x, vertex_type y, float ex, float ey, int8_t tx, int8_t ty, int32_t linesofar = 0); }; diff --git a/src/mbgl/geometry/sprite_atlas.hpp b/src/mbgl/geometry/sprite_atlas.hpp index 4a8c3fefa..2e794f651 100644 --- a/src/mbgl/geometry/sprite_atlas.hpp +++ b/src/mbgl/geometry/sprite_atlas.hpp @@ -69,7 +69,7 @@ public: inline const uint32_t* getData() const { return data.get(); } private: - const dimension width, height; + const GLsizei width, height; const dimension pixelWidth, pixelHeight; const float pixelRatio; diff --git a/src/mbgl/renderer/circle_bucket.hpp b/src/mbgl/renderer/circle_bucket.hpp index 727b9fa37..d25cbdad3 100644 --- a/src/mbgl/renderer/circle_bucket.hpp +++ b/src/mbgl/renderer/circle_bucket.hpp @@ -35,8 +35,8 @@ private: CircleVertexBuffer& vertexBuffer_; TriangleElementsBuffer& elementsBuffer_; - const size_t vertexStart_; - const size_t elementsStart_; + const GLsizei vertexStart_; + const GLsizei elementsStart_; std::vector> triangleGroups_; }; diff --git a/src/mbgl/renderer/fill_bucket.cpp b/src/mbgl/renderer/fill_bucket.cpp index 7fb25d9a8..38263b3a4 100644 --- a/src/mbgl/renderer/fill_bucket.cpp +++ b/src/mbgl/renderer/fill_bucket.cpp @@ -91,7 +91,7 @@ void FillBucket::tessellate() { return; } - size_t total_vertex_count = 0; + GLsizei total_vertex_count = 0; for (const auto& polygon : polygons) { total_vertex_count += polygon.size(); } @@ -110,7 +110,7 @@ void FillBucket::tessellate() { GLsizei lineIndex = lineGroup.vertex_length; for (const auto& polygon : polygons) { - const size_t group_count = polygon.size(); + const GLsizei group_count = static_cast(polygon.size()); assert(group_count >= 3); std::vector clipped_line; @@ -120,8 +120,8 @@ void FillBucket::tessellate() { vertexBuffer.add(pt.X, pt.Y); } - for (size_t i = 0; i < group_count; i++) { - const size_t prev_i = (i == 0 ? group_count : i) - 1; + for (GLsizei i = 0; i < group_count; i++) { + const GLsizei prev_i = (i == 0 ? group_count : i) - 1; lineElementsBuffer.add(lineIndex + prev_i, lineIndex + i); } @@ -134,12 +134,12 @@ void FillBucket::tessellate() { if (tessTesselate(tesselator, TESS_WINDING_ODD, TESS_POLYGONS, vertices_per_group, vertexSize, 0)) { const TESSreal *vertices = tessGetVertices(tesselator); - const size_t vertex_count = tessGetVertexCount(tesselator); + const GLsizei vertex_count = tessGetVertexCount(tesselator); TESSindex *vertex_indices = const_cast(tessGetVertexIndices(tesselator)); const TESSindex *elements = tessGetElements(tesselator); const int triangle_count = tessGetElementCount(tesselator); - for (size_t i = 0; i < vertex_count; ++i) { + for (GLsizei i = 0; i < vertex_count; ++i) { if (vertex_indices[i] == TESS_UNDEF) { vertexBuffer.add(::round(vertices[i * 2]), ::round(vertices[i * 2 + 1])); vertex_indices[i] = (TESSindex)total_vertex_count; diff --git a/src/mbgl/renderer/fill_bucket.hpp b/src/mbgl/renderer/fill_bucket.hpp index 2ff86ba9a..1e0285254 100644 --- a/src/mbgl/renderer/fill_bucket.hpp +++ b/src/mbgl/renderer/fill_bucket.hpp @@ -54,9 +54,9 @@ private: LineElementsBuffer& lineElementsBuffer; // hold information on where the vertices are located in the FillBuffer - const size_t vertex_start; - const size_t triangle_elements_start; - const size_t line_elements_start; + const GLsizei vertex_start; + const GLsizei triangle_elements_start; + const GLsizei line_elements_start; std::vector> triangleGroups; std::vector> lineGroups; diff --git a/src/mbgl/renderer/line_bucket.cpp b/src/mbgl/renderer/line_bucket.cpp index 9769cac33..9f4d060fc 100644 --- a/src/mbgl/renderer/line_bucket.cpp +++ b/src/mbgl/renderer/line_bucket.cpp @@ -32,8 +32,8 @@ void LineBucket::addGeometry(const GeometryCollection& geometryCollection) { } void LineBucket::addGeometry(const std::vector& vertices) { - const auto len = [&vertices] { - auto l = vertices.size(); + const GLsizei len = [&vertices] { + GLsizei l = static_cast(vertices.size()); // If the line has duplicate vertices at the end, adjust length to remove them. while (l > 2 && vertices[l - 1] == vertices[l - 2]) { l--; @@ -78,7 +78,7 @@ void LineBucket::addGeometry(const std::vector& vertices) { const GLint startVertex = vertexBuffer.index(); std::vector triangleStore; - for (size_t i = 0; i < len; ++i) { + for (GLsizei i = 0; i < len; ++i) { if (closed && i == len - 1) { // if the line is closed, we treat the last vertex like the first nextVertex = vertices[1]; @@ -303,8 +303,8 @@ void LineBucket::addGeometry(const std::vector& vertices) { startOfLine = false; } - const size_t endVertex = vertexBuffer.index(); - const size_t vertexCount = endVertex - startVertex; + const GLsizei endVertex = vertexBuffer.index(); + const GLsizei vertexCount = endVertex - startVertex; // Store the triangle/line groups. { diff --git a/src/mbgl/renderer/line_bucket.hpp b/src/mbgl/renderer/line_bucket.hpp index ea12a1d84..2be0cf392 100644 --- a/src/mbgl/renderer/line_bucket.hpp +++ b/src/mbgl/renderer/line_bucket.hpp @@ -58,8 +58,8 @@ private: LineVertexBuffer& vertexBuffer; TriangleElementsBuffer& triangleElementsBuffer; - const size_t vertex_start; - const size_t triangle_elements_start; + const GLsizei vertex_start; + const GLsizei triangle_elements_start; GLint e1; GLint e2; diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp index a1b5566f2..abb08f28b 100644 --- a/src/mbgl/renderer/painter.cpp +++ b/src/mbgl/renderer/painter.cpp @@ -235,7 +235,7 @@ void Painter::render(const Style& style, TransformState state_, const FrameData& // Make a second pass, rendering translucent objects. This time, we render bottom-to-top. renderPass(RenderPass::Translucent, order.begin(), order.end(), - order.size() - 1, -1); + static_cast(order.size()) - 1, -1); if (debug::renderTree) { Log::Info(Event::Render, "}"); indent--; } @@ -266,7 +266,7 @@ void Painter::render(const Style& style, TransformState state_, const FrameData& template void Painter::renderPass(RenderPass pass_, Iterator it, Iterator end, - std::size_t i, int8_t increment) { + GLsizei i, int8_t increment) { pass = pass_; MBGL_DEBUG_GROUP(pass == RenderPass::Opaque ? "opaque" : "translucent"); diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp index ce42b59d1..07bd4c4d3 100644 --- a/src/mbgl/renderer/painter.hpp +++ b/src/mbgl/renderer/painter.hpp @@ -143,7 +143,7 @@ private: template void renderPass(RenderPass, Iterator it, Iterator end, - std::size_t i, int8_t increment); + GLsizei i, int8_t increment); void prepareTile(const Tile& tile); @@ -201,7 +201,7 @@ private: Color background = {{ 0, 0, 0, 0 }}; int numSublayers = 3; - size_t currentLayer; + GLsizei currentLayer; float depthRangeSize; const float depthEpsilon = 1.0f / (1 << 16); diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp index 9b1deef91..dabffa14f 100644 --- a/src/mbgl/renderer/symbol_bucket.cpp +++ b/src/mbgl/renderer/symbol_bucket.cpp @@ -103,7 +103,8 @@ bool SymbolBucket::needsDependencies(const GeometryTileLayer& layer, // Determine and load glyph ranges std::set ranges; - for (std::size_t i = 0; i < layer.featureCount(); i++) { + const GLsizei featureCount = static_cast(layer.featureCount()); + for (GLsizei i = 0; i < featureCount; i++) { auto feature = layer.getFeature(i); GeometryTileFeatureExtractor extractor(*feature); From d8ffb76ff36915125543c80a0c04b9089cbbb370 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Tue, 15 Sep 2015 10:33:34 -0400 Subject: [PATCH 073/156] Take a screenshot after every test --- .../com/mapbox/mapboxgl/testapp/BaseTest.java | 27 ++++++ .../testapp/utils/ScreenshotUtil.java | 88 +++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/utils/ScreenshotUtil.java diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java index d9801cf1e..7ec3c3181 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java @@ -3,6 +3,8 @@ package com.mapbox.mapboxgl.testapp; import android.support.test.InstrumentationRegistry; import android.test.ActivityInstrumentationTestCase2; +import com.mapbox.mapboxgl.testapp.utils.ScreenshotUtil; + import org.junit.Before; /** @@ -17,6 +19,10 @@ public class BaseTest super(MainActivity.class); } + /* + * Get the activity before running every test + */ + @Before public void setUp() throws Exception { super.setUp(); @@ -24,4 +30,25 @@ public class BaseTest mActivity = getActivity(); } + /* + * Take a screenshot after every test + */ + + @Override + protected void tearDown() throws Exception { + try { + // Screenshots should be taken on the UI thread + runTestOnUiThread(new Runnable() { + @Override + public void run() { + ScreenshotUtil.take(getActivity()); + } + }); + } catch (Throwable throwable) { + throwable.printStackTrace(); + } + + super.tearDown(); + } + } diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/utils/ScreenshotUtil.java b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/utils/ScreenshotUtil.java new file mode 100644 index 000000000..0e35fad68 --- /dev/null +++ b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/utils/ScreenshotUtil.java @@ -0,0 +1,88 @@ +package com.mapbox.mapboxgl.testapp.utils; + +import android.app.Activity; +import android.graphics.Bitmap; +import android.os.Environment; +import android.util.Log; +import android.view.View; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.UUID; + +/** + * The built-in Fuzz Suite on AWS Device Farm takes screenshots after every test. However, + * this doesn't happen with Espresso unless we manually do it. This class fixes it. + */ +public class ScreenshotUtil { + + private static final String LOG_TAG = ScreenshotUtil.class.getName(); + + // Where to store the files. This path is required by AWS Device Farm: + // http://docs.aws.amazon.com/devicefarm/latest/developerguide/test-types-android-instrumentation.html#test-types-android-instrumentation-screenshots + private static final String SCREENSHOT_FOLDER = "test-screenshots"; + + // Image type and quality + private static final String DEFAULT_IMAGE_EXTENSION = ".png"; + private static final Bitmap.CompressFormat DEFAULT_IMAGE_FORMAT = Bitmap.CompressFormat.PNG; + private static final int DEFAULT_IMAGE_QUALITY = 100; + + public static void take(Activity activity) { + + // Check if storage is available + if (!isExternalStorageWritable()) { + Log.d(LOG_TAG, "External storage is not available."); + return; + } + + // Get a bitmap from the activity root view. When the drawing cache is enabled, + // the next call to getDrawingCache() will draw the view in a bitmap. + View rootView = activity.getWindow().getDecorView().getRootView(); + rootView.setDrawingCacheEnabled(true); + Bitmap bitmap = Bitmap.createBitmap(rootView.getDrawingCache()); + rootView.setDrawingCacheEnabled(false); + + // Save the bitmap in external storage + String uniqueAbsolutePath = getUniqueAbsolutePath(); + File outputFile = new File(uniqueAbsolutePath); + OutputStream outputStream = null; + try { + outputStream = new FileOutputStream(outputFile); + bitmap.compress(DEFAULT_IMAGE_FORMAT, DEFAULT_IMAGE_QUALITY, outputStream); + outputStream.flush(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + /* Checks if external storage is available for read and write */ + public static boolean isExternalStorageWritable() { + String state = Environment.getExternalStorageState(); + if (Environment.MEDIA_MOUNTED.equals(state)) { + return true; + } + return false; + } + + private static String getUniqueAbsolutePath() { + String externalPath = Environment.getExternalStorageDirectory().toString(); + String filename = UUID.randomUUID().toString() + DEFAULT_IMAGE_EXTENSION; + String path = externalPath + File.separator + SCREENSHOT_FOLDER + File.separator + filename; + Log.d(LOG_TAG, "Screenshot path: " + path); + return path; + } + +} From 019a3c05b009c5fba1b65b1aa8803753bf61d643 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Tue, 15 Sep 2015 11:20:24 -0400 Subject: [PATCH 074/156] added espresso-contrib to have access to contrib.DrawerMatchers.* --- android/java/MapboxGLAndroidSDKTestApp/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/android/java/MapboxGLAndroidSDKTestApp/build.gradle b/android/java/MapboxGLAndroidSDKTestApp/build.gradle index 69a068713..93ab32223 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/build.gradle +++ b/android/java/MapboxGLAndroidSDKTestApp/build.gradle @@ -99,6 +99,7 @@ dependencies { androidTestCompile 'com.android.support.test:runner:0.3' androidTestCompile 'com.android.support.test:rules:0.3' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2' + androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2' } checkstyle { From 06d609d630caecb7831090fc2c49a3c92b770aaa Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Tue, 15 Sep 2015 12:23:03 -0400 Subject: [PATCH 075/156] we now have 26 UI tests that cover all main elements and core interactions, including drawer and map inner elements --- .../MapboxGLAndroidSDKTestApp/build.gradle | 1 - .../mapboxgl/testapp/MainActivityTest.java | 246 +++++++++++++++++- 2 files changed, 245 insertions(+), 2 deletions(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/build.gradle b/android/java/MapboxGLAndroidSDKTestApp/build.gradle index 93ab32223..69a068713 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/build.gradle +++ b/android/java/MapboxGLAndroidSDKTestApp/build.gradle @@ -99,7 +99,6 @@ dependencies { androidTestCompile 'com.android.support.test:runner:0.3' androidTestCompile 'com.android.support.test:rules:0.3' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2' - androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2' } checkstyle { diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java index 1f786affd..08948b33b 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java @@ -3,15 +3,27 @@ package com.mapbox.mapboxgl.testapp; import org.junit.Test; import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.action.ViewActions.doubleClick; +import static android.support.test.espresso.action.ViewActions.longClick; +import static android.support.test.espresso.action.ViewActions.swipeDown; +import static android.support.test.espresso.action.ViewActions.swipeLeft; +import static android.support.test.espresso.action.ViewActions.swipeRight; +import static android.support.test.espresso.action.ViewActions.swipeUp; import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription; import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static android.support.test.espresso.matcher.ViewMatchers.withText; +import static org.hamcrest.Matchers.not; /** - * Tests MainActivity + * Tests on MainActivity */ public class MainActivityTest extends BaseTest { + private final static String HOME_BUTTON_STRING = "Navigate up"; + /* * Note that we need to keep the `test` prefix if we want to be able to run these * tests on AWS Device Farm, annotations are not enough: @@ -24,4 +36,236 @@ public class MainActivityTest extends BaseTest { .check(matches(isDisplayed())); } + /* + * Check UI ids are visible + */ + + @Test + public void testDrawerLayoutIsDisplayed() { + onView(withId(R.id.drawer_layout)) + .check(matches(isDisplayed())); + } + + @Test + public void testToolbarIsDisplayed() { + onView(withId(R.id.toolbar)) + .check(matches(isDisplayed())); + } + + @Test + public void testContentFrameIsDisplayed() { + onView(withId(R.id.content_frame)) + .check(matches(isDisplayed())); + } + + @Test + public void testViewFpsIsDisplayed() { + // By default, R.id.view_fps is not displayed + onView(withId(R.id.view_fps)) + .check(matches(not(isDisplayed()))); + } + + @Test + public void testLocationFABIsDisplayed() { + onView(withId(R.id.locationFAB)) + .check(matches(isDisplayed())); + } + + @Test + public void testNavViewIsNotDisplayed() { + // By default, nav_view not displayed + onView(withId(R.id.nav_view)) + .check(matches(not(isDisplayed()))); + } + + @Test + public void testNavViewIsDisplayed() { + // However, it's displayed when we click the home icon + onView(withContentDescription(HOME_BUTTON_STRING)) + .perform(click()); + onView(withId(R.id.nav_view)) + .check(matches(isDisplayed())); + } + + /* + * Some more tests on the map view (clicks, gestures) + */ + + @Test + public void testClickMap() { + onView(withId(R.id.mainMapView)) + .perform(click()) + .check(matches(isDisplayed())); + } + + @Test + public void testDoubleClickMap() { + onView(withId(R.id.mainMapView)) + .perform(doubleClick()) + .check(matches(isDisplayed())); + } + + @Test + public void testLongClickMap() { + onView(withId(R.id.mainMapView)) + .perform(longClick()) + .check(matches(isDisplayed())); + } + + @Test + public void testSwipeLeftMap() { + onView(withId(R.id.mainMapView)) + .perform(swipeLeft()) + .check(matches(isDisplayed())); + } + + @Test + public void testSwipeRightMap() { + onView(withId(R.id.mainMapView)) + .perform(swipeRight()) + .check(matches(isDisplayed())); + } + + @Test + public void testSwipeDownMap() { + onView(withId(R.id.mainMapView)) + .perform(swipeDown()) + .check(matches(isDisplayed())); + } + + @Test + public void testSwipeUpMap() { + onView(withId(R.id.mainMapView)) + .perform(swipeUp()) + .check(matches(isDisplayed())); + } + + /* + * Test the main drawer options + */ + + @Test + public void testNavViewActionDebug() { + onView(withContentDescription(HOME_BUTTON_STRING)) + .perform(click()); + onView(withText(R.string.action_debug)) + .perform(click()); + + // Clicking the item closes the drawer + onView(withId(R.id.nav_view)) + .check(matches(not(isDisplayed()))); + } + + @Test + public void testNavViewActionPointAnnotations() { + onView(withContentDescription(HOME_BUTTON_STRING)) + .perform(click()); + onView(withText(R.string.action_point_annotations)) + .perform(click()); + + // Clicking the item closes the drawer + onView(withId(R.id.nav_view)) + .check(matches(not(isDisplayed()))); + } + + @Test + public void testNavViewActionCompass() { + onView(withContentDescription(HOME_BUTTON_STRING)) + .perform(click()); + onView(withText(R.string.action_compass)) + .perform(click()); + + // Clicking the item closes the drawer + onView(withId(R.id.nav_view)) + .check(matches(not(isDisplayed()))); + } + + @Test + public void testNavViewStyleMapboxStreets() { + onView(withContentDescription(HOME_BUTTON_STRING)) + .perform(click()); + onView(withText(R.string.styleMapboxStreets)) + .perform(click()); + + // Clicking the item closes the drawer + onView(withId(R.id.nav_view)) + .check(matches(not(isDisplayed()))); + } + + @Test + public void testNavViewStyleEmerald() { + onView(withContentDescription(HOME_BUTTON_STRING)) + .perform(click()); + onView(withText(R.string.styleEmerald)) + .perform(click()); + + // Clicking the item closes the drawer + onView(withId(R.id.nav_view)) + .check(matches(not(isDisplayed()))); + } + + @Test + public void testNavViewStyleLight() { + onView(withContentDescription(HOME_BUTTON_STRING)) + .perform(click()); + onView(withText(R.string.styleLight)) + .perform(click()); + + // Clicking the item closes the drawer + onView(withId(R.id.nav_view)) + .check(matches(not(isDisplayed()))); + } + + @Test + public void testNavViewStyleDark() { + onView(withContentDescription(HOME_BUTTON_STRING)) + .perform(click()); + onView(withText(R.string.styleDark)) + .perform(click()); + + // Clicking the item closes the drawer + onView(withId(R.id.nav_view)) + .check(matches(not(isDisplayed()))); + } + + @Test + public void testNavViewStyleSatellite() { + onView(withContentDescription(HOME_BUTTON_STRING)) + .perform(click()); + onView(withText(R.string.styleSatellite)) + .perform(click()); + + // Clicking the item closes the drawer + onView(withId(R.id.nav_view)) + .check(matches(not(isDisplayed()))); + } + + /* + * We can also check the map inner elements are visible + */ + + @Test + public void testMapIconContentDescription() { + // Mapbox logo + onView(withContentDescription(getActivity().getResources() + .getString(R.string.mapboxIconContentDescription))) + .check(matches(isDisplayed())); + } + + @Test + public void testMapCompassContentDescription() { + // Map compass + onView(withContentDescription(getActivity().getResources() + .getString(R.string.compassContentDescription))) + .check(matches(isDisplayed())); + } + + @Test + public void testMapAttributionsIconContentDescription() { + // Attribution icon + onView(withContentDescription(getActivity().getResources() + .getString(R.string.attributionsIconContentDescription))) + .check(matches(isDisplayed())); + } + } From a101ab4cf5d3bec88dde0255c6a1b9fad8a86383 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 15 Sep 2015 13:27:45 -0400 Subject: [PATCH 076/156] [node] throw if a render is already pending, fixes #2247 --- platform/node/src/node_map.cpp | 4 ++++ platform/node/test/js/map.test.js | 8 ++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index 5b2a83916..f1abf4806 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -186,6 +186,10 @@ NAN_METHOD(NodeMap::Render) { return Nan::ThrowTypeError("Style is not loaded"); } + if (nodeMap->callback) { + return Nan::ThrowError("Map is currently rendering an image"); + } + auto options = ParseOptions(info[0]->ToObject()); assert(!nodeMap->callback); diff --git a/platform/node/test/js/map.test.js b/platform/node/test/js/map.test.js index 295fec693..1581d15cb 100644 --- a/platform/node/test/js/map.test.js +++ b/platform/node/test/js/map.test.js @@ -266,18 +266,14 @@ test('Map', function(t) { render(); }); - t.skip('throws if called in parallel', function(t) { - var completed = 0; - var remaining = 10; - var start = +new Date; - + t.test('throws if called in parallel', function(t) { var map = new mbgl.Map(options); map.load(style); t.throws(function() { map.render({}, function() {}); map.render({}, function() {}); - }); + }, /Map is currently rendering an image/); map.release(); t.end(); From 121e95ada4b20525a47a3e8873219d1d19e50cb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Wed, 2 Sep 2015 11:50:56 -0700 Subject: [PATCH 077/156] Upgrade Travis to Xcode 7 image Only for iOS. OS X remains on Xcode 6.4. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f3a830849..6d7d31123 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,7 @@ matrix: osx_image: xcode6.4 env: FLAVOR=osx BUILDTYPE=Debug - os: osx - osx_image: xcode6.4 + osx_image: xcode7 env: FLAVOR=ios BUILDTYPE=Release - os: linux env: FLAVOR=android ANDROID_ABI=arm-v7 BUILDTYPE=Release From 6ec8b2805db9c88b3a37616a2c1ce82951557e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Thu, 10 Sep 2015 14:44:39 -0700 Subject: [PATCH 078/156] Upgraded to iOS Simulator 9.0, KIF 3.3.0 Upgraded the test project. Rolled back part of 69cf6ed3d273fc10e8cea2caef223f4a281388f0 to work around facebook/xctool#528. --- scripts/ios/test.sh | 9 ++- test/ios/App-Info.plist | 6 +- test/ios/Bundle-Info.plist | 2 +- test/ios/KIF | 2 +- test/ios/ios-tests.xcodeproj/project.pbxproj | 66 +++++++------------ .../xcschemes/Mapbox GL Tests.xcscheme | 2 +- 6 files changed, 35 insertions(+), 52 deletions(-) diff --git a/scripts/ios/test.sh b/scripts/ios/test.sh index 170aa0f64..60ccc76a9 100755 --- a/scripts/ios/test.sh +++ b/scripts/ios/test.sh @@ -4,8 +4,11 @@ set -e set -o pipefail set -u -xctool \ +xcodebuild \ -project ./test/ios/ios-tests.xcodeproj \ -scheme 'Mapbox GL Tests' \ - -sdk iphonesimulator8.4 \ - test + -sdk iphonesimulator \ + -destination 'platform=iOS Simulator,name=iPhone 6,OS=latest' \ + -destination 'platform=iOS Simulator,name=iPad 2,OS=latest' \ + test \ + | xcpretty diff --git a/test/ios/App-Info.plist b/test/ios/App-Info.plist index f817ea1d9..ab5ac7ec8 100644 --- a/test/ios/App-Info.plist +++ b/test/ios/App-Info.plist @@ -9,7 +9,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - com.mapbox.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -28,6 +28,8 @@ pk.eyJ1IjoianVzdGluIiwiYSI6Ik9RX3RRQzAifQ.dmOg_BAp1ywuDZMM7YsXRg MGLMapboxMetricsEnabledSettingShownInApp + NSLocationAlwaysUsageDescription + Strictly for testing purposes, promise! UILaunchStoryboardName LaunchScreen UIRequiredDeviceCapabilities @@ -40,8 +42,6 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - NSLocationAlwaysUsageDescription - Strictly for testing purposes, promise! UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait diff --git a/test/ios/Bundle-Info.plist b/test/ios/Bundle-Info.plist index 4ea0aed89..169b6f710 100644 --- a/test/ios/Bundle-Info.plist +++ b/test/ios/Bundle-Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - com.mapbox.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundlePackageType diff --git a/test/ios/KIF b/test/ios/KIF index 976aafa2e..21a137bc8 160000 --- a/test/ios/KIF +++ b/test/ios/KIF @@ -1 +1 @@ -Subproject commit 976aafa2e211dd095411bfef09da6c0919d70476 +Subproject commit 21a137bc8068f9fb738f835c6e285d44fe2ce4dd diff --git a/test/ios/ios-tests.xcodeproj/project.pbxproj b/test/ios/ios-tests.xcodeproj/project.pbxproj index 640837243..2807ee01b 100644 --- a/test/ios/ios-tests.xcodeproj/project.pbxproj +++ b/test/ios/ios-tests.xcodeproj/project.pbxproj @@ -41,6 +41,13 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + DA3BDF011BA2326400553BD2 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = DDBD013A196DC3AE0033959E /* KIF.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 9CC9673B1AD4B1B600576D13; + remoteInfo = KIFFramework; + }; DDBD0143196DC3AE0033959E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = DDBD013A196DC3AE0033959E /* KIF.xcodeproj */; @@ -48,13 +55,6 @@ remoteGlobalIDString = EABD46AA1857A0C700A5F081; remoteInfo = KIF; }; - DDBD0145196DC3AE0033959E /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = DDBD013A196DC3AE0033959E /* KIF.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = EB72047C1680DDAD00278DA2; - remoteInfo = "KIF-OCUnit"; - }; DDBD0147196DC3AE0033959E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = DDBD013A196DC3AE0033959E /* KIF.xcodeproj */; @@ -69,13 +69,6 @@ remoteGlobalIDString = EABD46CD1857A0F300A5F081; remoteInfo = "KIF Tests"; }; - DDBD014B196DC3AE0033959E /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = DDBD013A196DC3AE0033959E /* KIF.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = EB60ECEB177F8DB3005A041A; - remoteInfo = "KIF Tests-OCUnit"; - }; DDBD0160196DC3D70033959E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = DD04331B196DB9BC00E6F39D /* Project object */; @@ -327,10 +320,9 @@ isa = PBXGroup; children = ( DDBD0144196DC3AE0033959E /* libKIF.a */, - DDBD0146196DC3AE0033959E /* libKIF-OCUnit.a */, DDBD0148196DC3AE0033959E /* Test Host.app */, DDBD014A196DC3AE0033959E /* KIF Tests - XCTest.xctest */, - DDBD014C196DC3AE0033959E /* KIF Tests-OCUnit.octest */, + DA3BDF021BA2326400553BD2 /* KIF.framework */, ); name = Products; sourceTree = ""; @@ -396,7 +388,7 @@ isa = PBXProject; attributes = { CLASSPREFIX = MGLT; - LastUpgradeCheck = 0620; + LastUpgradeCheck = 0700; ORGANIZATIONNAME = Mapbox; TargetAttributes = { DDBD0151196DC3D70033959E = { @@ -430,6 +422,13 @@ /* End PBXProject section */ /* Begin PBXReferenceProxy section */ + DA3BDF021BA2326400553BD2 /* KIF.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = KIF.framework; + remoteRef = DA3BDF011BA2326400553BD2 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; DDBD0144196DC3AE0033959E /* libKIF.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; @@ -437,13 +436,6 @@ remoteRef = DDBD0143196DC3AE0033959E /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - DDBD0146196DC3AE0033959E /* libKIF-OCUnit.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libKIF-OCUnit.a"; - remoteRef = DDBD0145196DC3AE0033959E /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; DDBD0148196DC3AE0033959E /* Test Host.app */ = { isa = PBXReferenceProxy; fileType = wrapper.application; @@ -458,13 +450,6 @@ remoteRef = DDBD0149196DC3AE0033959E /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - DDBD014C196DC3AE0033959E /* KIF Tests-OCUnit.octest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = "KIF Tests-OCUnit.octest"; - remoteRef = DDBD014B196DC3AE0033959E /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ @@ -547,6 +532,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -618,6 +604,7 @@ ../../build/ios/pkg/static, ); OTHER_LDFLAGS = "-ObjC"; + PRODUCT_BUNDLE_IDENTIFIER = "com.mapbox.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; WRAPPER_EXTENSION = app; @@ -641,6 +628,7 @@ ../../build/ios/pkg/static, ); OTHER_LDFLAGS = "-ObjC"; + PRODUCT_BUNDLE_IDENTIFIER = "com.mapbox.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; WRAPPER_EXTENSION = app; @@ -651,12 +639,7 @@ isa = XCBuildConfiguration; buildSettings = { BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/Mapbox GL Tests.app/Mapbox GL Tests"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - "$(DEVELOPER_FRAMEWORKS_DIR)", - "$(DEVELOPER_DIR)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks", - ); + FRAMEWORK_SEARCH_PATHS = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -680,6 +663,7 @@ XCTest, "-ObjC", ); + PRODUCT_BUNDLE_IDENTIFIER = "com.mapbox.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUNDLE_LOADER)"; WRAPPER_EXTENSION = xctest; @@ -690,12 +674,7 @@ isa = XCBuildConfiguration; buildSettings = { BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/Mapbox GL Tests.app/Mapbox GL Tests"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - "$(DEVELOPER_FRAMEWORKS_DIR)", - "$(DEVELOPER_DIR)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks", - ); + FRAMEWORK_SEARCH_PATHS = ""; GCC_PREPROCESSOR_DEFINITIONS = "KIF_XCTEST=1"; HEADER_SEARCH_PATHS = ( "$(inherited)", @@ -715,6 +694,7 @@ XCTest, "-ObjC", ); + PRODUCT_BUNDLE_IDENTIFIER = "com.mapbox.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUNDLE_LOADER)"; WRAPPER_EXTENSION = xctest; diff --git a/test/ios/ios-tests.xcodeproj/xcshareddata/xcschemes/Mapbox GL Tests.xcscheme b/test/ios/ios-tests.xcodeproj/xcshareddata/xcschemes/Mapbox GL Tests.xcscheme index 2737f5185..c80cdb3d5 100644 --- a/test/ios/ios-tests.xcodeproj/xcshareddata/xcschemes/Mapbox GL Tests.xcscheme +++ b/test/ios/ios-tests.xcodeproj/xcshareddata/xcschemes/Mapbox GL Tests.xcscheme @@ -1,6 +1,6 @@ Date: Fri, 11 Sep 2015 15:42:41 -0700 Subject: [PATCH 079/156] Increased timeout for rotation animation --- test/ios/MapViewTests.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/ios/MapViewTests.m b/test/ios/MapViewTests.m index f4ae501d7..98636d1a9 100644 --- a/test/ios/MapViewTests.m +++ b/test/ios/MapViewTests.m @@ -46,7 +46,7 @@ 270, @"setting direction should take effect"); - [tester waitForTimeInterval:1]; + [tester waitForTimeInterval:2]; XCTAssertEqual(tester.compass.alpha, 1, @@ -89,7 +89,7 @@ [tester.mapView resetNorth]; - [tester waitForTimeInterval:1]; + [tester waitForTimeInterval:2]; XCTAssertEqual(tester.mapView.direction, 0, From 2ae0fbeec4a4d5d10407fb934536701dbd65d74b Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Tue, 15 Sep 2015 14:07:24 -0400 Subject: [PATCH 080/156] #2018 - Adding basic second activity that displays a map --- .../src/main/AndroidManifest.xml | 1 + .../mapbox/mapboxgl/testapp/MainActivity.java | 5 ++ .../mapboxgl/testapp/SecondMapActivity.java | 83 ++++++++++++++++++ .../drawable-hdpi/ic_looks_two_white_24dp.png | Bin 0 -> 237 bytes .../drawable-mdpi/ic_looks_two_white_24dp.png | Bin 0 -> 155 bytes .../ic_looks_two_white_24dp.png | Bin 0 -> 228 bytes .../ic_looks_two_white_24dp.png | Bin 0 -> 315 bytes .../ic_looks_two_white_24dp.png | Bin 0 -> 408 bytes .../src/main/res/layout/activity_second.xml | 13 +++ .../src/main/res/menu/menu_drawer.xml | 28 +++--- .../src/main/res/values/strings.xml | 1 + 11 files changed, 120 insertions(+), 11 deletions(-) create mode 100644 android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/SecondMapActivity.java create mode 100644 android/java/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_looks_two_white_24dp.png create mode 100644 android/java/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/ic_looks_two_white_24dp.png create mode 100644 android/java/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_looks_two_white_24dp.png create mode 100644 android/java/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_looks_two_white_24dp.png create mode 100644 android/java/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_looks_two_white_24dp.png create mode 100644 android/java/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_second.xml diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/android/java/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml index 85be72bb7..8e2041a12 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml @@ -17,6 +17,7 @@ + diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java index ed9b7ef06..eb5d891cd 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxgl.testapp; import android.Manifest; +import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Color; import android.graphics.PointF; @@ -281,6 +282,10 @@ public class MainActivity extends AppCompatActivity { menuItem.setChecked(mMapView.isCompassEnabled()); return true; + case R.id.action_second_map_activity: + startActivity(new Intent(getApplicationContext(), SecondMapActivity.class)); + return true; + /* case R.id.followNone: mMapView.setUserLocationTrackingMode(MapView.UserLocationTrackingMode.NONE); diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/SecondMapActivity.java b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/SecondMapActivity.java new file mode 100644 index 000000000..71e2b8a88 --- /dev/null +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/SecondMapActivity.java @@ -0,0 +1,83 @@ +package com.mapbox.mapboxgl.testapp; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.util.Log; +import com.mapbox.mapboxgl.views.MapView; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class SecondMapActivity extends AppCompatActivity { + + private static final String TAG = "SecondMapActivity"; + + private MapView mMapView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.activity_second); + + mMapView = (MapView) findViewById(R.id.secondMapView); + // Load the access token + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(getResources().openRawResource(R.raw.token))); + String line = reader.readLine(); + mMapView.setAccessToken(line); + } catch (IOException e) { + Log.e(TAG, "Error loading access token from token.txt: " + e.toString()); + } + + mMapView.onCreate(savedInstanceState); + + mMapView.setStyleUrl(getString(R.string.styleURLMapboxStreets)); + } + + /** + * Dispatch onStart() to all fragments. Ensure any created loaders are + * now started. + */ + @Override + protected void onStart() { + super.onStart(); + mMapView.onStart(); + } + + @Override + protected void onStop() { + super.onStop(); + mMapView.onStop(); + } + + // Called when our app goes into the background + @Override + public void onPause() { + super.onPause(); + + mMapView.onPause(); + } + + // Called when our app comes into the foreground + @Override + public void onResume() { + super.onResume(); + + mMapView.onResume(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mMapView.onDestroy(); + } + + // Called when the system is running low on memory + @Override + public void onLowMemory() { + super.onLowMemory(); + + mMapView.onLowMemory(); + } +} diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_looks_two_white_24dp.png b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_looks_two_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..2c9cf5b3a919b777acd93dc92e623879da06652e GIT binary patch literal 237 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8Lp7Ec$)5Rc<;r(WbetiaD zkrY>j*-a5FkDMJ7A5T2ov|dC+^x-r|PY0KZt=pG%bQo;6H=BO%*ZBpaa_jbP6}4Jb zdD`Lpibr}|?+Xe#HXfYuF;nJ*kT4(H%Ciw|aq%twY^^B|xudPCo&EMs+pp7CGQXkb lP3qeS!JA@M-8;9emM=YH=g1{rxfn zpsFp`@y+CtIe37>Ij1@W$<+Mb6Mw<&;$VF CE;d;J literal 0 HcmV?d00001 diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_looks_two_white_24dp.png b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_looks_two_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..c9fc6633e8a2fc4d1dd5401b88fbc93416accfdb GIT binary patch literal 228 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}b0D)t)YnAr*{oulsT}8;H0*?74mE zlJAr^u2FYZ+E)t}3cFtU`O@UeM9;m2m&)JS$h!#e&a>+GIDKe+?iUxQT@JfWoVk~l zB$p9*O+GMYgFDK^F*;jh}smaTaVi(Rg b)-%|hEYkd4_C)*|(Af;0u6{1-oD!MTBj literal 0 HcmV?d00001 diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_looks_two_white_24dp.png b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_looks_two_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..f8ab38aa6a228f51fc5c08c8066eb0064643ed04 GIT binary patch literal 315 zcmV-B0mS}^P)Onpm>AAn64g|-30S)^6xC(=iLv#MG^v& zoRo9Uk?B}-Vv2fpEGeX+C5AR*&(s~6si4fBhz?{8)DhJ}1FeZ_tAS2LRW(px1{q|K zc+h2qC*JvO19aIv-)(^s5AJEGcX zpe0dt8mMq2qEE7Z#d!$e+>%sKqOf2~Wr`{rIxl8;uuoF`1Y247L%hy+sE_A z?AZ;EDCx*4w9Gl`)OpYCsIHCo1Q~}TP8XYB+Gh16nvcvM*52d((VRG?)c5b4 zATQ0OBF=zi1wwab>w=6dn5wcV`bGDG&BEnbW~AA@}b`87UX zF_J4d7JR(o0Iz@OM}~Aub`FIG1}2V#{cFw&3zz+5nzdD;_^kMaH@(^S7?LMhFF2}~ z-|%sw^#jXthvV`JpP2sygOmgHL?8Q-`TVDASz-%o?gPPshoanf&L}5{d@Qbd&%fbl zlR0aBgQ3`ta;^S`x(5$u1~oc695`y3aLjK0ajlC_`2`#p7+C}qlE6kW?O=T|zY53) z3Vy2p__bv@-^T{gd9#i)b7k!b`7Fe5;I(JVfgpxhvx*m!{kRq=PPt;UX%?%j4)29E v2`4AMVibSgSXun-GUGpWsN;Z)=e5iS^S8+R@*dw03~>feS3j3^P6 + + + + + diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml index a374ab18d..44117426a 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml @@ -19,18 +19,24 @@ android:checkable="true" /> - + diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml index 403da277c..765f4d196 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml @@ -10,6 +10,7 @@ Toggle compass Toggle debug mode Toggle point annotations + Launch 2nd Map FPS: From d3b34f644801e4e6f90df1aaa42ded286fa0ed08 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Tue, 15 Sep 2015 11:08:29 -0700 Subject: [PATCH 081/156] update changelog for ios-v2.1.1 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7ecd8cd1..9165386ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## iOS 2.1.1 + +- Fixes for Xcode 7 and Bitcode. ([#2238](https://github.com/mapbox/mapbox-gl-native/pull/2238)) + ## iOS 2.1.0 - A two-finger vertical swipe now tilts the map into perspective mode. ([#2116](https://github.com/mapbox/mapbox-gl-native/pull/2116)) From 5a06f27f27db3bc8372d3688ca0d4a397e171fc7 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Tue, 15 Sep 2015 11:08:54 -0700 Subject: [PATCH 082/156] update podspec for 2.1.1 --- ios/Mapbox-iOS-SDK.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Mapbox-iOS-SDK.podspec b/ios/Mapbox-iOS-SDK.podspec index 3fad85cf1..12d52b335 100644 --- a/ios/Mapbox-iOS-SDK.podspec +++ b/ios/Mapbox-iOS-SDK.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |m| m.name = 'Mapbox-iOS-SDK' - m.version = '2.1.0' + m.version = '2.1.1' 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 bindings.' From 3f837ecd94c3b5370577841733048ce18fdc011c Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Tue, 15 Sep 2015 14:17:46 -0400 Subject: [PATCH 083/156] added permission to save tests screenshots --- .../java/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/android/java/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml index 85be72bb7..15d5edc17 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml @@ -25,4 +25,5 @@ + From 4e1ead344bfb1f9ddb207924465fabae3d218d67 Mon Sep 17 00:00:00 2001 From: Lucas Wojciechowski Date: Wed, 2 Sep 2015 13:38:37 -0700 Subject: [PATCH 084/156] [node] Enable npm to build mapbox-gl-native package from source - Allow node bindings to be built if git submodules cannot be checked out - Made geojsonvt a mason package instead of a git submodule - Use globally installed mason if it cannot be checked out via git submodules --- .gitmodules | 3 --- configure | 30 ++++++++++++++++++++++-- gyp/core.gypi | 5 ++++ gyp/version.gypi | 2 +- scripts/android/configure.sh | 2 ++ scripts/build-version.py | 45 +++++++++++++++++++++++++----------- scripts/ios/configure.sh | 2 ++ scripts/ios/package.sh | 6 +++-- scripts/linux/configure.sh | 2 ++ scripts/main.mk | 10 ++++---- scripts/osx/configure.sh | 2 ++ scripts/osx/run.sh | 3 --- src/mbgl/map/annotation.cpp | 3 ++- src/mbgl/map/annotation.hpp | 3 ++- src/mbgl/util/geojsonvt | 1 - test/test.gypi | 3 +++ 16 files changed, 90 insertions(+), 32 deletions(-) delete mode 160000 src/mbgl/util/geojsonvt diff --git a/.gitmodules b/.gitmodules index 2aa6d52be..0152ed56b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -14,6 +14,3 @@ path = platform/ios/vendor/SMCalloutView url = https://github.com/nfarina/calloutview.git -[submodule "src/mbgl/util/geojsonvt"] - path = src/mbgl/util/geojsonvt - url = https://github.com/mapbox/geojson-vt-cpp diff --git a/configure b/configure index 6fbaa9f7f..6d0ac780c 100755 --- a/configure +++ b/configure @@ -15,8 +15,15 @@ function abort { >&2 echo -e "\033[1m\033[31m$1\033[0m"; exit 1; } function info { >&2 echo -e "\033[1m\033[33m$1\033[0m"; } function warn { >&2 echo -e "\033[1m\033[33m$1\033[0m"; } -# Install mason -export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" +if [ -d "`pwd`/.git" ]; then + info "This build is within a git repository" + export MASON_DIR="`pwd`/.mason" + export PATH="${MASON_DIR}:${PATH}" +else + info "This build is NOT within a git repository" + which mason || abort "You must install mason to build mapbox-gl-native (https://github.com/mapbox/mason)" + export MASON_DIR="$(dirname $(readlink $(which mason)))" +fi # You can override the function for a particular set of flags by defining a # print_XXX_flags function in your dependencies.sh file @@ -37,6 +44,23 @@ function print_flags { fi } +function print_build_flags { + local NAME=$1; shift + if [ "$(type -t print_${NAME}_flags)" = 'function' ]; then + print_${NAME}_flags + else + local VERSION=`echo "${NAME}_VERSION" | tr "[:lower:]" "[:upper:]"` + if [ ! -z ${!VERSION:-} ] ; then + mason build ${NAME} ${!VERSION} + for FLAGS in "$@" ; do + CONFIG+=" '${NAME}_${FLAGS}%': $(quote_flags $(mason ${FLAGS} ${NAME} ${!VERSION})),"$LN + done + else + warn "* Not using ${NAME}" + fi + fi +} + function print_default_flags { : } @@ -93,6 +117,8 @@ print_flags libuv static_libs cflags ldflags print_flags zlib static_libs cflags ldflags print_flags nunicode static_libs cflags ldflags print_flags libzip static_libs cflags ldflags +print_build_flags geojsonvt static_libs cflags ldflags +print_flags variant static_libs cflags ldflags CONFIG+=" } } diff --git a/gyp/core.gypi b/gyp/core.gypi index f9b361032..51009be69 100644 --- a/gyp/core.gypi +++ b/gyp/core.gypi @@ -31,10 +31,14 @@ '<@(libuv_cflags)', '<@(opengl_cflags)', '<@(boost_cflags)', + '<@(geojsonvt_cflags)', + '<@(variant_cflags)', ], 'cflags': [ '<@(libuv_cflags)', '<@(opengl_cflags)', + '<@(geojsonvt_cflags)', + '<@(variant_cflags)', '-fPIC' ], 'ldflags': [ @@ -43,6 +47,7 @@ ], 'libraries': [ '<@(libuv_static_libs)', + '<@(geojsonvt_static_libs)', ], }, diff --git a/gyp/version.gypi b/gyp/version.gypi index 1cc2eb351..4efdd079a 100644 --- a/gyp/version.gypi +++ b/gyp/version.gypi @@ -13,7 +13,7 @@ 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/include/mbgl/util/version.hpp', ], - 'action': ['<@(_inputs)', '<(SHARED_INTERMEDIATE_DIR)', ' + #include #include #include #include #include #include -#include #include #include diff --git a/src/mbgl/map/annotation.hpp b/src/mbgl/map/annotation.hpp index 5adec162f..6b80d9f6c 100644 --- a/src/mbgl/map/annotation.hpp +++ b/src/mbgl/map/annotation.hpp @@ -1,13 +1,14 @@ #ifndef MBGL_MAP_ANNOTATIONS #define MBGL_MAP_ANNOTATIONS +#include + #include #include #include #include #include #include -#include #include #include diff --git a/src/mbgl/util/geojsonvt b/src/mbgl/util/geojsonvt deleted file mode 160000 index 995ffc72c..000000000 --- a/src/mbgl/util/geojsonvt +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 995ffc72c556da4b4880a6036fbcf7159fc5ecce diff --git a/test/test.gypi b/test/test.gypi index a35b00133..c53263bd5 100644 --- a/test/test.gypi +++ b/test/test.gypi @@ -95,6 +95,7 @@ 'libraries': [ '<@(libuv_static_libs)', '<@(sqlite_static_libs)', + '<@(geojsonvt_static_libs)', ], 'variables': { 'cflags_cc': [ @@ -102,6 +103,8 @@ '<@(opengl_cflags)', '<@(boost_cflags)', '<@(sqlite_cflags)', + '<@(geojsonvt_cflags)', + '<@(variant_cflags)', ], 'ldflags': [ '<@(libuv_ldflags)', From 2235a86054d1192b93ce62bd2c6b56a5b8dfcc87 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Tue, 15 Sep 2015 14:18:00 -0400 Subject: [PATCH 085/156] manually add a screenshot name --- .../mapboxgl/testapp/utils/ScreenshotUtil.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/utils/ScreenshotUtil.java b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/utils/ScreenshotUtil.java index 0e35fad68..51eceaca9 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/utils/ScreenshotUtil.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/utils/ScreenshotUtil.java @@ -30,7 +30,7 @@ public class ScreenshotUtil { private static final Bitmap.CompressFormat DEFAULT_IMAGE_FORMAT = Bitmap.CompressFormat.PNG; private static final int DEFAULT_IMAGE_QUALITY = 100; - public static void take(Activity activity) { + public static void take(Activity activity, String testName) { // Check if storage is available if (!isExternalStorageWritable()) { @@ -46,7 +46,7 @@ public class ScreenshotUtil { rootView.setDrawingCacheEnabled(false); // Save the bitmap in external storage - String uniqueAbsolutePath = getUniqueAbsolutePath(); + String uniqueAbsolutePath = getUniqueAbsolutePath(testName); File outputFile = new File(uniqueAbsolutePath); OutputStream outputStream = null; try { @@ -77,9 +77,14 @@ public class ScreenshotUtil { return false; } - private static String getUniqueAbsolutePath() { - String externalPath = Environment.getExternalStorageDirectory().toString(); + private static String getUniqueAbsolutePath(String testName) { + // A screenshot after every test vs. manual tests String filename = UUID.randomUUID().toString() + DEFAULT_IMAGE_EXTENSION; + if (testName != null && !testName.isEmpty()) { + filename = testName + DEFAULT_IMAGE_EXTENSION; + } + + String externalPath = Environment.getExternalStorageDirectory().toString(); String path = externalPath + File.separator + SCREENSHOT_FOLDER + File.separator + filename; Log.d(LOG_TAG, "Screenshot path: " + path); return path; From df7ef8ee871c53a26a7075ab21efd2f3a7638036 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Tue, 15 Sep 2015 14:18:22 -0400 Subject: [PATCH 086/156] flag to enable automatic screenshots on teardown --- .../com/mapbox/mapboxgl/testapp/BaseTest.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java index 7ec3c3181..038cc3099 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java @@ -14,6 +14,7 @@ public class BaseTest extends ActivityInstrumentationTestCase2 { private MainActivity mActivity; + private final static boolean screenshotOnTearDown = false; public BaseTest() { super(MainActivity.class); @@ -36,12 +37,16 @@ public class BaseTest @Override protected void tearDown() throws Exception { + if (!screenshotOnTearDown) { + return; + } + try { // Screenshots should be taken on the UI thread runTestOnUiThread(new Runnable() { @Override public void run() { - ScreenshotUtil.take(getActivity()); + ScreenshotUtil.take(getActivity(), null); } }); } catch (Throwable throwable) { @@ -51,4 +56,18 @@ public class BaseTest super.tearDown(); } + protected void takeNamedScreenshot(final String name) { + try { + // Screenshots should be taken on the UI thread + runTestOnUiThread(new Runnable() { + @Override + public void run() { + ScreenshotUtil.take(getActivity(), name); + } + }); + } catch (Throwable throwable) { + throwable.printStackTrace(); + } + } + } From c0b9ec6da4654473780c5c747c43e396448b5d36 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Tue, 15 Sep 2015 14:19:23 -0400 Subject: [PATCH 087/156] ready for aws screenshots --- .../mapboxgl/testapp/MainActivityTest.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java index 08948b33b..64485ed59 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java @@ -150,7 +150,7 @@ public class MainActivityTest extends BaseTest { .perform(click()); onView(withText(R.string.action_debug)) .perform(click()); - + // Clicking the item closes the drawer onView(withId(R.id.nav_view)) .check(matches(not(isDisplayed()))); @@ -268,4 +268,18 @@ public class MainActivityTest extends BaseTest { .check(matches(isDisplayed())); } + /* + * Take a screenshot of Mapbox Streets to monitor #1649 + */ + + @Test + public void testMapboxStreetsBlackAndWhite() { + // Click home and switch to Mapbox streets + onView(withContentDescription(HOME_BUTTON_STRING)) + .perform(click()); + onView(withText(R.string.styleMapboxStreets)) + .perform(click()); + takeNamedScreenshot("testMapboxStreetsBlackAndWhite"); + } + } From f3e4d3238b52898cd6481a626640cf33f5cd88d8 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Tue, 15 Sep 2015 14:20:46 -0400 Subject: [PATCH 088/156] merge from master --- test/ios/KIF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ios/KIF b/test/ios/KIF index 21a137bc8..976aafa2e 160000 --- a/test/ios/KIF +++ b/test/ios/KIF @@ -1 +1 @@ -Subproject commit 21a137bc8068f9fb738f835c6e285d44fe2ce4dd +Subproject commit 976aafa2e211dd095411bfef09da6c0919d70476 From 29baa6f6ac23ed03c695dee70413ea558746526a Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Tue, 15 Sep 2015 11:21:45 -0700 Subject: [PATCH 089/156] [publish ios-v2.1.1] From 8c177e8b2bd2e1a84fadfb3bfc062dbba68f0358 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Tue, 15 Sep 2015 12:04:57 -0700 Subject: [PATCH 090/156] move back to symbolicated iOS builds for dev --- ios/Mapbox-iOS-SDK.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Mapbox-iOS-SDK.podspec b/ios/Mapbox-iOS-SDK.podspec index 12d52b335..eb94769dd 100644 --- a/ios/Mapbox-iOS-SDK.podspec +++ b/ios/Mapbox-iOS-SDK.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |m| m.name = 'Mapbox-iOS-SDK' - m.version = '2.1.1' + m.version = '2.1.1-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 bindings.' From ac64c34a497104b411672b17a8ca6d7526a53f60 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Tue, 15 Sep 2015 15:53:32 -0400 Subject: [PATCH 091/156] #2018 - Toolbar on Second Activity with back button support --- .../src/main/AndroidManifest.xml | 2 +- .../mapboxgl/testapp/SecondMapActivity.java | 20 +++++++++++++++++++ .../src/main/res/layout/activity_second.xml | 8 ++++++++ .../src/main/res/values/strings.xml | 2 ++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/android/java/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml index 8e2041a12..5e07c105a 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml @@ -17,7 +17,7 @@ - + diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/SecondMapActivity.java b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/SecondMapActivity.java index 71e2b8a88..ced82d1b8 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/SecondMapActivity.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/SecondMapActivity.java @@ -1,8 +1,12 @@ package com.mapbox.mapboxgl.testapp; import android.os.Bundle; +import android.support.v4.view.GravityCompat; import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; import android.util.Log; +import android.view.MenuItem; +import android.view.View; import com.mapbox.mapboxgl.views.MapView; import java.io.BufferedReader; import java.io.IOException; @@ -20,6 +24,11 @@ public class SecondMapActivity extends AppCompatActivity { setContentView(R.layout.activity_second); + Toolbar toolbar = (Toolbar) findViewById(R.id.secondToolBar); + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayShowHomeEnabled(true); + mMapView = (MapView) findViewById(R.id.secondMapView); // Load the access token try { @@ -80,4 +89,15 @@ public class SecondMapActivity extends AppCompatActivity { mMapView.onLowMemory(); } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + onBackPressed(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } } diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_second.xml b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_second.xml index 74c1011b5..2ffda1daa 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_second.xml +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_second.xml @@ -4,6 +4,14 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + Mapbox GL + Second Activity + Toggle GPS location Disable tracking Use follow tracking mode From 83a3148921d1117fc179ee174a3a9ec73c7672b3 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Tue, 15 Sep 2015 15:54:58 -0400 Subject: [PATCH 092/156] #2018 - Making Launch 2nd Activity draw menu item not checkable --- .../MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml index 44117426a..ff537aaf3 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml @@ -22,7 +22,7 @@ + diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml index 403da277c..836951cc5 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml @@ -3,6 +3,8 @@ Mapbox GL + Second Activity + Toggle GPS location Disable tracking Use follow tracking mode @@ -10,6 +12,7 @@ Toggle compass Toggle debug mode Toggle point annotations + Launch 2nd Map FPS: diff --git a/configure b/configure index 6fbaa9f7f..6d0ac780c 100755 --- a/configure +++ b/configure @@ -15,8 +15,15 @@ function abort { >&2 echo -e "\033[1m\033[31m$1\033[0m"; exit 1; } function info { >&2 echo -e "\033[1m\033[33m$1\033[0m"; } function warn { >&2 echo -e "\033[1m\033[33m$1\033[0m"; } -# Install mason -export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" +if [ -d "`pwd`/.git" ]; then + info "This build is within a git repository" + export MASON_DIR="`pwd`/.mason" + export PATH="${MASON_DIR}:${PATH}" +else + info "This build is NOT within a git repository" + which mason || abort "You must install mason to build mapbox-gl-native (https://github.com/mapbox/mason)" + export MASON_DIR="$(dirname $(readlink $(which mason)))" +fi # You can override the function for a particular set of flags by defining a # print_XXX_flags function in your dependencies.sh file @@ -37,6 +44,23 @@ function print_flags { fi } +function print_build_flags { + local NAME=$1; shift + if [ "$(type -t print_${NAME}_flags)" = 'function' ]; then + print_${NAME}_flags + else + local VERSION=`echo "${NAME}_VERSION" | tr "[:lower:]" "[:upper:]"` + if [ ! -z ${!VERSION:-} ] ; then + mason build ${NAME} ${!VERSION} + for FLAGS in "$@" ; do + CONFIG+=" '${NAME}_${FLAGS}%': $(quote_flags $(mason ${FLAGS} ${NAME} ${!VERSION})),"$LN + done + else + warn "* Not using ${NAME}" + fi + fi +} + function print_default_flags { : } @@ -93,6 +117,8 @@ print_flags libuv static_libs cflags ldflags print_flags zlib static_libs cflags ldflags print_flags nunicode static_libs cflags ldflags print_flags libzip static_libs cflags ldflags +print_build_flags geojsonvt static_libs cflags ldflags +print_flags variant static_libs cflags ldflags CONFIG+=" } } diff --git a/gyp/core.gypi b/gyp/core.gypi index f9b361032..51009be69 100644 --- a/gyp/core.gypi +++ b/gyp/core.gypi @@ -31,10 +31,14 @@ '<@(libuv_cflags)', '<@(opengl_cflags)', '<@(boost_cflags)', + '<@(geojsonvt_cflags)', + '<@(variant_cflags)', ], 'cflags': [ '<@(libuv_cflags)', '<@(opengl_cflags)', + '<@(geojsonvt_cflags)', + '<@(variant_cflags)', '-fPIC' ], 'ldflags': [ @@ -43,6 +47,7 @@ ], 'libraries': [ '<@(libuv_static_libs)', + '<@(geojsonvt_static_libs)', ], }, diff --git a/gyp/version.gypi b/gyp/version.gypi index 1cc2eb351..4efdd079a 100644 --- a/gyp/version.gypi +++ b/gyp/version.gypi @@ -13,7 +13,7 @@ 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/include/mbgl/util/version.hpp', ], - 'action': ['<@(_inputs)', '<(SHARED_INTERMEDIATE_DIR)', ' + #include #include #include #include #include #include -#include #include #include diff --git a/src/mbgl/map/annotation.hpp b/src/mbgl/map/annotation.hpp index 5adec162f..6b80d9f6c 100644 --- a/src/mbgl/map/annotation.hpp +++ b/src/mbgl/map/annotation.hpp @@ -1,13 +1,14 @@ #ifndef MBGL_MAP_ANNOTATIONS #define MBGL_MAP_ANNOTATIONS +#include + #include #include #include #include #include #include -#include #include #include diff --git a/test/test.gypi b/test/test.gypi index a35b00133..c53263bd5 100644 --- a/test/test.gypi +++ b/test/test.gypi @@ -95,6 +95,7 @@ 'libraries': [ '<@(libuv_static_libs)', '<@(sqlite_static_libs)', + '<@(geojsonvt_static_libs)', ], 'variables': { 'cflags_cc': [ @@ -102,6 +103,8 @@ '<@(opengl_cflags)', '<@(boost_cflags)', '<@(sqlite_cflags)', + '<@(geojsonvt_cflags)', + '<@(variant_cflags)', ], 'ldflags': [ '<@(libuv_ldflags)', From 42e6af0648a90b82dd557870a8930b4f20f8b036 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Tue, 15 Sep 2015 16:00:34 -0700 Subject: [PATCH 100/156] update changelog for ios-v2.1.2 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9165386ea..f2a33b100 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## iOS 2.1.2 + +- Built with Xcode 6.4 to not yet trigger Bitcode compatibility until Xcode 7 stabilizes. ([#2332](https://github.com/mapbox/mapbox-gl-native/issues/2332)) + ## iOS 2.1.1 - Fixes for Xcode 7 and Bitcode. ([#2238](https://github.com/mapbox/mapbox-gl-native/pull/2238)) From bdd8c329bb59ae4ef90509def560242196e0a0bc Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Tue, 15 Sep 2015 16:00:52 -0700 Subject: [PATCH 101/156] bump podspec for 2.1.2 --- ios/Mapbox-iOS-SDK.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Mapbox-iOS-SDK.podspec b/ios/Mapbox-iOS-SDK.podspec index 12d52b335..1284c6006 100644 --- a/ios/Mapbox-iOS-SDK.podspec +++ b/ios/Mapbox-iOS-SDK.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |m| m.name = 'Mapbox-iOS-SDK' - m.version = '2.1.1' + m.version = '2.1.2' 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 bindings.' From c9b14125d826d2f9990f1366d13823b8714ee4d8 Mon Sep 17 00:00:00 2001 From: Adam Hunter Date: Mon, 14 Sep 2015 12:02:35 -0700 Subject: [PATCH 102/156] Add test that setting the center coordinate cancels animations --- test/ios/MapViewTests.m | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/ios/MapViewTests.m b/test/ios/MapViewTests.m index 98636d1a9..516ff1df8 100644 --- a/test/ios/MapViewTests.m +++ b/test/ios/MapViewTests.m @@ -220,6 +220,26 @@ @"panning map right should decrease center longitude"); } +- (void)testSetCenterCancelsTransitions { + CLLocationCoordinate2D dc = CLLocationCoordinate2DMake(38.894368, -77.036487); + CLLocationCoordinate2D dc_west = CLLocationCoordinate2DMake(38.894368, -77.076487); + [tester.mapView setCenterCoordinate:dc animated:NO]; + [tester.mapView setCenterCoordinate:dc_west animated:YES]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.15 * NSEC_PER_SEC), + dispatch_get_main_queue(), + ^{ + [tester.mapView setCenterCoordinate:dc animated:NO]; + XCTAssertEqualWithAccuracy(dc.latitude, + tester.mapView.centerCoordinate.latitude, + 0.0005, + @"setting center coordinate should cancel transitions"); + XCTAssertEqualWithAccuracy(dc.longitude, + tester.mapView.centerCoordinate.longitude, + 0.0005, + @"setting center coordinate should cancel transitions"); + }); +} + - (void)testPanDisabled { tester.mapView.scrollEnabled = NO; CLLocationCoordinate2D centerCoordinate = tester.mapView.centerCoordinate; From 620e554f677d05edd0a588b56f343435516c05a8 Mon Sep 17 00:00:00 2001 From: Adam Hunter Date: Tue, 15 Sep 2015 11:33:01 -0700 Subject: [PATCH 103/156] Fixes the test for setting center canceling animations. A good submit to look at for writing asynchronous tests. --- test/ios/MapViewTests.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/ios/MapViewTests.m b/test/ios/MapViewTests.m index 516ff1df8..d0913670c 100644 --- a/test/ios/MapViewTests.m +++ b/test/ios/MapViewTests.m @@ -221,6 +221,8 @@ } - (void)testSetCenterCancelsTransitions { + XCTestExpectation *cameraIsInDCExpectation = [self expectationWithDescription:@"camera reset to DC"]; + CLLocationCoordinate2D dc = CLLocationCoordinate2DMake(38.894368, -77.036487); CLLocationCoordinate2D dc_west = CLLocationCoordinate2DMake(38.894368, -77.076487); [tester.mapView setCenterCoordinate:dc animated:NO]; @@ -237,7 +239,12 @@ tester.mapView.centerCoordinate.longitude, 0.0005, @"setting center coordinate should cancel transitions"); + [cameraIsInDCExpectation fulfill]; }); + + [self waitForExpectationsWithTimeout:1.0 handler:^(NSError *error) { + ; + }]; } - (void)testPanDisabled { From 529a7cc93c7819c62d81bd825e8682cf3f93b495 Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Wed, 16 Sep 2015 12:45:46 +1000 Subject: [PATCH 104/156] Create SharedSQLiteCache --- android/cpp/native_map_view.cpp | 4 ++-- include/mbgl/android/native_map_view.hpp | 2 +- include/mbgl/storage/sqlite_cache.hpp | 10 ++++++++++ platform/default/sqlite_cache.cpp | 12 ++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/android/cpp/native_map_view.cpp b/android/cpp/native_map_view.cpp index f38513b32..9ffb083ec 100644 --- a/android/cpp/native_map_view.cpp +++ b/android/cpp/native_map_view.cpp @@ -58,8 +58,8 @@ NativeMapView::NativeMapView(JNIEnv *env, jobject obj_, float pixelRatio_, int a pixelRatio(pixelRatio_), availableProcessors(availableProcessors_), totalMemory(totalMemory_), - fileCache(mbgl::android::cachePath + "/mbgl-cache.db"), - fileSource(&fileCache), + fileCache(mbgl::SharedSQLiteCache::get(mbgl::android::cachePath + "/mbgl-cache.db")), + fileSource(fileCache.get()), map(*this, fileSource, MapMode::Continuous) { mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::NativeMapView"); diff --git a/include/mbgl/android/native_map_view.hpp b/include/mbgl/android/native_map_view.hpp index d5606ae37..4033c628b 100644 --- a/include/mbgl/android/native_map_view.hpp +++ b/include/mbgl/android/native_map_view.hpp @@ -90,7 +90,7 @@ private: size_t totalMemory = 0; // Ensure these are initialised last - mbgl::SQLiteCache fileCache; + std::shared_ptr fileCache; mbgl::DefaultFileSource fileSource; mbgl::Map map; diff --git a/include/mbgl/storage/sqlite_cache.hpp b/include/mbgl/storage/sqlite_cache.hpp index 65328652f..3054b6c73 100644 --- a/include/mbgl/storage/sqlite_cache.hpp +++ b/include/mbgl/storage/sqlite_cache.hpp @@ -26,6 +26,16 @@ private: const std::unique_ptr> thread; }; +class SharedSQLiteCache : util::noncopyable { +public: + static std::shared_ptr get(const std::string &path = ":memory:"); + +private: + SharedSQLiteCache() {} + + static std::weak_ptr masterPtr; +}; + } #endif diff --git a/platform/default/sqlite_cache.cpp b/platform/default/sqlite_cache.cpp index 9d5d0541e..8863c151e 100644 --- a/platform/default/sqlite_cache.cpp +++ b/platform/default/sqlite_cache.cpp @@ -264,4 +264,16 @@ void SQLiteCache::Impl::refresh(const Resource& resource, int64_t expires) { } } +std::shared_ptr SharedSQLiteCache::get(const std::string &path) { + std::shared_ptr temp = masterPtr.lock(); + if (!temp) { + temp.reset(new SQLiteCache(path)); + masterPtr = temp; + } + + return temp; +} + +std::weak_ptr SharedSQLiteCache::masterPtr; + } From 99053f47f7a407f3e0a6fbdede5627366349f680 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Wed, 16 Sep 2015 09:29:53 -0400 Subject: [PATCH 105/156] merge with master --- CHANGELOG.md | 4 ++++ ios/Mapbox-iOS-SDK.podspec | 2 +- test/ios/MapViewTests.m | 27 +++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9165386ea..f2a33b100 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## iOS 2.1.2 + +- Built with Xcode 6.4 to not yet trigger Bitcode compatibility until Xcode 7 stabilizes. ([#2332](https://github.com/mapbox/mapbox-gl-native/issues/2332)) + ## iOS 2.1.1 - Fixes for Xcode 7 and Bitcode. ([#2238](https://github.com/mapbox/mapbox-gl-native/pull/2238)) diff --git a/ios/Mapbox-iOS-SDK.podspec b/ios/Mapbox-iOS-SDK.podspec index eb94769dd..139ad655f 100644 --- a/ios/Mapbox-iOS-SDK.podspec +++ b/ios/Mapbox-iOS-SDK.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |m| m.name = 'Mapbox-iOS-SDK' - m.version = '2.1.1-symbols' + m.version = '2.1.2-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 bindings.' diff --git a/test/ios/MapViewTests.m b/test/ios/MapViewTests.m index 98636d1a9..d0913670c 100644 --- a/test/ios/MapViewTests.m +++ b/test/ios/MapViewTests.m @@ -220,6 +220,33 @@ @"panning map right should decrease center longitude"); } +- (void)testSetCenterCancelsTransitions { + XCTestExpectation *cameraIsInDCExpectation = [self expectationWithDescription:@"camera reset to DC"]; + + CLLocationCoordinate2D dc = CLLocationCoordinate2DMake(38.894368, -77.036487); + CLLocationCoordinate2D dc_west = CLLocationCoordinate2DMake(38.894368, -77.076487); + [tester.mapView setCenterCoordinate:dc animated:NO]; + [tester.mapView setCenterCoordinate:dc_west animated:YES]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.15 * NSEC_PER_SEC), + dispatch_get_main_queue(), + ^{ + [tester.mapView setCenterCoordinate:dc animated:NO]; + XCTAssertEqualWithAccuracy(dc.latitude, + tester.mapView.centerCoordinate.latitude, + 0.0005, + @"setting center coordinate should cancel transitions"); + XCTAssertEqualWithAccuracy(dc.longitude, + tester.mapView.centerCoordinate.longitude, + 0.0005, + @"setting center coordinate should cancel transitions"); + [cameraIsInDCExpectation fulfill]; + }); + + [self waitForExpectationsWithTimeout:1.0 handler:^(NSError *error) { + ; + }]; +} + - (void)testPanDisabled { tester.mapView.scrollEnabled = NO; CLLocationCoordinate2D centerCoordinate = tester.mapView.centerCoordinate; From e4d1e67d71f17476f6a50d98ee22e9427578ccb5 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Wed, 16 Sep 2015 11:01:45 -0400 Subject: [PATCH 106/156] second activity test class --- .../testapp/SecondMapActivityTest.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/SecondMapActivityTest.java diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/SecondMapActivityTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/SecondMapActivityTest.java new file mode 100644 index 000000000..593b0b2ee --- /dev/null +++ b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/SecondMapActivityTest.java @@ -0,0 +1,41 @@ +package com.mapbox.mapboxgl.testapp; + +import android.support.test.rule.ActivityTestRule; +import android.support.test.runner.AndroidJUnit4; +import android.test.suitebuilder.annotation.LargeTest; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; + +/** + * Tests on SecondMapActivity. + */ +@RunWith(AndroidJUnit4.class) +@LargeTest +public class SecondMapActivityTest extends BaseTest { + + @Rule + public ActivityTestRule mActivityRule = new ActivityTestRule<>( + SecondMapActivity.class); + + private SecondMapActivity mActivity = null; + + @Before + public void setActivity() { + mActivity = mActivityRule.getActivity(); + } + + @Test + public void testSanity() { + onView(withId(R.id.secondMapView)) + .check(matches(isDisplayed())); + } + +} From c3dffb6e46e28a56f7707443ba2025b1aac4fd12 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Wed, 16 Sep 2015 11:02:11 -0400 Subject: [PATCH 107/156] moved screenshot tests to its own class --- .../testapp/MainActivityScreenTest.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityScreenTest.java diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityScreenTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityScreenTest.java new file mode 100644 index 000000000..af35620f6 --- /dev/null +++ b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityScreenTest.java @@ -0,0 +1,61 @@ +package com.mapbox.mapboxgl.testapp; + +import android.support.test.rule.ActivityTestRule; +import android.support.test.runner.AndroidJUnit4; +import android.test.suitebuilder.annotation.LargeTest; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static android.support.test.espresso.matcher.ViewMatchers.withText; + +/** + * Tests on MainActivity with screenshots + */ +@RunWith(AndroidJUnit4.class) +@LargeTest +public class MainActivityScreenTest extends BaseTest { + + private final static String HOME_BUTTON_STRING = "Navigate up"; + + @Rule + public ActivityTestRule mActivityRule = new ActivityTestRule<>( + MainActivity.class); + + private MainActivity mActivity = null; + + @Before + public void setActivity() { + mActivity = mActivityRule.getActivity(); + } + + @Test + public void testSanity() { + checkViewIsDisplayed(R.id.mainMapView); + } + + /* + * Take a screenshot of Mapbox Streets to monitor #1649 + */ + + @Test + public void testMapboxStreetsBlackAndWhite() { + // Click home and switch to Mapbox streets + onView(withContentDescription(HOME_BUTTON_STRING)) + .perform(click()); + onView(withText(R.string.styleMapboxStreets)) + .perform(click()); + + // Standard screenshot + takeNamedScreenshot(mActivity, "testMapboxStreetsBlackAndWhite"); + } + +} From 602a075333861160ead82067fda8f568deec3112 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Wed, 16 Sep 2015 11:03:10 -0400 Subject: [PATCH 108/156] using the new version way of instanstiating the activity class --- .../com/mapbox/mapboxgl/testapp/BaseTest.java | 66 +++++-------------- .../mapboxgl/testapp/MainActivityTest.java | 37 ++++++----- 2 files changed, 36 insertions(+), 67 deletions(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java index 60ac10f14..9c6646105 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java @@ -1,5 +1,6 @@ package com.mapbox.mapboxgl.testapp; +import android.app.Activity; import android.support.test.InstrumentationRegistry; import android.test.ActivityInstrumentationTestCase2; @@ -7,66 +8,31 @@ import com.mapbox.mapboxgl.testapp.utils.ScreenshotUtil; import org.junit.Before; +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; + /** * Base Espresso class for all tests, helps working with ActivityInstrumentationTestCase2 */ -public class BaseTest - extends ActivityInstrumentationTestCase2 { +public class BaseTest { - private MainActivity mActivity; - private final static boolean screenshotOnTearDown = false; + /* + * Shortcuts for common UI tests + */ - public BaseTest() { - super(MainActivity.class); + protected void checkViewIsDisplayed(int id) { + onView(withId(id)) + .check(matches(isDisplayed())); } /* - * Get the activity before running every test + * Screenshots logic */ - @Before - public void setUp() throws Exception { - super.setUp(); - injectInstrumentation(InstrumentationRegistry.getInstrumentation()); - mActivity = getActivity(); - } - - /* - * Take a screenshot after every test - */ - - @Override - protected void tearDown() throws Exception { - if (screenshotOnTearDown) { - try { - // Screenshots should be taken on the UI thread - runTestOnUiThread(new Runnable() { - @Override - public void run() { - ScreenshotUtil.take(getActivity(), null); - } - }); - } catch (Throwable throwable) { - throwable.printStackTrace(); - } - } - - super.tearDown(); - mActivity = null; - } - - protected void takeNamedScreenshot(final String name) { - try { - // Screenshots should be taken on the UI thread - runTestOnUiThread(new Runnable() { - @Override - public void run() { - ScreenshotUtil.take(getActivity(), name); - } - }); - } catch (Throwable throwable) { - throwable.printStackTrace(); - } + protected void takeNamedScreenshot(Activity activity, String name) { + ScreenshotUtil.take(activity, name); } } diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java index 86f501b13..b880176fe 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityTest.java @@ -1,8 +1,13 @@ package com.mapbox.mapboxgl.testapp; +import android.support.test.rule.ActivityTestRule; +import android.support.test.runner.AndroidJUnit4; import android.test.suitebuilder.annotation.LargeTest; +import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.runner.RunWith; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.action.ViewActions.click; @@ -22,11 +27,23 @@ import static org.hamcrest.Matchers.not; /** * Tests on MainActivity */ +@RunWith(AndroidJUnit4.class) @LargeTest public class MainActivityTest extends BaseTest { private final static String HOME_BUTTON_STRING = "Navigate up"; + @Rule + public ActivityTestRule mActivityRule = new ActivityTestRule<>( + MainActivity.class); + + private MainActivity mActivity = null; + + @Before + public void setActivity() { + mActivity = mActivityRule.getActivity(); + } + /* * Note that we need to keep the `test` prefix if we want to be able to run these * tests on AWS Device Farm, annotations are not enough: @@ -250,7 +267,7 @@ public class MainActivityTest extends BaseTest { @Test public void testMapIconContentDescription() { // Mapbox logo - onView(withContentDescription(getActivity().getResources() + onView(withContentDescription(mActivity.getResources() .getString(R.string.mapboxIconContentDescription))) .check(matches(isDisplayed())); } @@ -258,7 +275,7 @@ public class MainActivityTest extends BaseTest { @Test public void testMapCompassContentDescription() { // Map compass - onView(withContentDescription(getActivity().getResources() + onView(withContentDescription(mActivity.getResources() .getString(R.string.compassContentDescription))) .check(matches(isDisplayed())); } @@ -266,23 +283,9 @@ public class MainActivityTest extends BaseTest { @Test public void testMapAttributionsIconContentDescription() { // Attribution icon - onView(withContentDescription(getActivity().getResources() + onView(withContentDescription(mActivity.getResources() .getString(R.string.attributionsIconContentDescription))) .check(matches(isDisplayed())); } - /* - * Take a screenshot of Mapbox Streets to monitor #1649 - */ - - @Test - public void testMapboxStreetsBlackAndWhite() { - // Click home and switch to Mapbox streets - onView(withContentDescription(HOME_BUTTON_STRING)) - .perform(click()); - onView(withText(R.string.styleMapboxStreets)) - .perform(click()); - takeNamedScreenshot("testMapboxStreetsBlackAndWhite"); - } - } From f775348ec327a4f5341c561ba8d008b4370905eb Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Wed, 16 Sep 2015 11:03:32 -0400 Subject: [PATCH 109/156] fixed the screenshot class to include the surface view --- .../testapp/utils/ScreenshotUtil.java | 55 ++++++++++++++++--- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/utils/ScreenshotUtil.java b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/utils/ScreenshotUtil.java index 51eceaca9..258a38923 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/utils/ScreenshotUtil.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/utils/ScreenshotUtil.java @@ -2,15 +2,19 @@ package com.mapbox.mapboxgl.testapp.utils; import android.app.Activity; import android.graphics.Bitmap; +import android.graphics.Canvas; import android.os.Environment; import android.util.Log; +import android.view.TextureView; import android.view.View; +import android.view.ViewGroup; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; /** @@ -45,6 +49,20 @@ public class ScreenshotUtil { Bitmap bitmap = Bitmap.createBitmap(rootView.getDrawingCache()); rootView.setDrawingCacheEnabled(false); + // Add the SurfaceView bit (see getAllTextureViews() below) + List tilingViews = getAllTextureViews(rootView); + if (tilingViews.size() > 0) { + Canvas canvas = new Canvas(bitmap); + for (TextureView TextureView : tilingViews) { + Bitmap b = TextureView.getBitmap(TextureView.getWidth(), TextureView.getHeight()); + int[] location = new int[2]; + TextureView.getLocationInWindow(location); + int[] location2 = new int[2]; + TextureView.getLocationOnScreen(location2); + canvas.drawBitmap(b, location[0], location[1], null); + } + } + // Save the bitmap in external storage String uniqueAbsolutePath = getUniqueAbsolutePath(testName); File outputFile = new File(uniqueAbsolutePath); @@ -53,8 +71,6 @@ public class ScreenshotUtil { outputStream = new FileOutputStream(outputFile); bitmap.compress(DEFAULT_IMAGE_FORMAT, DEFAULT_IMAGE_QUALITY, outputStream); outputStream.flush(); - } catch (FileNotFoundException e) { - e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { @@ -68,13 +84,34 @@ public class ScreenshotUtil { } } - /* Checks if external storage is available for read and write */ - public static boolean isExternalStorageWritable() { - String state = Environment.getExternalStorageState(); - if (Environment.MEDIA_MOUNTED.equals(state)) { - return true; + /* + * The classic way of taking a screenshot (above) doesn't work with TextureView, this fixes it: + * http://stackoverflow.com/questions/19704060/screen-capture-textureview-is-black-using-drawingcache + */ + + public static List getAllTextureViews(View view) + { + List tilingViews = new ArrayList(); + if (view instanceof TextureView) { + tilingViews.add((TextureView)view); + } else if(view instanceof ViewGroup) { + ViewGroup viewGroup = (ViewGroup)view; + for (int i = 0; i < viewGroup.getChildCount(); i++) { + tilingViews.addAll(getAllTextureViews(viewGroup.getChildAt(i))); + } } - return false; + + return tilingViews; + } + + /* + * Utils + */ + + public static boolean isExternalStorageWritable() { + // Checks if external storage is available for read and write + String state = Environment.getExternalStorageState(); + return Environment.MEDIA_MOUNTED.equals(state); } private static String getUniqueAbsolutePath(String testName) { From ed33a5ee6442510fe511b9ce44a7faa86cd584cf Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Wed, 16 Sep 2015 11:17:42 -0400 Subject: [PATCH 110/156] screenshots should be taken on ui thread --- .../java/com/mapbox/mapboxgl/testapp/BaseTest.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java index 9c6646105..f3ae2018c 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/BaseTest.java @@ -31,8 +31,16 @@ public class BaseTest { * Screenshots logic */ - protected void takeNamedScreenshot(Activity activity, String name) { - ScreenshotUtil.take(activity, name); + protected void takeNamedScreenshot(final Activity activity, final String name) { + + // Screenshots need to be taken on the UI thread + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + ScreenshotUtil.take(activity, name); + } + }); + } } From 77faa7ea15ae136b2ff504fc49ebfe1926089393 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Wed, 16 Sep 2015 11:19:44 -0400 Subject: [PATCH 111/156] zoom in --- .../mapbox/mapboxgl/testapp/MainActivityScreenTest.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityScreenTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityScreenTest.java index af35620f6..80dc0aa77 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityScreenTest.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxgl/testapp/MainActivityScreenTest.java @@ -11,8 +11,7 @@ import org.junit.runner.RunWith; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.action.ViewActions.click; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.action.ViewActions.doubleClick; import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription; import static android.support.test.espresso.matcher.ViewMatchers.withId; import static android.support.test.espresso.matcher.ViewMatchers.withText; @@ -54,6 +53,12 @@ public class MainActivityScreenTest extends BaseTest { onView(withText(R.string.styleMapboxStreets)) .perform(click()); + // Zoom in + onView(withId(R.id.mainMapView)) + .perform(doubleClick()); + onView(withId(R.id.mainMapView)) + .perform(doubleClick()); + // Standard screenshot takeNamedScreenshot(mActivity, "testMapboxStreetsBlackAndWhite"); } From d83be119472704973697b089321b14ce33cd9956 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 15 Sep 2015 17:48:07 -0700 Subject: [PATCH 112/156] Don't leak GlyphAtlas textures (fixes #2338) --- src/mbgl/geometry/glyph_atlas.cpp | 11 +++++++++++ src/mbgl/geometry/glyph_atlas.hpp | 1 + 2 files changed, 12 insertions(+) diff --git a/src/mbgl/geometry/glyph_atlas.cpp b/src/mbgl/geometry/glyph_atlas.cpp index 43ea58553..b90444e58 100644 --- a/src/mbgl/geometry/glyph_atlas.cpp +++ b/src/mbgl/geometry/glyph_atlas.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include #include @@ -20,6 +22,15 @@ GlyphAtlas::GlyphAtlas(uint16_t width_, uint16_t height_) dirty(true) { } +GlyphAtlas::~GlyphAtlas() { + assert(util::ThreadContext::currentlyOn(util::ThreadType::Map)); + + if (texture) { + mbgl::util::ThreadContext::getGLObjectStore()->abandonTexture(texture); + texture = 0; + } +} + void GlyphAtlas::addGlyphs(uintptr_t tileUID, const std::u32string& text, const std::string& stackName, diff --git a/src/mbgl/geometry/glyph_atlas.hpp b/src/mbgl/geometry/glyph_atlas.hpp index c5c785994..120530183 100644 --- a/src/mbgl/geometry/glyph_atlas.hpp +++ b/src/mbgl/geometry/glyph_atlas.hpp @@ -17,6 +17,7 @@ namespace mbgl { class GlyphAtlas : public util::noncopyable { public: GlyphAtlas(uint16_t width, uint16_t height); + ~GlyphAtlas(); void addGlyphs(uintptr_t tileUID, const std::u32string& text, From 573b43f257fbd4da0b7c87a526c8df61b4165a97 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Wed, 16 Sep 2015 13:39:46 -0400 Subject: [PATCH 113/156] unit tests + mockito --- .../MapboxGLAndroidSDKTestApp/build.gradle | 1 + .../src/test/java/CoordinateRegionTest.java | 54 ++++++++++ .../src/test/java/CoordinateSpanTest.java | 33 +++++++ .../src/test/java/LatLngTest.java | 98 +++++++++++++++++++ 4 files changed, 186 insertions(+) create mode 100644 android/java/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateRegionTest.java create mode 100644 android/java/MapboxGLAndroidSDKTestApp/src/test/java/LatLngTest.java diff --git a/android/java/MapboxGLAndroidSDKTestApp/build.gradle b/android/java/MapboxGLAndroidSDKTestApp/build.gradle index 9bc7d493f..98c26912f 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/build.gradle +++ b/android/java/MapboxGLAndroidSDKTestApp/build.gradle @@ -96,6 +96,7 @@ dependencies { // Testing dependencies testCompile 'junit:junit:4.12' + testCompile 'org.mockito:mockito-core:1.+' androidTestCompile 'com.android.support.test:runner:0.4' androidTestCompile 'com.android.support.test:rules:0.4' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1' diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateRegionTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateRegionTest.java new file mode 100644 index 000000000..9672d9da5 --- /dev/null +++ b/android/java/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateRegionTest.java @@ -0,0 +1,54 @@ +import com.mapbox.mapboxgl.geometry.CoordinateRegion; +import com.mapbox.mapboxgl.geometry.CoordinateSpan; +import com.mapbox.mapboxgl.geometry.LatLng; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class CoordinateRegionTest { + + @Test + public void testSanity() { + LatLng center = new LatLng(1.2, 3.4, 5.6); + CoordinateSpan span = new CoordinateSpan(9.8, 7.6); + CoordinateRegion coordinateRegion = new CoordinateRegion(center, span); + assertNotNull("coordinateRegion should not be null", coordinateRegion); + } + + @Test + public void testCenterConstructor() { + LatLng center = new LatLng(1.2, 3.4, 5.6); + CoordinateSpan span = new CoordinateSpan(9.8, 7.6); + CoordinateRegion coordinateRegion = new CoordinateRegion(center, span); + assertEquals("center should match", coordinateRegion.getCenter(), center); + } + + @Test + public void testSpanConstructor() { + LatLng center = new LatLng(1.2, 3.4, 5.6); + CoordinateSpan span = new CoordinateSpan(9.8, 7.6); + CoordinateRegion coordinateRegion = new CoordinateRegion(center, span); + assertEquals("span should match", coordinateRegion.getSpan(), span); + } + + @Test + public void testCenterMethod() { + LatLng center = new LatLng(1.2, 3.4, 5.6); + CoordinateSpan span = new CoordinateSpan(9.8, 7.6); + CoordinateRegion coordinateRegion = new CoordinateRegion(null, span); + coordinateRegion.setCenter(center); + assertEquals("center should match", coordinateRegion.getCenter(), center); + } + + @Test + public void testSpanMethod() { + LatLng center = new LatLng(1.2, 3.4, 5.6); + CoordinateSpan span = new CoordinateSpan(9.8, 7.6); + CoordinateRegion coordinateRegion = new CoordinateRegion(center, null); + coordinateRegion.setSpan(span); + assertEquals("span should match", coordinateRegion.getSpan(), span); + } + +} diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateSpanTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateSpanTest.java index 26734e1a7..0ccb76624 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateSpanTest.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateSpanTest.java @@ -2,14 +2,47 @@ import com.mapbox.mapboxgl.geometry.CoordinateSpan; import org.junit.Test; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; public class CoordinateSpanTest { + private static final double DELTA = 1e-15; + @Test public void testSanity() { CoordinateSpan coordinateSpan = new CoordinateSpan(0.0, 0.0); assertNotNull("coordinateSpan should not be null", coordinateSpan); } + @Test + public void testLatitudeConstructor() { + double latitude = 1.23; + CoordinateSpan coordinateSpan = new CoordinateSpan(latitude, 0.0); + assertEquals("latitude in constructor", coordinateSpan.getLatitudeSpan(), latitude, DELTA); + } + + @Test + public void testLongitudeConstructor() { + double longitude = 1.23; + CoordinateSpan coordinateSpan = new CoordinateSpan(0.0, longitude); + assertEquals("latitude in constructor", coordinateSpan.getLongitudeSpan(), longitude, DELTA); + } + + @Test + public void testLatitudeMethod() { + double latitude = 1.23; + CoordinateSpan coordinateSpan = new CoordinateSpan(0.0, 0.0); + coordinateSpan.setLatitudeSpan(latitude); + assertEquals("latitude in constructor", coordinateSpan.getLatitudeSpan(), latitude, DELTA); + } + + @Test + public void testLongitudeMethod() { + double longitude = 1.23; + CoordinateSpan coordinateSpan = new CoordinateSpan(0.0, 0.0); + coordinateSpan.setLongitudeSpan(longitude); + assertEquals("latitude in constructor", coordinateSpan.getLongitudeSpan(), longitude, DELTA); + } + } diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/test/java/LatLngTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/test/java/LatLngTest.java new file mode 100644 index 000000000..a3065789b --- /dev/null +++ b/android/java/MapboxGLAndroidSDKTestApp/src/test/java/LatLngTest.java @@ -0,0 +1,98 @@ +import android.location.Location; + +import com.mapbox.mapboxgl.geometry.LatLng; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class LatLngTest { + + private static final double DELTA = 1e-15; + + @Test + public void testSanity() { + LatLng latLng = new LatLng(0.0, 0.0); + assertNotNull("latLng should not be null", latLng); + } + + @Test + public void testLatitudeConstructor() { + double latitude = 1.2; + LatLng latLng = new LatLng(latitude, 3.4); + assertEquals("latitude should match", latLng.getLatitude(), latitude, DELTA); + } + + @Test + public void testLongitudeConstructor() { + double longitude = 3.4; + LatLng latLng = new LatLng(1.2, longitude); + assertEquals("longitude should match", latLng.getLongitude(), longitude, DELTA); + } + + @Test + public void testAltitudeConstructor() { + LatLng latLng1 = new LatLng(1.2, 3.4); + assertEquals("altitude default value", latLng1.getAltitude(), 0.0, DELTA); + + double altitude = 5.6; + LatLng latLng2 = new LatLng(1.2, 3.4, altitude); + assertEquals("altitude default value", latLng2.getAltitude(), altitude, DELTA); + } + + /* + * A sample test where Mockito is necessary + */ + + @Test + public void testLocationProvider() { + double latitude = 1.2; + double longitude = 3.4; + double altitude = 5.6; + + // Mock the location class + Location locationMocked = mock(Location.class); + when(locationMocked.getLatitude()).thenReturn(latitude); + when(locationMocked.getLongitude()).thenReturn(longitude); + when(locationMocked.getAltitude()).thenReturn(altitude); + + // Test the constructor + LatLng latLng = new LatLng(locationMocked); + assertEquals("latitude should match", latLng.getLatitude(), latitude, DELTA); + assertEquals("longitude should match", latLng.getLongitude(), longitude, DELTA); + assertEquals("altitude should match", latLng.getAltitude(), altitude, DELTA); + } + + @Test + public void testHashCode() { + double latitude = 1.2; + double longitude = 3.4; + double altitude = 5.6; + LatLng latLng = new LatLng(latitude, longitude, altitude); + assertEquals("hash code should match", latLng.hashCode(), -151519232); + } + + @Test + public void testToString() { + double latitude = 1.2; + double longitude = 3.4; + double altitude = 5.6; + LatLng latLng = new LatLng(latitude, longitude, altitude); + assertEquals("string should match", + latLng.toString(), + "LatLng [longitude=3.4, latitude=1.2, altitude=5.6]"); + } + + @Test + public void testDistanceTo() { + LatLng latLng1 = new LatLng(0.0, 0.0); + LatLng latLng2 = new LatLng(1.0, 1.0); + assertEquals("distances should match", + latLng1.distanceTo(latLng2), + 157425.53710839353, DELTA); + } + +} From 0281d010bd02839f091b64e507a493a497d8daf1 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Wed, 16 Sep 2015 13:43:26 -0400 Subject: [PATCH 114/156] two classes at once on aws --- android/java/MapboxGLAndroidSDKTestApp/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/android/java/MapboxGLAndroidSDKTestApp/README.md b/android/java/MapboxGLAndroidSDKTestApp/README.md index 47f6cedcb..96e2e30b7 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/README.md +++ b/android/java/MapboxGLAndroidSDKTestApp/README.md @@ -40,6 +40,8 @@ Then: * On step 4, customize your device state (if needed) * Finally, confirm the configuration and run the tests. +On Step 2, you can also separate by commas different classes: `com.mapbox.mapboxgl.testapp.MainActivityTest,com.mapbox.mapboxgl.testapp.MainActivityScreenTest` + If you have no tests for your app, or want to test some random user behaviour, you can just choose "Built-in: Fuzz" in step 2. From ce2793d84d139118f50061cd17a32f11e1469b64 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Wed, 16 Sep 2015 13:49:52 -0400 Subject: [PATCH 115/156] placeholders for the remaining objects --- .../src/test/java/BoundingBoxTest.java | 15 +++++++++++++++ .../src/test/java/LatLngZoomTest.java | 15 +++++++++++++++ .../src/test/java/ProjectedMetersTest.java | 15 +++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 android/java/MapboxGLAndroidSDKTestApp/src/test/java/BoundingBoxTest.java create mode 100644 android/java/MapboxGLAndroidSDKTestApp/src/test/java/LatLngZoomTest.java create mode 100644 android/java/MapboxGLAndroidSDKTestApp/src/test/java/ProjectedMetersTest.java diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/test/java/BoundingBoxTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/test/java/BoundingBoxTest.java new file mode 100644 index 000000000..a94bbc773 --- /dev/null +++ b/android/java/MapboxGLAndroidSDKTestApp/src/test/java/BoundingBoxTest.java @@ -0,0 +1,15 @@ +import com.mapbox.mapboxgl.geometry.BoundingBox; + +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; + +public class BoundingBoxTest { + + @Test + public void testSanity() { + BoundingBox boundingBox = new BoundingBox(0.0, 0.0, 0.0, 0.0); + assertNotNull("boundingBox should not be null", boundingBox); + } + +} diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/test/java/LatLngZoomTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/test/java/LatLngZoomTest.java new file mode 100644 index 000000000..7b6dfbde7 --- /dev/null +++ b/android/java/MapboxGLAndroidSDKTestApp/src/test/java/LatLngZoomTest.java @@ -0,0 +1,15 @@ +import com.mapbox.mapboxgl.geometry.LatLngZoom; + +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; + +public class LatLngZoomTest { + + @Test + public void testSanity() { + LatLngZoom latLngZoom = new LatLngZoom(0.0, 0.0, 0.0); + assertNotNull("latLngZoom should not be null", latLngZoom); + } + +} diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/test/java/ProjectedMetersTest.java b/android/java/MapboxGLAndroidSDKTestApp/src/test/java/ProjectedMetersTest.java new file mode 100644 index 000000000..39655bdf3 --- /dev/null +++ b/android/java/MapboxGLAndroidSDKTestApp/src/test/java/ProjectedMetersTest.java @@ -0,0 +1,15 @@ +import com.mapbox.mapboxgl.geometry.ProjectedMeters; + +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; + +public class ProjectedMetersTest { + + @Test + public void testSanity() { + ProjectedMeters projectedMeters = new ProjectedMeters(0.0, 0.0); + assertNotNull("projectedMeters should not be null", projectedMeters); + } + +} From 2ba21b5dd563c502eceedae1a81ffb7b0bf8ee75 Mon Sep 17 00:00:00 2001 From: Lucas Wojciechowski Date: Wed, 16 Sep 2015 10:50:39 -0700 Subject: [PATCH 116/156] [node] node-v2.0.0-pre.5 [publish binary] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 33ffb3288..8f13d884a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mapbox-gl-native", - "version": "2.0.0-pre.4", + "version": "2.0.0-pre.5", "description": "Renders map tiles with Mapbox GL", "keywords": [ "mapbox", From ec19af2aa5c114f9a485af511ccedbbec1b36c59 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Wed, 16 Sep 2015 14:03:03 -0400 Subject: [PATCH 117/156] import JUnit tests instructions --- android/java/MapboxGLAndroidSDKTestApp/README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/README.md b/android/java/MapboxGLAndroidSDKTestApp/README.md index 96e2e30b7..646f29c4b 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/README.md +++ b/android/java/MapboxGLAndroidSDKTestApp/README.md @@ -48,8 +48,9 @@ you can just choose "Built-in: Fuzz" in step 2. ### Running pure JUnit tests These tests run on a local JVM on your development machine and they are extremely fast to run -(as compared to Espresso). These tests are located under `src/test/java` and to run them you just -need to right click the corresponding test class or method and select "Run ...". +(as compared to Espresso). These tests are located under `src/test/java`. To run them you switch +to the Unit Tests build variant, then right click the corresponding test class or method +and select "Run ...". You can also have a run configuration: * Click on Run -> Edit Configurations... @@ -59,6 +60,12 @@ You can also have a run configuration: * As folder, choose the following folder: `mapbox-gl-native/android/java/MapboxGLAndroidSDKTestApp/src/test/java` * Click OK to save the new configuration +You can also run the tests from the command line with: + +``` +$ ./gradlew test --continue -p MapboxGLAndroidSDKTestApp +``` + ### Running the UI/Application Exerciser Monkey Similar to the "Built-in: Fuzz" test mentioned above, Android provides From 49d855769b0ac710d6e93285e90cb8fb75940f8f Mon Sep 17 00:00:00 2001 From: Nicki Dlugash Date: Mon, 14 Sep 2015 15:55:42 -0400 Subject: [PATCH 118/156] moved styles to v1.1.0 --- styles | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styles b/styles index 19dde3cb1..014e36833 160000 --- a/styles +++ b/styles @@ -1 +1 @@ -Subproject commit 19dde3cb1c36fe5f42dafc78c806fd7aca98126c +Subproject commit 014e36833420c81b29bec816b479ea61e94821d4 From f1edf1043bce36d7841ae72233353563a90aed81 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Thu, 3 Sep 2015 17:01:46 -0400 Subject: [PATCH 119/156] fix circle clipping bug https://github.com/mapbox/mapbox-gl-js/commit/91d2e0ee5cf4ed3811804ef40b1696f93de74410 --- src/mbgl/renderer/circle_bucket.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mbgl/renderer/circle_bucket.cpp b/src/mbgl/renderer/circle_bucket.cpp index a6a439d86..ae8eeef9d 100644 --- a/src/mbgl/renderer/circle_bucket.cpp +++ b/src/mbgl/renderer/circle_bucket.cpp @@ -35,11 +35,15 @@ bool CircleBucket::hasData() const { } void CircleBucket::addGeometry(const GeometryCollection& geometryCollection) { + const int extent = 4096; for (auto& circle : geometryCollection) { for(auto & geometry : circle) { auto x = geometry.x; auto y = geometry.y; + // Do not include points that are outside the tile boundaries. + if (x < 0 || x >= extent || y < 0 || y >= extent) continue; + // this geometry will be of the Point type, and we'll derive // two triangles from it. // From 1b87232bec8d7173ed2f5d666b49ebc36a3b8135 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 15 Sep 2015 10:35:13 -0700 Subject: [PATCH 120/156] [core] Update test-suite --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8f13d884a..2b10196a5 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ ], "devDependencies": { "aws-sdk": "^2.1.47", - "mapbox-gl-test-suite": "git+https://github.com/mapbox/mapbox-gl-test-suite.git#6cfd7eb20de77018a7f10770f56df9ce1f8a76ac", + "mapbox-gl-test-suite": "git+https://github.com/mapbox/mapbox-gl-test-suite.git#592540ebf822fd2e3cfdebbfabce92c1f5ef5b10", "request": "^2.61.0", "tape": "^4.2.0" }, From 4dce45ffc660fc41220c1d2cbb94962ed114e633 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Fri, 10 Jul 2015 15:31:06 +0200 Subject: [PATCH 121/156] [Android] add instructions to install Android Support Repository [skip ci] --- INSTALL.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index fcc5d90c6..4c39cc4cc 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -270,6 +270,10 @@ Install [Android Studio](https://developer.android.com/sdk/installing/studio.htm brew cask install android-studio android +In the Android SDK Manager also select and install "Android Support Repository" and "Android Support Library" from "Extras": + +![image](https://cloud.githubusercontent.com/assets/98601/9915837/289f398e-5c6e-11e5-9a84-ed4d08d52d1f.png) + By default, the SDK will be installed to `/usr/local/opt/android-sdk`. If you open Android Studio at this point, you may get an error message telling you that it can't find a JVM, it's because you installed a custom Java VM from Oracle. Follow [these instructions](http://tools.android.com/recent/androidstudio1rc3_releasecandidate3released) to start Android Studio. You'll wind up setting these environment variables in your .bash_profile or similar: echo "export ANDROID_HOME=`brew --prefix android-sdk`" >> .bash_profile From 79dc20808fd4ed72922742fa650a0dd1bbdc9038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 8 Sep 2015 14:21:03 -0700 Subject: [PATCH 122/156] Prefix user defaults in iosapp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We technically don’t need to, but the demo app should practice good hygiene since we expect developers to copy from it. --- ios/app/MBXViewController.mm | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ios/app/MBXViewController.mm b/ios/app/MBXViewController.mm index d94e41b5f..bb35a0791 100644 --- a/ios/app/MBXViewController.mm +++ b/ios/app/MBXViewController.mm @@ -31,9 +31,9 @@ static NSUInteger const kStyleVersion = 8; if (self == [MBXViewController class]) { [[NSUserDefaults standardUserDefaults] registerDefaults:@{ - @"userTrackingMode": @(MGLUserTrackingModeNone), - @"showsUserLocation": @NO, - @"debug": @NO, + @"MBXUserTrackingMode": @(MGLUserTrackingModeNone), + @"MBXShowsUserLocation": @NO, + @"MBXDebug": @NO, }]; } } @@ -91,10 +91,10 @@ static NSUInteger const kStyleVersion = 8; { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSData *archivedCamera = [NSKeyedArchiver archivedDataWithRootObject:self.mapView.camera]; - [defaults setObject:archivedCamera forKey:@"camera"]; - [defaults setInteger:self.mapView.userTrackingMode forKey:@"userTrackingMode"]; - [defaults setBool:self.mapView.showsUserLocation forKey:@"showsUserLocation"]; - [defaults setBool:self.mapView.debugActive forKey:@"debug"]; + [defaults setObject:archivedCamera forKey:@"MBXCamera"]; + [defaults setInteger:self.mapView.userTrackingMode forKey:@"MBXUserTrackingMode"]; + [defaults setBool:self.mapView.showsUserLocation forKey:@"MBXShowsUserLocation"]; + [defaults setBool:self.mapView.debugActive forKey:@"MBXDebug"]; [defaults synchronize]; } } @@ -103,21 +103,21 @@ static NSUInteger const kStyleVersion = 8; { if (self.mapView) { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSData *archivedCamera = [defaults objectForKey:@"camera"]; + NSData *archivedCamera = [defaults objectForKey:@"MBXCamera"]; MGLMapCamera *camera = archivedCamera ? [NSKeyedUnarchiver unarchiveObjectWithData:archivedCamera] : nil; if (camera) { self.mapView.camera = camera; } - NSInteger uncheckedTrackingMode = [defaults integerForKey:@"userTrackingMode"]; + NSInteger uncheckedTrackingMode = [defaults integerForKey:@"MBXUserTrackingMode"]; if (uncheckedTrackingMode >= 0 && (NSUInteger)uncheckedTrackingMode >= MGLUserTrackingModeNone && (NSUInteger)uncheckedTrackingMode <= MGLUserTrackingModeFollowWithCourse) { self.mapView.userTrackingMode = (MGLUserTrackingMode)uncheckedTrackingMode; } - self.mapView.showsUserLocation = [defaults boolForKey:@"showsUserLocation"]; - self.mapView.debugActive = [defaults boolForKey:@"debug"]; + self.mapView.showsUserLocation = [defaults boolForKey:@"MBXShowsUserLocation"]; + self.mapView.debugActive = [defaults boolForKey:@"MBXDebug"]; } } From fee31b05b9e698f8755a867f7c219d7b7de987c4 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Wed, 16 Sep 2015 16:45:18 -0400 Subject: [PATCH 123/156] back to right submodules versions --- .mason | 2 +- styles | 2 +- test/ios/KIF | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.mason b/.mason index c066f7d19..d8597d944 160000 --- a/.mason +++ b/.mason @@ -1 +1 @@ -Subproject commit c066f7d19f88b854da1002ce2f96aa7aba628cb5 +Subproject commit d8597d944533dbb5e28d08dfdba22a82c93171b7 diff --git a/styles b/styles index 014e36833..19dde3cb1 160000 --- a/styles +++ b/styles @@ -1 +1 @@ -Subproject commit 014e36833420c81b29bec816b479ea61e94821d4 +Subproject commit 19dde3cb1c36fe5f42dafc78c806fd7aca98126c diff --git a/test/ios/KIF b/test/ios/KIF index 976aafa2e..21a137bc8 160000 --- a/test/ios/KIF +++ b/test/ios/KIF @@ -1 +1 @@ -Subproject commit 976aafa2e211dd095411bfef09da6c0919d70476 +Subproject commit 21a137bc8068f9fb738f835c6e285d44fe2ce4dd From 765bae4c5cb0c55517bf0b5edd79066b41316bb0 Mon Sep 17 00:00:00 2001 From: Bastien Mayard Date: Tue, 25 Aug 2015 11:01:52 +0200 Subject: [PATCH 124/156] fix Makefile clean to clean ./android/java/MapboxGLAndroidSDK/build too --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c69e426dd..1a75c9759 100644 --- a/Makefile +++ b/Makefile @@ -130,7 +130,7 @@ clean: clear_sqlite_cache clear_xcode_cache -rm -rf ./ios/build -rm -rf ./test/build -rm -rf ./config/*.gypi - -rm -rf ./android/java/build ./android/java/MapboxGLAndroidSDKTestApp/build ./android/java/MapboxGLAndroidSDKTestApp/build + -rm -rf ./android/java/build ./android/java/MapboxGLAndroidSDK/build ./android/java/MapboxGLAndroidSDKTestApp/build -rm -rf ./android/java/MapboxGLAndroidSDK/src/main/jniLibs ./android/java/MapboxGLAndroidSDK/src/main/assets -rm -f ./android/test/features.zip From 8d322c65728ffe0d4f69fcd3b73b007a53eb505a Mon Sep 17 00:00:00 2001 From: Bastien Mayard Date: Wed, 9 Sep 2015 11:12:29 +0200 Subject: [PATCH 125/156] Change MapView.MapChange visibility to public since OnMapChangedListener.onMapChanged requires it. --- .../src/main/java/com/mapbox/mapboxgl/views/MapView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java index 614ccdb11..97163b0fa 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java @@ -197,7 +197,7 @@ public class MapView extends FrameLayout implements LocationListener { // Used to manage Event Listeners private ArrayList mOnMapChangedListener; - private enum MapChange { + public enum MapChange { MapChangeNullChange(-1), MapChangeRegionWillChange(0), MapChangeRegionWillChangeAnimated(1), From 311bf93abe9f815668e8e0a779c87c3eb5c1199d Mon Sep 17 00:00:00 2001 From: Lucas Wojciechowski Date: Wed, 16 Sep 2015 16:27:53 -0700 Subject: [PATCH 126/156] Revert "[node] Enable npm to build mapbox-gl-native package from source" This reverts commit 4e1ead344bfb1f9ddb207924465fabae3d218d67. --- .gitmodules | 3 +++ configure | 30 ++---------------------- gyp/core.gypi | 5 ---- gyp/version.gypi | 2 +- scripts/android/configure.sh | 2 -- scripts/build-version.py | 45 +++++++++++------------------------- scripts/ios/configure.sh | 2 -- scripts/ios/package.sh | 6 ++--- scripts/linux/configure.sh | 2 -- scripts/main.mk | 10 ++++---- scripts/osx/configure.sh | 2 -- scripts/osx/run.sh | 3 +++ src/mbgl/map/annotation.cpp | 3 +-- src/mbgl/map/annotation.hpp | 3 +-- src/mbgl/util/geojsonvt | 1 + test/test.gypi | 3 --- 16 files changed, 32 insertions(+), 90 deletions(-) create mode 160000 src/mbgl/util/geojsonvt diff --git a/.gitmodules b/.gitmodules index 0152ed56b..2aa6d52be 100644 --- a/.gitmodules +++ b/.gitmodules @@ -14,3 +14,6 @@ path = platform/ios/vendor/SMCalloutView url = https://github.com/nfarina/calloutview.git +[submodule "src/mbgl/util/geojsonvt"] + path = src/mbgl/util/geojsonvt + url = https://github.com/mapbox/geojson-vt-cpp diff --git a/configure b/configure index 6d0ac780c..6fbaa9f7f 100755 --- a/configure +++ b/configure @@ -15,15 +15,8 @@ function abort { >&2 echo -e "\033[1m\033[31m$1\033[0m"; exit 1; } function info { >&2 echo -e "\033[1m\033[33m$1\033[0m"; } function warn { >&2 echo -e "\033[1m\033[33m$1\033[0m"; } -if [ -d "`pwd`/.git" ]; then - info "This build is within a git repository" - export MASON_DIR="`pwd`/.mason" - export PATH="${MASON_DIR}:${PATH}" -else - info "This build is NOT within a git repository" - which mason || abort "You must install mason to build mapbox-gl-native (https://github.com/mapbox/mason)" - export MASON_DIR="$(dirname $(readlink $(which mason)))" -fi +# Install mason +export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" # You can override the function for a particular set of flags by defining a # print_XXX_flags function in your dependencies.sh file @@ -44,23 +37,6 @@ function print_flags { fi } -function print_build_flags { - local NAME=$1; shift - if [ "$(type -t print_${NAME}_flags)" = 'function' ]; then - print_${NAME}_flags - else - local VERSION=`echo "${NAME}_VERSION" | tr "[:lower:]" "[:upper:]"` - if [ ! -z ${!VERSION:-} ] ; then - mason build ${NAME} ${!VERSION} - for FLAGS in "$@" ; do - CONFIG+=" '${NAME}_${FLAGS}%': $(quote_flags $(mason ${FLAGS} ${NAME} ${!VERSION})),"$LN - done - else - warn "* Not using ${NAME}" - fi - fi -} - function print_default_flags { : } @@ -117,8 +93,6 @@ print_flags libuv static_libs cflags ldflags print_flags zlib static_libs cflags ldflags print_flags nunicode static_libs cflags ldflags print_flags libzip static_libs cflags ldflags -print_build_flags geojsonvt static_libs cflags ldflags -print_flags variant static_libs cflags ldflags CONFIG+=" } } diff --git a/gyp/core.gypi b/gyp/core.gypi index 51009be69..f9b361032 100644 --- a/gyp/core.gypi +++ b/gyp/core.gypi @@ -31,14 +31,10 @@ '<@(libuv_cflags)', '<@(opengl_cflags)', '<@(boost_cflags)', - '<@(geojsonvt_cflags)', - '<@(variant_cflags)', ], 'cflags': [ '<@(libuv_cflags)', '<@(opengl_cflags)', - '<@(geojsonvt_cflags)', - '<@(variant_cflags)', '-fPIC' ], 'ldflags': [ @@ -47,7 +43,6 @@ ], 'libraries': [ '<@(libuv_static_libs)', - '<@(geojsonvt_static_libs)', ], }, diff --git a/gyp/version.gypi b/gyp/version.gypi index 4efdd079a..1cc2eb351 100644 --- a/gyp/version.gypi +++ b/gyp/version.gypi @@ -13,7 +13,7 @@ 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/include/mbgl/util/version.hpp', ], - 'action': ['<@(_inputs)', '<(SHARED_INTERMEDIATE_DIR)'], + 'action': ['<@(_inputs)', '<(SHARED_INTERMEDIATE_DIR)', ' - #include #include #include #include #include #include +#include #include #include diff --git a/src/mbgl/map/annotation.hpp b/src/mbgl/map/annotation.hpp index 6b80d9f6c..5adec162f 100644 --- a/src/mbgl/map/annotation.hpp +++ b/src/mbgl/map/annotation.hpp @@ -1,14 +1,13 @@ #ifndef MBGL_MAP_ANNOTATIONS #define MBGL_MAP_ANNOTATIONS -#include - #include #include #include #include #include #include +#include #include #include diff --git a/src/mbgl/util/geojsonvt b/src/mbgl/util/geojsonvt new file mode 160000 index 000000000..995ffc72c --- /dev/null +++ b/src/mbgl/util/geojsonvt @@ -0,0 +1 @@ +Subproject commit 995ffc72c556da4b4880a6036fbcf7159fc5ecce diff --git a/test/test.gypi b/test/test.gypi index c53263bd5..a35b00133 100644 --- a/test/test.gypi +++ b/test/test.gypi @@ -95,7 +95,6 @@ 'libraries': [ '<@(libuv_static_libs)', '<@(sqlite_static_libs)', - '<@(geojsonvt_static_libs)', ], 'variables': { 'cflags_cc': [ @@ -103,8 +102,6 @@ '<@(opengl_cflags)', '<@(boost_cflags)', '<@(sqlite_cflags)', - '<@(geojsonvt_cflags)', - '<@(variant_cflags)', ], 'ldflags': [ '<@(libuv_ldflags)', From d156a147448f3acf2efaa3f1389aa6ae486ed6ff Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 16 Sep 2015 17:04:21 -0700 Subject: [PATCH 127/156] Revert "moved styles to v1.1.0" This reverts commit 49d855769b0ac710d6e93285e90cb8fb75940f8f. --- styles | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styles b/styles index 014e36833..19dde3cb1 160000 --- a/styles +++ b/styles @@ -1 +1 @@ -Subproject commit 014e36833420c81b29bec816b479ea61e94821d4 +Subproject commit 19dde3cb1c36fe5f42dafc78c806fd7aca98126c From 2141d95196cbdf63fd4bd8b34824660bf774bb08 Mon Sep 17 00:00:00 2001 From: Henry Dooley Date: Tue, 15 Sep 2015 13:39:35 -0700 Subject: [PATCH 128/156] [core] Annotation cleanup Eliminate dead code and unecessary STL container usage. Refactor large methods into smaller functional units. --- src/mbgl/map/annotation.cpp | 244 +++++++++++++++--------------------- src/mbgl/map/annotation.hpp | 29 +++-- 2 files changed, 119 insertions(+), 154 deletions(-) diff --git a/src/mbgl/map/annotation.cpp b/src/mbgl/map/annotation.cpp index 874459797..9cfb857bc 100644 --- a/src/mbgl/map/annotation.cpp +++ b/src/mbgl/map/annotation.cpp @@ -89,166 +89,118 @@ AnnotationManager::addTileFeature(const uint32_t annotationID, assert(type != AnnotationType::Any); // track the annotation global ID and its original geometry - auto anno_it = annotations.emplace(annotationID, - std::make_unique(type, segments, styleProperties)); - - std::unordered_set affectedTiles; + annotations.emplace(annotationID, std::make_unique(type, segments, styleProperties)); if (type == AnnotationType::Shape) { - - orderedShapeAnnotations.push_back(annotationID); - - using namespace mapbox::util::geojsonvt; - - const uint32_t z2 = 1 << maxZoom; - const double baseTolerance = 3; - const uint16_t extent = 4096; - - const double tolerance = baseTolerance / (z2 * extent); - - ProjectedGeometryContainer rings; - - std::vector points; - - for (size_t i = 0; i < segments[0].size(); ++i) { // first segment for now (no holes) - const double constraintedLatitude = ::fmin(::fmax(segments[0][i].latitude, -util::LATITUDE_MAX), util::LATITUDE_MAX); - points.push_back(LonLat(segments[0][i].longitude, constraintedLatitude)); - } - - ProjectedFeatureType featureType; - - if (styleProperties.is()) { - featureType = ProjectedFeatureType::Polygon; - - if (points.front().lon != points.back().lon || points.front().lat != points.back().lat) { - points.push_back(LonLat(points.front().lon, points.front().lat)); - } - } else { - featureType = ProjectedFeatureType::LineString; - } - - ProjectedGeometryContainer ring = Convert::project(points, tolerance); - - rings.members.push_back(ring); - - std::vector features; - - features.push_back(Convert::create(Tags(), featureType, rings)); - - shapeTilers.emplace(annotationID, std::make_unique(features, maxZoom, 4, 100, 10)); - + return addShapeFeature(annotationID, segments, styleProperties, maxZoom); } else { + return addPointFeature(annotationID, projectedFeature, featureProperties, maxZoom); + } +} - // side length of map at max zoom - uint32_t z2 = 1 << maxZoom; +std::unordered_set +AnnotationManager::addShapeFeature(const uint32_t annotationID, + const AnnotationSegments& segments, + const StyleProperties& styleProperties, + const uint8_t maxZoom) { + // Currently unused. + std::unordered_set affectedTiles; - const uint16_t extent = 4096; + orderedShapeAnnotations.push_back(annotationID); - uint32_t x = 0; - uint32_t y = 0; + using namespace mapbox::util::geojsonvt; - for (int8_t z = maxZoom; z >= 0; z--) { + const uint32_t z2 = 1 << maxZoom; + const double baseTolerance = 3; + const uint16_t extent = 4096; - std::unordered_map featureTiles; + const double tolerance = baseTolerance / (z2 * extent); - if (type == AnnotationType::Point) { - auto& pp = projectedFeature[0][0]; + ProjectedGeometryContainer rings; - x = pp.x * z2; - y = pp.y * z2; + std::vector points; - const Coordinate coordinate(extent * (pp.x * z2 - x), extent * (pp.y * z2 - y)); + for (size_t i = 0; i < segments[0].size(); ++i) { // first segment for now (no holes) + const double constraintedLatitude = ::fmin(::fmax(segments[0][i].latitude, -util::LATITUDE_MAX), util::LATITUDE_MAX); + points.push_back(LonLat(segments[0][i].longitude, constraintedLatitude)); + } - GeometryCollection geometries = {{ {{ coordinate }} }}; + ProjectedFeatureType featureType; - featureTiles.emplace(TileID(z, x, y, z), geometries); - } else { - for (size_t l = 0; l < projectedFeature.size(); ++l) { - for (size_t p = 0; p < projectedFeature[l].size(); ++p) { - - auto& pp = projectedFeature[l][p]; - - x = pp.x * z2; - y = pp.y * z2; - - const Coordinate coordinate(extent * (pp.x * z2 - x), extent * (pp.y * z2 - y)); - - auto tile_it = featureTiles.find(TileID(z, x, y, z)); - - if (tile_it != featureTiles.end()) { - GeometryCollection& geometries = featureTiles.find(TileID(z, x, y, z))->second; - if (!geometries.empty()) { - geometries.back().push_back(coordinate); - } else { - geometries.push_back({{ coordinate }}); - } - } else { - GeometryCollection geometries = {{ {{ coordinate }} }}; - featureTiles.emplace(TileID(z, x, y, z), geometries); - } - } - } - } - - for (auto& featureTile : featureTiles) { - // determine feature type - FeatureType featureType; - if (type == AnnotationType::Point) { - featureType = FeatureType::Point; - } else if (styleProperties.is()) { - featureType = FeatureType::LineString; - } else if (styleProperties.is()) { - featureType = FeatureType::Polygon; - } else { - throw std::runtime_error("Invalid feature type"); - } - - // create tile feature - auto feature = std::make_shared( - featureType, - featureTile.second, - featureProperties - ); - - // check for tile & create if necessary - auto tile_pos = tiles.emplace(featureTile.first, - std::make_pair(std::unordered_set({ annotationID }), - std::make_unique())); - - // check for annotation layer & create if necessary - util::ptr layer; - std::string layerID = ""; - if (type == AnnotationType::Point) { - layerID = PointLayerID; - } else { - layerID = ShapeLayerID + "." + util::toString(annotationID); - } - if (tile_pos.second || tile_pos.first->second.second->getMutableLayer(layerID) == nullptr) { - layer = std::make_shared(); - tile_pos.first->second.second->addLayer(layerID, layer); - } else { - layer = tile_pos.first->second.second->getMutableLayer(layerID); - - // associate annotation with tile - tile_pos.first->second.first.insert(annotationID); - } - - // add feature to layer - layer->addFeature(feature); - - // Record annotation association with tile and tile feature. This is used to determine stale tiles, - // as well as to remove the feature from the tile upon annotation deletion. - anno_it.first->second->tilePointFeatures.emplace(featureTile.first, std::weak_ptr(feature)); - - // track affected tile - affectedTiles.insert(featureTile.first); - } - - // get ready for the next-lower zoom number - z2 /= 2; - x /= 2; - y /= 2; + if (styleProperties.is()) { + featureType = ProjectedFeatureType::Polygon; + + if (points.front().lon != points.back().lon || points.front().lat != points.back().lat) { + points.push_back(LonLat(points.front().lon, points.front().lat)); } + } else { + featureType = ProjectedFeatureType::LineString; + } + + ProjectedGeometryContainer ring = Convert::project(points, tolerance); + rings.members.push_back(ring); + + std::vector features; + features.push_back(Convert::create(Tags(), featureType, rings)); + + shapeTilers.emplace(annotationID, std::make_unique(features, maxZoom, 4, 100, 10)); + + return affectedTiles; +} + +std::unordered_set +AnnotationManager::addPointFeature(const uint32_t annotationID, + const std::vector>>& projectedFeature, + const std::unordered_map& featureProperties, + const uint8_t maxZoom) { + std::unordered_set affectedTiles; + + auto anno_it = annotations.find(annotationID); + assert(anno_it != annotations.end()); + + const uint16_t extent = 4096; + auto& pp = projectedFeature[0][0]; + + for (int8_t z = maxZoom; z >= 0; z--) { + uint32_t z2 = 1 << z; + uint32_t x = pp.x * z2; + uint32_t y = pp.y * z2; + + const Coordinate coordinate(extent * (pp.x * z2 - x), extent * (pp.y * z2 - y)); + + GeometryCollection geometries = {{ {{ coordinate }} }}; + TileID featureTileID = TileID(z, x, y, z); + + auto feature = std::make_shared(FeatureType::Point, geometries, featureProperties); + + // check for tile & create if necessary + auto tile_pos = tiles.emplace(featureTileID, + std::make_pair(std::unordered_set({ annotationID }), + std::make_unique())); + + // check for annotation layer & create if necessary + util::ptr layer; + std::string layerID = PointLayerID; + + if (tile_pos.second || tile_pos.first->second.second->getMutableLayer(layerID) == nullptr) { + layer = std::make_shared(); + tile_pos.first->second.second->addLayer(layerID, layer); + } else { + layer = tile_pos.first->second.second->getMutableLayer(layerID); + + // associate annotation with tile + tile_pos.first->second.first.insert(annotationID); + } + + // add feature to layer + layer->addFeature(feature); + + // Record annotation association with tile and tile feature. This is used to determine stale tiles, + // as well as to remove the feature from the tile upon annotation deletion. + anno_it->second->tilePointFeatures.emplace(featureTileID, std::weak_ptr(feature)); + + // track affected tile + affectedTiles.insert(featureTileID); } return affectedTiles; diff --git a/src/mbgl/map/annotation.hpp b/src/mbgl/map/annotation.hpp index 5adec162f..7691e4508 100644 --- a/src/mbgl/map/annotation.hpp +++ b/src/mbgl/map/annotation.hpp @@ -80,14 +80,27 @@ public: private: inline uint32_t nextID(); static vec2 projectPoint(const LatLng& point); - std::unordered_set addTileFeature( - const uint32_t annotationID, - const AnnotationSegments&, - const std::vector>>& projectedFeature, - const AnnotationType&, - const StyleProperties&, - const std::unordered_map& featureProperties, - const uint8_t maxZoom); + + std::unordered_set + addTileFeature(const uint32_t annotationID, + const AnnotationSegments&, + const std::vector>>& projectedFeature, + const AnnotationType&, + const StyleProperties&, + const std::unordered_map& featureProperties, + const uint8_t maxZoom); + + std::unordered_set + addShapeFeature(const uint32_t annotationID, + const AnnotationSegments& segments, + const StyleProperties& styleProperties, + const uint8_t maxZoom); + + std::unordered_set + addPointFeature(const uint32_t annotationID, + const std::vector>>& projectedFeature, + const std::unordered_map& featureProperties, + const uint8_t maxZoom); private: std::string defaultPointAnnotationSymbol; From d86d11fb3e22da3ecc5ad692a37fb8aa5efdfc27 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 17 Sep 2015 09:16:11 -0700 Subject: [PATCH 129/156] Fully delete test/suite submodule --- test/suite | 1 - 1 file changed, 1 deletion(-) delete mode 160000 test/suite diff --git a/test/suite b/test/suite deleted file mode 160000 index 35c52c078..000000000 --- a/test/suite +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 35c52c078ceee4abf31b22d42ef5cdde307a5883 From e69a110c230c52b33881083d3018b7718f7fec2a Mon Sep 17 00:00:00 2001 From: Adam Hunter Date: Thu, 17 Sep 2015 14:52:04 -0700 Subject: [PATCH 130/156] Renderbuffer create should be paired with renderbuffer delete. --- platform/default/headless_view.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/default/headless_view.cpp b/platform/default/headless_view.cpp index a582ed579..0e688163a 100644 --- a/platform/default/headless_view.cpp +++ b/platform/default/headless_view.cpp @@ -202,7 +202,7 @@ void HeadlessView::clearBuffers() { } if (fboColor) { - MBGL_CHECK_ERROR(glDeleteTextures(1, &fboColor)); + MBGL_CHECK_ERROR(glDeleteRenderbuffersEXT(1, &fboColor)); fboColor = 0; } From f536db3116ebbf1c4c6b30ecdb359f986211e952 Mon Sep 17 00:00:00 2001 From: Lucas Wojciechowski Date: Thu, 17 Sep 2015 14:49:54 -0700 Subject: [PATCH 131/156] Add node_modules to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 123bf8cba..bd6707ba9 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ /src/shader/shaders_gl.cpp /src/shader/shaders_gles2.cpp /bin/style.bin.js +/node_modules *~ /ios/benchmark/assets/tiles/mapbox.mapbox-streets-v6/ From 12d0bdd8248e1e96ff75c6a1c12f8e166c6819dc Mon Sep 17 00:00:00 2001 From: Lucas Wojciechowski Date: Fri, 18 Sep 2015 12:18:41 -0700 Subject: [PATCH 132/156] Bumped to npm version 2.0.0-pre.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b10196a5..69f75a4fc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mapbox-gl-native", - "version": "2.0.0-pre.5", + "version": "2.0.0-pre.7", "description": "Renders map tiles with Mapbox GL", "keywords": [ "mapbox", From b81f7967134d5404950c693caaeebe177b92e1b3 Mon Sep 17 00:00:00 2001 From: Lucas Wojciechowski Date: Fri, 18 Sep 2015 12:50:37 -0700 Subject: [PATCH 133/156] [publish binary] From 0f80fb9103a3e014f82c7d4990b401706a0430fd Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Sat, 19 Sep 2015 08:51:52 +1000 Subject: [PATCH 134/156] [skip-ci] Update the Android build instructions --- INSTALL.md | 60 ++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 4c39cc4cc..cb72c55a9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,6 +1,6 @@ # Install -This document describes the process for setting up Mapbox GL for development _on the framework itself_. +This document describes the process for setting up Mapbox GL for development _on the framework itself_. # Depends @@ -29,7 +29,7 @@ Be sure to pull down all submodules first: ## OS X -This process gives you either a native OS X windowed app or a Linux desktop app with a map view for development purposes, built on an OS X host system. +This process gives you either a native OS X windowed app or a Linux desktop app with a map view for development purposes, built on an OS X host system. ### Build @@ -65,9 +65,9 @@ OS X 10.9+ ## iOS (Test App) -This process gives you a native iOS app for simulator or device which compiles the source to GL within it for fastest turnaround time during development. Normal, production use of the library is via a precompiled binary linked into the app target. +This process gives you a native iOS app for simulator or device which compiles the source to GL within it for fastest turnaround time during development. Normal, production use of the library is via a precompiled binary linked into the app target. -Developing for iOS implies an OS X host system. +Developing for iOS implies an OS X host system. ### Build @@ -85,13 +85,13 @@ You can run `make itest` to run the included integration tests. Requires `gem in - Double-tap to zoom in one level - Two-finger single-tap to zoom out one level - Double-tap, long-pressing the second, then pan up and down to "quick zoom" (iPhone only, meant for one-handed use) -- Use the debug menu to add test annotations, reset position, and toggle debug info. +- Use the debug menu to add test annotations, reset position, and toggle debug info. ## iOS (Your App) -**If you want a production version of this project, use [Mapbox Mobile](http://mapbox.com/mobile).** +**If you want a production version of this project, use [Mapbox Mobile](http://mapbox.com/mobile).** -This section is for people contributing to Mapbox GL directly in the context of their own app. +This section is for people contributing to Mapbox GL directly in the context of their own app. ### Build @@ -103,44 +103,44 @@ This section is for people contributing to Mapbox GL directly in the context of cp appledoc /usr/local/bin cp -Rf Templates/ ~/.appledoc ``` - + 1. Run `make ipackage`. The packaging script will produce the statically-linked `libMapbox.a`, `Mapbox.bundle` for resources, a `Headers` folder, and a `Docs` folder with HTML API documentation. ### Test -In the context of your own app, you can now either: +In the context of your own app, you can now either: #### CocoaPods -Currently, until [#1437](https://github.com/mapbox/mapbox-gl-native/issues/1437) is completed, to install a _development version_ of Mapbox GL using CocoaPods you will need to build it from source manually per above. +Currently, until [#1437](https://github.com/mapbox/mapbox-gl-native/issues/1437) is completed, to install a _development version_ of Mapbox GL using CocoaPods you will need to build it from source manually per above. -1. Zip up the build product. +1. Zip up the build product. cd build/ios/pkg/static ZIP=mapbox-ios-sdk.zip rm -f ../${ZIP} zip -r ../${ZIP} * -1. Modify a custom `Mapbox-iOS-SDK.podspec` to download this zip file. +1. Modify a custom `Mapbox-iOS-SDK.podspec` to download this zip file. {...} - + m.source = { :http => "http://{...}/mapbox-ios-sdk.zip", :flatten => true } - + {...} -1. Update your app's `Podfile` to point to the `Mapbox-iOS-SDK.podspec`. +1. Update your app's `Podfile` to point to the `Mapbox-iOS-SDK.podspec`. pod 'Mapbox-iOS-SDK', :podspec => 'http://{...}/Mapbox-iOS-SDK.podspec' -1. Run `pod update` to grab the newly-built library. +1. Run `pod update` to grab the newly-built library. #### Binary -1. Built from source manually per above. +1. Built from source manually per above. 1. Copy the contents of `build/ios/pkg/static` into your project. It should happen automatically, but ensure that: @@ -173,7 +173,7 @@ iOS: 7.0+ We are using Ubuntu for development. While the software should work on other distributions as well, we are not providing explicit build instructions here. -This process gives you a Linux desktop app built on a Linux host system. +This process gives you a Linux desktop app built on a Linux host system. ### Build @@ -239,19 +239,19 @@ Install Oracle JDK 7 (requires license agreement) from http://www.oracle.com/tec export JAVA_HOME="/dir/to/jdk1.7.0_71" -Install the [Android NDK Revision 10e](https://developer.android.com/tools/sdk/ndk/index.html). - - export ANDROID_NDK_PATH="/dir/to/android-ndk-r10e" - Install the Android SDK. We recommend doing this by way of [Android Studio](https://developer.android.com/sdk/installing/studio.html). export ANDROID_HOME="/dir/to/android-sdk-linux" +In the Android SDK Manager also select and install "Android Support Repository" and "Android Support Library" from "Extras": + +![image](https://cloud.githubusercontent.com/assets/98601/9915837/289f398e-5c6e-11e5-9a84-ed4d08d52d1f.png) + Run: make android -You can then open `android/java` in Android Studio via "Import Non-Android Studio Project". +You can then open `android/java` in Android Studio via "Import project (Eclipse ADT, Gradle, etc.)". ### Build (OS X Host) @@ -259,13 +259,11 @@ Install Oracle JDK 7+: brew cask install java -Install the [Android NDK Revision 10e](https://developer.android.com/tools/sdk/ndk/index.html) for 64-bit OS X: +Install the Android SDK: - brew install android-ndk + brew install android-sdk -This will also install the dependency `android-sdk`. - -Install [Android Studio](https://developer.android.com/sdk/installing/studio.html): +Install Android Studio: brew cask install android-studio android @@ -287,7 +285,7 @@ Run: make android open -a Android\ Studio -You can then open `android/java` in Android Studio via "import project (Eclipse ADT, Gradle, etc.)". +You can then open `android/java` in Android Studio via "Import project (Eclipse ADT, Gradle, etc.)". ### Setting up Android emulator @@ -295,7 +293,7 @@ If you want to run the test app in the emulator, we recommend the x86 build beca First ensure you have an `MAPBOX_ACCESS_TOKEN` environment variable set, as described below. Then, create an x86 build: - ANDROID_ABI=x86 make android + make android-lib-x86 In Android Studio, create an x86 AVD (Android Virtual Device): @@ -321,7 +319,7 @@ If your device does not show up, you have not set it up properly. Double check ### Distribution -Use the `Makefile` target `make apackage` in order to build JNI libraries for all supported ABI's for eventual distribution of the whole package. +Use the `Makefile` target `make apackage` in order to build JNI libraries for all supported ABI's for eventual distribution of the whole package. ### Target From 50ad8ac54d617fedd97752f1ad740bb61b52383f Mon Sep 17 00:00:00 2001 From: Eric Horacek Date: Sat, 19 Sep 2015 12:44:41 -0700 Subject: [PATCH 135/156] =?UTF-8?q?Remove=20implicit=20conversion=20from?= =?UTF-8?q?=20double=20=E2=86=92=20float?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Occurs when targeting a 32-bit architecture --- include/mbgl/ios/MGLGeometry.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mbgl/ios/MGLGeometry.h b/include/mbgl/ios/MGLGeometry.h index 2dee7c76c..847b7cc04 100644 --- a/include/mbgl/ios/MGLGeometry.h +++ b/include/mbgl/ios/MGLGeometry.h @@ -85,7 +85,7 @@ NS_INLINE NSString *MGLStringFromCoordinateBounds(MGLCoordinateBounds bounds) { NS_INLINE CGFloat MGLRadiansFromDegrees(CLLocationDegrees degrees) { - return degrees * M_PI / 180; + return (CGFloat)(degrees * M_PI) / 180; } NS_INLINE CLLocationDegrees MGLDegreesFromRadians(CGFloat radians) From 1d565a515953432ef9dc79fadaf62e3217c42920 Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Mon, 21 Sep 2015 14:38:11 +1000 Subject: [PATCH 136/156] Remove Android style URL validation Fixes #2370 --- .../src/main/java/com/mapbox/mapboxgl/views/MapView.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java index 97163b0fa..6be20990a 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java @@ -744,16 +744,7 @@ public class MapView extends FrameLayout implements LocationListener { return mNativeMapView.isFullyLoaded(); } - private void validateStyleUrl(String url) { - url = url.replaceFirst("asset://", "http://"); - HttpUrl parsedUrl = HttpUrl.parse(url); - if (parsedUrl == null) { - throw new RuntimeException("Style URL is not a valid http, https or asset URL."); - } - } - public void setStyleUrl(String url) { - validateStyleUrl(url); mStyleUrl = url; mNativeMapView.setStyleUrl(url); } From 2762f53cdf3f39e209f0c8f584567ff93b4f1b90 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Fri, 18 Sep 2015 14:42:56 -0400 Subject: [PATCH 137/156] [iOS] disable perfectly good tests so they stop flapping on Travis Travis is inconsistently failing the following tests, so let's temporarily disable them. - `testDirectionSet` - `testCompassTap` - `testDirectionReset` - `testCenterSet` - `testDelegateRegionDidChange` It bears repeating that these tests _only_ fail on Travis, running them locally has always passed. Fixes #2347 --- test/ios/MapViewTests.m | 2 +- .../xcschemes/Mapbox GL Tests.xcscheme | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/test/ios/MapViewTests.m b/test/ios/MapViewTests.m index d0913670c..1de31c6cc 100644 --- a/test/ios/MapViewTests.m +++ b/test/ios/MapViewTests.m @@ -66,7 +66,7 @@ [tester.compass tap]; - [tester waitForTimeInterval:1]; + [tester waitForTimeInterval:2]; XCTAssertEqual(tester.mapView.direction, 0, diff --git a/test/ios/ios-tests.xcodeproj/xcshareddata/xcschemes/Mapbox GL Tests.xcscheme b/test/ios/ios-tests.xcodeproj/xcshareddata/xcschemes/Mapbox GL Tests.xcscheme index c80cdb3d5..5f3f7f192 100644 --- a/test/ios/ios-tests.xcodeproj/xcshareddata/xcschemes/Mapbox GL Tests.xcscheme +++ b/test/ios/ios-tests.xcodeproj/xcshareddata/xcschemes/Mapbox GL Tests.xcscheme @@ -52,9 +52,24 @@ ReferencedContainer = "container:ios-tests.xcodeproj"> + + + + + + + + + + From feae692dbaefa51b893528a31139fb8282b3e889 Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Tue, 22 Sep 2015 16:23:39 +1000 Subject: [PATCH 138/156] Fix freezing on Android when rotating Fixes #1941 --- android/cpp/native_map_view.cpp | 5 +++++ .../src/main/java/com/mapbox/mapboxgl/views/MapView.java | 9 --------- .../java/com/mapbox/mapboxgl/testapp/MainActivity.java | 3 +++ include/mbgl/map/map.hpp | 1 + src/mbgl/map/map.cpp | 4 ++++ 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/android/cpp/native_map_view.cpp b/android/cpp/native_map_view.cpp index 9ffb083ec..02228d85b 100644 --- a/android/cpp/native_map_view.cpp +++ b/android/cpp/native_map_view.cpp @@ -699,6 +699,11 @@ void NativeMapView::updateFps() { void NativeMapView::onInvalidate() { mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::onInvalidate()"); + if (map.isPaused()) { + mbgl::Log::Debug(mbgl::Event::Android, "Not rendering as map is paused"); + return; + } + const bool dirty = !clean.test_and_set(); if (dirty) { float zoomFactor = map.getMaxZoom() - map.getMinZoom() + 1; diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java index 6be20990a..b4eece5ec 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java @@ -1009,14 +1009,6 @@ public class MapView extends FrameLayout implements LocationListener { mNativeMapView.resizeFramebuffer(width, height); } - // Called when we need to redraw the view - // This is called before our view is first visible to prevent an initial - // flicker (see Android SDK documentation) - /*@Override - public void surfaceRedrawNeeded(SurfaceHolder holder) { - mNativeMapView.update(); - }*/ // TODO call update somewhere? - // Not used @Override public void onSurfaceTextureUpdated (SurfaceTexture surface) { @@ -1796,7 +1788,6 @@ public class MapView extends FrameLayout implements LocationListener { }); } - /** * Defines callback for events OnMapChange */ diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java index eb5d891cd..2f9b374e2 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java @@ -177,12 +177,14 @@ public class MainActivity extends AppCompatActivity { @Override protected void onStart() { super.onStart(); + mMapView.onStart(); } @Override protected void onStop() { super.onStop(); + mMapView.onStop(); } @@ -205,6 +207,7 @@ public class MainActivity extends AppCompatActivity { @Override protected void onDestroy() { super.onDestroy(); + mMapView.onDestroy(); } diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 4cd9293c9..06695778e 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -58,6 +58,7 @@ public: // Pauses the render thread. The render thread will stop running but will not be terminated and will not lose state until resumed. void pause(); + bool isPaused(); // Resumes a paused render thread void resume(); diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 9195f6b58..3e7a61a4e 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -39,6 +39,10 @@ void Map::pause() { } } +bool Map::isPaused() { + return paused; +} + void Map::resume() { data->condResume.notify_all(); paused = false; From 4e885d600a4776d087c8c0e94719df9e45293408 Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Tue, 22 Sep 2015 10:06:32 +1000 Subject: [PATCH 139/156] Restore libcurl HTTP on Android --- android/mapboxgl-app.gypi | 5 ++ platform/default/http_request_curl.cpp | 109 +++++++++++++++++++++++++ scripts/android/configure.sh | 2 + scripts/android/defaults.mk | 2 +- 4 files changed, 117 insertions(+), 1 deletion(-) diff --git a/android/mapboxgl-app.gypi b/android/mapboxgl-app.gypi index e3db1269d..e32775ff7 100644 --- a/android/mapboxgl-app.gypi +++ b/android/mapboxgl-app.gypi @@ -25,6 +25,8 @@ '<@(boost_cflags)', ], 'libraries': [ + '<@(openssl_static_libs)', + '<@(libcurl_static_libs)', '<@(libpng_static_libs)', '<@(jpeg_static_libs)', '<@(sqlite_static_libs)', @@ -43,6 +45,8 @@ '<@(libpng_ldflags)', '<@(jpeg_ldflags)', '<@(sqlite_ldflags)', + '<@(openssl_ldflags)', + '<@(libcurl_ldflags)', '<@(zlib_ldflags)', '<@(libzip_ldflags)', ], @@ -70,6 +74,7 @@ 'copies': [ { 'files': [ + '../common/ca-bundle.crt', '../styles/styles' ], 'destination': '<(pwd)/../android/java/MapboxGLAndroidSDK/src/main/assets' diff --git a/platform/default/http_request_curl.cpp b/platform/default/http_request_curl.cpp index e416034b4..0f7f8c0ac 100644 --- a/platform/default/http_request_curl.cpp +++ b/platform/default/http_request_curl.cpp @@ -11,6 +11,12 @@ #include +#ifdef __ANDROID__ +#include +#include +#include +#endif + #include #include #include @@ -325,6 +331,104 @@ int HTTPCURLContext::startTimeout(CURLM * /* multi */, long timeout_ms, void *us // ------------------------------------------------------------------------------------------------- +#ifdef __ANDROID__ + +// This function is called to load the CA bundle +// from http://curl.haxx.se/libcurl/c/cacertinmem.html¯ +static CURLcode sslctx_function(CURL * /* curl */, void *sslctx, void * /* parm */) { + + int error = 0; + struct zip *apk = zip_open(mbgl::android::apkPath.c_str(), 0, &error); + if (apk == nullptr) { + return CURLE_SSL_CACERT_BADFILE; + } + + struct zip_file *apkFile = zip_fopen(apk, "assets/ca-bundle.crt", ZIP_FL_NOCASE); + if (apkFile == nullptr) { + zip_close(apk); + apk = nullptr; + return CURLE_SSL_CACERT_BADFILE; + } + + struct zip_stat stat; + if (zip_stat(apk, "assets/ca-bundle.crt", ZIP_FL_NOCASE, &stat) != 0) { + zip_fclose(apkFile); + apkFile = nullptr; + zip_close(apk); + apk = nullptr; + return CURLE_SSL_CACERT_BADFILE; + } + + if (stat.size > std::numeric_limits::max()) { + zip_fclose(apkFile); + apkFile = nullptr; + zip_close(apk); + apk = nullptr; + return CURLE_SSL_CACERT_BADFILE; + } + + const auto pem = std::make_unique(stat.size); + + if (static_cast(zip_fread(apkFile, reinterpret_cast(pem.get()), stat.size)) != stat.size) { + zip_fclose(apkFile); + apkFile = nullptr; + zip_close(apk); + apk = nullptr; + return CURLE_SSL_CACERT_BADFILE; + } + + // get a pointer to the X509 certificate store (which may be empty!) + X509_STORE *store = SSL_CTX_get_cert_store((SSL_CTX *)sslctx); + if (store == nullptr) { + return CURLE_SSL_CACERT_BADFILE; + } + + // get a BIO + BIO *bio = BIO_new_mem_buf(pem.get(), static_cast(stat.size)); + if (bio == nullptr) { + store = nullptr; + return CURLE_SSL_CACERT_BADFILE; + } + + // use it to read the PEM formatted certificate from memory into an X509 + // structure that SSL can use + X509 *cert = nullptr; + while (PEM_read_bio_X509(bio, &cert, 0, nullptr) != nullptr) { + if (cert == nullptr) { + BIO_free(bio); + bio = nullptr; + store = nullptr; + return CURLE_SSL_CACERT_BADFILE; + } + + // add our certificate to this store + if (X509_STORE_add_cert(store, cert) == 0) { + X509_free(cert); + cert = nullptr; + BIO_free(bio); + bio = nullptr; + store = nullptr; + return CURLE_SSL_CACERT_BADFILE; + } + + X509_free(cert); + cert = nullptr; + } + + // decrease reference counts + BIO_free(bio); + bio = nullptr; + + zip_fclose(apkFile); + apkFile = nullptr; + zip_close(apk); + apk = nullptr; + + // all set to go + return CURLE_OK; +} +#endif + HTTPCURLRequest::HTTPCURLRequest(HTTPCURLContext* context_, const Resource& resource_, Callback callback_, uv_loop_t*, std::shared_ptr response_) : HTTPRequestBase(resource_, callback_), context(context_), @@ -354,7 +458,12 @@ HTTPCURLRequest::HTTPCURLRequest(HTTPCURLContext* context_, const Resource& reso handleError(curl_easy_setopt(handle, CURLOPT_PRIVATE, this)); handleError(curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, error)); +#ifdef __ANDROID__ + handleError(curl_easy_setopt(handle, CURLOPT_SSLCERTTYPE, "PEM")); + handleError(curl_easy_setopt(handle, CURLOPT_SSL_CTX_FUNCTION, sslctx_function)); +#else handleError(curl_easy_setopt(handle, CURLOPT_CAINFO, "ca-bundle.crt")); +#endif handleError(curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1)); handleError(curl_easy_setopt(handle, CURLOPT_URL, resource.url.c_str())); handleError(curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, writeCallback)); diff --git a/scripts/android/configure.sh b/scripts/android/configure.sh index 70c8973a8..5e5a9034c 100644 --- a/scripts/android/configure.sh +++ b/scripts/android/configure.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash BOOST_VERSION=1.57.0 +LIBCURL_VERSION=7.40.0 +OPENSSL_VERSION=1.0.1l LIBPNG_VERSION=1.6.16 JPEG_VERSION=v9a SQLITE_VERSION=3.8.8.1 diff --git a/scripts/android/defaults.mk b/scripts/android/defaults.mk index 29f047c88..436f9db71 100644 --- a/scripts/android/defaults.mk +++ b/scripts/android/defaults.mk @@ -1,7 +1,7 @@ HEADLESS ?= none PLATFORM ?= android ASSET ?= zip -HTTP ?= android +HTTP ?= curl CACHE ?= sqlite GYP_FLAVOR_SUFFIX=-android From d89aa51e0f59b2465dbbe5e56dd7c59ed88b2e86 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Tue, 22 Sep 2015 05:53:42 -0400 Subject: [PATCH 140/156] [iOS] Give iosapp the option to use `always` location permissions Useful in testing metrics and background location. Default is still `whenInUse`, user must switch in `Settings.app`. --- ios/app/app-info.plist | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ios/app/app-info.plist b/ios/app/app-info.plist index 665324693..d497d09e7 100644 --- a/ios/app/app-info.plist +++ b/ios/app/app-info.plist @@ -60,5 +60,7 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + NSLocationAlwaysUsageDescription + The map will ALWAYS display the user's location. From db6a08d8caef8818032a89725340419f258d09ea Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Fri, 18 Sep 2015 09:43:15 +1000 Subject: [PATCH 141/156] Add Crashlytics NDK to Android Closes #2107 --- Makefile | 2 +- android/java/.gitignore | 6 +++++ .../MapboxGLAndroidSDKTestApp/build.gradle | 18 +++++++++++++++ .../mapbox/mapboxgl/testapp/MainActivity.java | 3 ++- android/mapboxgl-app.gypi | 8 ++++++- scripts/android/run.sh | 22 +++++++++++-------- 6 files changed, 47 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 1a75c9759..c7099ce03 100644 --- a/Makefile +++ b/Makefile @@ -131,7 +131,7 @@ clean: clear_sqlite_cache clear_xcode_cache -rm -rf ./test/build -rm -rf ./config/*.gypi -rm -rf ./android/java/build ./android/java/MapboxGLAndroidSDK/build ./android/java/MapboxGLAndroidSDKTestApp/build - -rm -rf ./android/java/MapboxGLAndroidSDK/src/main/jniLibs ./android/java/MapboxGLAndroidSDK/src/main/assets + -rm -rf ./android/java/MapboxGLAndroidSDK/src/main/libs ./android/java/MapboxGLAndroidSDK/src/main/obj.target ./android/java/MapboxGLAndroidSDK/src/main/assets -rm -f ./android/test/features.zip distclean: clean diff --git a/android/java/.gitignore b/android/java/.gitignore index 866441810..a79fb8fae 100644 --- a/android/java/.gitignore +++ b/android/java/.gitignore @@ -10,6 +10,12 @@ build/ *.so *.apk +# JNI +MapboxGLAndroidSDK/src/main/libs/ +MapboxGLAndroidSDK/src/main/jniLibs/ +MapboxGLAndroidSDK/src/main/obj/ +MapboxGLAndroidSDK/src/main/obj.target/ + # Lib assets MapboxGLAndroidSDK/src/main/assets/ diff --git a/android/java/MapboxGLAndroidSDKTestApp/build.gradle b/android/java/MapboxGLAndroidSDKTestApp/build.gradle index 98c26912f..f71d821c2 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/build.gradle +++ b/android/java/MapboxGLAndroidSDKTestApp/build.gradle @@ -80,6 +80,21 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + + splits { + abi { + enable true + reset() + include 'armeabi', 'armeabi-v7a', 'x86', 'mips' + universalApk true + } + } +} + +crashlytics { + enableNdk true + androidNdkOut '../MapboxGLAndroidSDK/src/main/obj.target' + androidNdkLibsOut '../MapboxGLAndroidSDK/src/main/obj.target' } dependencies { @@ -93,6 +108,9 @@ dependencies { compile('com.crashlytics.sdk.android:crashlytics:2.5.1@aar') { transitive = true; } + compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.1@aar') { + transitive = true; + } // Testing dependencies testCompile 'junit:junit:4.12' diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java index 2f9b374e2..3f14ab557 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java @@ -25,6 +25,7 @@ import android.view.View; import android.widget.TextView; import android.widget.Toast; import com.crashlytics.android.Crashlytics; +import com.crashlytics.android.ndk.CrashlyticsNdk; import com.mapbox.mapboxgl.annotations.Marker; import com.mapbox.mapboxgl.annotations.MarkerOptions; import com.mapbox.mapboxgl.annotations.PolygonOptions; @@ -78,7 +79,7 @@ public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - Fabric.with(this, new Crashlytics()); + Fabric.with(this, new Crashlytics(), new CrashlyticsNdk()); // Load the layout setContentView(R.layout.activity_main); diff --git a/android/mapboxgl-app.gypi b/android/mapboxgl-app.gypi index e3db1269d..5731d21f8 100644 --- a/android/mapboxgl-app.gypi +++ b/android/mapboxgl-app.gypi @@ -74,13 +74,19 @@ ], 'destination': '<(pwd)/../android/java/MapboxGLAndroidSDK/src/main/assets' }, + { + 'files': [ + '<(PRODUCT_DIR)/obj.target' + ], + 'destination': '<(pwd)/../android/java/MapboxGLAndroidSDK/src/main' + }, ], 'actions': [ { 'action_name': 'Strip dynamic library', 'inputs': [ '<(PRODUCT_DIR)/lib.target/libmapbox-gl.so' ], - 'outputs': [ '<(pwd)/../android/java/MapboxGLAndroidSDK/src/main/jniLibs/$(JNIDIR)/libmapbox-gl.so' ], + 'outputs': [ '<(pwd)/../android/java/MapboxGLAndroidSDK/src/main/libs/$(JNIDIR)/libmapbox-gl.so' ], 'action': [ '$(STRIP)', '<@(_inputs)', '-o', '<@(_outputs)' ] }, ], diff --git a/scripts/android/run.sh b/scripts/android/run.sh index 2ef0c40c9..73ffc4c5c 100755 --- a/scripts/android/run.sh +++ b/scripts/android/run.sh @@ -39,16 +39,20 @@ if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then S3_PREFIX=s3://mapbox/mapbox-gl-native/android/build/${TRAVIS_JOB_NUMBER} APK_OUTPUTS=./android/java/MapboxGLAndroidSDKTestApp/build/outputs/apk + JNILIB=`mason env JNIDIR` - # Upload either the debug or the release build - if [ ${BUILDTYPE} == "Debug" ] ; then - aws s3 cp \ - ${APK_OUTPUTS}/MapboxGLAndroidSDKTestApp-debug.apk \ - ${S3_PREFIX}/MapboxGLAndroidSDKTestApp-debug.apk - elif [ ${BUILDTYPE} == "Release" ] ; then - aws s3 cp \ - ${APK_OUTPUTS}/MapboxGLAndroidSDKTestApp-release-unsigned.apk \ - ${S3_PREFIX}/MapboxGLAndroidSDKTestApp-release-unsigned.apk + # ARM64 does not build APK for now + if [ ${JNIDIR} != "arm64-v8a" ] ; then + # Upload either the debug or the release build + if [ ${BUILDTYPE} == "Debug" ] ; then + aws s3 cp \ + ${APK_OUTPUTS}/MapboxGLAndroidSDKTestApp-${JNILIB}-debug.apk \ + ${S3_PREFIX}/MapboxGLAndroidSDKTestApp-debug.apk + elif [ ${BUILDTYPE} == "Release" ] ; then + aws s3 cp \ + ${APK_OUTPUTS}/MapboxGLAndroidSDKTestApp-${JNILIB}-release-unsigned.apk \ + ${S3_PREFIX}/MapboxGLAndroidSDKTestApp-release-unsigned.apk + fi fi mapbox_time_finish From 8cf927f6c423ad5e5ce9c8931002ee1c1dce1d9d Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Thu, 17 Sep 2015 17:34:13 -0700 Subject: [PATCH 142/156] Improve handling of cancelled HTTP requests Fix a memory leak of NativeMapView Java object --- android/cpp/native_map_view.cpp | 4 +-- .../com/mapbox/mapboxgl/http/HTTPContext.java | 4 +++ include/mbgl/android/native_map_view.hpp | 2 +- platform/android/http_request_android.cpp | 35 +++++++++++-------- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/android/cpp/native_map_view.cpp b/android/cpp/native_map_view.cpp index 02228d85b..6c1cd87bb 100644 --- a/android/cpp/native_map_view.cpp +++ b/android/cpp/native_map_view.cpp @@ -73,7 +73,7 @@ NativeMapView::NativeMapView(JNIEnv *env, jobject obj_, float pixelRatio_, int a return; } - obj = env->NewGlobalRef(obj_); + obj = env->NewWeakGlobalRef(obj_); if (obj == nullptr) { env->ExceptionDescribe(); return; @@ -93,7 +93,7 @@ NativeMapView::~NativeMapView() { JNIEnv *env = nullptr; ret = vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6); if (ret == JNI_OK) { - env->DeleteGlobalRef(obj); + env->DeleteWeakGlobalRef(obj); } else { mbgl::Log::Error(mbgl::Event::JNI, "GetEnv() failed with %i", ret); throw new std::runtime_error("GetEnv() failed"); diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/http/HTTPContext.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/http/HTTPContext.java index 4558bbfe3..775daaafd 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/http/HTTPContext.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/http/HTTPContext.java @@ -20,6 +20,7 @@ class HTTPContext { private static final int CONNECTION_ERROR = 0; private static final int TEMPORARY_ERROR = 1; private static final int PERMANENT_ERROR = 2; + private static final int CANCELED_ERROR = 3; private static HTTPContext mInstance = null; @@ -78,7 +79,10 @@ class HTTPContext { type = CONNECTION_ERROR; } else if ((e instanceof InterruptedIOException)) { type = TEMPORARY_ERROR; + } else if (mCall.isCanceled()) { + type = CANCELED_ERROR; } + nativeOnFailure(mNativePtr, type, e.getMessage()); } diff --git a/include/mbgl/android/native_map_view.hpp b/include/mbgl/android/native_map_view.hpp index 4033c628b..0a4e856db 100644 --- a/include/mbgl/android/native_map_view.hpp +++ b/include/mbgl/android/native_map_view.hpp @@ -62,7 +62,7 @@ private: private: JavaVM *vm = nullptr; - jobject obj = nullptr; + jweak obj = nullptr; ANativeWindow *window = nullptr; EGLDisplay display = EGL_NO_DISPLAY; diff --git a/platform/android/http_request_android.cpp b/platform/android/http_request_android.cpp index 249cb731e..5c5805906 100644 --- a/platform/android/http_request_android.cpp +++ b/platform/android/http_request_android.cpp @@ -75,7 +75,8 @@ private: static const int connectionError = 0; static const int temporaryError = 1; - static const int permanentError = 1; + static const int permanentError = 2; + static const int canceledError = 3; }; // ------------------------------------------------------------------------------------------------- @@ -305,22 +306,26 @@ void HTTPAndroidRequest::onResponse(int code, std::string message, std::string e } void HTTPAndroidRequest::onFailure(int type, std::string message) { - if (!response) { - response = std::make_unique(); - } + if (type != canceledError) { + if (!response) { + response = std::make_unique(); + } - response->status = Response::Error; - response->message = message; + response->status = Response::Error; + response->message = message; - switch (type) { - case connectionError: - status = ResponseStatus::ConnectionError; - - case temporaryError: - status = ResponseStatus::TemporaryError; - - default: - status = ResponseStatus::PermanentError; + switch (type) { + case connectionError: + status = ResponseStatus::ConnectionError; + break; + case temporaryError: + status = ResponseStatus::TemporaryError; + break; + default: + status = ResponseStatus::PermanentError; + } + } else { + status = ResponseStatus::Canceled; } async.send(); From 15cffcd3a2137ce97a093e114aa4d3e71fd9990b Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Wed, 16 Sep 2015 17:52:49 -0700 Subject: [PATCH 143/156] fixes #2350: remove iOS-specific SQLite cache wrapper --- gyp/platform-ios.gypi | 2 - platform/ios/MGLFileCache.h | 14 ------ platform/ios/MGLFileCache.mm | 83 ------------------------------------ platform/ios/MGLMapView.mm | 28 ++++++++---- 4 files changed, 19 insertions(+), 108 deletions(-) delete mode 100644 platform/ios/MGLFileCache.h delete mode 100644 platform/ios/MGLFileCache.mm diff --git a/gyp/platform-ios.gypi b/gyp/platform-ios.gypi index 6234f4d88..f639051c6 100644 --- a/gyp/platform-ios.gypi +++ b/gyp/platform-ios.gypi @@ -25,8 +25,6 @@ '../include/mbgl/ios/MGLMapView.h', '../include/mbgl/ios/MGLMapView+IBAdditions.h', '../platform/ios/MGLMapView.mm', - '../platform/ios/MGLFileCache.h', - '../platform/ios/MGLFileCache.mm', '../include/mbgl/ios/MGLAccountManager.h', '../platform/ios/MGLAccountManager_Private.h', '../platform/ios/MGLAccountManager.m', diff --git a/platform/ios/MGLFileCache.h b/platform/ios/MGLFileCache.h deleted file mode 100644 index 082cec69a..000000000 --- a/platform/ios/MGLFileCache.h +++ /dev/null @@ -1,14 +0,0 @@ -#import "MGLTypes.h" - -#include - -NS_ASSUME_NONNULL_BEGIN - -@interface MGLFileCache : NSObject - -+ (mbgl::SQLiteCache *)obtainSharedCacheWithObject:(NSObject *)object; -+ (void)releaseSharedCacheForObject:(NSObject *)object; - -@end - -NS_ASSUME_NONNULL_END diff --git a/platform/ios/MGLFileCache.mm b/platform/ios/MGLFileCache.mm deleted file mode 100644 index 3303b395f..000000000 --- a/platform/ios/MGLFileCache.mm +++ /dev/null @@ -1,83 +0,0 @@ -#import "MGLFileCache.h" - -@interface MGLFileCache () - -@property (nonatomic) MGLFileCache *sharedInstance; -@property (nonatomic) mbgl::SQLiteCache *sharedCache; -@property (nonatomic) NSHashTable *retainers; - -@end - -@implementation MGLFileCache - -const std::string &defaultCacheDatabasePath() { - static const std::string path = []() -> std::string { - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); - if ([paths count] == 0) { - // Disable the cache if we don't have a location to write. - return ""; - } - - NSString *libraryDirectory = [paths objectAtIndex:0]; - return [[libraryDirectory stringByAppendingPathComponent:@"cache.db"] UTF8String]; - }(); - return path; -} - -- (instancetype)init { - self = [super init]; - if (self) { - _retainers = [NSHashTable weakObjectsHashTable]; - } - return self; -} - -+ (instancetype)sharedInstance { - static dispatch_once_t onceToken; - static MGLFileCache *_sharedInstance; - dispatch_once(&onceToken, ^{ - _sharedInstance = [[self alloc] init]; - }); - return _sharedInstance; -} - -- (void)teardown { - if (self.sharedCache) { - delete self.sharedCache; - self.sharedCache = nullptr; - } -} - -- (void)dealloc { - [self.retainers removeAllObjects]; - [self teardown]; -} - -+ (mbgl::SQLiteCache *)obtainSharedCacheWithObject:(NSObject *)object { - return [[MGLFileCache sharedInstance] obtainSharedCacheWithObject:object]; -} - -- (mbgl::SQLiteCache *)obtainSharedCacheWithObject:(NSObject *)object { - assert([[NSThread currentThread] isMainThread]); - if (!self.sharedCache) { - self.sharedCache = new mbgl::SQLiteCache(defaultCacheDatabasePath()); - } - [self.retainers addObject:object]; - return self.sharedCache; -} - -+ (void)releaseSharedCacheForObject:(NSObject *)object { - return [[MGLFileCache sharedInstance] releaseSharedCacheForObject:object]; -} - -- (void)releaseSharedCacheForObject:(NSObject *)object { - assert([[NSThread currentThread] isMainThread]); - if ([self.retainers containsObject:object]) { - [self.retainers removeObject:object]; - } - if ([self.retainers count] == 0) { - [self teardown]; - } -} - -@end diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 705627663..3cee7db4e 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -28,7 +29,6 @@ #import "NSException+MGLAdditions.h" #import "MGLUserLocationAnnotationView.h" #import "MGLUserLocation_Private.h" -#import "MGLFileCache.h" #import "MGLAccountManager_Private.h" #import "MGLMapboxEvents.h" @@ -112,12 +112,14 @@ mbgl::util::UnitBezier MGLUnitBezierForMediaTimingFunction(CAMediaTimingFunction { mbgl::Map *_mbglMap; MBGLView *_mbglView; + std::shared_ptr _mbglFileCache; mbgl::DefaultFileSource *_mbglFileSource; - BOOL _isWaitingForRedundantReachableNotification; - + NS_MUTABLE_ARRAY_OF(NSURL *) *_bundledStyleURLs; + BOOL _isWaitingForRedundantReachableNotification; BOOL _isTargetingInterfaceBuilder; + CLLocationDegrees _pendingLatitude; CLLocationDegrees _pendingLongitude; } @@ -225,14 +227,24 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) self.backgroundColor = [UIColor clearColor]; self.clipsToBounds = YES; - // setup mbgl map - // + // setup mbgl view const float scaleFactor = [UIScreen instancesRespondToSelector:@selector(nativeScale)] ? [[UIScreen mainScreen] nativeScale] : [[UIScreen mainScreen] scale]; _mbglView = new MBGLView(self, scaleFactor); - _mbglFileSource = new mbgl::DefaultFileSource([MGLFileCache obtainSharedCacheWithObject:self]); - // Start paused + // setup mbgl cache & file source + NSString *fileCachePath = @""; + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); + if ([paths count] != 0) { + NSString *libraryDirectory = [paths objectAtIndex:0]; + fileCachePath = [libraryDirectory stringByAppendingPathComponent:@"cache.db"]; + } + _mbglFileCache = mbgl::SharedSQLiteCache::get([fileCachePath UTF8String]); + _mbglFileSource = new mbgl::DefaultFileSource(_mbglFileCache.get()); + + // setup mbgl map _mbglMap = new mbgl::Map(*_mbglView, *_mbglFileSource, mbgl::MapMode::Continuous); + + // start paused if in IB if (_isTargetingInterfaceBuilder || background) { self.dormant = YES; _mbglMap->pause(); @@ -465,8 +477,6 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) _mbglFileSource = nullptr; } - [MGLFileCache releaseSharedCacheForObject:self]; - if (_mbglView) { delete _mbglView; From 18bc490f40e997bc2a1cbaa2cf82a9ffd2fa2405 Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Thu, 24 Sep 2015 09:18:38 +1000 Subject: [PATCH 144/156] Fix build with Crashlytics NDK on 64bit --- Makefile | 2 +- android/java/.gitignore | 2 -- android/mapboxgl-app.gypi | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index c7099ce03..9f727abc2 100644 --- a/Makefile +++ b/Makefile @@ -131,7 +131,7 @@ clean: clear_sqlite_cache clear_xcode_cache -rm -rf ./test/build -rm -rf ./config/*.gypi -rm -rf ./android/java/build ./android/java/MapboxGLAndroidSDK/build ./android/java/MapboxGLAndroidSDKTestApp/build - -rm -rf ./android/java/MapboxGLAndroidSDK/src/main/libs ./android/java/MapboxGLAndroidSDK/src/main/obj.target ./android/java/MapboxGLAndroidSDK/src/main/assets + -rm -rf ./android/java/MapboxGLAndroidSDK/src/main/jniLibs ./android/java/MapboxGLAndroidSDK/src/main/obj.target ./android/java/MapboxGLAndroidSDK/src/main/assets -rm -f ./android/test/features.zip distclean: clean diff --git a/android/java/.gitignore b/android/java/.gitignore index a79fb8fae..626b99594 100644 --- a/android/java/.gitignore +++ b/android/java/.gitignore @@ -11,9 +11,7 @@ build/ *.apk # JNI -MapboxGLAndroidSDK/src/main/libs/ MapboxGLAndroidSDK/src/main/jniLibs/ -MapboxGLAndroidSDK/src/main/obj/ MapboxGLAndroidSDK/src/main/obj.target/ # Lib assets diff --git a/android/mapboxgl-app.gypi b/android/mapboxgl-app.gypi index 7a8c52d5b..74415df7b 100644 --- a/android/mapboxgl-app.gypi +++ b/android/mapboxgl-app.gypi @@ -91,7 +91,7 @@ { 'action_name': 'Strip dynamic library', 'inputs': [ '<(PRODUCT_DIR)/lib.target/libmapbox-gl.so' ], - 'outputs': [ '<(pwd)/../android/java/MapboxGLAndroidSDK/src/main/libs/$(JNIDIR)/libmapbox-gl.so' ], + 'outputs': [ '<(pwd)/../android/java/MapboxGLAndroidSDK/src/main/jniLibs/$(JNIDIR)/libmapbox-gl.so' ], 'action': [ '$(STRIP)', '<@(_inputs)', '-o', '<@(_outputs)' ] }, ], From 2c4a9f6a3be8945559f127adb8695a11d833cd89 Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Thu, 24 Sep 2015 12:18:59 +1000 Subject: [PATCH 145/156] Refactor NativeMapView to hold std::unique_ptr to Map and DefaultFileSource Add missing asserts to attach_jni_thread/detach_jni_thread Fixes #2406 --- android/cpp/jni.cpp | 6 ++++ android/cpp/native_map_view.cpp | 41 +++++++++++++----------- include/mbgl/android/native_map_view.hpp | 4 +-- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/android/cpp/jni.cpp b/android/cpp/jni.cpp index 140cc9f3c..5ed0a730c 100644 --- a/android/cpp/jni.cpp +++ b/android/cpp/jni.cpp @@ -117,6 +117,9 @@ bool throw_jni_error(JNIEnv *env, const char *msg) { } bool attach_jni_thread(JavaVM* vm, JNIEnv** env, std::string threadName) { + assert(vm != nullptr); + assert(env != nullptr); + JavaVMAttachArgs args = {JNI_VERSION_1_2, threadName.c_str(), NULL}; jint ret; @@ -142,6 +145,9 @@ bool attach_jni_thread(JavaVM* vm, JNIEnv** env, std::string threadName) { void detach_jni_thread(JavaVM* vm, JNIEnv** env, bool detach) { if (detach) { + assert(vm != nullptr); + assert(env != nullptr); + jint ret; if ((ret = vm->DetachCurrentThread()) != JNI_OK) { mbgl::Log::Error(mbgl::Event::JNI, "DetachCurrentThread() failed with %i", ret); diff --git a/android/cpp/native_map_view.cpp b/android/cpp/native_map_view.cpp index 6c1cd87bb..cc04f089e 100644 --- a/android/cpp/native_map_view.cpp +++ b/android/cpp/native_map_view.cpp @@ -57,14 +57,9 @@ NativeMapView::NativeMapView(JNIEnv *env, jobject obj_, float pixelRatio_, int a : mbgl::View(*this), pixelRatio(pixelRatio_), availableProcessors(availableProcessors_), - totalMemory(totalMemory_), - fileCache(mbgl::SharedSQLiteCache::get(mbgl::android::cachePath + "/mbgl-cache.db")), - fileSource(fileCache.get()), - map(*this, fileSource, MapMode::Continuous) { + totalMemory(totalMemory_) { mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::NativeMapView"); - map.pause(); - assert(env != nullptr); assert(obj_ != nullptr); @@ -78,6 +73,12 @@ NativeMapView::NativeMapView(JNIEnv *env, jobject obj_, float pixelRatio_, int a env->ExceptionDescribe(); return; } + + fileCache = mbgl::SharedSQLiteCache::get(mbgl::android::cachePath + "/mbgl-cache.db"); + fileSource = std::make_unique(fileCache.get()); + map = std::make_unique(*this, *fileSource, MapMode::Continuous); + + map->pause(); } NativeMapView::~NativeMapView() { @@ -89,6 +90,10 @@ NativeMapView::~NativeMapView() { assert(vm != nullptr); assert(obj != nullptr); + map.reset(); + fileSource.reset(); + fileCache.reset(); + jint ret; JNIEnv *env = nullptr; ret = vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6); @@ -183,9 +188,9 @@ void NativeMapView::notify() { // noop } -mbgl::Map &NativeMapView::getMap() { return map; } +mbgl::Map &NativeMapView::getMap() { return *map; } -mbgl::DefaultFileSource &NativeMapView::getFileSource() { return fileSource; } +mbgl::DefaultFileSource &NativeMapView::getFileSource() { return *fileSource; } bool NativeMapView::inEmulator() { // Detect if we are in emulator @@ -620,7 +625,7 @@ void NativeMapView::pause() { mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::pause"); if ((display != EGL_NO_DISPLAY) && (context != EGL_NO_CONTEXT)) { - map.pause(); + map->pause(); } } @@ -631,7 +636,7 @@ void NativeMapView::resume() { assert(context != EGL_NO_CONTEXT); if (surface != EGL_NO_SURFACE) { - map.resume(); + map->resume(); } else { mbgl::Log::Debug(mbgl::Event::Android, "Not resuming because we are not ready"); } @@ -699,37 +704,37 @@ void NativeMapView::updateFps() { void NativeMapView::onInvalidate() { mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::onInvalidate()"); - if (map.isPaused()) { + if (map->isPaused()) { mbgl::Log::Debug(mbgl::Event::Android, "Not rendering as map is paused"); return; } const bool dirty = !clean.test_and_set(); if (dirty) { - float zoomFactor = map.getMaxZoom() - map.getMinZoom() + 1; + float zoomFactor = map->getMaxZoom() - map->getMinZoom() + 1; float cpuFactor = availableProcessors; float memoryFactor = static_cast(totalMemory) / 1000.0f / 1000.0f / 1000.0f; - float sizeFactor = (static_cast(map.getWidth()) / mbgl::util::tileSize) * - (static_cast(map.getHeight()) / mbgl::util::tileSize); + float sizeFactor = (static_cast(map->getWidth()) / mbgl::util::tileSize) * + (static_cast(map->getHeight()) / mbgl::util::tileSize); size_t cacheSize = zoomFactor * cpuFactor * memoryFactor * sizeFactor * 0.5f; - map.setSourceTileCacheSize(cacheSize); + map->setSourceTileCacheSize(cacheSize); - map.renderSync(); + map->renderSync(); } } void NativeMapView::resizeView(int w, int h) { width = w; height = h; - map.update(mbgl::Update::Dimensions); + map->update(mbgl::Update::Dimensions); } void NativeMapView::resizeFramebuffer(int w, int h) { fbWidth = w; fbHeight = h; - map.update(mbgl::Update::Repaint); + map->update(mbgl::Update::Repaint); } } diff --git a/include/mbgl/android/native_map_view.hpp b/include/mbgl/android/native_map_view.hpp index 0a4e856db..fe619ba6f 100644 --- a/include/mbgl/android/native_map_view.hpp +++ b/include/mbgl/android/native_map_view.hpp @@ -91,8 +91,8 @@ private: // Ensure these are initialised last std::shared_ptr fileCache; - mbgl::DefaultFileSource fileSource; - mbgl::Map map; + std::unique_ptr fileSource; + std::unique_ptr map; std::atomic_flag clean = ATOMIC_FLAG_INIT; }; From e5ff4638b38c497cf37cffde30b46d9af54cc60d Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Thu, 24 Sep 2015 13:33:01 +1000 Subject: [PATCH 146/156] Actually disable universal APKs --- android/java/MapboxGLAndroidSDKTestApp/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/build.gradle b/android/java/MapboxGLAndroidSDKTestApp/build.gradle index f71d821c2..d61fe2912 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/build.gradle +++ b/android/java/MapboxGLAndroidSDKTestApp/build.gradle @@ -86,7 +86,6 @@ android { enable true reset() include 'armeabi', 'armeabi-v7a', 'x86', 'mips' - universalApk true } } } From 85ec3eb0a5739c4f7b160d82715d3be51e10a02b Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Thu, 24 Sep 2015 17:18:30 +1000 Subject: [PATCH 147/156] Refactor Android render loop to limit frame rate to 60 FPS Move expensive cache size calulation to initialisation Fix setGestureInProgress bug Renamed several functions to match current usage Refactor map updates to reduce GPS marker lag Fixes #1676 Fixes #2290 Fixes #2396 --- android/cpp/jni.cpp | 8 +- android/cpp/native_map_view.cpp | 33 ++--- .../com/mapbox/mapboxgl/views/MapView.java | 139 ++++++++++-------- .../mapbox/mapboxgl/views/NativeMapView.java | 6 +- include/mbgl/android/native_map_view.hpp | 4 +- 5 files changed, 98 insertions(+), 92 deletions(-) diff --git a/android/cpp/jni.cpp b/android/cpp/jni.cpp index 5ed0a730c..dcf64eed2 100644 --- a/android/cpp/jni.cpp +++ b/android/cpp/jni.cpp @@ -470,11 +470,11 @@ void JNICALL nativeUpdate(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) { nativeMapView->getMap().update(mbgl::Update::Repaint); } -void JNICALL nativeOnInvalidate(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) { - mbgl::Log::Debug(mbgl::Event::JNI, "nativeOnInvalidate"); +void JNICALL nativeRenderSync(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) { + mbgl::Log::Debug(mbgl::Event::JNI, "nativeRenderSync"); assert(nativeMapViewPtr != 0); NativeMapView *nativeMapView = reinterpret_cast(nativeMapViewPtr); - nativeMapView->onInvalidate(); + nativeMapView->renderSync(); } void JNICALL nativeViewResize(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jint width, jint height) { @@ -1625,7 +1625,7 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { {"nativePause", "(J)V", reinterpret_cast(&nativePause)}, {"nativeResume", "(J)V", reinterpret_cast(&nativeResume)}, {"nativeUpdate", "(J)V", reinterpret_cast(&nativeUpdate)}, - {"nativeOnInvalidate", "(J)V", reinterpret_cast(&nativeOnInvalidate)}, + {"nativeRenderSync", "(J)V", reinterpret_cast(&nativeRenderSync)}, {"nativeViewResize", "(JII)V", reinterpret_cast(static_cast(&nativeViewResize))}, diff --git a/android/cpp/native_map_view.cpp b/android/cpp/native_map_view.cpp index cc04f089e..31fb5453a 100644 --- a/android/cpp/native_map_view.cpp +++ b/android/cpp/native_map_view.cpp @@ -78,6 +78,16 @@ NativeMapView::NativeMapView(JNIEnv *env, jobject obj_, float pixelRatio_, int a fileSource = std::make_unique(fileCache.get()); map = std::make_unique(*this, *fileSource, MapMode::Continuous); + float zoomFactor = map->getMaxZoom() - map->getMinZoom() + 1; + float cpuFactor = availableProcessors; + float memoryFactor = static_cast(totalMemory) / 1000.0f / 1000.0f / 1000.0f; + float sizeFactor = (static_cast(map->getWidth()) / mbgl::util::tileSize) * + (static_cast(map->getHeight()) / mbgl::util::tileSize); + + size_t cacheSize = zoomFactor * cpuFactor * memoryFactor * sizeFactor * 0.5f; + + map->setSourceTileCacheSize(cacheSize); + map->pause(); } @@ -148,8 +158,6 @@ void NativeMapView::deactivate() { void NativeMapView::invalidate() { mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::invalidate()"); - clean.clear(); - assert(vm != nullptr); assert(obj != nullptr); @@ -169,7 +177,7 @@ void NativeMapView::beforeRender() { } void NativeMapView::afterRender() { - mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::swap"); + mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::afterRender"); if ((display != EGL_NO_DISPLAY) && (surface != EGL_NO_SURFACE)) { if (!eglSwapBuffers(display, surface)) { @@ -701,28 +709,15 @@ void NativeMapView::updateFps() { detach_jni_thread(vm, &env, detach); } -void NativeMapView::onInvalidate() { - mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::onInvalidate()"); +void NativeMapView::renderSync() { + mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::renderSync()"); if (map->isPaused()) { mbgl::Log::Debug(mbgl::Event::Android, "Not rendering as map is paused"); return; } - const bool dirty = !clean.test_and_set(); - if (dirty) { - float zoomFactor = map->getMaxZoom() - map->getMinZoom() + 1; - float cpuFactor = availableProcessors; - float memoryFactor = static_cast(totalMemory) / 1000.0f / 1000.0f / 1000.0f; - float sizeFactor = (static_cast(map->getWidth()) / mbgl::util::tileSize) * - (static_cast(map->getHeight()) / mbgl::util::tileSize); - - size_t cacheSize = zoomFactor * cpuFactor * memoryFactor * sizeFactor * 0.5f; - - map->setSourceTileCacheSize(cacheSize); - - map->renderSync(); - } + map->renderSync(); } void NativeMapView::resizeView(int w, int h) { diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java index b4eece5ec..70fb5e138 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java @@ -31,6 +31,7 @@ import android.support.v4.view.GestureDetectorCompat; import android.support.v4.view.ScaleGestureDetectorCompat; import android.support.v7.app.AlertDialog; import android.text.TextUtils; +import android.util.Log; import android.view.GestureDetector; import android.view.Gravity; import android.view.ScaleGestureDetector; @@ -63,7 +64,7 @@ import com.mapzen.android.lost.api.LocationListener; import com.mapzen.android.lost.api.LocationRequest; import com.mapzen.android.lost.api.LocationServices; import com.mapzen.android.lost.api.LostApiClient; -import com.squareup.okhttp.HttpUrl; + import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; @@ -138,6 +139,9 @@ public class MapView extends FrameLayout implements LocationListener { // Used to call JNI NativeMapView private NativeMapView mNativeMapView; + // Used to track rendering + private Boolean mDirty = false; + // Used to handle DPI scaling private float mScreenDensity = 1.0f; @@ -400,6 +404,12 @@ public class MapView extends FrameLayout implements LocationListener { .setSmallestDisplacement(1) .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); + // Setup User Location UI + mGpsMarker = new ImageView(getContext()); + mGpsMarker.setImageResource(R.drawable.location_marker); + mGpsMarker.setVisibility(View.INVISIBLE); + addView(mGpsMarker); + // Setup Compass mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE); mSensorAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); @@ -411,6 +421,7 @@ public class MapView extends FrameLayout implements LocationListener { mCompassView.setContentDescription(getResources().getString(R.string.compassContentDescription)); LayoutParams lp = new FrameLayout.LayoutParams((int)(48 * mScreenDensity), (int)(48 * mScreenDensity)); mCompassView.setLayoutParams(lp); + mCompassView.setVisibility(View.INVISIBLE); addView(mCompassView); mCompassView.setOnClickListener(new CompassOnClickListener()); @@ -883,7 +894,9 @@ public class MapView extends FrameLayout implements LocationListener { addOnMapChangedListener(new OnMapChangedListener() { @Override public void onMapChanged(MapChange change) { - updateMap(change); + if (change.equals(MapChange.MapChangeRegionWillChange) || change.equals(MapChange.MapChangeRegionWillChangeAnimated)) { + deselectAnnotation(); + } } }); } @@ -957,7 +970,7 @@ public class MapView extends FrameLayout implements LocationListener { if (mIsMyLocationEnabled) { toggleGps(false); - }; + } mNativeMapView.pause(); } @@ -1074,7 +1087,8 @@ public class MapView extends FrameLayout implements LocationListener { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { // Check and ignore non touch or left clicks - if ((android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) && (event.getButtonState() != 0) && (event.getButtonState() != MotionEvent.BUTTON_PRIMARY)) { + + if ((event.getButtonState() != 0) && (event.getButtonState() != MotionEvent.BUTTON_PRIMARY)) { return false; } @@ -1103,7 +1117,6 @@ public class MapView extends FrameLayout implements LocationListener { long tapInterval = event.getEventTime() - event.getDownTime(); boolean isTap = tapInterval <= ViewConfiguration.getTapTimeout(); boolean inProgress = mRotateGestureDetector.isInProgress() || mScaleGestureDetector.isInProgress(); - mNativeMapView.setGestureInProgress(false); if (mTwoTap && isTap && !inProgress) { PointF focalPoint = TwoFingerGestureDetector.determineFocalPoint(event); @@ -1113,6 +1126,7 @@ public class MapView extends FrameLayout implements LocationListener { } mTwoTap = false; + mNativeMapView.setGestureInProgress(false); break; case MotionEvent.ACTION_CANCEL: @@ -1780,12 +1794,30 @@ public class MapView extends FrameLayout implements LocationListener { // Called when the map needs to be rerendered // Called via JNI from NativeMapView protected void onInvalidate() { - post(new Runnable() { + synchronized (mDirty) { + if (!mDirty) { + mDirty = true; + postRender(); + } + } + } + + private void postRender() { + Runnable mRunnable = new Runnable() { @Override public void run() { - mNativeMapView.invalidate(); + updateCompass(); + updateGpsMarker(); + mNativeMapView.renderSync(); + mDirty = false; } - }); + }; + + if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + postOnAnimation(mRunnable); + } else { + postDelayed(mRunnable, 1000 / 60); + } } /** @@ -1876,7 +1908,6 @@ public class MapView extends FrameLayout implements LocationListener { public final void setMyLocationEnabled (boolean enabled) { mIsMyLocationEnabled = enabled; toggleGps(enabled); - updateMap(MapChange.MapChangeNullChange); } /** @@ -1898,18 +1929,20 @@ public class MapView extends FrameLayout implements LocationListener { mLocationClient.connect(); updateLocation(LocationServices.FusedLocationApi.getLastLocation()); LocationServices.FusedLocationApi.requestLocationUpdates(mLocationRequest, this); - mSensorManager.registerListener(mCompassListener, mSensorAccelerometer, SensorManager.SENSOR_DELAY_UI); - mSensorManager.registerListener(mCompassListener, mSensorMagneticField, SensorManager.SENSOR_DELAY_UI); + //mSensorManager.registerListener(mCompassListener, mSensorAccelerometer, SensorManager.SENSOR_DELAY_UI); + //mSensorManager.registerListener(mCompassListener, mSensorMagneticField, SensorManager.SENSOR_DELAY_UI); } } else { if (mLocationClient.isConnected()) { LocationServices.FusedLocationApi.removeLocationUpdates(this); mLocationClient.disconnect(); mGpsLocation = null; - mSensorManager.unregisterListener(mCompassListener, mSensorAccelerometer); - mSensorManager.unregisterListener(mCompassListener, mSensorMagneticField); + //mSensorManager.unregisterListener(mCompassListener, mSensorAccelerometer); + //mSensorManager.unregisterListener(mCompassListener, mSensorMagneticField); } } + + onInvalidate(); } /** @@ -1931,18 +1964,8 @@ public class MapView extends FrameLayout implements LocationListener { * @param compassEnabled true to enable the compass; false to disable the compass. */ public void setCompassEnabled (boolean compassEnabled) { - // Set value this.mIsCompassEnabled = compassEnabled; - - // Toggle UI - if (mIsCompassEnabled) { - mCompassView.setVisibility(View.VISIBLE); - } else { - mCompassView.setVisibility(View.GONE); - } - - // Update Map - updateMap(MapChange.MapChangeNullChange); + onInvalidate(); } public void setCompassGravity(int gravity){ @@ -2022,7 +2045,7 @@ public class MapView extends FrameLayout implements LocationListener { } } - updateMap(MapChange.MapChangeNullChange); + onInvalidate(); } @Override @@ -2088,7 +2111,7 @@ public class MapView extends FrameLayout implements LocationListener { private void updateLocation(Location location) { if (location != null) { mGpsLocation = location; - updateMap(MapChange.MapChangeNullChange); + updateGpsMarker(); } } @@ -2102,22 +2125,17 @@ public class MapView extends FrameLayout implements LocationListener { } // Updates the UI to match the current map's position - private void updateMap(MapChange change) { - // Using direct access to mIsCompassEnabled instead of isCompassEnabled() for - // small performance boost as this method is called rapidly. - if (mIsCompassEnabled) { + private void updateCompass() { + if (isCompassEnabled()) { + mCompassView.setVisibility(VISIBLE); rotateImageView(mCompassView, (float) getDirection()); + } else { + mCompassView.setVisibility(INVISIBLE); } + } + private void updateGpsMarker() { if (isMyLocationEnabled() && mGpsLocation != null) { - if (mGpsMarker == null) { - // Setup User Location UI - // NOTE: mIsMyLocationEnabled == false to begin with - mGpsMarker = new ImageView(getContext()); - mGpsMarker.setImageResource(R.drawable.location_marker); - addView(mGpsMarker); - } - mGpsMarker.setVisibility(View.VISIBLE); LatLng coordinate = new LatLng(mGpsLocation); PointF screenLocation = toScreenLocation(coordinate); @@ -2130,26 +2148,6 @@ public class MapView extends FrameLayout implements LocationListener { mGpsMarker.setLayoutParams(lp); rotateImageView(mGpsMarker, 0.0f); mGpsMarker.requestLayout(); - - // Update direction if tracking mode - if(mUserLocationTrackingMode == UserLocationTrackingMode.FOLLOW_BEARING && mCompassValid){ - // TODO need to do proper filtering (see branch filter-compass) or else map will lock up because of all the compass events - long t = new Date().getTime(); - if((t-t0)>1000){ - t0 = t; - setDirection(-mCompassBearing, true); - } - } - -/* - // TODO - Too much overhead on main thread. Needs to be refactored before it - // can be re-enabled - // Update map position if NOT in NONE mode - if (mUserLocationTrackingMode != UserLocationTrackingMode.NONE) { - setCenterCoordinate(new LatLng(mGpsLocation)); - } -*/ - /* // Used For User Location Bearing UI if (mGpsLocation.hasBearing() || mCompassValid) { @@ -2169,13 +2167,28 @@ public class MapView extends FrameLayout implements LocationListener { mGpsMarker.setVisibility(View.INVISIBLE); } } - - if (change.equals(MapChange.MapChangeRegionWillChange) || change.equals(MapChange.MapChangeRegionWillChangeAnimated)) { - deselectAnnotation(); - } - } + // Old tracking code + // Update direction if tracking mode + /*if(mUserLocationTrackingMode == UserLocationTrackingMode.FOLLOW_BEARING && mCompassValid){ + // TODO need to do proper filtering (see branch filter-compass) or else map will lock up because of all the compass events + long t = new Date().getTime(); + if((t-t0)>1000){ + t0 = t; + setDirection(-mCompassBearing, true); + } + }*/ + +/* + // TODO - Too much overhead on main thread. Needs to be refactored before it + // can be re-enabled + // Update map position if NOT in NONE mode + if (mUserLocationTrackingMode != UserLocationTrackingMode.NONE) { + setCenterCoordinate(new LatLng(mGpsLocation)); + } +*/ + private void selectAnnotation(Annotation annotation) { if (annotation == null) { diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java index 3cf56a8de..1023fa1ff 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java @@ -96,8 +96,8 @@ class NativeMapView { nativeUpdate(mNativeMapViewPtr); } - public void invalidate() { - nativeOnInvalidate(mNativeMapViewPtr); + public void renderSync() { + nativeRenderSync(mNativeMapViewPtr); } public void resizeView(int width, int height) { @@ -475,7 +475,7 @@ class NativeMapView { private native void nativeUpdate(long nativeMapViewPtr); - private native void nativeOnInvalidate(long nativeMapViewPtr); + private native void nativeRenderSync(long nativeMapViewPtr); private native void nativeViewResize(long nativeMapViewPtr, int width, int height); diff --git a/include/mbgl/android/native_map_view.hpp b/include/mbgl/android/native_map_view.hpp index fe619ba6f..0908f7563 100644 --- a/include/mbgl/android/native_map_view.hpp +++ b/include/mbgl/android/native_map_view.hpp @@ -50,7 +50,7 @@ public: void enableFps(bool enable); void updateFps(); - void onInvalidate(); + void renderSync(); void resizeView(int width, int height); void resizeFramebuffer(int width, int height); @@ -93,8 +93,6 @@ private: std::shared_ptr fileCache; std::unique_ptr fileSource; std::unique_ptr map; - - std::atomic_flag clean = ATOMIC_FLAG_INIT; }; } } From db2afca0781494e2d2583c6d83c4bcd198513ebe Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Thu, 24 Sep 2015 10:11:58 -0500 Subject: [PATCH 148/156] #2414 - Removing Crashlytics NDK integration as it's preventing TestApp from running --- android/java/MapboxGLAndroidSDKTestApp/build.gradle | 9 --------- .../java/com/mapbox/mapboxgl/testapp/MainActivity.java | 3 +-- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/build.gradle b/android/java/MapboxGLAndroidSDKTestApp/build.gradle index d61fe2912..b42f3565d 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/build.gradle +++ b/android/java/MapboxGLAndroidSDKTestApp/build.gradle @@ -90,12 +90,6 @@ android { } } -crashlytics { - enableNdk true - androidNdkOut '../MapboxGLAndroidSDK/src/main/obj.target' - androidNdkLibsOut '../MapboxGLAndroidSDK/src/main/obj.target' -} - dependencies { compile(project(':MapboxGLAndroidSDK')) { transitive = true @@ -107,9 +101,6 @@ dependencies { compile('com.crashlytics.sdk.android:crashlytics:2.5.1@aar') { transitive = true; } - compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.1@aar') { - transitive = true; - } // Testing dependencies testCompile 'junit:junit:4.12' diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java index 3f14ab557..2f9b374e2 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java @@ -25,7 +25,6 @@ import android.view.View; import android.widget.TextView; import android.widget.Toast; import com.crashlytics.android.Crashlytics; -import com.crashlytics.android.ndk.CrashlyticsNdk; import com.mapbox.mapboxgl.annotations.Marker; import com.mapbox.mapboxgl.annotations.MarkerOptions; import com.mapbox.mapboxgl.annotations.PolygonOptions; @@ -79,7 +78,7 @@ public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - Fabric.with(this, new Crashlytics(), new CrashlyticsNdk()); + Fabric.with(this, new Crashlytics()); // Load the layout setContentView(R.layout.activity_main); From c3fe83f709839b3faf4900eb67f52053234ea363 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Thu, 24 Sep 2015 10:36:36 -0500 Subject: [PATCH 149/156] #2414 - Add explicit null check for infoWindow --- .../src/main/java/com/mapbox/mapboxgl/annotations/Marker.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Marker.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Marker.java index 17317bffb..2e76a8d9b 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Marker.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Marker.java @@ -78,7 +78,9 @@ public class Marker extends Annotation { } public void hideInfoWindow() { - infoWindow.close(); + if (infoWindow != null) { + infoWindow.close(); + } infoWindowShown = false; } From 142b59246e13b6801f49d79bd029f57fdd2f7d45 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 22 Sep 2015 17:31:00 -0400 Subject: [PATCH 150/156] [osx] disable -Wunused-local-typedefs Fixes OS X builds with Xcode 7, necessitated by https://svn.boost.org/trac/boost/ticket/11240 --- bin/render.cpp | 6 +++++- macosx/main.mm | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/render.cpp b/bin/render.cpp index 3da0c9358..2248d8603 100644 --- a/bin/render.cpp +++ b/bin/render.cpp @@ -9,13 +9,17 @@ #include #include +#pragma clang diagnostic push #pragma GCC diagnostic push -#ifndef __clang__ +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wunused-local-typedefs" +#else #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #pragma GCC diagnostic ignored "-Wshadow" #endif #include #pragma GCC diagnostic pop +#pragma clang diagnostic pop namespace po = boost::program_options; diff --git a/macosx/main.mm b/macosx/main.mm index 24251e6d4..7698773e7 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -12,13 +12,17 @@ #import +#pragma clang diagnostic push #pragma GCC diagnostic push -#ifndef __clang__ +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wunused-local-typedefs" +#else #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #pragma GCC diagnostic ignored "-Wshadow" #endif #include #pragma GCC diagnostic pop +#pragma clang diagnostic pop #include From ac6575065b07d6e3594fb453bed3ce0447512b74 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 23 Sep 2015 12:31:26 -0400 Subject: [PATCH 151/156] [osx] build OS X with Xcode 7 patch mason to set 'tbh' MASON_DYNLIB_SUFFIX on iOS 9+ and OS X 10.11+ --- .mason | 2 +- .travis.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.mason b/.mason index d8597d944..36dc9282d 160000 --- a/.mason +++ b/.mason @@ -1 +1 @@ -Subproject commit d8597d944533dbb5e28d08dfdba22a82c93171b7 +Subproject commit 36dc9282d7b79b4533c511529d6f83fe5719f673 diff --git a/.travis.yml b/.travis.yml index 6d7d31123..f9d22b51e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ matrix: sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5' ] packages: [ 'gdb', 'clang-3.5', 'libstdc++-4.9-dev', 'libstdc++6', 'libllvm3.4', 'xutils-dev', 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ] - os: osx - osx_image: xcode6.4 + osx_image: xcode7 env: FLAVOR=osx BUILDTYPE=Debug - os: osx osx_image: xcode7 @@ -77,15 +77,15 @@ matrix: sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5' ] packages: [ 'gdb', 'clang-3.5', 'libstdc++-4.9-dev', 'libstdc++6', 'libllvm3.4', 'xutils-dev', 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ] - os: osx - osx_image: xcode6.4 + osx_image: xcode7 compiler: clang env: FLAVOR=node NODE_VERSION=iojs-v3 - os: osx - osx_image: xcode6.4 + osx_image: xcode7 compiler: clang env: FLAVOR=node NODE_VERSION=0.12 - os: osx - osx_image: xcode6.4 + osx_image: xcode7 compiler: clang env: FLAVOR=node NODE_VERSION=0.10 From 8ef59dd1ecfb6e51c9ae952974fbfadde983dac8 Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Fri, 25 Sep 2015 06:58:31 +1000 Subject: [PATCH 152/156] Update Crashlytics --- android/java/MapboxGLAndroidSDKTestApp/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/java/MapboxGLAndroidSDKTestApp/build.gradle b/android/java/MapboxGLAndroidSDKTestApp/build.gradle index b42f3565d..a04279edd 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/build.gradle +++ b/android/java/MapboxGLAndroidSDKTestApp/build.gradle @@ -98,7 +98,7 @@ dependencies { compile 'com.android.support:support-v4:23.0.1' compile 'com.android.support:appcompat-v7:23.0.1' compile 'com.android.support:design:23.0.1' - compile('com.crashlytics.sdk.android:crashlytics:2.5.1@aar') { + compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') { transitive = true; } From cd57ad52df243520cd7c93832a6ea4841b6fb959 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Fri, 25 Sep 2015 09:53:44 -0500 Subject: [PATCH 153/156] #2275 - Setting version_name to 0.1.0 for release --- android/java/MapboxGLAndroidSDK/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/java/MapboxGLAndroidSDK/gradle.properties b/android/java/MapboxGLAndroidSDK/gradle.properties index 680aad376..50eaf0a97 100644 --- a/android/java/MapboxGLAndroidSDK/gradle.properties +++ b/android/java/MapboxGLAndroidSDK/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.mapbox.mapboxgl -VERSION_NAME=0.0.1-SNAPSHOT +VERSION_NAME=0.1.0 POM_DESCRIPTION=Mapbox GL Android SDK POM_URL=https://github.com/mapbox/mapbox-gl-native From 01ff7b17355f643fff6823d6709641a4dcfe6534 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Sat, 22 Aug 2015 01:56:08 -0400 Subject: [PATCH 154/156] Reverse quickzoom up/down zooming to be out/in --- platform/ios/MGLMapView.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 3cee7db4e..80788bd73 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -1336,7 +1336,7 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) } else if (quickZoom.state == UIGestureRecognizerStateChanged) { - CGFloat distance = self.quickZoomStart - [quickZoom locationInView:quickZoom.view].y; + CGFloat distance = [quickZoom locationInView:quickZoom.view].y - self.quickZoomStart; CGFloat newZoom = log2f(self.scale) + (distance / 100); From 417f26fba662cdba7c1ff6f79c16f897f7868b97 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Sat, 22 Aug 2015 01:57:28 -0400 Subject: [PATCH 155/156] Quicken quick zoom gesture Double tapping and holding, then moving up/down will now immediately zoom out/in. --- platform/ios/MGLMapView.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 80788bd73..122de0114 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -370,7 +370,8 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) { _quickZoom = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleQuickZoomGesture:)]; _quickZoom.numberOfTapsRequired = 1; - _quickZoom.minimumPressDuration = 0.25; + _quickZoom.minimumPressDuration = 0; + [_quickZoom requireGestureRecognizerToFail:doubleTap]; [self addGestureRecognizer:_quickZoom]; } From ed702a68e51ebfd5154a92ebe6d1f1d373f0d4b2 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Sat, 22 Aug 2015 02:02:30 -0400 Subject: [PATCH 156/156] Make quickzoom zoom slightly more quickly --- platform/ios/MGLMapView.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 122de0114..a2f67c7bb 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -1339,7 +1339,7 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) { CGFloat distance = [quickZoom locationInView:quickZoom.view].y - self.quickZoomStart; - CGFloat newZoom = log2f(self.scale) + (distance / 100); + CGFloat newZoom = log2f(self.scale) + (distance / 75); if (newZoom < _mbglMap->getMinZoom()) return;