summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorm-stephen <truestyle2005@163.com>2019-07-09 14:41:07 +0800
committerGitHub <noreply@github.com>2019-07-09 14:41:07 +0800
commitb1f7fbe39d5c8d2d6411e78b36ecbf51836a2f27 (patch)
tree914c806c3f70f7f29860450491e0d3af9fb29d6a
parent2c4c17243f99527bece85a8a5e66a58d20dc93dd (diff)
parentd6c1c838eb0c612aa971740fc58cc2a2e1086f77 (diff)
downloadqtlocation-mapboxgl-b1f7fbe39d5c8d2d6411e78b36ecbf51836a2f27.tar.gz
Merge branch 'master' into Stephen-CJK
-rw-r--r--Makefile20
-rw-r--r--platform/android/.editorconfig2
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java4
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java14
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java2
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinatorTest.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/log/LoggerTest.kt16
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleTest.kt4
-rw-r--r--platform/android/MapboxGLAndroidSDKLint/src/main/java/com/mapbox/mapboxsdk/lint/KeepDetector.kt6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/AppCenter.kt1
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/InstrumentationRunner.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactoryTest.kt1
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/BaseIntegrationTest.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/FragmentBackStackTest.kt7
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReopenTest.kt3
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReuseTest.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/OrientationChangeTest.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/QueryRenderedFeaturesBoxCountTest.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReopenTest.kt4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReuseTest.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/ViewPagerScrollTest.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt432
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt152
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxLocationTestingUtils.kt1
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt1
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/BaseLayerTest.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/NativeMapViewTest.kt7
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TransformTest.kt6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/VisibleRegionTest.kt8
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/offline/OfflineDownloadTest.kt88
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotterTest.kt26
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseTest.java5
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/fragment/MapDialogFragmentTest.kt1
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/ImageMissingTest.kt4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/RemoveUnusedImagesTest.kt12
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt3
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/CacheTest.kt3
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceMapTest.kt4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.kt8
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/PixelTestActivity.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/NestedViewPagerActivity.kt11
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.kt4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationFragmentActivity.kt4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/GLSurfaceRecyclerViewActivity.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/OverlayMapActivity.kt4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/TextureRecyclerViewActivity.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/ChangeResourcesCachePathActivity.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/DownloadRegionActivity.kt17
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/MergeOfflineRegionsActivity.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterMarkerActivity.java9
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/storage/CacheManagementActivity.kt1
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DraggableMarkerActivity.kt18
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FileUtils.kt1
-rw-r--r--platform/android/build.gradle4
-rw-r--r--platform/android/gradle/dependencies.gradle6
-rw-r--r--platform/android/gradle/download-schema.gradle8
-rw-r--r--platform/android/gradle/ktlint.gradle27
-rw-r--r--platform/ios/CHANGELOG.md9
-rw-r--r--platform/ios/Mapbox-iOS-SDK-snapshot-dynamic.podspec2
-rw-r--r--platform/ios/Mapbox-iOS-SDK-stripped.podspec2
-rw-r--r--platform/ios/Mapbox-iOS-SDK.podspec2
-rw-r--r--platform/ios/ios.xcodeproj/project.pbxproj4
-rw-r--r--platform/ios/test/MGLMapViewPitchTests.m155
m---------platform/ios/vendor/mapbox-events-ios0
-rw-r--r--src/core-files.json2
-rw-r--r--src/mbgl/annotation/render_annotation_source.hpp5
-rw-r--r--src/mbgl/renderer/image_atlas.cpp41
-rw-r--r--src/mbgl/renderer/image_atlas.hpp14
-rw-r--r--src/mbgl/renderer/image_manager.cpp9
-rw-r--r--src/mbgl/renderer/image_manager.hpp1
-rw-r--r--src/mbgl/renderer/layers/render_hillshade_layer.cpp4
-rw-r--r--src/mbgl/renderer/layers/render_raster_layer.cpp11
-rw-r--r--src/mbgl/renderer/layers/render_raster_layer.hpp5
-rw-r--r--src/mbgl/renderer/layers/render_symbol_layer.cpp9
-rw-r--r--src/mbgl/renderer/paint_parameters.cpp4
-rw-r--r--src/mbgl/renderer/paint_parameters.hpp5
-rw-r--r--src/mbgl/renderer/render_layer.cpp32
-rw-r--r--src/mbgl/renderer/render_layer.hpp6
-rw-r--r--src/mbgl/renderer/render_orchestrator.cpp38
-rw-r--r--src/mbgl/renderer/render_source.cpp6
-rw-r--r--src/mbgl/renderer/render_source.hpp33
-rw-r--r--src/mbgl/renderer/render_tile.cpp48
-rw-r--r--src/mbgl/renderer/render_tile.hpp13
-rw-r--r--src/mbgl/renderer/sources/render_custom_geometry_source.hpp5
-rw-r--r--src/mbgl/renderer/sources/render_geojson_source.hpp5
-rw-r--r--src/mbgl/renderer/sources/render_image_source.cpp102
-rw-r--r--src/mbgl/renderer/sources/render_image_source.hpp43
-rw-r--r--src/mbgl/renderer/sources/render_raster_dem_source.hpp7
-rw-r--r--src/mbgl/renderer/sources/render_raster_source.hpp5
-rw-r--r--src/mbgl/renderer/sources/render_tile_source.cpp62
-rw-r--r--src/mbgl/renderer/sources/render_tile_source.hpp8
-rw-r--r--src/mbgl/renderer/sources/render_vector_source.hpp5
-rw-r--r--src/mbgl/renderer/tile_pyramid.cpp29
-rw-r--r--src/mbgl/renderer/tile_pyramid.hpp5
-rw-r--r--src/mbgl/renderer/tile_render_data.cpp40
-rw-r--r--src/mbgl/renderer/tile_render_data.hpp61
-rw-r--r--src/mbgl/text/cross_tile_symbol_index.cpp2
-rw-r--r--src/mbgl/text/placement.cpp3
-rw-r--r--src/mbgl/text/placement.hpp1
-rw-r--r--src/mbgl/tile/geometry_tile.cpp188
-rw-r--r--src/mbgl/tile/geometry_tile.hpp36
-rw-r--r--src/mbgl/tile/geometry_tile_worker.cpp4
-rw-r--r--src/mbgl/tile/raster_dem_tile.cpp16
-rw-r--r--src/mbgl/tile/raster_dem_tile.hpp8
-rw-r--r--src/mbgl/tile/raster_tile.cpp15
-rw-r--r--src/mbgl/tile/raster_tile.hpp8
-rw-r--r--src/mbgl/tile/tile.hpp13
-rw-r--r--test/tile/custom_geometry_tile.test.cpp4
-rw-r--r--test/tile/geojson_tile.test.cpp12
113 files changed, 1461 insertions, 687 deletions
diff --git a/Makefile b/Makefile
index aefd0b0458..5a127471c9 100644
--- a/Makefile
+++ b/Makefile
@@ -771,6 +771,11 @@ apackage: platform/android/gradle/configuration.gradle
android-ui-test: platform/android/gradle/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=all :MapboxGLAndroidSDKTestApp:assembleDebug :MapboxGLAndroidSDKTestApp:assembleAndroidTest
+#Run instrumentations tests on MicroSoft App Center
+.PHONY: run-android-test-app-center
+run-android-test-app-center:
+ cd platform/android && appcenter test run espresso --app "mapboxcn-outlook.com/MapsSdk" --devices "mapboxcn-outlook.com/china" --app-path MapboxGLAndroidSDKTestApp/build/outputs/apk/debug/MapboxGLAndroidSDKTestApp-debug.apk --test-series "master" --locale "en_US" --build-dir MapboxGLAndroidSDKTestApp/build/outputs/apk/androidTest/debug
+
# Uploads the compiled Android SDK to Bintray
.PHONY: run-android-upload-to-bintray
run-android-upload-to-bintray: platform/android/gradle/configuration.gradle
@@ -791,21 +796,26 @@ android-gfxinfo:
test-code-android:
node platform/android/scripts/generate-test-code.js
-# Runs checkstyle and lint on the Android code
+# Runs checkstyle and lint on the java code
.PHONY: android-check
-android-check : android-checkstyle run-android-nitpick android-lint-sdk android-lint-test-app
+android-check : android-checkstyle run-android-nitpick android-lint-sdk android-lint-test-app android-ktlint
-# Runs checkstyle on the Android code
+# Runs checkstyle on the java code
.PHONY: android-checkstyle
android-checkstyle: platform/android/gradle/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none :MapboxGLAndroidSDK:checkstyle :MapboxGLAndroidSDKTestApp:checkstyle
-# Runs lint on the Android SDK code
+# Runs checkstyle on the kotlin code
+.PHONY: android-ktlint
+android-ktlint:
+ cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none ktlint
+
+# Runs lint on the Android SDK java code
.PHONY: android-lint-sdk
android-lint-sdk: platform/android/gradle/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none :MapboxGLAndroidSDK:lint
-# Runs lint on the Android test app code
+# Runs lint on the Android test app java code
.PHONY: android-lint-test-app
android-lint-test-app: platform/android/gradle/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none :MapboxGLAndroidSDKTestApp:lint
diff --git a/platform/android/.editorconfig b/platform/android/.editorconfig
new file mode 100644
index 0000000000..7ebd2b7bb0
--- /dev/null
+++ b/platform/android/.editorconfig
@@ -0,0 +1,2 @@
+[*.{kt,kts}]
+indent_size=2 \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
index 81cd1830e6..1367de8729 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
@@ -91,7 +91,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
@UiThread
public MapView(@NonNull Context context) {
super(context);
- initialize(context, MapboxMapOptions.createFromAttributes(context, null));
+ initialize(context, MapboxMapOptions.createFromAttributes(context));
}
@UiThread
@@ -109,7 +109,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
@UiThread
public MapView(@NonNull Context context, @Nullable MapboxMapOptions options) {
super(context);
- initialize(context, options == null ? MapboxMapOptions.createFromAttributes(context, null) : options);
+ initialize(context, options == null ? MapboxMapOptions.createFromAttributes(context) : options);
}
@CallSuper
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
index cc2124c6c7..09bb5012d1 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
@@ -14,6 +14,7 @@ import android.support.v4.content.res.ResourcesCompat;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.Gravity;
+
import com.mapbox.mapboxsdk.R;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
@@ -136,7 +137,18 @@ public class MapboxMapOptions implements Parcelable {
}
/**
- * Creates a MapboxMapsOptions from the attribute set.s
+ * Creates a default MapboxMapsOptions from a given context.
+ *
+ * @param context Context related to a map view.
+ * @return the MapboxMapOptions created from attributes
+ */
+ @NonNull
+ public static MapboxMapOptions createFromAttributes(@NonNull Context context) {
+ return createFromAttributes(context, null);
+ }
+
+ /**
+ * Creates a MapboxMapsOptions from the attribute set.
*
* @param context Context related to a map view.
* @param attrs Attributeset containing configuration
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java
index f3c8fd32cf..884e0a42be 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java
@@ -44,7 +44,7 @@ public class MapFragmentUtils {
options = args.getParcelable(MapboxConstants.FRAG_ARG_MAPBOXMAPOPTIONS);
} else {
// load default options
- options = MapboxMapOptions.createFromAttributes(context, null);
+ options = MapboxMapOptions.createFromAttributes(context);
}
return options;
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinatorTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinatorTest.kt
index 0091c50b08..1b927d213a 100644
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinatorTest.kt
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinatorTest.kt
@@ -529,4 +529,4 @@ private fun <E> SparseArray<E>.contains(listener: AnimationsValueChangeListener<
}
}
return false
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/log/LoggerTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/log/LoggerTest.kt
index 8b55419ea4..82e1c67f67 100644
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/log/LoggerTest.kt
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/log/LoggerTest.kt
@@ -28,7 +28,7 @@ class LoggerTest {
fun verbosityLogLevelIgnore() {
Logger.setVerbosity(Logger.DEBUG)
Logger.v(TAG, MESSAGE)
- verify(exactly = 0){ logger.v(TAG, MESSAGE) }
+ verify(exactly = 0) { logger.v(TAG, MESSAGE) }
}
@Test
@@ -42,7 +42,7 @@ class LoggerTest {
fun debugLogLevelIgnore() {
Logger.setVerbosity(Logger.WARN)
Logger.d(TAG, MESSAGE)
- verify(exactly = 0){ logger.d(TAG, MESSAGE) }
+ verify(exactly = 0) { logger.d(TAG, MESSAGE) }
}
@Test
@@ -56,7 +56,7 @@ class LoggerTest {
fun warnLogLevelIgnore() {
Logger.setVerbosity(Logger.ERROR)
Logger.w(TAG, MESSAGE)
- verify(exactly = 0){ logger.w(TAG, MESSAGE) }
+ verify(exactly = 0) { logger.w(TAG, MESSAGE) }
}
@Test
@@ -70,7 +70,7 @@ class LoggerTest {
fun errorLogLevelIgnore() {
Logger.setVerbosity(Logger.NONE)
Logger.e(TAG, MESSAGE)
- verify(exactly = 0){ logger.e(TAG, MESSAGE) }
+ verify(exactly = 0) { logger.e(TAG, MESSAGE) }
}
@Test
@@ -80,10 +80,10 @@ class LoggerTest {
Logger.d(TAG, MESSAGE)
Logger.w(TAG, MESSAGE)
Logger.e(TAG, MESSAGE)
- verify(exactly = 0){ logger.v(TAG, MESSAGE) }
- verify(exactly = 0){ logger.d(TAG, MESSAGE) }
- verify(exactly = 0){ logger.w(TAG, MESSAGE) }
- verify(exactly = 0){ logger.e(TAG, MESSAGE) }
+ verify(exactly = 0) { logger.v(TAG, MESSAGE) }
+ verify(exactly = 0) { logger.d(TAG, MESSAGE) }
+ verify(exactly = 0) { logger.w(TAG, MESSAGE) }
+ verify(exactly = 0) { logger.e(TAG, MESSAGE) }
}
companion object {
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleTest.kt
index ef30d46a7f..7b5ed67184 100644
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleTest.kt
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleTest.kt
@@ -287,7 +287,7 @@ class StyleTest {
@Test
fun testAddImage() {
- val bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)
+ val bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)
val builder = Style.Builder().fromUrl(Style.SATELLITE).withImage("id", bitmap)
mapboxMap.setStyle(builder)
verify(exactly = 1) { nativeMapView.styleUri = Style.SATELLITE }
@@ -408,4 +408,4 @@ class StyleTest {
Assert.assertEquals("Layer that failed to be added shouldn't be cached", layer1, mapboxMap.style!!.getLayer("layer1"))
}
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKLint/src/main/java/com/mapbox/mapboxsdk/lint/KeepDetector.kt b/platform/android/MapboxGLAndroidSDKLint/src/main/java/com/mapbox/mapboxsdk/lint/KeepDetector.kt
index 64838f91db..21093fc15b 100644
--- a/platform/android/MapboxGLAndroidSDKLint/src/main/java/com/mapbox/mapboxsdk/lint/KeepDetector.kt
+++ b/platform/android/MapboxGLAndroidSDKLint/src/main/java/com/mapbox/mapboxsdk/lint/KeepDetector.kt
@@ -45,9 +45,9 @@ class KeepDetector : Detector(), SourceCodeScanner, FileScanner {
context.report(ISSUE_NOT_KEPT, node,
context.getNameLocation(node),
"This method contains native references and will be minified.")
- } else if (node.isConstructor
- && node.parameterList.parameters.find { it.type == PsiType.LONG && it.name!!.contains("native") } != null
- && checkKeepAnnotation(node)) {
+ } else if (node.isConstructor &&
+ node.parameterList.parameters.find { it.type == PsiType.LONG && it.name!!.contains("native") } != null &&
+ checkKeepAnnotation(node)) {
context.report(ISSUE_NOT_KEPT, node,
context.getNameLocation(node as UElement),
"This constructor might contain native references and will be minified. " +
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/AppCenter.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/AppCenter.kt
index fb946a9c31..16eb3d1f1a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/AppCenter.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/AppCenter.kt
@@ -8,7 +8,6 @@ abstract class AppCenter {
@get:Rule
var reportHelper = Factory.getReportHelper()!!
-
@After
open fun afterTest() {
reportHelper.label(javaClass.simpleName)
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/InstrumentationRunner.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/InstrumentationRunner.kt
index 6873b33262..5c275df078 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/InstrumentationRunner.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/InstrumentationRunner.kt
@@ -8,4 +8,4 @@ class InstrumentationRunner : AndroidJUnitRunner() {
override fun newApplication(cl: ClassLoader?, className: String?, context: Context?): Application {
return super.newApplication(cl, InstrumentationApplication::class.java.name, context)
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactoryTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactoryTest.kt
index 446b731a61..50b9626edc 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactoryTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactoryTest.kt
@@ -140,5 +140,4 @@ class CameraUpdateFactoryTest : BaseTest() {
assertEquals("tilt should match:", 40.0, cameraPosition.tilt, 0.1)
}
}
-
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/BaseIntegrationTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/BaseIntegrationTest.kt
index 554ab644b6..2afff34d34 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/BaseIntegrationTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/BaseIntegrationTest.kt
@@ -10,7 +10,7 @@ import org.junit.Before
const val TIMEOUT_UI_SEARCH_WAIT = 5000L
-abstract class BaseIntegrationTest : AppCenter(){
+abstract class BaseIntegrationTest : AppCenter() {
protected lateinit var device: UiDevice
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/FragmentBackStackTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/FragmentBackStackTest.kt
index b0f6436bdd..5673ffd4c1 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/FragmentBackStackTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/FragmentBackStackTest.kt
@@ -3,15 +3,8 @@ package com.mapbox.mapboxsdk.integration
import android.support.test.filters.LargeTest
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
-import android.support.test.uiautomator.By
-import android.support.test.uiautomator.SearchCondition
import android.support.test.uiautomator.UiSelector
-import android.support.test.uiautomator.Until
-import com.mapbox.mapboxsdk.testapp.R
import com.mapbox.mapboxsdk.testapp.activity.fragment.FragmentBackStackActivity
-import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity
-import kotlinx.android.synthetic.main.activity_backstack_fragment.view.*
-import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReopenTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReopenTest.kt
index f22b5f7c9d..40bc182bd7 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReopenTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReopenTest.kt
@@ -8,7 +8,6 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
-
/**
* Regression test that validates reopening an Activity with a GLSurfaceView
*/
@@ -27,4 +26,4 @@ class GLSurfaceViewReopenTest : BaseIntegrationTest() {
device.launchActivity(activityRule.activity, SimpleMapActivity::class.java)
device.waitForIdle()
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReuseTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReuseTest.kt
index 945fac677e..5bf45518ec 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReuseTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReuseTest.kt
@@ -4,8 +4,6 @@ import android.support.test.filters.LargeTest
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import com.mapbox.mapboxsdk.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
-import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity
-import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/OrientationChangeTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/OrientationChangeTest.kt
index 941b7ea8dc..8d5b5eb8aa 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/OrientationChangeTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/OrientationChangeTest.kt
@@ -3,9 +3,7 @@ package com.mapbox.mapboxsdk.integration
import android.support.test.filters.LargeTest
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
-import com.mapbox.mapboxsdk.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity
-import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/QueryRenderedFeaturesBoxCountTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/QueryRenderedFeaturesBoxCountTest.kt
index 076bcba7e6..e94d568e86 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/QueryRenderedFeaturesBoxCountTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/QueryRenderedFeaturesBoxCountTest.kt
@@ -27,4 +27,4 @@ class QueryRenderedFeaturesBoxCountTest : BaseIntegrationTest() {
device.launchActivity(activityRule.activity, QueryRenderedFeaturesBoxCountActivity::class.java)
device.waitForIdle()
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReopenTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReopenTest.kt
index 44da557904..cbfd5d6d55 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReopenTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReopenTest.kt
@@ -3,14 +3,10 @@ package com.mapbox.mapboxsdk.integration
import android.support.test.filters.LargeTest
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
-import com.mapbox.mapboxsdk.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
-import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity
import com.mapbox.mapboxsdk.testapp.activity.textureview.TextureViewDebugModeActivity
-import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
-import java.lang.Thread.sleep
/**
* Regression test that validates reopening an Activity with a TextureView
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReuseTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReuseTest.kt
index 5c3d66c462..dc2f74df4a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReuseTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReuseTest.kt
@@ -3,9 +3,7 @@ package com.mapbox.mapboxsdk.integration
import android.support.test.filters.LargeTest
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
-import com.mapbox.mapboxsdk.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
import com.mapbox.mapboxsdk.testapp.activity.maplayout.TextureRecyclerViewActivity
-import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/ViewPagerScrollTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/ViewPagerScrollTest.kt
index b918801296..5178ea9fc0 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/ViewPagerScrollTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/ViewPagerScrollTest.kt
@@ -5,8 +5,6 @@ import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import android.support.test.uiautomator.UiSelector
import com.mapbox.mapboxsdk.testapp.activity.fragment.ViewPagerActivity
-import com.mapbox.mapboxsdk.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
-import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt
index f9827c767e..fb113502ee 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt
@@ -54,7 +54,6 @@ class LocationComponentTest : EspressoTest() {
private lateinit var locationComponentActivationOptions: LocationComponentActivationOptions
-
override fun validateTestSetup() {
super.validateTestSetup()
assertThat(mapboxMap.style, notNullValue())
@@ -71,8 +70,13 @@ class LocationComponentTest : EspressoTest() {
fun locationComponent_initializesLocationEngineCorrectlyWhenOnesNotProvided() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
@@ -93,9 +97,13 @@ class LocationComponentTest : EspressoTest() {
fun locationComponent_initializesLocationEngineCorrectlyWhenOnesNotProvidedButHasOptions() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, style)
.locationComponentOptions(
@@ -131,9 +139,13 @@ class LocationComponentTest : EspressoTest() {
fun locationComponent_doesntInitializeEngineWhenNullProvided() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, style)
.locationEngine(null)
@@ -170,8 +182,13 @@ class LocationComponentTest : EspressoTest() {
fun settingMapStyleImmediatelyBeforeLoadingComponent_throwsInvalidStyle() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
component.activateLocationComponent(LocationComponentActivationOptions
@@ -188,9 +205,13 @@ class LocationComponentTest : EspressoTest() {
fun locationComponent_doesntShowUntilFirstLocationFix() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -222,10 +243,13 @@ class LocationComponentTest : EspressoTest() {
fun locationComponentOptions_disablingStaleStateDoesWorkCorrectly() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -258,9 +282,13 @@ class LocationComponentTest : EspressoTest() {
fun locationComponentOptions_loadsForegroundBitmapFromNameOption() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -306,9 +334,13 @@ class LocationComponentTest : EspressoTest() {
fun locationComponentOptions_loadsGpsNameWithGpsRenderMode() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -343,9 +375,13 @@ class LocationComponentTest : EspressoTest() {
fun locationComponentOptions_customIconNameRevertsToDefault() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -379,9 +415,13 @@ class LocationComponentTest : EspressoTest() {
fun locationComponentOptions_customGpsIconNameChangeBackWithMode() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -414,9 +454,13 @@ class LocationComponentTest : EspressoTest() {
fun stillStaleAfterResuming() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -451,9 +495,13 @@ class LocationComponentTest : EspressoTest() {
fun stillNotStaleAfterResuming() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -483,9 +531,13 @@ class LocationComponentTest : EspressoTest() {
val rgbaColor = ColorUtils.colorToRgbaString(color)
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -516,9 +568,13 @@ class LocationComponentTest : EspressoTest() {
fun forceLocationUpdate_doesMoveLocationLayerIconToCorrectPosition() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -541,9 +597,13 @@ class LocationComponentTest : EspressoTest() {
fun disablingComponentHidesPuck() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -568,9 +628,13 @@ class LocationComponentTest : EspressoTest() {
fun disablingComponentAndChangingStyleAllowsToEnableAgain() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -592,9 +656,13 @@ class LocationComponentTest : EspressoTest() {
fun lifecycle_isDisabledOnStart() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.onStop()
component.onStart()
@@ -619,9 +687,13 @@ class LocationComponentTest : EspressoTest() {
fun lifecycle_keepsEnabledWhenStoppedAndStarted() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -641,8 +713,13 @@ class LocationComponentTest : EspressoTest() {
fun lifecycle_keepsDisabledWhenStoppedAndStarted() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(
LocationComponentActivationOptions
.builder(context, style)
@@ -663,8 +740,13 @@ class LocationComponentTest : EspressoTest() {
fun lifecycle_ableToChangeStyleAfterResuming() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -685,8 +767,13 @@ class LocationComponentTest : EspressoTest() {
fun lifecycle_interruptedDuringStyleChange() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -705,8 +792,13 @@ class LocationComponentTest : EspressoTest() {
fun lifecycle_forceLocationUpdateAfterStopped() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -726,8 +818,13 @@ class LocationComponentTest : EspressoTest() {
fun lifecycle_acceptAndReuseLocationUpdatesBeforeLayerStarted() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -750,8 +847,13 @@ class LocationComponentTest : EspressoTest() {
fun lifecycle_lifecycleChangeRightAfterStyleReload() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -781,8 +883,13 @@ class LocationComponentTest : EspressoTest() {
fun mapChange_settingComponentStyle() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -810,8 +917,13 @@ class LocationComponentTest : EspressoTest() {
fun mapChange_forcingLocation() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -836,8 +948,13 @@ class LocationComponentTest : EspressoTest() {
fun mapChange_settingMapStyleBeforeComponentCreation() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
TestingAsyncUtils.waitForLayer(uiController, mapView)
@@ -868,8 +985,13 @@ class LocationComponentTest : EspressoTest() {
fun animators_layerBearingCorrect() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -896,8 +1018,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_cameraLatLngBearingCorrect() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -932,8 +1059,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_cameraBearingCorrect() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -971,8 +1103,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_cameraNoneCorrect() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1011,8 +1148,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_focalPointAdjustment() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1033,8 +1175,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_dontZoomWhileNotTracking() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1056,8 +1203,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_zoomWhileTracking() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1079,8 +1231,13 @@ class LocationComponentTest : EspressoTest() {
@Ignore
fun animators_zoomWhileTrackingCanceledOnModeChange() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1103,8 +1260,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_dontZoomWhileStopped() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1130,8 +1292,13 @@ class LocationComponentTest : EspressoTest() {
@Ignore
fun animators_cancelZoomWhileTracking() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1154,8 +1321,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_dontTiltWhileNotTracking() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1177,8 +1349,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_tiltWhileTracking() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1200,8 +1377,13 @@ class LocationComponentTest : EspressoTest() {
@Ignore
fun animators_tiltWhileTrackingCanceledOnModeChange() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1224,8 +1406,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_dontTiltWhileStopped() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1250,8 +1437,13 @@ class LocationComponentTest : EspressoTest() {
@Ignore
fun animators_cancelTiltWhileTracking() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1273,8 +1465,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun cameraPositionAdjustedToTrackingModeWhenComponentEnabled() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1301,8 +1498,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun cameraPositionSnappedToTargetIfExceedsThreshold() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1330,8 +1532,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun compassEngine_onComponentInitializedDefaultIsProvided() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1347,8 +1554,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun compassEngine_changesWhenNewProvided() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt
index 95a3891b6d..110d879bf3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt
@@ -35,6 +35,7 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
+import kotlin.math.abs
@RunWith(AndroidJUnit4::class)
class LocationLayerControllerTest : EspressoTest() {
@@ -67,8 +68,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun renderModeNormal_sourceDoesGetAdded() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -90,8 +96,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun renderModeNormal_trackingNormalLayersDoGetAdded() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -114,8 +125,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun renderModeCompass_bearingLayersDoGetAdded() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -138,8 +154,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun renderModeGps_navigationLayersDoGetAdded() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -162,8 +183,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun dontShowPuckWhenRenderModeSetAndComponentDisabled() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -187,8 +213,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun whenLocationComponentDisabled_doesSetAllLayersToVisibilityNone() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -213,8 +244,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun onMapChange_locationComponentLayersDoGetRedrawn() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -245,8 +281,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun whenStyleChanged_continuesUsingStaleIcons() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -271,8 +312,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun whenStyleChanged_isDisabled_hasLayerBelow_staysHidden() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -300,8 +346,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun whenStyleChanged_staleStateChanges() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -323,8 +374,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun whenStyleChanged_layerVisibilityUpdates() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
uiController.loopMainThreadForAtLeast(100)
var show = true
@@ -349,8 +405,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun accuracy_visibleWithNewLocation() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -372,8 +433,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun accuracy_visibleWhenCameraEased() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -387,10 +453,9 @@ class LocationLayerControllerTest : EspressoTest() {
uiController.loopMainThreadForAtLeast(300)
TestingAsyncUtils.waitForLayer(uiController, mapView)
-
- assertThat(Math.abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1
- && Math.abs(target.latitude - mapboxMap.cameraPosition.target.latitude) < 0.1
- && Math.abs(target.longitude - mapboxMap.cameraPosition.target.longitude) < 0.1,
+ assertThat(Math.abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1 &&
+ Math.abs(target.latitude - mapboxMap.cameraPosition.target.latitude) < 0.1 &&
+ Math.abs(target.longitude - mapboxMap.cameraPosition.target.longitude) < 0.1,
`is`(true))
val expectedRadius = Utils.calculateZoomLevelRadius(mapboxMap, location) /*meters projected to radius on zoom 16*/
@@ -405,8 +470,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun accuracy_visibleWhenCameraMoved() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -419,9 +489,10 @@ class LocationLayerControllerTest : EspressoTest() {
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(target, zoom))
TestingAsyncUtils.waitForLayer(uiController, mapView)
- assertThat(Math.abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1
- && Math.abs(target.latitude - mapboxMap.cameraPosition.target.latitude) < 0.1
- && Math.abs(target.longitude - mapboxMap.cameraPosition.target.longitude) < 0.1,
+ assertThat(
+ abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1 &&
+ abs(target.latitude - mapboxMap.cameraPosition.target.latitude) < 0.1 &&
+ abs(target.longitude - mapboxMap.cameraPosition.target.longitude) < 0.1,
`is`(true))
val expectedRadius = Utils.calculateZoomLevelRadius(mapboxMap, location) /*meters projected to radius on zoom 16*/
@@ -436,8 +507,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun applyStyle_layerBelow_restoreLayerVisibility() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -467,4 +543,4 @@ class LocationLayerControllerTest : EspressoTest() {
private fun executeComponentTest(listener: LocationComponentAction.OnPerformLocationComponentAction) {
onView(withId(R.id.content)).perform(LocationComponentAction(mapboxMap, listener))
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt
index 64123cc8c4..daf6b89f59 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt
@@ -10,8 +10,10 @@ import com.mapbox.mapboxsdk.location.LocationComponent
import com.mapbox.mapboxsdk.maps.Style
import org.hamcrest.Matcher
-class LocationComponentAction(private val mapboxMap: MapboxMap,
- private val onPerformLocationComponentAction: OnPerformLocationComponentAction) : ViewAction {
+class LocationComponentAction(
+ private val mapboxMap: MapboxMap,
+ private val onPerformLocationComponentAction: OnPerformLocationComponentAction
+) : ViewAction {
override fun getConstraints(): Matcher<View> {
return isDisplayed()
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxLocationTestingUtils.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxLocationTestingUtils.kt
index edbb1c6c65..18da6d1d10 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxLocationTestingUtils.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxLocationTestingUtils.kt
@@ -7,7 +7,6 @@ import android.graphics.drawable.Drawable
import android.location.Location
import android.os.Handler
import android.os.Looper
-import android.support.test.espresso.UiController
import com.mapbox.geojson.Feature
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.MapboxMap
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt
index 5aded25d1e..050535f6df 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt
@@ -3,7 +3,6 @@ package com.mapbox.mapboxsdk.location.utils
import android.support.test.espresso.IdlingResource
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style
-import java.util.logging.Handler
/**
* Resource, that's idling until the provided style is loaded.
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/BaseLayerTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/BaseLayerTest.kt
index 7019129e6e..27c040fbb6 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/BaseLayerTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/BaseLayerTest.kt
@@ -7,7 +7,7 @@ import com.mapbox.mapboxsdk.style.layers.Layer
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
-abstract class BaseLayerTest : AppCenter(){
+abstract class BaseLayerTest : AppCenter() {
private lateinit var nativeMapView: NativeMap
companion object {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/NativeMapViewTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/NativeMapViewTest.kt
index 409d956a13..d5834db553 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/NativeMapViewTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/NativeMapViewTest.kt
@@ -95,7 +95,6 @@ class NativeMapViewTest : AppCenter() {
assertEquals("Longitude should match", expected.longitude, actual.longitude, DELTA)
}
-
@Test
@UiThreadTest
fun testBearingDefault() {
@@ -160,7 +159,7 @@ class NativeMapViewTest : AppCenter() {
@UiThreadTest
fun testLatLngForPixel() {
val expected = LATLNG_TEST
- nativeMapView.setLatLng(LATLNG_TEST,0)
+ nativeMapView.setLatLng(LATLNG_TEST, 0)
val actual = nativeMapView.latLngForPixel(
PointF((WIDTH / 2).toFloat(), (HEIGHT / 2).toFloat())
)
@@ -367,11 +366,11 @@ class NativeMapViewTest : AppCenter() {
class DummyRenderer(context: Context) : MapRenderer(context, null) {
override fun requestRender() {
- //no-op
+ // no-op
}
override fun queueEvent(runnable: Runnable?) {
- //no-op
+ // no-op
}
}
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TransformTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TransformTest.kt
index 85a4bd65a8..6b59411ae8 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TransformTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TransformTest.kt
@@ -8,10 +8,10 @@ import com.mapbox.mapboxsdk.testapp.activity.EspressoTest
import org.junit.Assert.assertEquals
import org.junit.Test
-class TransformTest: EspressoTest() {
+class TransformTest : EspressoTest() {
companion object {
- val initialCameraUpdate = CameraUpdateFactory.newLatLngZoom(LatLng(12.0,12.0), 12.0)!!
+ val initialCameraUpdate = CameraUpdateFactory.newLatLngZoom(LatLng(12.0, 12.0), 12.0)!!
}
@Test
@@ -23,7 +23,7 @@ class TransformTest: EspressoTest() {
val expectedCameraPosition = mapboxMap.cameraPosition
mapboxMap.moveCamera(initialCameraUpdate)
- mapboxMap.setPadding(250,250,0,0)
+ mapboxMap.setPadding(250, 250, 0, 0)
mapboxMap.scrollBy(400.0f, 0.0f)
val actualCameraPosition = mapboxMap.cameraPosition
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/VisibleRegionTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/VisibleRegionTest.kt
index 24c7bc0226..684b13af5d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/VisibleRegionTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/VisibleRegionTest.kt
@@ -384,9 +384,8 @@ class VisibleRegionTest : BaseTest() {
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
)
-
for (bearing in 45 until 360 step 45) {
- mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()));
+ mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()))
val visibleRegion = mapboxMap.projection.visibleRegion
assertTrue(latLngs.all { visibleRegion.latLngBounds.contains(it) })
}
@@ -398,7 +397,7 @@ class VisibleRegionTest : BaseTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
- val d = Math.min(mapboxMap.width, mapboxMap.height) / 4;
+ val d = Math.min(mapboxMap.width, mapboxMap.height) / 4
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f - d / 2f, mapView.height / 2f),
@@ -408,9 +407,8 @@ class VisibleRegionTest : BaseTest() {
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
)
-
for (bearing in 45 until 360 step 45) {
- mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()));
+ mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()))
val visibleRegion = mapboxMap.projection.visibleRegion
assertTrue(latLngs.all { visibleRegion.latLngBounds.contains(it) })
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/offline/OfflineDownloadTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/offline/OfflineDownloadTest.kt
new file mode 100644
index 0000000000..5c574f9332
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/offline/OfflineDownloadTest.kt
@@ -0,0 +1,88 @@
+package com.mapbox.mapboxsdk.offline
+
+import android.support.test.rule.ActivityTestRule
+import android.support.test.runner.AndroidJUnit4
+import com.mapbox.geojson.Point
+import com.mapbox.mapboxsdk.log.Logger
+import com.mapbox.mapboxsdk.maps.Style
+import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.TimeUnit
+import java.util.concurrent.TimeoutException
+
+/**
+ * Integration test that validates downloading an offline region from a point geometry at zoomlevel 17
+ */
+@RunWith(AndroidJUnit4::class)
+class OfflineDownloadTest : OfflineRegion.OfflineRegionObserver {
+
+ @Rule
+ @JvmField
+ var rule = ActivityTestRule(FeatureOverviewActivity::class.java)
+
+ private val countDownLatch = CountDownLatch(1)
+ private lateinit var offlineRegion: OfflineRegion
+
+ @Test(timeout = 30000)
+ fun offlineDownload() {
+ rule.runOnUiThreadActivity {
+ OfflineManager.getInstance(rule.activity).createOfflineRegion(
+ createTestRegionDefinition(),
+ ByteArray(0),
+ object : OfflineManager.CreateOfflineRegionCallback {
+ override fun onCreate(region: OfflineRegion?) {
+ region?.let {
+ offlineRegion = it
+ offlineRegion.setDownloadState(OfflineRegion.STATE_ACTIVE)
+ offlineRegion.setObserver(this@OfflineDownloadTest)
+ }
+ }
+
+ override fun onError(error: String?) {
+ Logger.e(TAG, "Error while creating offline region: $error")
+ }
+ })
+ }
+
+ if (!countDownLatch.await(30, TimeUnit.SECONDS)) {
+ throw TimeoutException()
+ }
+ }
+
+ override fun onStatusChanged(status: OfflineRegionStatus?) {
+ status?.let {
+ if (it.isComplete) {
+ offlineRegion.setDownloadState(OfflineRegion.STATE_INACTIVE)
+ countDownLatch.countDown()
+ }
+ }
+ }
+
+ override fun onError(error: OfflineRegionError?) {
+ Logger.e(TAG, "Error while downloading offline region: $error")
+ }
+
+ override fun mapboxTileCountLimitExceeded(limit: Long) {
+ Logger.e(TAG, "Tile count limited exceeded: $limit")
+ }
+
+ fun createTestRegionDefinition(): OfflineRegionDefinition {
+ return OfflineGeometryRegionDefinition(
+ Style.MAPBOX_STREETS,
+ Point.fromLngLat(50.847857, 4.360137),
+ 17.0,
+ 17.0,
+ 1.0f,
+ false
+ )
+ }
+
+ companion object {
+ const val TAG = "OfflineDownloadTest"
+ }
+}
+
+fun ActivityTestRule<*>.runOnUiThreadActivity(runnable: () -> Unit) = activity.runOnUiThread(runnable) \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotterTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotterTest.kt
new file mode 100644
index 0000000000..e295b5b10b
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotterTest.kt
@@ -0,0 +1,26 @@
+package com.mapbox.mapboxsdk.snapshotter
+
+import android.support.test.rule.ActivityTestRule
+import android.support.test.runner.AndroidJUnit4
+import com.mapbox.mapboxsdk.testapp.activity.snapshot.MapSnapshotterMarkerActivity
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+
+/**
+ * Integration test that validates if a snapshot is created with MapSnapshotterMarkerActivity
+ */
+@RunWith(AndroidJUnit4::class)
+class MapSnapshotterTest {
+
+ @Rule
+ @JvmField
+ var rule = ActivityTestRule(MapSnapshotterMarkerActivity::class.java)
+
+ @Test(timeout = 10000)
+ fun mapSnapshotter() {
+ while (rule.activity.mapSnapshot == null) {
+ Thread.sleep(250)
+ }
+ }
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseTest.java
index 054069f92c..45dac23611 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseTest.java
@@ -1,5 +1,6 @@
package com.mapbox.mapboxsdk.testapp.activity;
+import android.content.Context;
import android.support.annotation.CallSuper;
import android.support.annotation.UiThread;
import android.support.test.rule.ActivityTestRule;
@@ -95,4 +96,8 @@ public abstract class BaseTest extends AppCenter {
}
}
+ protected Context getContext() {
+ return rule.getActivity();
+ }
+
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/fragment/MapDialogFragmentTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/fragment/MapDialogFragmentTest.kt
index 2abee8095c..f695f3efe2 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/fragment/MapDialogFragmentTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/fragment/MapDialogFragmentTest.kt
@@ -9,7 +9,6 @@ import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.testapp.R
-import com.mapbox.mapboxsdk.testapp.action.WaitAction
import com.mapbox.mapboxsdk.testapp.activity.maplayout.MapInDialogActivity
import org.junit.Ignore
import org.junit.Rule
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/ImageMissingTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/ImageMissingTest.kt
index 539cc85035..b569f7ca3d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/ImageMissingTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/ImageMissingTest.kt
@@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
@RunWith(AndroidJUnit4::class)
-class ImageMissingTest : AppCenter(){
+class ImageMissingTest : AppCenter() {
@Rule
@JvmField
@@ -152,4 +152,4 @@ class ImageMissingTest : AppCenter(){
}
"""
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/RemoveUnusedImagesTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/RemoveUnusedImagesTest.kt
index 492a75b7cf..41b100b4d2 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/RemoveUnusedImagesTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/RemoveUnusedImagesTest.kt
@@ -36,7 +36,7 @@ class RemoveUnusedImagesTest : AppCenter() {
rule.runOnUiThread {
mapView = rule.activity.findViewById(R.id.mapView)
mapView.getMapAsync {
- mapboxMap = it;
+ mapboxMap = it
mapboxMap.setStyle(Style.Builder().fromJson(styleJson))
}
}
@@ -47,7 +47,7 @@ class RemoveUnusedImagesTest : AppCenter() {
var callbackLatch = CountDownLatch(2)
rule.runOnUiThread {
mapView.addOnStyleImageMissingListener {
- mapboxMap.style!!.addImage(it, Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888))
+ mapboxMap.style!!.addImage(it, Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888))
}
// Remove layer and source, so that rendered tiles are no longer used, therefore, map must
@@ -69,7 +69,7 @@ class RemoveUnusedImagesTest : AppCenter() {
}
}
- if(!latch.await(5, TimeUnit.SECONDS) && !callbackLatch.await(5, TimeUnit.SECONDS)){
+ if (!latch.await(5, TimeUnit.SECONDS) && !callbackLatch.await(5, TimeUnit.SECONDS)) {
throw TimeoutException()
}
}
@@ -78,7 +78,7 @@ class RemoveUnusedImagesTest : AppCenter() {
fun testRemoveUnusedImagesDefaultListener() {
rule.runOnUiThread {
mapView.addOnStyleImageMissingListener {
- mapboxMap.style!!.addImage(it, Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888))
+ mapboxMap.style!!.addImage(it, Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888))
}
// Remove layer and source, so that rendered tiles are no longer used, thus
@@ -97,7 +97,7 @@ class RemoveUnusedImagesTest : AppCenter() {
}
}
- if(!latch.await(5, TimeUnit.SECONDS)){
+ if (!latch.await(5, TimeUnit.SECONDS)) {
throw TimeoutException()
}
}
@@ -160,4 +160,4 @@ class RemoveUnusedImagesTest : AppCenter() {
}
"""
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt
index ac73b028f3..951750f354 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt
@@ -2,16 +2,13 @@ package com.mapbox.mapboxsdk.testapp.maps
import android.support.test.espresso.UiController
import android.support.test.runner.AndroidJUnit4
-import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.style.layers.SymbolLayer
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest
-import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity
import com.mapbox.mapboxsdk.testapp.utils.TestingAsyncUtils
-import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/CacheTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/CacheTest.kt
index 299e193c96..e28aec558c 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/CacheTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/CacheTest.kt
@@ -85,5 +85,4 @@ class CacheTest {
}
countDownLatch.await()
}
-
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceMapTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceMapTest.kt
index 7a5801a814..b67e6eded5 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceMapTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceMapTest.kt
@@ -43,8 +43,8 @@ open class FileSourceMapTest : AppCenter() {
}
override fun onError(message: String) {
- Assert.assertEquals("Cannot set path, file source is activated."
- + " Make sure that the map or a resources download is not running.", message)
+ Assert.assertEquals("Cannot set path, file source is activated." +
+ " Make sure that the map or a resources download is not running.", message)
latch.countDown()
}
})
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.kt
index 6f318f77eb..23707f52a5 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.kt
@@ -32,11 +32,11 @@ class LatLngBoundsActivity : AppCompatActivity() {
private lateinit var bounds: LatLngBounds
private val peekHeight by lazy {
- 375.toPx(this) //375dp
+ 375.toPx(this) // 375dp
}
private val additionalPadding by lazy {
- 32.toPx(this) //32dp
+ 32.toPx(this) // 32dp
}
override fun onCreate(savedInstanceState: Bundle?) {
@@ -160,8 +160,6 @@ class LatLngBoundsActivity : AppCompatActivity() {
super.onSaveInstanceState(outState)
mapView.onSaveInstanceState(outState)
}
-
}
-fun Int.toPx(context: Context): Int = (this * context.resources.displayMetrics.density).toInt()
-
+fun Int.toPx(context: Context): Int = (this * context.resources.displayMetrics.density).toInt() \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/PixelTestActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/PixelTestActivity.kt
index b69d1ee5ed..7de4da1985 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/PixelTestActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/PixelTestActivity.kt
@@ -63,4 +63,4 @@ class PixelTestActivity : AppCompatActivity(), OnMapReadyCallback {
super.onLowMemory()
mapView.onLowMemory()
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/NestedViewPagerActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/NestedViewPagerActivity.kt
index 37909662ab..de7f0bb5ac 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/NestedViewPagerActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/NestedViewPagerActivity.kt
@@ -17,7 +17,6 @@ import android.widget.TextView
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.MapboxMapOptions
-import com.mapbox.mapboxsdk.maps.OnMapReadyCallback
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.maps.SupportMapFragment
import com.mapbox.mapboxsdk.testapp.R
@@ -106,7 +105,7 @@ class NestedViewPagerActivity : AppCompatActivity() {
class MapPagerAdapter(private val context: Context, fm: FragmentManager?) : FragmentStatePagerAdapter(fm) {
override fun getItem(position: Int): Fragment {
- val options = MapboxMapOptions.createFromAttributes(context, null)
+ val options = MapboxMapOptions.createFromAttributes(context)
options.textureMode(true)
options.doubleTapGesturesEnabled(false)
options.rotateGesturesEnabled(false)
@@ -127,7 +126,8 @@ class NestedViewPagerActivity : AppCompatActivity() {
options.camera(CameraPosition.Builder().target(LatLng(62.326440, 92.764913)).zoom(3.0).build())
val fragment = SupportMapFragment.newInstance(options)
fragment.getMapAsync { mapboxMap -> mapboxMap.setStyle(Style.DARK) }
- return fragment }
+ return fragment
+ }
3 -> {
return EmptyFragment.newInstance()
}
@@ -135,7 +135,8 @@ class NestedViewPagerActivity : AppCompatActivity() {
options.camera(CameraPosition.Builder().target(LatLng(-25.007786, 133.623852)).zoom(3.0).build())
val fragment = SupportMapFragment.newInstance(options)
fragment.getMapAsync { mapboxMap -> mapboxMap.setStyle(Style.SATELLITE) }
- return fragment }
+ return fragment
+ }
5 -> {
return EmptyFragment.newInstance()
}
@@ -162,4 +163,4 @@ class NestedViewPagerActivity : AppCompatActivity() {
}
}
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.kt
index b6fba01d81..d1cb9acab6 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.kt
@@ -45,7 +45,7 @@ class ViewPagerActivity : AppCompatActivity() {
}
override fun getItem(position: Int): Fragment? {
- val options = MapboxMapOptions.createFromAttributes(context, null)
+ val options = MapboxMapOptions.createFromAttributes(context)
options.textureMode(true)
options.camera(
CameraPosition.Builder()
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.kt
index d01c8eb508..7c111865d1 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.kt
@@ -83,7 +83,7 @@ class SnapshotActivity : AppCompatActivity(), OnMapReadyCallback {
}
companion object {
- const val TAG ="Mbgl-SnapshotActivity"
+ const val TAG = "Mbgl-SnapshotActivity"
const val LOG_MESSAGE = "OnSnapshot"
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationFragmentActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationFragmentActivity.kt
index 6a01d14249..9411c1c6a7 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationFragmentActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationFragmentActivity.kt
@@ -119,7 +119,7 @@ class LocationFragmentActivity : AppCompatActivity() {
}
override fun onFailure(exception: Exception) {
- //noop
+ // noop
}
override fun onStart() {
@@ -172,4 +172,4 @@ class LocationFragmentActivity : AppCompatActivity() {
return textView
}
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java
index 4af6777995..9db7cb2c9d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java
@@ -133,7 +133,7 @@ public class BottomSheetActivity extends AppCompatActivity {
Bundle bundle = new Bundle();
bundle.putInt("mapcounter", mapCounter);
mapFragment.setArguments(bundle);
- MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(context, null);
+ MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(context);
mapFragment.setArguments(MapFragmentUtils.createFragmentArgs(mapboxMapOptions));
return mapFragment;
}
@@ -211,7 +211,7 @@ public class BottomSheetActivity extends AppCompatActivity {
public static BottomSheetFragment newInstance(Context context) {
BottomSheetFragment mapFragment = new BottomSheetFragment();
- MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(context, null);
+ MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(context);
mapboxMapOptions.renderSurfaceOnTop(true);
mapFragment.setArguments(MapFragmentUtils.createFragmentArgs(mapboxMapOptions));
return mapFragment;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/GLSurfaceRecyclerViewActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/GLSurfaceRecyclerViewActivity.kt
index 3acb7aa382..eae8c71f7e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/GLSurfaceRecyclerViewActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/GLSurfaceRecyclerViewActivity.kt
@@ -151,4 +151,4 @@ open class GLSurfaceRecyclerViewActivity : AppCompatActivity() {
}
}
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/OverlayMapActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/OverlayMapActivity.kt
index d0f3f2e964..3666459951 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/OverlayMapActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/OverlayMapActivity.kt
@@ -65,7 +65,7 @@ class OverlayMapActivity : AppCompatActivity() {
class OverlayView(context: Context) : View(context) {
private lateinit var paint: Paint
-
+
@SuppressLint("DrawAllocation") // only happens once
override fun onDraw(canvas: Canvas?) {
super.onDraw(canvas)
@@ -83,4 +83,4 @@ class OverlayMapActivity : AppCompatActivity() {
}
}
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/TextureRecyclerViewActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/TextureRecyclerViewActivity.kt
index 940d4b4f19..2f3017435b 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/TextureRecyclerViewActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/TextureRecyclerViewActivity.kt
@@ -12,4 +12,4 @@ class TextureRecyclerViewActivity : GLSurfaceRecyclerViewActivity() {
override fun getMapItemLayoutId(): Int {
return R.layout.item_map_texture
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/ChangeResourcesCachePathActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/ChangeResourcesCachePathActivity.kt
index 74b5bde17d..4e1963d7fc 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/ChangeResourcesCachePathActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/ChangeResourcesCachePathActivity.kt
@@ -74,7 +74,7 @@ class ChangeResourcesCachePathActivity : AppCompatActivity(),
offlineManager.listOfflineRegions(object : OfflineManager.ListOfflineRegionsCallback {
override fun onList(offlineRegions: Array<out OfflineRegion>?) {
- Logger.i(TAG, "Number of saved offline regions in the new path: ${offlineRegions?.size.toString()}")
+ Logger.i(TAG, "Number of saved offline regions in the new path: ${offlineRegions?.size}")
}
override fun onError(error: String?) {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/DownloadRegionActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/DownloadRegionActivity.kt
index 41dbe56112..36a8ccf0f1 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/DownloadRegionActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/DownloadRegionActivity.kt
@@ -145,7 +145,8 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
}
if (status.completedResourceCount > status.requiredResourceCount &&
- previousCompletedResourceCount <= status.requiredResourceCount) {
+ previousCompletedResourceCount <= status.requiredResourceCount
+ ) {
logMessage("FAILURE! Completed > required")
}
}
@@ -279,11 +280,9 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
}
override fun onStartTrackingTouch(seekBar: SeekBar) {
-
}
override fun onStopTrackingTouch(seekBar: SeekBar) {
-
}
})
@@ -293,17 +292,19 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
}
override fun onStartTrackingTouch(seekBar: SeekBar) {
-
}
override fun onStopTrackingTouch(seekBar: SeekBar) {
-
}
})
}
- private fun validCoordinates(latitudeNorth: Double, longitudeEast: Double, latitudeSouth: Double,
- longitudeWest: Double): Boolean {
+ private fun validCoordinates(
+ latitudeNorth: Double,
+ longitudeEast: Double,
+ latitudeSouth: Double,
+ longitudeWest: Double
+ ): Boolean {
if (latitudeNorth < -90 || latitudeNorth > 90) {
return false
} else if (longitudeEast < -180 || longitudeEast > 180) {
@@ -315,4 +316,4 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
}
return true
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/MergeOfflineRegionsActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/MergeOfflineRegionsActivity.kt
index 12169dbe8f..0f59191d06 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/MergeOfflineRegionsActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/MergeOfflineRegionsActivity.kt
@@ -144,4 +144,4 @@ class MergeOfflineRegionsActivity : AppCompatActivity() {
super.onSaveInstanceState(outState)
mapView.onSaveInstanceState(outState)
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterMarkerActivity.java
index d7ceda699e..dea10198b6 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterMarkerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterMarkerActivity.java
@@ -6,6 +6,8 @@ import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.PointF;
import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.annotation.VisibleForTesting;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.View;
@@ -64,6 +66,7 @@ public class MapSnapshotterMarkerActivity extends AppCompatActivity implements M
@SuppressLint("ClickableViewAccessibility")
@Override
public void onSnapshotReady(MapSnapshot snapshot) {
+ this.mapSnapshot = snapshot;
Timber.i("Snapshot ready");
ImageView imageView = (ImageView) findViewById(R.id.snapshot_image);
Bitmap image = addMarker(snapshot);
@@ -93,4 +96,10 @@ public class MapSnapshotterMarkerActivity extends AppCompatActivity implements M
return snapshot.getBitmap();
}
+ @VisibleForTesting
+ @Nullable
+ public MapSnapshot getMapSnapshot() {
+ return mapSnapshot;
+ }
+
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/storage/CacheManagementActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/storage/CacheManagementActivity.kt
index c9fdb79e6e..54427ad20d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/storage/CacheManagementActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/storage/CacheManagementActivity.kt
@@ -5,7 +5,6 @@ import android.os.Looper
import android.support.design.widget.Snackbar
import android.support.v7.app.AppCompatActivity
import com.mapbox.mapboxsdk.offline.OfflineManager
-import com.mapbox.mapboxsdk.storage.FileSource
import com.mapbox.mapboxsdk.testapp.R
import junit.framework.Assert.assertTrue
import kotlinx.android.synthetic.main.activity_cache_management.*
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DraggableMarkerActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DraggableMarkerActivity.kt
index 0b784675e9..6de00e24f9 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DraggableMarkerActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DraggableMarkerActivity.kt
@@ -171,11 +171,17 @@ class DraggableMarkerActivity : AppCompatActivity() {
* @param touchAreaMaxX maximum value of X-axis motion event
* @param touchAreaMaxY maximum value of Y-axis motion event
*/
- class DraggableSymbolsManager(mapView: MapView, private val mapboxMap: MapboxMap,
- private val symbolsCollection: FeatureCollection,
- private val symbolsSource: GeoJsonSource, private val symbolsLayerId: String,
- private val touchAreaShiftX: Int = 0, private val touchAreaShiftY: Int = 0,
- private val touchAreaMaxX: Int = mapView.width, private val touchAreaMaxY: Int = mapView.height) {
+ class DraggableSymbolsManager(
+ mapView: MapView,
+ private val mapboxMap: MapboxMap,
+ private val symbolsCollection: FeatureCollection,
+ private val symbolsSource: GeoJsonSource,
+ private val symbolsLayerId: String,
+ private val touchAreaShiftY: Int = 0,
+ private val touchAreaShiftX: Int = 0,
+ private val touchAreaMaxX: Int = mapView.width,
+ private val touchAreaMaxY: Int = mapView.height
+ ) {
private val androidGesturesManager: AndroidGesturesManager = AndroidGesturesManager(mapView.context, false)
private var draggedSymbolId: String? = null
@@ -322,4 +328,4 @@ class DraggableMarkerActivity : AppCompatActivity() {
private fun MapboxMap.queryRenderedSymbols(latLng: LatLng, layerId: String): List<Feature> {
return this.queryRenderedFeatures(this.projection.toScreenLocation(latLng), layerId)
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java
index 689ce1f0a7..3d65a92f72 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java
@@ -117,7 +117,7 @@ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap.
setContentView(R.layout.activity_symbollayer);
// Create map configuration
- MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(this, null);
+ MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(this);
mapboxMapOptions.camera(new CameraPosition.Builder().target(
new LatLng(52.35273, 4.91638))
.zoom(13)
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FileUtils.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FileUtils.kt
index 457ad928db..e0c1ca4207 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FileUtils.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FileUtils.kt
@@ -19,7 +19,6 @@ class FileUtils {
override fun doInBackground(vararg strings: String): Boolean? {
val assetName = strings[0]
val destinationPath = strings[1]
-
contextWeakReference.get()?.let {
try {
copyAsset(it, assetName, destinationPath)
diff --git a/platform/android/build.gradle b/platform/android/build.gradle
index 947e5adb1a..ed6c8d1208 100644
--- a/platform/android/build.gradle
+++ b/platform/android/build.gradle
@@ -26,6 +26,7 @@ allprojects {
// Snapshot repository
// maven { url 'https://oss.jfrog.org/artifactory/oss-snapshot-local/' }
}
+ apply from: "${rootDir}/gradle/ktlint.gradle"
}
subprojects {
@@ -34,5 +35,4 @@ subprojects {
// Load build system information. If this file does not exist, run
// `make platform/android/gradle/configuration.gradle`
-apply from: "${rootDir}/gradle/configuration.gradle"
-apply from: "${rootDir}/gradle/download-schema.gradle" \ No newline at end of file
+apply from: "${rootDir}/gradle/configuration.gradle" \ No newline at end of file
diff --git a/platform/android/gradle/dependencies.gradle b/platform/android/gradle/dependencies.gradle
index a7ff1dbfe6..de14666e71 100644
--- a/platform/android/gradle/dependencies.gradle
+++ b/platform/android/gradle/dependencies.gradle
@@ -33,7 +33,8 @@ ext {
gms : '16.0.0',
soLoader : '0.6.0',
jacoco : '0.8.3',
- appcenter : '1.4'
+ appcenter : '1.4',
+ ktlint : '0.33.0'
]
dependenciesList = [
@@ -82,6 +83,7 @@ ext {
lint : "com.android.tools.lint:lint:${versions.lint}",
lintApi : "com.android.tools.lint:lint-api:${versions.lint}",
lintChecks : "com.android.tools.lint:lint-checks:${versions.lint}",
- lintTests : "com.android.tools.lint:lint-tests:${versions.lint}"
+ lintTests : "com.android.tools.lint:lint-tests:${versions.lint}",
+ ktlint : "com.pinterest:ktlint:${versions.ktlint}"
]
}
diff --git a/platform/android/gradle/download-schema.gradle b/platform/android/gradle/download-schema.gradle
deleted file mode 100644
index 3d3beac651..0000000000
--- a/platform/android/gradle/download-schema.gradle
+++ /dev/null
@@ -1,8 +0,0 @@
-task downloadSchema(type: Copy) {
- def address='https://mapbox.s3.amazonaws.com/mapbox-gl-native/event-schema/mobile-event-schemas.jsonl.gz'
- def target='MapboxGLAndroidSDK/src/test/resources/'
-
- new File(target + "${address.tokenize('/')[-1]}").withOutputStream { out ->
- new URL(address).withInputStream { from -> out << from }
- }
-} \ No newline at end of file
diff --git a/platform/android/gradle/ktlint.gradle b/platform/android/gradle/ktlint.gradle
new file mode 100644
index 0000000000..31743ccd49
--- /dev/null
+++ b/platform/android/gradle/ktlint.gradle
@@ -0,0 +1,27 @@
+apply from: "${rootDir}/gradle/dependencies.gradle"
+
+repositories {
+ jcenter()
+}
+
+configurations {
+ ktlint
+}
+
+dependencies {
+ ktlint dependenciesList.ktlint
+}
+
+task ktlint(type: JavaExec, group: "verification") {
+ description = "Check Kotlin code style."
+ classpath = configurations.ktlint
+ main = "com.pinterest.ktlint.Main"
+ args "src/**/*.kt"
+}
+
+task ktlintFormat(type: JavaExec, group: "formatting") {
+ description = "Fix Kotlin code style deviations."
+ classpath = configurations.ktlint
+ main = "com.pinterest.ktlint.Main"
+ args "-F", "src/**/*.kt"
+} \ No newline at end of file
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md
index 925cb662a2..2162591846 100644
--- a/platform/ios/CHANGELOG.md
+++ b/platform/ios/CHANGELOG.md
@@ -4,12 +4,6 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
## master
-### Styles and rendering
-
-* Fixed style change transition regression caused by delayed setting of the updated layer properties. ([#15016](https://github.com/mapbox/mapbox-gl-native/pull/15016))
-
-### Other changes
-
* The `MGLIdeographicFontFamilyName` Info.plist key now also accepts an array of font family names, to customize font fallback behavior. It can also be set to a Boolean value of `NO` to force the SDK to typeset CJK characters in a remote font specified by `MGLSymbolStyleLayer.textFontNames`. ([#14862](https://github.com/mapbox/mapbox-gl-native/pull/14862))
## 5.2.0
@@ -21,10 +15,13 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
### Packaging
* Removed previously deprecated methods and properties that had been marked `unavailable`. ([#15000](https://github.com/mapbox/mapbox-gl-native/pull/15000))
+* The downloaded zip file of this framework no longer contains a local podspec. ([#15027](https://github.com/mapbox/mapbox-gl-native/pull/15027))
### Styles and rendering
+* Hiragana and katakana are now included in the range of CJK glyphs that are rendered locally by default. ([#15009](https://github.com/mapbox/mapbox-gl-native/pull/15009))
* Added the `-[MGLMapViewDelegate mapView:shouldRemoveStyleImage:]` method for optimizing style image caching. ([#14769](https://github.com/mapbox/mapbox-gl-native/pull/14769))
+* Fixed style change transition regression caused by delayed setting of the updated layer properties. ([#15016](https://github.com/mapbox/mapbox-gl-native/pull/15016))
### Other changes
diff --git a/platform/ios/Mapbox-iOS-SDK-snapshot-dynamic.podspec b/platform/ios/Mapbox-iOS-SDK-snapshot-dynamic.podspec
index ad2df155ec..e7142ef340 100644
--- a/platform/ios/Mapbox-iOS-SDK-snapshot-dynamic.podspec
+++ b/platform/ios/Mapbox-iOS-SDK-snapshot-dynamic.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |m|
- version = '5.2.0-alpha.1'
+ version = '5.2.0-alpha.2'
m.name = 'Mapbox-iOS-SDK-snapshot-dynamic'
m.version = "#{version}-snapshot"
diff --git a/platform/ios/Mapbox-iOS-SDK-stripped.podspec b/platform/ios/Mapbox-iOS-SDK-stripped.podspec
index bdc795fe75..0166123a7e 100644
--- a/platform/ios/Mapbox-iOS-SDK-stripped.podspec
+++ b/platform/ios/Mapbox-iOS-SDK-stripped.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |m|
- version = '5.2.0-alpha.1'
+ version = '5.2.0-alpha.2'
m.name = 'Mapbox-iOS-SDK-stripped'
m.version = "#{version}-stripped"
diff --git a/platform/ios/Mapbox-iOS-SDK.podspec b/platform/ios/Mapbox-iOS-SDK.podspec
index b0d02d14df..242bdc4853 100644
--- a/platform/ios/Mapbox-iOS-SDK.podspec
+++ b/platform/ios/Mapbox-iOS-SDK.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |m|
- version = '5.2.0-alpha.1'
+ version = '5.2.0-alpha.2'
m.name = 'Mapbox-iOS-SDK'
m.version = version
diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj
index 7c2935fc59..fbf7974be0 100644
--- a/platform/ios/ios.xcodeproj/project.pbxproj
+++ b/platform/ios/ios.xcodeproj/project.pbxproj
@@ -371,6 +371,7 @@
9620BB3A1E69FE1700705A1D /* MGLSDKUpdateChecker.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9620BB371E69FE1700705A1D /* MGLSDKUpdateChecker.mm */; };
9620BB3B1E69FE1700705A1D /* MGLSDKUpdateChecker.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9620BB371E69FE1700705A1D /* MGLSDKUpdateChecker.mm */; };
9621F2502091020E005B3800 /* NSExpression+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3510FFEE1D6D9D8C00F413B2 /* NSExpression+MGLAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 96381C0222C6F3950053497D /* MGLMapViewPitchTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 96381C0122C6F3950053497D /* MGLMapViewPitchTests.m */; };
9654C1261FFC1AB900DB6A19 /* MGLPolyline_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 9654C1251FFC1AB900DB6A19 /* MGLPolyline_Private.h */; };
9654C1291FFC1CCD00DB6A19 /* MGLPolygon_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 9654C1271FFC1CC000DB6A19 /* MGLPolygon_Private.h */; };
9658C155204761FC00D8A674 /* MGLMapViewScaleBarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9658C154204761FC00D8A674 /* MGLMapViewScaleBarTests.m */; };
@@ -1102,6 +1103,7 @@
960D0C351ECF5AAF008E151F /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
9620BB361E69FE1700705A1D /* MGLSDKUpdateChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLSDKUpdateChecker.h; sourceTree = "<group>"; };
9620BB371E69FE1700705A1D /* MGLSDKUpdateChecker.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = MGLSDKUpdateChecker.mm; sourceTree = "<group>"; };
+ 96381C0122C6F3950053497D /* MGLMapViewPitchTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLMapViewPitchTests.m; sourceTree = "<group>"; };
9654C1251FFC1AB900DB6A19 /* MGLPolyline_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLPolyline_Private.h; sourceTree = "<group>"; };
9654C1271FFC1CC000DB6A19 /* MGLPolygon_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLPolygon_Private.h; sourceTree = "<group>"; };
9658C154204761FC00D8A674 /* MGLMapViewScaleBarTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLMapViewScaleBarTests.m; sourceTree = "<group>"; };
@@ -2035,6 +2037,7 @@
DA695425215B1E75002041A4 /* MGLMapCameraTests.m */,
96ED34DD22374C0900E9FCA9 /* MGLMapViewDirectionTests.mm */,
16376B481FFEED010000563E /* MGLMapViewLayoutTests.m */,
+ 96381C0122C6F3950053497D /* MGLMapViewPitchTests.m */,
9658C154204761FC00D8A674 /* MGLMapViewScaleBarTests.m */,
076171C22139C70900668A35 /* MGLMapViewTests.m */,
1F95931C1E6DE2E900D5B294 /* MGLNSDateAdditionsTests.mm */,
@@ -3240,6 +3243,7 @@
96036A0620059BBA00510F3D /* MGLNSOrthographyAdditionsTests.m in Sources */,
1F95931D1E6DE2E900D5B294 /* MGLNSDateAdditionsTests.mm in Sources */,
DA695426215B1E76002041A4 /* MGLMapCameraTests.m in Sources */,
+ 96381C0222C6F3950053497D /* MGLMapViewPitchTests.m in Sources */,
CA8FBC0921A47BB100D1203C /* MGLRendererConfigurationTests.mm in Sources */,
CAD9D0AA22A86D6F001B25EE /* MGLResourceTests.mm in Sources */,
DD58A4C61D822BD000E1F038 /* MGLExpressionTests.mm in Sources */,
diff --git a/platform/ios/test/MGLMapViewPitchTests.m b/platform/ios/test/MGLMapViewPitchTests.m
new file mode 100644
index 0000000000..b7b18973a1
--- /dev/null
+++ b/platform/ios/test/MGLMapViewPitchTests.m
@@ -0,0 +1,155 @@
+#import <Mapbox/Mapbox.h>
+#import <XCTest/XCTest.h>
+
+@interface MockUIPanGestureRecognizer : UIPanGestureRecognizer
+@property CGFloat mbx_tiltGestureYTranslation;
+@property NSUInteger mbx_numberOfFingersForGesture;
+@end
+
+@implementation MockUIPanGestureRecognizer
+- (instancetype)initWithTarget:(id)target action:(SEL)action {
+ if (self = [super initWithTarget:target action:action]) {
+ self.mbx_tiltGestureYTranslation = 0;
+ self.mbx_numberOfFingersForGesture = 2;
+ }
+ return self;
+}
+- (NSUInteger)numberOfTouches { return self.mbx_numberOfFingersForGesture; }
+- (CGPoint)translationInView:(UIView *)view { return CGPointMake(0, self.mbx_tiltGestureYTranslation); }
+- (void)setTiltGestureYTranslationForPitchDegrees:(CGFloat)degrees {
+ // The tilt gesture takes the number of screen points the fingers have moved and then divides them by a "slowdown" factor, which happens to be set to 2.0 in -[MGLMapView handleTwoFingerDragGesture:].
+ self.mbx_tiltGestureYTranslation = -(degrees * 2.0);
+}
+@end
+
+// Forward declare relevant private methods
+@interface MGLMapView (MGLMapViewPitchTests)
+- (void)handleTwoFingerDragGesture:(UIPanGestureRecognizer *)rotate;
+- (MGLMapCamera *)cameraByTiltingToPitch:(CGFloat)pitch;
+@end
+
+@interface MGLMapViewPitchTests : XCTestCase
+@property (nonatomic) MGLMapView *mapView;
+@end
+
+@implementation MGLMapViewPitchTests
+
+- (void)setUp {
+ [super setUp];
+
+ [MGLAccountManager setAccessToken:@"pk.feedcafedeadbeefbadebede"];
+ NSURL *styleURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"one-liner" withExtension:@"json"];
+ self.mapView = [[MGLMapView alloc] initWithFrame:CGRectMake(0, 0, 400, 400) styleURL:styleURL];
+}
+
+- (void)tearDown {
+ self.mapView = nil;
+ [MGLAccountManager setAccessToken:nil];
+ [super tearDown];
+}
+
+- (void)testPitchEnabled {
+ self.mapView.pitchEnabled = NO;
+ self.mapView.camera = [self.mapView cameraByTiltingToPitch:30];
+ XCTAssertEqualWithAccuracy(self.mapView.camera.pitch, 30, 0.001, @"Tilt should not be set when pitchEnabled = NO.");
+
+ self.mapView.pitchEnabled = YES;
+ self.mapView.camera = [self.mapView cameraByTiltingToPitch:30];
+ XCTAssertEqualWithAccuracy(self.mapView.camera.pitch, 30, 0.001, @"Tilt should be set when pitchEnabled = YES.");
+}
+
+- (void)testPitchInValidRange {
+ for (NSNumber *degrees in @[@0, @5, @20, @40, @60]) {
+ CGFloat inputDegrees = [degrees floatValue];
+ self.mapView.camera = [self.mapView cameraByTiltingToPitch:inputDegrees];
+ XCTAssertEqualWithAccuracy(self.mapView.camera.pitch, inputDegrees, 0.001, @"Tilt should be able to be set within range 0-60°.");
+ }
+}
+
+- (void)testNegativePitchClamping {
+ for (NSNumber *degrees in @[@CGFLOAT_MIN, @-999, @-60, @-30, @-0]) {
+ CGFloat inputDegrees = [degrees floatValue];
+ self.mapView.camera = [self.mapView cameraByTiltingToPitch:inputDegrees];
+ XCTAssertEqualWithAccuracy(self.mapView.camera.pitch, 0, 0.001, @"Minimum tilt should be clamped to 0°.");
+ }
+}
+
+- (void)testPositivePitchClamping {
+ for (NSNumber *degrees in @[@61, @90, @999, @CGFLOAT_MAX]) {
+ CGFloat inputDegrees = [degrees floatValue];
+ self.mapView.camera = [self.mapView cameraByTiltingToPitch:inputDegrees];
+ XCTAssertEqualWithAccuracy(self.mapView.camera.pitch, 60, 0.001, @"Maximum tilt should be clamped to 60°.");
+ }
+}
+
+- (void)testPitchAtVariousZoomLevels {
+ for (NSNumber *zoomLevel in @[@0, @5, @10, @15, @18, @21, @CGFLOAT_MAX]) {
+ self.mapView.camera = [self.mapView cameraByTiltingToPitch:0];
+ self.mapView.zoomLevel = 0;
+
+ CGFloat inputZoomLevel = [zoomLevel floatValue];
+ self.mapView.zoomLevel = inputZoomLevel;
+ self.mapView.camera = [self.mapView cameraByTiltingToPitch:30];
+ XCTAssertEqualWithAccuracy(self.mapView.camera.pitch, 30, 0.001, @"Tilting should be allowed at z%.f.", inputZoomLevel);
+ }
+}
+
+- (void)testTiltGesture {
+ MockUIPanGestureRecognizer *gesture = [[MockUIPanGestureRecognizer alloc] initWithTarget:self.mapView action:nil];
+ gesture.state = UIGestureRecognizerStateBegan;
+ [self.mapView handleTwoFingerDragGesture:gesture];
+ XCTAssertEqual(self.mapView.camera.pitch, 0, @"Pitch should initially be set to 0°.");
+
+ // Use a tilt gesture to tilt the map within its acceptable range (0-60°).
+ for (NSNumber *degrees in @[@0, @5, @20, @40, @60]) {
+ self.mapView.camera = [self.mapView cameraByTiltingToPitch:0];
+ gesture.state = UIGestureRecognizerStateChanged;
+
+ CGFloat inputDegrees = [degrees floatValue];
+ [gesture setTiltGestureYTranslationForPitchDegrees:inputDegrees];
+ [self.mapView handleTwoFingerDragGesture:gesture];
+ XCTAssertEqualWithAccuracy(self.mapView.camera.pitch, inputDegrees, 0.001, @"Pitch should be set to %.f°.", inputDegrees);
+ }
+}
+
+- (void)testTiltGestureFromInitialTilt {
+ CGFloat initialTilt = 20;
+ CGFloat additionalTilt = 30;
+
+ // Set the map camera to a pitched state, perhaps from a previous gesture or camera movement.
+ self.mapView.camera = [self.mapView cameraByTiltingToPitch:initialTilt];
+ XCTAssertEqual(self.mapView.camera.pitch, initialTilt, @"Tilt should initially be set to %.f°.", initialTilt);
+
+ // Initialize a tilt gesture.
+ MockUIPanGestureRecognizer *gesture = [[MockUIPanGestureRecognizer alloc] initWithTarget:self.mapView action:nil];
+ gesture.state = UIGestureRecognizerStateBegan;
+ [self.mapView handleTwoFingerDragGesture:gesture];
+
+ // Use the gesture to tilt the map even more.
+ gesture.state = UIGestureRecognizerStateChanged;
+ [gesture setTiltGestureYTranslationForPitchDegrees:additionalTilt];
+ [self.mapView handleTwoFingerDragGesture:gesture];
+ XCTAssertEqualWithAccuracy(self.mapView.camera.pitch, initialTilt + additionalTilt, 0.001, @"Tilt should be set to %.f°.", initialTilt + additionalTilt);
+}
+
+- (void)testTiltGestureNumberOfFingersRequired {
+ // Initialize a tilt gesture with two fingers.
+ MockUIPanGestureRecognizer *gesture = [[MockUIPanGestureRecognizer alloc] initWithTarget:self.mapView action:nil];
+ gesture.state = UIGestureRecognizerStateBegan;
+ gesture.mbx_numberOfFingersForGesture = 2;
+
+ // Use the gesture to tilt to 30°.
+ [gesture setTiltGestureYTranslationForPitchDegrees:30];
+ [self.mapView handleTwoFingerDragGesture:gesture];
+ XCTAssertEqualWithAccuracy(self.mapView.camera.pitch, 30, 0.001, @"Tilt gesture should work with two fingers down.");
+
+ // Change the gesture's number of fingers to one and try to update the pitch.
+ gesture.mbx_numberOfFingersForGesture = 1;
+ gesture.state = UIGestureRecognizerStateChanged;
+ [gesture setTiltGestureYTranslationForPitchDegrees:0];
+ [self.mapView handleTwoFingerDragGesture:gesture];
+ XCTAssertEqual(gesture.state, UIGestureRecognizerStateEnded, @"Gesture should end when the number of fingers is less than two.");
+ XCTAssertEqualWithAccuracy(self.mapView.camera.pitch, 30, 0.001, @"Pitch should remain unchanged if gesture has ended.");
+}
+
+@end
diff --git a/platform/ios/vendor/mapbox-events-ios b/platform/ios/vendor/mapbox-events-ios
-Subproject 9f1be0cd2a8d15312f40343a9d9615b16dcc8a6
+Subproject 2e6bbd9f3c898f33a49e20fb97eca86eeb6351e
diff --git a/src/core-files.json b/src/core-files.json
index fcc0dba9f5..f2da5a3d05 100644
--- a/src/core-files.json
+++ b/src/core-files.json
@@ -143,6 +143,7 @@
"src/mbgl/renderer/sources/render_vector_source.cpp",
"src/mbgl/renderer/style_diff.cpp",
"src/mbgl/renderer/tile_pyramid.cpp",
+ "src/mbgl/renderer/tile_render_data.cpp",
"src/mbgl/sprite/sprite_loader.cpp",
"src/mbgl/sprite/sprite_loader_worker.cpp",
"src/mbgl/sprite/sprite_parser.cpp",
@@ -665,6 +666,7 @@
"mbgl/renderer/tile_mask.hpp": "src/mbgl/renderer/tile_mask.hpp",
"mbgl/renderer/tile_parameters.hpp": "src/mbgl/renderer/tile_parameters.hpp",
"mbgl/renderer/tile_pyramid.hpp": "src/mbgl/renderer/tile_pyramid.hpp",
+ "mbgl/renderer/tile_render_data.hpp": "src/mbgl/renderer/tile_render_data.hpp",
"mbgl/renderer/transition_parameters.hpp": "src/mbgl/renderer/transition_parameters.hpp",
"mbgl/renderer/update_parameters.hpp": "src/mbgl/renderer/update_parameters.hpp",
"mbgl/renderer/upload_parameters.hpp": "src/mbgl/renderer/upload_parameters.hpp",
diff --git a/src/mbgl/annotation/render_annotation_source.hpp b/src/mbgl/annotation/render_annotation_source.hpp
index e5d5130446..948a0b0d8d 100644
--- a/src/mbgl/annotation/render_annotation_source.hpp
+++ b/src/mbgl/annotation/render_annotation_source.hpp
@@ -29,9 +29,4 @@ private:
const AnnotationSource::Impl& impl() const;
};
-template <>
-inline bool RenderSource::is<RenderAnnotationSource>() const {
- return baseImpl->type == style::SourceType::Annotations;
-}
-
} // namespace mbgl
diff --git a/src/mbgl/renderer/image_atlas.cpp b/src/mbgl/renderer/image_atlas.cpp
index da7f5a30be..c9cedb3386 100644
--- a/src/mbgl/renderer/image_atlas.cpp
+++ b/src/mbgl/renderer/image_atlas.cpp
@@ -1,6 +1,4 @@
#include <mbgl/renderer/image_atlas.hpp>
-#include <mbgl/gfx/upload_pass.hpp>
-#include <mbgl/gfx/context.hpp>
#include <mbgl/renderer/image_manager.hpp>
#include <mapbox/shelf-pack.hpp>
@@ -53,27 +51,36 @@ const mapbox::Bin& _packImage(mapbox::ShelfPack& pack, const style::Image::Impl&
return bin;
}
-void ImageAtlas::patchUpdatedImages(gfx::UploadPass& uploadPass, gfx::Texture& atlasTexture, const ImageManager& imageManager) {
+namespace {
+
+void populateImagePatches(
+ ImagePositions& imagePositions,
+ const ImageManager& imageManager,
+ std::vector<ImagePatch>& /*out*/ patches) {
for (auto& updatedImageVersion : imageManager.updatedImageVersions) {
- auto iconPosition = iconPositions.find(updatedImageVersion.first);
- if (iconPosition != iconPositions.end()) {
- patchUpdatedImage(uploadPass, atlasTexture, iconPosition->second, imageManager, updatedImageVersion.first, updatedImageVersion.second);
- }
- auto patternPosition = patternPositions.find(updatedImageVersion.first);
- if (patternPosition != patternPositions.end()) {
- patchUpdatedImage(uploadPass, atlasTexture, patternPosition->second, imageManager, updatedImageVersion.first, updatedImageVersion.second);
+ const std::string& name = updatedImageVersion.first;
+ const uint32_t version = updatedImageVersion.second;
+ auto it = imagePositions.find(updatedImageVersion.first);
+ if (it != imagePositions.end()) {
+ auto& position = it->second;
+ if (position.version == version) continue;
+
+ auto updatedImage = imageManager.getSharedImage(name);
+ if (updatedImage == nullptr) continue;
+
+ patches.emplace_back(*updatedImage, position.textureRect);
+ position.version = version;
}
}
}
-void ImageAtlas::patchUpdatedImage(gfx::UploadPass& uploadPass, gfx::Texture& atlasTexture, ImagePosition& position, const ImageManager& imageManager, const std::string& name, uint16_t version) {
- if (position.version == version) return;
-
- auto updatedImage = imageManager.getImage(name);
- if (updatedImage == nullptr) return;
+} // namespace
- uploadPass.updateTextureSub(atlasTexture, updatedImage->image, position.textureRect.x, position.textureRect.y);
- position.version = version;
+std::vector<ImagePatch> ImageAtlas::getImagePatchesAndUpdateVersions(const ImageManager& imageManager) {
+ std::vector<ImagePatch> imagePatches;
+ populateImagePatches(iconPositions, imageManager, imagePatches);
+ populateImagePatches(patternPositions, imageManager, imagePatches);
+ return imagePatches;
}
ImageAtlas makeImageAtlas(const ImageMap& icons, const ImageMap& patterns, const std::unordered_map<std::string, uint32_t>& versionMap) {
diff --git a/src/mbgl/renderer/image_atlas.hpp b/src/mbgl/renderer/image_atlas.hpp
index b59153c4a6..56d7406a0a 100644
--- a/src/mbgl/renderer/image_atlas.hpp
+++ b/src/mbgl/renderer/image_atlas.hpp
@@ -54,15 +54,23 @@ public:
using ImagePositions = std::map<std::string, ImagePosition>;
+class ImagePatch {
+public:
+ ImagePatch(Immutable<style::Image::Impl> image_,
+ const Rect<uint16_t>& textureRect_)
+ : image(std::move(image_))
+ , textureRect(textureRect_) {}
+ Immutable<style::Image::Impl> image;
+ Rect<uint16_t> textureRect;
+};
+
class ImageAtlas {
public:
PremultipliedImage image;
ImagePositions iconPositions;
ImagePositions patternPositions;
- void patchUpdatedImages(gfx::UploadPass&, gfx::Texture&, const ImageManager&);
-private:
- void patchUpdatedImage(gfx::UploadPass&, gfx::Texture&, ImagePosition& position, const ImageManager& imageManager, const std::string& name, uint16_t version);
+ std::vector<ImagePatch> getImagePatchesAndUpdateVersions(const ImageManager&);
};
ImageAtlas makeImageAtlas(const ImageMap&, const ImageMap&, const std::unordered_map<std::string, uint32_t>& versionMap);
diff --git a/src/mbgl/renderer/image_manager.cpp b/src/mbgl/renderer/image_manager.cpp
index ff4c20eefb..3c22cdcf32 100644
--- a/src/mbgl/renderer/image_manager.cpp
+++ b/src/mbgl/renderer/image_manager.cpp
@@ -84,9 +84,16 @@ void ImageManager::removeImage(const std::string& id) {
}
const style::Image::Impl* ImageManager::getImage(const std::string& id) const {
+ if (auto* image = getSharedImage(id)) {
+ return image->get();
+ }
+ return nullptr;
+}
+
+const Immutable<style::Image::Impl>* ImageManager::getSharedImage(const std::string& id) const {
const auto it = images.find(id);
if (it != images.end()) {
- return it->second.get();
+ return &(it->second);
}
return nullptr;
}
diff --git a/src/mbgl/renderer/image_manager.hpp b/src/mbgl/renderer/image_manager.hpp
index 5305358513..9097418681 100644
--- a/src/mbgl/renderer/image_manager.hpp
+++ b/src/mbgl/renderer/image_manager.hpp
@@ -36,6 +36,7 @@ public:
void dumpDebugLogs() const;
const style::Image::Impl* getImage(const std::string&) const;
+ const Immutable<style::Image::Impl>* getSharedImage(const std::string&) const;
void addImage(Immutable<style::Image::Impl>);
bool updateImage(Immutable<style::Image::Impl>);
diff --git a/src/mbgl/renderer/layers/render_hillshade_layer.cpp b/src/mbgl/renderer/layers/render_hillshade_layer.cpp
index aa34814036..2cbb77f24b 100644
--- a/src/mbgl/renderer/layers/render_hillshade_layer.cpp
+++ b/src/mbgl/renderer/layers/render_hillshade_layer.cpp
@@ -67,9 +67,7 @@ bool RenderHillshadeLayer::hasCrossfade() const {
void RenderHillshadeLayer::prepare(const LayerPrepareParameters& params) {
RenderLayer::prepare(params);
- if (auto* demsrc = params.source->as<RenderRasterDEMSource>()) {
- maxzoom = demsrc->getMaxZoom();
- }
+ maxzoom = params.source->getMaxZoom();
}
void RenderHillshadeLayer::render(PaintParameters& parameters) {
diff --git a/src/mbgl/renderer/layers/render_raster_layer.cpp b/src/mbgl/renderer/layers/render_raster_layer.cpp
index 9811899d83..e22e14275c 100644
--- a/src/mbgl/renderer/layers/render_raster_layer.cpp
+++ b/src/mbgl/renderer/layers/render_raster_layer.cpp
@@ -3,6 +3,7 @@
#include <mbgl/renderer/render_tile.hpp>
#include <mbgl/renderer/paint_parameters.hpp>
#include <mbgl/renderer/render_static_data.hpp>
+#include <mbgl/renderer/sources/render_image_source.hpp>
#include <mbgl/programs/programs.hpp>
#include <mbgl/programs/raster_program.hpp>
#include <mbgl/tile/tile.hpp>
@@ -74,13 +75,7 @@ static std::array<float, 3> spinWeights(float spin) {
void RenderRasterLayer::prepare(const LayerPrepareParameters& params) {
RenderLayer::prepare(params);
- auto* imageSource = params.source->as<RenderImageSource>();
- if (imageSource && imageSource->isLoaded()) {
- assert(imageSource->isEnabled());
- assert(imageSource->sharedData.bucket);
- assert(imageSource->sharedData.matrices);
- imageData = imageSource->sharedData;
- }
+ imageData = params.source->getImageRenderData();
}
void RenderRasterLayer::render(PaintParameters& parameters) {
@@ -147,7 +142,7 @@ void RenderRasterLayer::render(PaintParameters& parameters) {
assert(bucket.texture);
size_t i = 0;
- for (const auto& matrix_ : *imageData->matrices) {
+ for (const auto& matrix_ : imageData->matrices) {
draw(matrix_,
*bucket.vertexBuffer,
*bucket.indexBuffer,
diff --git a/src/mbgl/renderer/layers/render_raster_layer.hpp b/src/mbgl/renderer/layers/render_raster_layer.hpp
index 9ef7c9837f..94bbd36a0d 100644
--- a/src/mbgl/renderer/layers/render_raster_layer.hpp
+++ b/src/mbgl/renderer/layers/render_raster_layer.hpp
@@ -1,12 +1,13 @@
#pragma once
#include <mbgl/renderer/render_layer.hpp>
-#include <mbgl/renderer/sources/render_image_source.hpp>
#include <mbgl/style/layers/raster_layer_impl.hpp>
#include <mbgl/style/layers/raster_layer_properties.hpp>
namespace mbgl {
+class ImageSourceRenderData;
+
class RenderRasterLayer final : public RenderLayer {
public:
explicit RenderRasterLayer(Immutable<style::RasterLayer::Impl>);
@@ -22,7 +23,7 @@ private:
// Paint properties
style::RasterPaintProperties::Unevaluated unevaluated;
- optional<ImageLayerRenderData> imageData;
+ const ImageSourceRenderData* imageData = nullptr;
};
} // namespace mbgl
diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp
index 33b095b7e7..60b0c8e2d8 100644
--- a/src/mbgl/renderer/layers/render_symbol_layer.cpp
+++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp
@@ -493,7 +493,7 @@ style::TextPaintProperties::PossiblyEvaluated RenderSymbolLayer::textPaintProper
}
void RenderSymbolLayer::prepare(const LayerPrepareParameters& params) {
- renderTiles = params.source->getRenderedTiles();
+ renderTiles = params.source->getRenderTiles();
const auto comp = [bearing = params.state.getBearing()](const RenderTile& a, const RenderTile& b) {
Point<float> pa(a.id.canonical.x, a.id.canonical.y);
Point<float> pb(b.id.canonical.x, b.id.canonical.y);
@@ -508,11 +508,14 @@ void RenderSymbolLayer::prepare(const LayerPrepareParameters& params) {
std::sort(renderTiles.begin(), renderTiles.end(), comp);
placementData.clear();
- for (RenderTile& renderTile : renderTiles) {
+ for (const RenderTile& renderTile : renderTiles) {
auto* bucket = static_cast<SymbolBucket*>(renderTile.getBucket(*baseImpl));
if (bucket && bucket->bucketLeaderID == getID()) {
// Only place this layer if it's the "group leader" for the bucket
- placementData.push_back({*bucket, renderTile});
+ const Tile* tile = params.source->getRenderedTile(renderTile.id);
+ assert(tile);
+ assert(tile->kind == Tile::Kind::Geometry);
+ placementData.push_back({*bucket, renderTile, static_cast<const GeometryTile*>(tile)->getFeatureIndex()});
}
}
}
diff --git a/src/mbgl/renderer/paint_parameters.cpp b/src/mbgl/renderer/paint_parameters.cpp
index 5034850264..0bb66972a8 100644
--- a/src/mbgl/renderer/paint_parameters.cpp
+++ b/src/mbgl/renderer/paint_parameters.cpp
@@ -90,7 +90,7 @@ void PaintParameters::clearStencil() {
namespace {
// Detects a difference in keys of renderTiles and tileClippingMaskIDs
-bool tileIDsIdentical(const std::vector<std::reference_wrapper<RenderTile>>& renderTiles,
+bool tileIDsIdentical(const RenderTiles& renderTiles,
const std::map<UnwrappedTileID, int32_t>& tileClippingMaskIDs) {
assert(std::is_sorted(renderTiles.begin(), renderTiles.end(),
[](const RenderTile& a, const RenderTile& b) { return a.id < b.id; }));
@@ -103,7 +103,7 @@ bool tileIDsIdentical(const std::vector<std::reference_wrapper<RenderTile>>& ren
} // namespace
-void PaintParameters::renderTileClippingMasks(const std::vector<std::reference_wrapper<RenderTile>>& renderTiles) {
+void PaintParameters::renderTileClippingMasks(const RenderTiles& renderTiles) {
if (renderTiles.empty() || tileIDsIdentical(renderTiles, tileClippingMaskIDs)) {
// The current stencil mask is for this source already; no need to draw another one.
return;
diff --git a/src/mbgl/renderer/paint_parameters.hpp b/src/mbgl/renderer/paint_parameters.hpp
index d78125da54..a0d26df7c5 100644
--- a/src/mbgl/renderer/paint_parameters.hpp
+++ b/src/mbgl/renderer/paint_parameters.hpp
@@ -2,6 +2,7 @@
#include <mbgl/renderer/render_pass.hpp>
#include <mbgl/renderer/render_light.hpp>
+#include <mbgl/renderer/render_source.hpp>
#include <mbgl/map/mode.hpp>
#include <mbgl/map/transform_state.hpp>
#include <mbgl/gfx/depth_mode.hpp>
@@ -23,8 +24,6 @@ class ImageManager;
class LineAtlas;
class PatternAtlas;
class UnwrappedTileID;
-class RenderSource;
-class RenderTile;
namespace gfx {
class Context;
@@ -89,7 +88,7 @@ public:
// Stencil handling
public:
- void renderTileClippingMasks(const std::vector<std::reference_wrapper<RenderTile>>&);
+ void renderTileClippingMasks(const RenderTiles&);
gfx::StencilMode stencilModeForClipping(const UnwrappedTileID&) const;
gfx::StencilMode stencilModeFor3D();
diff --git a/src/mbgl/renderer/render_layer.cpp b/src/mbgl/renderer/render_layer.cpp
index 4ad93a0d16..9e79d7338c 100644
--- a/src/mbgl/renderer/render_layer.cpp
+++ b/src/mbgl/renderer/render_layer.cpp
@@ -47,17 +47,17 @@ bool RenderLayer::supportsZoom(float zoom) const {
void RenderLayer::prepare(const LayerPrepareParameters& params) {
assert(params.source);
- renderTiles = filterRenderTiles(params.source->getRenderedTiles());
+ renderTiles = filterRenderTiles(params.source->getRenderTiles());
}
optional<Color> RenderLayer::getSolidBackground() const {
return nullopt;
}
-RenderLayer::RenderTiles RenderLayer::filterRenderTiles(RenderTiles tiles) const {
+RenderTiles RenderLayer::filterRenderTiles(RenderTiles tiles) const {
RenderTiles filtered;
- for (RenderTile& tile : tiles) {
+ for (const RenderTile& tile : tiles) {
if (tile.holdForFade()) {
continue;
}
@@ -78,21 +78,21 @@ void RenderLayer::checkRenderability(const PaintParameters& parameters,
}
if (activeBindingCount > parameters.context.maximumVertexBindingCount) {
- Log::Info(Event::OpenGL,
- "The layer '%s' uses more data-driven properties than the current device "
- "supports, and will have rendering errors. To ensure compatibility with this "
- "device, use %d fewer data driven properties in this layer.",
- getID().c_str(),
- activeBindingCount - parameters.context.minimumRequiredVertexBindingCount);
+ Log::Error(Event::OpenGL,
+ "The layer '%s' uses more data-driven properties than the current device "
+ "supports, and will have rendering errors. To ensure compatibility with this "
+ "device, use %d fewer data driven properties in this layer.",
+ getID().c_str(),
+ activeBindingCount - parameters.context.minimumRequiredVertexBindingCount);
hasRenderFailures = true;
} else if (activeBindingCount > parameters.context.minimumRequiredVertexBindingCount) {
- Log::Info(Event::OpenGL,
- "The layer '%s' uses more data-driven properties than some devices may support. "
- "Though it will render correctly on this device, it may have rendering errors "
- "on other devices. To ensure compatibility with all devices, use %d fewer "
- "data-driven properties in this layer.",
- getID().c_str(),
- activeBindingCount - parameters.context.minimumRequiredVertexBindingCount);
+ Log::Warning(Event::OpenGL,
+ "The layer '%s' uses more data-driven properties than some devices may support. "
+ "Though it will render correctly on this device, it may have rendering errors "
+ "on other devices. To ensure compatibility with all devices, use %d fewer "
+ "data-driven properties in this layer.",
+ getID().c_str(),
+ activeBindingCount - parameters.context.minimumRequiredVertexBindingCount);
hasRenderFailures = true;
}
}
diff --git a/src/mbgl/renderer/render_layer.hpp b/src/mbgl/renderer/render_layer.hpp
index 1eaa79ab2b..11c7587893 100644
--- a/src/mbgl/renderer/render_layer.hpp
+++ b/src/mbgl/renderer/render_layer.hpp
@@ -30,7 +30,8 @@ public:
class LayerPlacementData {
public:
std::reference_wrapper<Bucket> bucket;
- std::reference_wrapper<RenderTile> tile;
+ std::reference_wrapper<const RenderTile> tile;
+ std::shared_ptr<FeatureIndex> featureIndex;
};
class LayerPrepareParameters {
@@ -42,6 +43,8 @@ public:
const TransformState& state;
};
+using RenderTiles = std::vector<std::reference_wrapper<const RenderTile>>;
+
class RenderLayer {
protected:
RenderLayer(Immutable<style::LayerProperties>);
@@ -114,7 +117,6 @@ protected:
void checkRenderability(const PaintParameters&, uint32_t activeBindingCount);
protected:
- using RenderTiles = std::vector<std::reference_wrapper<RenderTile>>;
// Stores current set of tiles to be rendered for this layer.
RenderTiles renderTiles;
diff --git a/src/mbgl/renderer/render_orchestrator.cpp b/src/mbgl/renderer/render_orchestrator.cpp
index acc50318d6..fafbc8b635 100644
--- a/src/mbgl/renderer/render_orchestrator.cpp
+++ b/src/mbgl/renderer/render_orchestrator.cpp
@@ -55,25 +55,11 @@ private:
uint32_t index;
};
-class SourceRenderItem final : public RenderItem {
-public:
- explicit SourceRenderItem(RenderSource& source_)
- : source(source_) {}
-
-private:
- bool hasRenderPass(RenderPass) const override { return false; }
- void upload(gfx::UploadPass& pass) const override { source.get().upload(pass); }
- void render(PaintParameters& parameters) const override { source.get().finishRender(parameters); }
- const std::string& getName() const override { return source.get().baseImpl->id; }
-
- std::reference_wrapper<RenderSource> source;
-};
-
class RenderTreeImpl final : public RenderTree {
public:
RenderTreeImpl(std::unique_ptr<RenderTreeParameters> parameters_,
std::set<LayerRenderItem> layerRenderItems_,
- std::vector<SourceRenderItem> sourceRenderItems_,
+ std::vector<std::unique_ptr<RenderItem>> sourceRenderItems_,
LineAtlas& lineAtlas_,
PatternAtlas& patternAtlas_)
: RenderTree(std::move(parameters_)),
@@ -87,13 +73,16 @@ public:
return { layerRenderItems.begin(), layerRenderItems.end() };
}
RenderItems getSourceRenderItems() const override {
- return { sourceRenderItems.begin(), sourceRenderItems.end() };
+ RenderItems result;
+ result.reserve(sourceRenderItems.size());
+ for (const auto& item : sourceRenderItems) result.emplace_back(*item);
+ return result;
}
LineAtlas& getLineAtlas() const override { return lineAtlas; }
PatternAtlas& getPatternAtlas() const override { return patternAtlas; }
std::set<LayerRenderItem> layerRenderItems;
- std::vector<SourceRenderItem> sourceRenderItems;
+ std::vector<std::unique_ptr<RenderItem>> sourceRenderItems;
std::reference_wrapper<LineAtlas> lineAtlas;
std::reference_wrapper<PatternAtlas> patternAtlas;
};
@@ -339,12 +328,10 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
return nullptr;
}
- std::vector<SourceRenderItem> sourceRenderItems;
- // Update all matrices and generate data that we should upload to the GPU.
+ // Prepare. Update all matrices and generate data that we should upload to the GPU.
for (const auto& entry : renderSources) {
if (entry.second->isEnabled()) {
- entry.second->prepare({renderTreeParameters->transformParams, updateParameters.debugOptions});
- sourceRenderItems.emplace_back(*entry.second);
+ entry.second->prepare({renderTreeParameters->transformParams, updateParameters.debugOptions, *imageManager});
}
}
@@ -355,7 +342,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
layersNeedPlacement.emplace_back(renderLayer);
}
}
-
+ // Symbol placement.
{
if (!isMapModeContinuous) {
// TODO: Think about right way for symbol index to handle still rendering
@@ -406,6 +393,13 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
imageManager->reduceMemoryUseIfCacheSizeExceedsLimit();
}
+ std::vector<std::unique_ptr<RenderItem>> sourceRenderItems;
+ for (const auto& entry : renderSources) {
+ if (entry.second->isEnabled()) {
+ sourceRenderItems.emplace_back(entry.second->createRenderItem());
+ }
+ }
+
return std::make_unique<RenderTreeImpl>(
std::move(renderTreeParameters),
std::move(layerRenderItems),
diff --git a/src/mbgl/renderer/render_source.cpp b/src/mbgl/renderer/render_source.cpp
index d0f5689a9e..7b47602cd1 100644
--- a/src/mbgl/renderer/render_source.cpp
+++ b/src/mbgl/renderer/render_source.cpp
@@ -11,6 +11,7 @@
#include <mbgl/tile/tile.hpp>
#include <mbgl/layermanager/layer_manager.hpp>
+#include <mbgl/util/constants.hpp>
#include <utility>
namespace mbgl {
@@ -73,4 +74,9 @@ bool RenderSource::isEnabled() const {
return enabled;
}
+uint8_t RenderSource::getMaxZoom() const {
+ assert(false);
+ return util::TERRAIN_RGB_MAXZOOM;
+}
+
} // namespace mbgl
diff --git a/src/mbgl/renderer/render_source.hpp b/src/mbgl/renderer/render_source.hpp
index 71e38f2afd..fc770f83cf 100644
--- a/src/mbgl/renderer/render_source.hpp
+++ b/src/mbgl/renderer/render_source.hpp
@@ -28,6 +28,9 @@ class RenderSourceObserver;
class TileParameters;
class CollisionIndex;
class TransformParameters;
+class ImageManager;
+class ImageSourceRenderData;
+class RenderItem;
namespace gfx {
class UploadPass;
@@ -37,28 +40,16 @@ class SourcePrepareParameters {
public:
const TransformParameters& transform;
const MapDebugOptions& debugOptions;
+ const ImageManager& imageManager;
};
+using RenderTiles = std::vector<std::reference_wrapper<const RenderTile>>;
+
class RenderSource : protected TileObserver {
public:
static std::unique_ptr<RenderSource> create(Immutable<style::Source::Impl>);
virtual ~RenderSource();
- // Check whether this source is of the given subtype.
- template <class T>
- bool is() const;
-
- // Dynamically cast this source to the given subtype.
- template <class T>
- T* as() {
- return is<T>() ? reinterpret_cast<T*>(this) : nullptr;
- }
-
- template <class T>
- const T* as() const {
- return is<T>() ? reinterpret_cast<const T*>(this) : nullptr;
- }
-
bool isEnabled() const;
virtual bool isLoaded() const = 0;
@@ -67,14 +58,16 @@ public:
bool needsRendering,
bool needsRelayout,
const TileParameters&) = 0;
-
- virtual void upload(gfx::UploadPass&) = 0;
+ // Note: calling of this method might reset the contained render data.
+ virtual std::unique_ptr<RenderItem> createRenderItem() = 0;
+ // Creates the render data to be passed to the render item.
virtual void prepare(const SourcePrepareParameters&) = 0;
- virtual void finishRender(PaintParameters&) = 0;
virtual void updateFadingTiles() = 0;
virtual bool hasFadingTiles() const = 0;
// Returns a list of RenderTiles, sorted by tile id.
- virtual std::vector<std::reference_wrapper<RenderTile>> getRenderedTiles() = 0;
+ virtual RenderTiles getRenderTiles() = 0;
+ virtual const ImageSourceRenderData* getImageRenderData() const { return nullptr; }
+ virtual const Tile* getRenderedTile(const UnwrappedTileID&) const { return nullptr; }
virtual std::unordered_map<std::string, std::vector<Feature>>
queryRenderedFeatures(const ScreenLineString& geometry,
@@ -98,6 +91,8 @@ public:
virtual void dumpDebugLogs() const = 0;
+ virtual uint8_t getMaxZoom() const;
+
void setObserver(RenderSourceObserver*);
Immutable<style::Source::Impl> baseImpl;
diff --git a/src/mbgl/renderer/render_tile.cpp b/src/mbgl/renderer/render_tile.cpp
index f1f6a4ac45..fbb2ae81de 100644
--- a/src/mbgl/renderer/render_tile.cpp
+++ b/src/mbgl/renderer/render_tile.cpp
@@ -4,6 +4,7 @@
#include <mbgl/renderer/buckets/debug_bucket.hpp>
#include <mbgl/renderer/render_source.hpp>
#include <mbgl/renderer/render_static_data.hpp>
+#include <mbgl/renderer/tile_render_data.hpp>
#include <mbgl/programs/programs.hpp>
#include <mbgl/map/transform_state.hpp>
#include <mbgl/gfx/cull_face_mode.hpp>
@@ -15,7 +16,8 @@ namespace mbgl {
using namespace style;
-RenderTile::RenderTile(UnwrappedTileID id_, Tile& tile_) : id(std::move(id_)), tile(tile_) {
+RenderTile::RenderTile(UnwrappedTileID id_, Tile& tile_)
+ : id(std::move(id_)), tile(tile_) {
}
RenderTile::~RenderTile() = default;
@@ -65,41 +67,33 @@ const OverscaledTileID& RenderTile::getOverscaledTileID() const { return tile.id
bool RenderTile::holdForFade() const { return tile.holdForFade(); }
Bucket* RenderTile::getBucket(const style::Layer::Impl& impl) const {
- return tile.getBucket(impl);
+ assert(renderData);
+ return renderData->getBucket(impl);
}
const LayerRenderData* RenderTile::getLayerRenderData(const style::Layer::Impl& impl) const {
- return tile.getLayerRenderData(impl);
+ assert(renderData);
+ return renderData->getLayerRenderData(impl);
}
optional<ImagePosition> RenderTile::getPattern(const std::string& pattern) const {
- assert(tile.kind == Tile::Kind::Geometry);
- return static_cast<const GeometryTile&>(tile).getPattern(pattern);
+ assert(renderData);
+ return renderData->getPattern(pattern);
}
const gfx::Texture& RenderTile::getGlyphAtlasTexture() const {
- assert(tile.kind == Tile::Kind::Geometry);
- assert(static_cast<const GeometryTile&>(tile).glyphAtlasTexture);
- return *(static_cast<const GeometryTile&>(tile).glyphAtlasTexture);
+ assert(renderData);
+ return renderData->getGlyphAtlasTexture();
}
const gfx::Texture& RenderTile::getIconAtlasTexture() const {
- assert(tile.kind == Tile::Kind::Geometry);
- assert(static_cast<const GeometryTile&>(tile).iconAtlasTexture);
- return *(static_cast<const GeometryTile&>(tile).iconAtlasTexture);
+ assert(renderData);
+ return renderData->getIconAtlasTexture();
}
-std::shared_ptr<FeatureIndex> RenderTile::getFeatureIndex() const {
- assert(tile.kind == Tile::Kind::Geometry);
- return static_cast<const GeometryTile&>(tile).getFeatureIndex();
-}
-
-void RenderTile::setMask(TileMask&& mask) {
- tile.setMask(std::move(mask));
-}
-
-void RenderTile::upload(gfx::UploadPass& uploadPass) {
- tile.upload(uploadPass);
+void RenderTile::upload(gfx::UploadPass& uploadPass) const {
+ assert(renderData);
+ renderData->upload(uploadPass);
if (debugBucket) {
debugBucket->upload(uploadPass);
@@ -107,6 +101,12 @@ void RenderTile::upload(gfx::UploadPass& uploadPass) {
}
void RenderTile::prepare(const SourcePrepareParameters& parameters) {
+ renderData = tile.createRenderData();
+ assert(renderData);
+ renderData->prepare(parameters);
+
+ needsRendering = tile.usedByRenderedLayers;
+
if (parameters.debugOptions != MapDebugOptions::NoDebug &&
(!debugBucket || debugBucket->renderable != tile.isRenderable() ||
debugBucket->complete != tile.isComplete() ||
@@ -129,8 +129,8 @@ void RenderTile::prepare(const SourcePrepareParameters& parameters) {
matrix::multiply(nearClippedMatrix, transform.nearClippedProjMatrix, nearClippedMatrix);
}
-void RenderTile::finishRender(PaintParameters& parameters) {
- if (!tile.usedByRenderedLayers || parameters.debugOptions == MapDebugOptions::NoDebug)
+void RenderTile::finishRender(PaintParameters& parameters) const {
+ if (!needsRendering || parameters.debugOptions == MapDebugOptions::NoDebug)
return;
static const style::Properties<>::PossiblyEvaluated properties {};
diff --git a/src/mbgl/renderer/render_tile.hpp b/src/mbgl/renderer/render_tile.hpp
index f0abb4150c..34d027cae5 100644
--- a/src/mbgl/renderer/render_tile.hpp
+++ b/src/mbgl/renderer/render_tile.hpp
@@ -4,10 +4,9 @@
#include <mbgl/gfx/texture.hpp>
#include <mbgl/tile/tile_id.hpp>
#include <mbgl/util/mat4.hpp>
+#include <mbgl/renderer/image_atlas.hpp>
#include <mbgl/style/layer_impl.hpp>
#include <mbgl/style/types.hpp>
-#include <mbgl/renderer/image_atlas.hpp>
-#include <mbgl/renderer/tile_mask.hpp>
#include <array>
#include <memory>
@@ -26,6 +25,7 @@ class PaintParameters;
class DebugBucket;
class SourcePrepareParameters;
class FeatureIndex;
+class TileRenderData;
class RenderTile final {
public:
@@ -58,12 +58,10 @@ public:
optional<ImagePosition> getPattern(const std::string& pattern) const;
const gfx::Texture& getGlyphAtlasTexture() const;
const gfx::Texture& getIconAtlasTexture() const;
- std::shared_ptr<FeatureIndex> getFeatureIndex() const;
- void setMask(TileMask&&);
- void upload(gfx::UploadPass&);
+ void upload(gfx::UploadPass&) const;
void prepare(const SourcePrepareParameters&);
- void finishRender(PaintParameters&);
+ void finishRender(PaintParameters&) const;
mat4 translateVtxMatrix(const mat4& tileMatrix,
const std::array<float, 2>& translation,
@@ -72,6 +70,9 @@ public:
const bool inViewportPixelUnits) const;
private:
Tile& tile;
+ // The following members are reset at placement stage.
+ std::unique_ptr<TileRenderData> renderData;
+ bool needsRendering = false;
};
} // namespace mbgl
diff --git a/src/mbgl/renderer/sources/render_custom_geometry_source.hpp b/src/mbgl/renderer/sources/render_custom_geometry_source.hpp
index 331ae455e7..e94af0473f 100644
--- a/src/mbgl/renderer/sources/render_custom_geometry_source.hpp
+++ b/src/mbgl/renderer/sources/render_custom_geometry_source.hpp
@@ -19,9 +19,4 @@ private:
const style::CustomGeometrySource::Impl& impl() const;
};
-template <>
-inline bool RenderSource::is<RenderCustomGeometrySource>() const {
- return baseImpl->type == style::SourceType::CustomVector;
-}
-
} // namespace mbgl
diff --git a/src/mbgl/renderer/sources/render_geojson_source.hpp b/src/mbgl/renderer/sources/render_geojson_source.hpp
index 3896457806..8e923362b9 100644
--- a/src/mbgl/renderer/sources/render_geojson_source.hpp
+++ b/src/mbgl/renderer/sources/render_geojson_source.hpp
@@ -32,9 +32,4 @@ private:
std::weak_ptr<style::GeoJSONData> data;
};
-template <>
-inline bool RenderSource::is<RenderGeoJSONSource>() const {
- return baseImpl->type == style::SourceType::GeoJSON;
-}
-
} // namespace mbgl
diff --git a/src/mbgl/renderer/sources/render_image_source.cpp b/src/mbgl/renderer/sources/render_image_source.cpp
index db5ba75ffc..7e793c6a4a 100644
--- a/src/mbgl/renderer/sources/render_image_source.cpp
+++ b/src/mbgl/renderer/sources/render_image_source.cpp
@@ -17,43 +17,16 @@ namespace mbgl {
using namespace style;
-RenderImageSource::RenderImageSource(Immutable<style::ImageSource::Impl> impl_)
- : RenderSource(impl_) {
-}
-
-RenderImageSource::~RenderImageSource() = default;
-
-const style::ImageSource::Impl& RenderImageSource::impl() const {
- return static_cast<const style::ImageSource::Impl&>(*baseImpl);
-}
-
-bool RenderImageSource::isLoaded() const {
- return !!sharedData.bucket;
-}
-
-void RenderImageSource::upload(gfx::UploadPass& uploadPass) {
- if (sharedData.bucket->needsUpload()) {
- sharedData.bucket->upload(uploadPass);
- }
-}
+ImageSourceRenderData::~ImageSourceRenderData() = default;
-void RenderImageSource::prepare(const SourcePrepareParameters& parameters) {
- if (!isLoaded()) {
- return;
- }
-
- sharedData.matrices = std::make_shared<std::vector<mat4>>(tileIds.size(), mat4());
- const auto& transformParams = parameters.transform;
- for (size_t i = 0u; i < tileIds.size(); ++i) {
- mat4& matrix = (*sharedData.matrices)[i];
- matrix::identity(matrix);
- transformParams.state.matrixFor(matrix, tileIds[i]);
- matrix::multiply(matrix, transformParams.alignedProjMatrix, matrix);
+void ImageSourceRenderData::upload(gfx::UploadPass& uploadPass) const {
+ if (bucket && bucket->needsUpload()) {
+ bucket->upload(uploadPass);
}
}
-void RenderImageSource::finishRender(PaintParameters& parameters) {
- if (!isLoaded() || !(parameters.debugOptions & MapDebugOptions::TileBorders)) {
+void ImageSourceRenderData::render(PaintParameters& parameters) const {
+ if (!bucket || !(parameters.debugOptions & MapDebugOptions::TileBorders)) {
return;
}
@@ -62,7 +35,7 @@ void RenderImageSource::finishRender(PaintParameters& parameters) {
auto& programInstance = parameters.programs.debug;
- for (auto matrix : *sharedData.matrices) {
+ for (auto matrix : matrices) {
programInstance.draw(
parameters.context,
*parameters.renderPass,
@@ -93,6 +66,43 @@ void RenderImageSource::finishRender(PaintParameters& parameters) {
}
}
+RenderImageSource::RenderImageSource(Immutable<style::ImageSource::Impl> impl_)
+ : RenderSource(std::move(impl_)) {
+}
+
+RenderImageSource::~RenderImageSource() = default;
+
+const style::ImageSource::Impl& RenderImageSource::impl() const {
+ return static_cast<const style::ImageSource::Impl&>(*baseImpl);
+}
+
+bool RenderImageSource::isLoaded() const {
+ return !!bucket;
+}
+
+std::unique_ptr<RenderItem> RenderImageSource::createRenderItem() {
+ assert(renderData);
+ return std::move(renderData);
+}
+
+void RenderImageSource::prepare(const SourcePrepareParameters& parameters) {
+ assert(!renderData);
+ if (!isLoaded()) {
+ renderData = std::make_unique<ImageSourceRenderData>(bucket, std::vector<mat4>{}, baseImpl->id);
+ return;
+ }
+
+ std::vector<mat4> matrices{tileIds.size(), mat4()};
+ const auto& transformParams = parameters.transform;
+ for (size_t i = 0u; i < tileIds.size(); ++i) {
+ mat4& matrix = matrices[i];
+ matrix::identity(matrix);
+ transformParams.state.matrixFor(matrix, tileIds[i]);
+ matrix::multiply(matrix, transformParams.alignedProjMatrix, matrix);
+ }
+ renderData = std::make_unique<ImageSourceRenderData>(bucket, std::move(matrices), baseImpl->id);
+}
+
std::unordered_map<std::string, std::vector<Feature>>
RenderImageSource::queryRenderedFeatures(const ScreenLineString&,
const TransformState&,
@@ -193,29 +203,29 @@ void RenderImageSource::update(Immutable<style::Source::Impl> baseImpl_,
auto gc = TileCoordinate::toGeometryCoordinate(tileIds[0], tileCoords);
geomCoords.push_back(gc);
}
- if (!sharedData.bucket) {
- sharedData.bucket = std::make_unique<RasterBucket>(image);
+ if (!bucket) {
+ bucket = std::make_shared<RasterBucket>(image);
} else {
- sharedData.bucket->clear();
- if (image != sharedData.bucket->image) {
- sharedData.bucket->setImage(image);
+ bucket->clear();
+ if (image != bucket->image) {
+ bucket->setImage(image);
}
}
// Set Bucket Vertices, Indices, and segments
- sharedData.bucket->vertices.emplace_back(
+ bucket->vertices.emplace_back(
RasterProgram::layoutVertex({ geomCoords[0].x, geomCoords[0].y }, { 0, 0 }));
- sharedData.bucket->vertices.emplace_back(
+ bucket->vertices.emplace_back(
RasterProgram::layoutVertex({ geomCoords[1].x, geomCoords[1].y }, { util::EXTENT, 0 }));
- sharedData.bucket->vertices.emplace_back(
+ bucket->vertices.emplace_back(
RasterProgram::layoutVertex({ geomCoords[3].x, geomCoords[3].y }, { 0, util::EXTENT }));
- sharedData.bucket->vertices.emplace_back(
+ bucket->vertices.emplace_back(
RasterProgram::layoutVertex({ geomCoords[2].x, geomCoords[2].y }, { util::EXTENT, util::EXTENT }));
- sharedData.bucket->indices.emplace_back(0, 1, 2);
- sharedData.bucket->indices.emplace_back(1, 2, 3);
+ bucket->indices.emplace_back(0, 1, 2);
+ bucket->indices.emplace_back(1, 2, 3);
- sharedData.bucket->segments.emplace_back(0, 0, 4, 6);
+ bucket->segments.emplace_back(0, 0, 4, 6);
}
void RenderImageSource::dumpDebugLogs() const {
diff --git a/src/mbgl/renderer/sources/render_image_source.hpp b/src/mbgl/renderer/sources/render_image_source.hpp
index a656ccd539..d21f4fae10 100644
--- a/src/mbgl/renderer/sources/render_image_source.hpp
+++ b/src/mbgl/renderer/sources/render_image_source.hpp
@@ -2,28 +2,43 @@
#include <mbgl/renderer/render_source.hpp>
#include <mbgl/renderer/render_tile.hpp>
+#include <mbgl/renderer/render_tree.hpp>
#include <mbgl/style/sources/image_source_impl.hpp>
namespace mbgl {
class RasterBucket;
-class ImageLayerRenderData {
+class ImageSourceRenderData final : public RenderItem {
public:
- std::shared_ptr<RasterBucket> bucket;
- std::shared_ptr<std::vector<mat4>> matrices;
+ ImageSourceRenderData(std::shared_ptr<RasterBucket> bucket_,
+ std::vector<mat4> matrices_,
+ std::string name_)
+ : bucket(std::move(bucket_)),
+ matrices(std::move(matrices_)),
+ name(std::move(name_)) {}
+ ~ImageSourceRenderData() override;
+ const std::shared_ptr<RasterBucket> bucket;
+ const std::vector<mat4> matrices;
+
+private:
+ void upload(gfx::UploadPass&) const override;
+ void render(PaintParameters&) const override;
+ bool hasRenderPass(RenderPass) const override { return false; }
+ const std::string& getName() const override { return name; }
+
+ std::string name;
};
-class RenderImageSource : public RenderSource {
+class RenderImageSource final : public RenderSource {
public:
- RenderImageSource(Immutable<style::ImageSource::Impl>);
+ explicit RenderImageSource(Immutable<style::ImageSource::Impl>);
~RenderImageSource() override;
bool isLoaded() const final;
- void upload(gfx::UploadPass&) final;
+ std::unique_ptr<RenderItem> createRenderItem() override;
void prepare(const SourcePrepareParameters&) final;
- void finishRender(PaintParameters&) final;
void updateFadingTiles() final {}
bool hasFadingTiles() const final { return false; }
@@ -33,8 +48,10 @@ public:
bool needsRelayout,
const TileParameters&) final;
- std::vector<std::reference_wrapper<RenderTile>> getRenderedTiles() final {
- return {};
+ RenderTiles getRenderTiles() override { return {}; }
+
+ const ImageSourceRenderData* getImageRenderData() const override {
+ return renderData.get();
}
std::unordered_map<std::string, std::vector<Feature>>
@@ -54,13 +71,9 @@ private:
friend class RenderRasterLayer;
const style::ImageSource::Impl& impl() const;
- ImageLayerRenderData sharedData;
+ std::shared_ptr<RasterBucket> bucket;
+ std::unique_ptr<ImageSourceRenderData> renderData;
std::vector<UnwrappedTileID> tileIds;
};
-template <>
-inline bool RenderSource::is<RenderImageSource>() const {
- return baseImpl->type == style::SourceType::Image;
-}
-
} // namespace mbgl
diff --git a/src/mbgl/renderer/sources/render_raster_dem_source.hpp b/src/mbgl/renderer/sources/render_raster_dem_source.hpp
index d1e7f03e10..e49ad1d1d4 100644
--- a/src/mbgl/renderer/sources/render_raster_dem_source.hpp
+++ b/src/mbgl/renderer/sources/render_raster_dem_source.hpp
@@ -26,7 +26,7 @@ public:
std::vector<Feature>
querySourceFeatures(const SourceQueryOptions&) const override;
- uint8_t getMaxZoom() const { return maxzoom; }
+ uint8_t getMaxZoom() const override { return maxzoom; }
private:
const style::RasterSource::Impl& impl() const;
@@ -37,9 +37,4 @@ private:
void onTileChanged(Tile&) override;
};
-template <>
-inline bool RenderSource::is<RenderRasterDEMSource>() const {
- return baseImpl->type == style::SourceType::RasterDEM;
-}
-
} // namespace mbgl
diff --git a/src/mbgl/renderer/sources/render_raster_source.hpp b/src/mbgl/renderer/sources/render_raster_source.hpp
index ec6d7f2474..dc80630add 100644
--- a/src/mbgl/renderer/sources/render_raster_source.hpp
+++ b/src/mbgl/renderer/sources/render_raster_source.hpp
@@ -31,9 +31,4 @@ private:
optional<Tileset> tileset;
};
-template <>
-inline bool RenderSource::is<RenderRasterSource>() const {
- return baseImpl->type == style::SourceType::Raster;
-}
-
} // namespace mbgl
diff --git a/src/mbgl/renderer/sources/render_tile_source.cpp b/src/mbgl/renderer/sources/render_tile_source.cpp
index 1037a2f78e..99bdfde485 100644
--- a/src/mbgl/renderer/sources/render_tile_source.cpp
+++ b/src/mbgl/renderer/sources/render_tile_source.cpp
@@ -2,15 +2,46 @@
#include <mbgl/renderer/buckets/debug_bucket.hpp>
#include <mbgl/renderer/render_tile.hpp>
+#include <mbgl/renderer/render_tree.hpp>
#include <mbgl/renderer/paint_parameters.hpp>
+#include <mbgl/renderer/tile_render_data.hpp>
#include <mbgl/tile/vector_tile.hpp>
namespace mbgl {
using namespace style;
+class TileSourceRenderItem : public RenderItem {
+public:
+ TileSourceRenderItem(Immutable<std::vector<RenderTile>> renderTiles_, std::string name_)
+ : renderTiles(std::move(renderTiles_))
+ , name(std::move(name_)) {}
+
+private:
+ void upload(gfx::UploadPass&) const override;
+ void render(PaintParameters&) const override;
+ bool hasRenderPass(RenderPass) const override { return false; }
+ const std::string& getName() const override { return name; }
+
+ Immutable<std::vector<RenderTile>> renderTiles;
+ std::string name;
+};
+
+void TileSourceRenderItem::upload(gfx::UploadPass& parameters) const {
+ for (auto& tile : *renderTiles) {
+ tile.upload(parameters);
+ }
+}
+
+void TileSourceRenderItem::render(PaintParameters& parameters) const {
+ for (auto& tile : *renderTiles) {
+ tile.finishRender(parameters);
+ }
+}
+
RenderTileSource::RenderTileSource(Immutable<style::Source::Impl> impl_)
- : RenderSource(std::move(impl_)) {
+ : RenderSource(std::move(impl_))
+ , renderTiles(makeMutable<std::vector<RenderTile>>()) {
tilePyramid.setObserver(this);
}
@@ -20,25 +51,18 @@ bool RenderTileSource::isLoaded() const {
return tilePyramid.isLoaded();
}
-void RenderTileSource::upload(gfx::UploadPass& parameters) {
- for (auto& tile : renderTiles) {
- tile.upload(parameters);
- }
+std::unique_ptr<RenderItem> RenderTileSource::createRenderItem() {
+ return std::make_unique<TileSourceRenderItem>(renderTiles, baseImpl->id);
}
void RenderTileSource::prepare(const SourcePrepareParameters& parameters) {
- renderTiles.clear();
- renderTiles.reserve(tilePyramid.getRenderedTiles().size());
+ auto tiles = makeMutable<std::vector<RenderTile>>();
+ tiles->reserve(tilePyramid.getRenderedTiles().size());
for (auto& entry : tilePyramid.getRenderedTiles()) {
- renderTiles.emplace_back(entry.first, entry.second);
- renderTiles.back().prepare(parameters);
- }
-}
-
-void RenderTileSource::finishRender(PaintParameters& parameters) {
- for (auto& tile : renderTiles) {
- tile.finishRender(parameters);
+ tiles->emplace_back(entry.first, entry.second);
+ tiles->back().prepare(parameters);
}
+ renderTiles = std::move(tiles);
}
void RenderTileSource::updateFadingTiles() {
@@ -49,8 +73,12 @@ bool RenderTileSource::hasFadingTiles() const {
return tilePyramid.hasFadingTiles();
}
-std::vector<std::reference_wrapper<RenderTile>> RenderTileSource::getRenderedTiles() {
- return { renderTiles.begin(), renderTiles.end() };
+RenderTiles RenderTileSource::getRenderTiles() {
+ return { renderTiles->begin(), renderTiles->end() };
+}
+
+const Tile* RenderTileSource::getRenderedTile(const UnwrappedTileID& tileID) const {
+ return tilePyramid.getRenderedTile(tileID);
}
std::unordered_map<std::string, std::vector<Feature>>
diff --git a/src/mbgl/renderer/sources/render_tile_source.hpp b/src/mbgl/renderer/sources/render_tile_source.hpp
index 5501e260f5..e3148b45b9 100644
--- a/src/mbgl/renderer/sources/render_tile_source.hpp
+++ b/src/mbgl/renderer/sources/render_tile_source.hpp
@@ -16,13 +16,13 @@ public:
bool isLoaded() const override;
- void upload(gfx::UploadPass&) override;
+ std::unique_ptr<RenderItem> createRenderItem() override;
void prepare(const SourcePrepareParameters&) override;
- void finishRender(PaintParameters&) override;
void updateFadingTiles() override;
bool hasFadingTiles() const override;
- std::vector<std::reference_wrapper<RenderTile>> getRenderedTiles() override;
+ RenderTiles getRenderTiles() override;
+ const Tile* getRenderedTile(const UnwrappedTileID&) const override;
std::unordered_map<std::string, std::vector<Feature>>
queryRenderedFeatures(const ScreenLineString& geometry,
@@ -39,7 +39,7 @@ public:
protected:
TilePyramid tilePyramid;
- std::vector<RenderTile> renderTiles;
+ Immutable<std::vector<RenderTile>> renderTiles;
};
} // namespace mbgl
diff --git a/src/mbgl/renderer/sources/render_vector_source.hpp b/src/mbgl/renderer/sources/render_vector_source.hpp
index c1ffdd207c..d5ac443e1c 100644
--- a/src/mbgl/renderer/sources/render_vector_source.hpp
+++ b/src/mbgl/renderer/sources/render_vector_source.hpp
@@ -20,9 +20,4 @@ private:
optional<Tileset> tileset;
};
-template <>
-inline bool RenderSource::is<RenderVectorSource>() const {
- return baseImpl->type == style::SourceType::Vector;
-}
-
} // namespace mbgl
diff --git a/src/mbgl/renderer/tile_pyramid.cpp b/src/mbgl/renderer/tile_pyramid.cpp
index b931b2d279..e08803134d 100644
--- a/src/mbgl/renderer/tile_pyramid.cpp
+++ b/src/mbgl/renderer/tile_pyramid.cpp
@@ -39,11 +39,16 @@ bool TilePyramid::isLoaded() const {
return true;
}
-Tile* TilePyramid::getTile(const OverscaledTileID& tileID){
+Tile* TilePyramid::getTile(const OverscaledTileID& tileID) {
auto it = tiles.find(tileID);
return it == tiles.end() ? cache.get(tileID) : it->second.get();
}
+const Tile* TilePyramid::getRenderedTile(const UnwrappedTileID& tileID) const {
+ auto it = renderedTiles.find(tileID);
+ return it != renderedTiles.end() ? &it->second.get() : nullptr;
+}
+
void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& layers,
const bool needsRendering,
const bool needsRelayout,
@@ -68,7 +73,7 @@ void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& l
}
tiles.clear();
- renderTiles.clear();
+ renderedTiles.clear();
return;
}
@@ -153,7 +158,7 @@ void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& l
return tiles.emplace(tileID, std::move(tile)).first->second.get();
};
- auto previouslyRenderedTiles = std::move(renderTiles);
+ auto previouslyRenderedTiles = std::move(renderedTiles);
auto renderTileFn = [&](const UnwrappedTileID& tileID, Tile& tile) {
addRenderTile(tileID, tile);
@@ -161,7 +166,7 @@ void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& l
tile.markRenderedIdeal();
};
- renderTiles.clear();
+ renderedTiles.clear();
if (!panTiles.empty()) {
algorithm::updateRenderables(getTileFn, createTileFn, retainTileFn,
@@ -219,7 +224,7 @@ void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& l
fadingTiles = false;
// Initialize renderable tiles and update the contained layer render data.
- for (auto& entry : renderTiles) {
+ for (auto& entry : renderedTiles) {
Tile& tile = entry.second;
assert(tile.isRenderable());
tile.usedByRenderedLayers = false;
@@ -268,11 +273,11 @@ void TilePyramid::handleWrapJump(float lng) {
}
tiles = std::move(newTiles);
- for (auto& tile : renderTiles) {
+ for (auto& tile : renderedTiles) {
UnwrappedTileID newID = tile.first.unwrapTo(tile.first.wrap + wrapDelta);
newRenderTiles.emplace(newID, tile.second);
}
- renderTiles = std::move(newRenderTiles);
+ renderedTiles = std::move(newRenderTiles);
}
}
@@ -283,7 +288,7 @@ std::unordered_map<std::string, std::vector<Feature>> TilePyramid::queryRendered
const RenderedQueryOptions& options,
const mat4& projMatrix) const {
std::unordered_map<std::string, std::vector<Feature>> result;
- if (renderTiles.empty() || geometry.empty()) {
+ if (renderedTiles.empty() || geometry.empty()) {
return result;
}
@@ -301,7 +306,7 @@ std::unordered_map<std::string, std::vector<Feature>> TilePyramid::queryRendered
std::tie(b.canonical.z, b.canonical.y, b.wrap, b.canonical.x);
};
- std::map<UnwrappedTileID, std::reference_wrapper<Tile>, decltype(cmp)> sortedTiles{renderTiles.begin(), renderTiles.end(), cmp};
+ std::map<UnwrappedTileID, std::reference_wrapper<Tile>, decltype(cmp)> sortedTiles{renderedTiles.begin(), renderedTiles.end(), cmp};
auto maxPitchScaleFactor = transformState.maxPitchScaleFactor();
@@ -369,17 +374,17 @@ void TilePyramid::dumpDebugLogs() const {
void TilePyramid::clearAll() {
tiles.clear();
- renderTiles.clear();
+ renderedTiles.clear();
cache.clear();
}
void TilePyramid::addRenderTile(const UnwrappedTileID& tileID, Tile& tile) {
assert(tile.isRenderable());
- renderTiles.emplace(tileID, tile);
+ renderedTiles.emplace(tileID, tile);
}
void TilePyramid::updateFadingTiles() {
- for (auto& entry : renderTiles) {
+ for (auto& entry : renderedTiles) {
Tile& tile = entry.second;
if (tile.holdForFade()) {
tile.performedFadePlacement();
diff --git a/src/mbgl/renderer/tile_pyramid.hpp b/src/mbgl/renderer/tile_pyramid.hpp
index 610828bdb3..675831fbc9 100644
--- a/src/mbgl/renderer/tile_pyramid.hpp
+++ b/src/mbgl/renderer/tile_pyramid.hpp
@@ -43,8 +43,9 @@ public:
optional<LatLngBounds> bounds,
std::function<std::unique_ptr<Tile> (const OverscaledTileID&)> createTile);
- const std::map<UnwrappedTileID, std::reference_wrapper<Tile>>& getRenderedTiles() const { return renderTiles; }
+ const std::map<UnwrappedTileID, std::reference_wrapper<Tile>>& getRenderedTiles() const { return renderedTiles; }
Tile* getTile(const OverscaledTileID&);
+ const Tile* getRenderedTile(const UnwrappedTileID&) const;
void handleWrapJump(float lng);
@@ -75,7 +76,7 @@ private:
std::map<OverscaledTileID, std::unique_ptr<Tile>> tiles;
TileCache cache;
- std::map<UnwrappedTileID, std::reference_wrapper<Tile>> renderTiles; // Sorted by tile id.
+ std::map<UnwrappedTileID, std::reference_wrapper<Tile>> renderedTiles; // Sorted by tile id.
TileObserver* observer = nullptr;
float prevLng = 0;
diff --git a/src/mbgl/renderer/tile_render_data.cpp b/src/mbgl/renderer/tile_render_data.cpp
new file mode 100644
index 0000000000..300e8d8488
--- /dev/null
+++ b/src/mbgl/renderer/tile_render_data.cpp
@@ -0,0 +1,40 @@
+#include <mbgl/renderer/tile_render_data.hpp>
+
+namespace mbgl {
+
+TileRenderData::TileRenderData() = default;
+
+TileRenderData::TileRenderData(std::shared_ptr<TileAtlasTextures> atlasTextures_)
+ : atlasTextures(std::move(atlasTextures_)) {
+}
+
+TileRenderData::~TileRenderData() = default;
+
+const gfx::Texture& TileRenderData::getGlyphAtlasTexture() const {
+ assert(atlasTextures);
+ assert(atlasTextures->glyph);
+ return *atlasTextures->glyph;
+}
+
+const gfx::Texture& TileRenderData::getIconAtlasTexture() const {
+ assert(atlasTextures);
+ assert(atlasTextures->icon);
+ return *atlasTextures->icon;
+}
+
+optional<ImagePosition> TileRenderData::getPattern(const std::string&) const {
+ assert(false);
+ return nullopt;
+}
+
+const LayerRenderData* TileRenderData::getLayerRenderData(const style::Layer::Impl&) const {
+ assert(false);
+ return nullptr;
+}
+
+Bucket* TileRenderData::getBucket(const style::Layer::Impl&) const {
+ assert(false);
+ return nullptr;
+}
+
+} // namespace mbgl
diff --git a/src/mbgl/renderer/tile_render_data.hpp b/src/mbgl/renderer/tile_render_data.hpp
new file mode 100644
index 0000000000..85bbc49565
--- /dev/null
+++ b/src/mbgl/renderer/tile_render_data.hpp
@@ -0,0 +1,61 @@
+#pragma once
+
+#include <mbgl/gfx/texture.hpp>
+#include <mbgl/renderer/image_atlas.hpp>
+#include <mbgl/style/layer_impl.hpp>
+
+#include <memory>
+
+namespace mbgl {
+
+namespace gfx {
+class UploadPass;
+} // namespace gfx
+
+class Bucket;
+class LayerRenderData;
+class SourcePrepareParameters;
+
+class TileAtlasTextures {
+public:
+ optional<gfx::Texture> glyph;
+ optional<gfx::Texture> icon;
+};
+
+class TileRenderData {
+public:
+ virtual ~TileRenderData();
+ const gfx::Texture& getGlyphAtlasTexture() const;
+ const gfx::Texture& getIconAtlasTexture() const;
+ // To be implemented for concrete tile types.
+ virtual optional<ImagePosition> getPattern(const std::string&) const;
+ virtual const LayerRenderData* getLayerRenderData(const style::Layer::Impl&) const;
+ virtual Bucket* getBucket(const style::Layer::Impl&) const;
+ virtual void upload(gfx::UploadPass&) {}
+ virtual void prepare(const SourcePrepareParameters&) {}
+
+protected:
+ TileRenderData();
+ TileRenderData(std::shared_ptr<TileAtlasTextures>);
+ std::shared_ptr<TileAtlasTextures> atlasTextures;
+};
+
+template <typename BucketType>
+class SharedBucketTileRenderData final : public TileRenderData {
+public:
+ SharedBucketTileRenderData(std::shared_ptr<BucketType> bucket_)
+ : bucket(std::move(bucket_)) {}
+
+private:
+ // TileRenderData overrides.
+ Bucket* getBucket(const style::Layer::Impl&) const override {
+ return bucket ? bucket.get() : nullptr;
+ }
+ void upload(gfx::UploadPass& uploadPass) override {
+ if (bucket) bucket->upload(uploadPass);
+ }
+
+ std::shared_ptr<BucketType> bucket;
+};
+
+} // namespace mbgl
diff --git a/src/mbgl/text/cross_tile_symbol_index.cpp b/src/mbgl/text/cross_tile_symbol_index.cpp
index b92bab861f..43ed85d957 100644
--- a/src/mbgl/text/cross_tile_symbol_index.cpp
+++ b/src/mbgl/text/cross_tile_symbol_index.cpp
@@ -172,7 +172,7 @@ bool CrossTileSymbolIndex::addLayer(const RenderLayer& layer, float lng) {
layerIndex.handleWrapJump(lng);
for (const auto& item : layer.getPlacementData()) {
- RenderTile& renderTile = item.tile;
+ const RenderTile& renderTile = item.tile;
Bucket& bucket = item.bucket;
auto result = bucket.registerAtCrossTileIndex(layerIndex, renderTile.getOverscaledTileID(), maxCrossTileID);
assert(result.first != 0u);
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index edf73101ab..62110fefa7 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -78,6 +78,7 @@ void Placement::placeLayer(const RenderLayer& layer, const mat4& projMatrix, boo
item.tile,
projMatrix,
layer.baseImpl->source,
+ item.featureIndex,
showCollisionBoxes};
bucket.place(*this, params, seenCrossTileIDs);
}
@@ -332,7 +333,7 @@ void Placement::placeBucket(
// matching FeatureIndex/data for querying purposes
retainedQueryData.emplace(std::piecewise_construct,
std::forward_as_tuple(bucket.bucketInstanceId),
- std::forward_as_tuple(bucket.bucketInstanceId, renderTile.getFeatureIndex(), overscaledID));
+ std::forward_as_tuple(bucket.bucketInstanceId, params.featureIndex, overscaledID));
}
void Placement::commit(TimePoint now) {
diff --git a/src/mbgl/text/placement.hpp b/src/mbgl/text/placement.hpp
index 6ffe58afc5..0f56b0007e 100644
--- a/src/mbgl/text/placement.hpp
+++ b/src/mbgl/text/placement.hpp
@@ -93,6 +93,7 @@ public:
const RenderTile& tile;
const mat4& projMatrix;
std::string sourceId;
+ std::shared_ptr<FeatureIndex> featureIndex;
bool showCollisionBoxes;
};
diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp
index 1bc7646d1e..e87d21503a 100644
--- a/src/mbgl/tile/geometry_tile.cpp
+++ b/src/mbgl/tile/geometry_tile.cpp
@@ -6,6 +6,7 @@
#include <mbgl/style/layer_impl.hpp>
#include <mbgl/style/layers/background_layer.hpp>
#include <mbgl/style/layers/custom_layer.hpp>
+#include <mbgl/renderer/render_source.hpp>
#include <mbgl/renderer/tile_parameters.hpp>
#include <mbgl/renderer/layers/render_background_layer.hpp>
#include <mbgl/renderer/layers/render_custom_layer.hpp>
@@ -18,11 +19,107 @@
#include <mbgl/map/transform_state.hpp>
#include <mbgl/util/logging.hpp>
#include <mbgl/actor/scheduler.hpp>
+#include <mbgl/renderer/tile_render_data.hpp>
+
+#include <mbgl/gfx/upload_pass.hpp>
namespace mbgl {
+LayerRenderData* GeometryTile::LayoutResult::getLayerRenderData(const style::Layer::Impl& layerImpl) {
+ auto it = layerRenderData.find(layerImpl.id);
+ if (it == layerRenderData.end()) {
+ return nullptr;
+ }
+ LayerRenderData& result = it->second;
+ if (result.layerProperties->baseImpl->getTypeInfo() != layerImpl.getTypeInfo()) {
+ // Layer data might be outdated, see issue #12432.
+ return nullptr;
+ }
+ return &result;
+}
+
+class GeometryTileRenderData final : public TileRenderData {
+public:
+ GeometryTileRenderData(
+ std::shared_ptr<GeometryTile::LayoutResult> layoutResult_,
+ std::shared_ptr<TileAtlasTextures> atlasTextures_)
+ : TileRenderData(std::move(atlasTextures_))
+ , layoutResult(std::move(layoutResult_)) {
+ }
+
+private:
+ // TileRenderData overrides.
+ optional<ImagePosition> getPattern(const std::string&) const override;
+ const LayerRenderData* getLayerRenderData(const style::Layer::Impl&) const override;
+ Bucket* getBucket(const style::Layer::Impl&) const override;
+ void upload(gfx::UploadPass&) override;
+ void prepare(const SourcePrepareParameters&) override;
+
+ std::shared_ptr<GeometryTile::LayoutResult> layoutResult;
+ std::vector<ImagePatch> imagePatches;
+};
+
using namespace style;
+optional<ImagePosition> GeometryTileRenderData::getPattern(const std::string& pattern) const {
+ if (layoutResult) {
+ const auto& iconAtlas = layoutResult->iconAtlas;
+ auto it = iconAtlas.patternPositions.find(pattern);
+ if (it != iconAtlas.patternPositions.end()) {
+ return it->second;
+ }
+ }
+ return nullopt;
+}
+
+void GeometryTileRenderData::upload(gfx::UploadPass& uploadPass) {
+ if (!layoutResult) return;
+
+ auto uploadFn = [&] (Bucket& bucket) {
+ if (bucket.needsUpload()) {
+ bucket.upload(uploadPass);
+ }
+ };
+
+ for (auto& entry : layoutResult->layerRenderData) {
+ uploadFn(*entry.second.bucket);
+ }
+
+ assert(atlasTextures);
+
+ if (layoutResult->glyphAtlasImage) {
+ atlasTextures->glyph = uploadPass.createTexture(*layoutResult->glyphAtlasImage);
+ layoutResult->glyphAtlasImage = {};
+ }
+
+ if (layoutResult->iconAtlas.image.valid()) {
+ atlasTextures->icon = uploadPass.createTexture(layoutResult->iconAtlas.image);
+ layoutResult->iconAtlas.image = {};
+ }
+
+ if (atlasTextures->icon && !imagePatches.empty()) {
+ for (const auto& imagePatch : imagePatches) { // patch updated images.
+ uploadPass.updateTextureSub(*atlasTextures->icon, imagePatch.image->image, imagePatch.textureRect.x, imagePatch.textureRect.y);
+ }
+ imagePatches.clear();
+ }
+}
+
+void GeometryTileRenderData::prepare(const SourcePrepareParameters& parameters) {
+ if (!layoutResult) return;
+ imagePatches = layoutResult->iconAtlas.getImagePatchesAndUpdateVersions(parameters.imageManager);
+}
+
+Bucket* GeometryTileRenderData::getBucket(const Layer::Impl& layer) const {
+ const LayerRenderData* data = getLayerRenderData(layer);
+ return data ? data->bucket.get() : nullptr;
+}
+
+const LayerRenderData* GeometryTileRenderData::getLayerRenderData(const style::Layer::Impl& layerImpl) const {
+ return layoutResult ? layoutResult->getLayerRenderData(layerImpl) : nullptr;
+}
+
+
/*
Correlation between GeometryTile and GeometryTileWorker is safeguarded by two
correlation schemes:
@@ -88,6 +185,9 @@ void GeometryTile::setData(std::unique_ptr<const GeometryTileData> data_) {
worker.self().invoke(&GeometryTileWorker::setData, std::move(data_), correlationID);
}
+std::unique_ptr<TileRenderData> GeometryTile::createRenderData() {
+ return std::make_unique<GeometryTileRenderData>(layoutResult, atlasTextures);
+}
void GeometryTile::setLayers(const std::vector<Immutable<LayerProperties>>& layers) {
// Mark the tile as pending again if it was complete before to prevent signaling a complete
@@ -123,24 +223,18 @@ void GeometryTile::setShowCollisionBoxes(const bool showCollisionBoxes_) {
}
}
-void GeometryTile::onLayout(LayoutResult result, const uint64_t resultCorrelationID) {
+void GeometryTile::onLayout(std::shared_ptr<LayoutResult> result, const uint64_t resultCorrelationID) {
loaded = true;
renderable = true;
if (resultCorrelationID == correlationID) {
pending = false;
}
-
- layerIdToLayerRenderData = std::move(result.renderData);
-
- latestFeatureIndex = std::move(result.featureIndex);
- if (result.glyphAtlasImage) {
- glyphAtlasImage = std::move(*result.glyphAtlasImage);
- }
- if (result.iconAtlas.image.valid()) {
- iconAtlas = std::move(result.iconAtlas);
+ layoutResult = std::move(result);
+ if (!atlasTextures) {
+ atlasTextures = std::make_shared<TileAtlasTextures>();
}
-
+
observer->onTileChanged(*this);
}
@@ -168,52 +262,12 @@ void GeometryTile::getImages(ImageRequestPair pair) {
imageManager.getImages(*this, std::move(pair));
}
-const optional<ImagePosition> GeometryTile::getPattern(const std::string& pattern) const {
- auto it = iconAtlas.patternPositions.find(pattern);
- if (it != iconAtlas.patternPositions.end()) {
- return it->second;
- }
- return nullopt;
-}
-
-void GeometryTile::upload(gfx::UploadPass& uploadPass) {
- auto uploadFn = [&] (Bucket& bucket) {
- if (bucket.needsUpload()) {
- bucket.upload(uploadPass);
- }
- };
-
- for (auto& entry : layerIdToLayerRenderData) {
- uploadFn(*entry.second.bucket);
- }
-
- if (glyphAtlasImage) {
- glyphAtlasTexture = uploadPass.createTexture(*glyphAtlasImage);
- glyphAtlasImage = {};
- }
-
- if (iconAtlas.image.valid()) {
- iconAtlasTexture = uploadPass.createTexture(iconAtlas.image);
- iconAtlas.image = {};
- }
-
- if (iconAtlasTexture) {
- iconAtlas.patchUpdatedImages(uploadPass, *iconAtlasTexture, imageManager);
- }
-}
-
-Bucket* GeometryTile::getBucket(const Layer::Impl& layer) const {
- const LayerRenderData* data = getLayerRenderData(layer);
- return data ? data->bucket.get() : nullptr;
-}
-
-const LayerRenderData* GeometryTile::getLayerRenderData(const style::Layer::Impl& layerImpl) const {
- auto* that = const_cast<GeometryTile*>(this);
- return that->getMutableLayerRenderData(layerImpl);
+const std::shared_ptr<FeatureIndex> GeometryTile::getFeatureIndex() const {
+ return layoutResult ? layoutResult->featureIndex : nullptr;
}
bool GeometryTile::layerPropertiesUpdated(const Immutable<style::LayerProperties>& layerProperties) {
- LayerRenderData* renderData = getMutableLayerRenderData(*layerProperties->baseImpl);
+ LayerRenderData* renderData = getLayerRenderData(*layerProperties->baseImpl);
if (!renderData) {
return false;
}
@@ -226,25 +280,23 @@ bool GeometryTile::layerPropertiesUpdated(const Immutable<style::LayerProperties
return true;
}
-LayerRenderData* GeometryTile::getMutableLayerRenderData(const style::Layer::Impl& layerImpl) {
- auto it = layerIdToLayerRenderData.find(layerImpl.id);
- if (it == layerIdToLayerRenderData.end()) {
- return nullptr;
- }
- LayerRenderData& result = it->second;
- if (result.layerProperties->baseImpl->getTypeInfo() != layerImpl.getTypeInfo()) {
- // Layer data might be outdated, see issue #12432.
- return nullptr;
+const GeometryTileData* GeometryTile::getData() const {
+ if (!layoutResult || !layoutResult->featureIndex) {
+ return nullptr;
}
- return &result;
+ return layoutResult->featureIndex->getData();
+}
+
+LayerRenderData* GeometryTile::getLayerRenderData(const style::Layer::Impl& layerImpl) {
+ return layoutResult ? layoutResult->getLayerRenderData(layerImpl) : nullptr;
}
float GeometryTile::getQueryPadding(const std::vector<const RenderLayer*>& layers) {
float queryPadding = 0;
for (const RenderLayer* layer : layers) {
- auto bucket = getBucket(*layer->baseImpl);
- if (bucket && bucket->hasData()) {
- queryPadding = std::max(queryPadding, bucket->getQueryRadius(*layer));
+ const LayerRenderData* data = getLayerRenderData(*layer->baseImpl);
+ if (data && data->bucket && data->bucket->hasData()) {
+ queryPadding = std::max(queryPadding, data->bucket->getQueryRadius(*layer));
}
}
return queryPadding;
@@ -266,7 +318,7 @@ void GeometryTile::queryRenderedFeatures(
transformState.matrixFor(posMatrix, id.toUnwrapped());
matrix::multiply(posMatrix, projMatrix, posMatrix);
- latestFeatureIndex->query(result,
+ layoutResult->featureIndex->query(result,
queryGeometry,
transformState,
posMatrix,
diff --git a/src/mbgl/tile/geometry_tile.hpp b/src/mbgl/tile/geometry_tile.hpp
index c206dd1157..3d75dfc456 100644
--- a/src/mbgl/tile/geometry_tile.hpp
+++ b/src/mbgl/tile/geometry_tile.hpp
@@ -23,6 +23,7 @@ class SourceQueryOptions;
class TileParameters;
class GlyphAtlas;
class ImageAtlas;
+class TileAtlasTextures;
class GeometryTile : public Tile, public GlyphRequestor, public ImageRequestor {
public:
@@ -35,6 +36,7 @@ public:
void setError(std::exception_ptr);
void setData(std::unique_ptr<const GeometryTileData>);
+ std::unique_ptr<TileRenderData> createRenderData() override;
void setLayers(const std::vector<Immutable<style::LayerProperties>>&) override;
void setShowCollisionBoxes(const bool showCollisionBoxes) override;
@@ -44,9 +46,6 @@ public:
void getGlyphs(GlyphDependencies);
void getImages(ImageRequestPair);
- void upload(gfx::UploadPass&) override;
- Bucket* getBucket(const style::Layer::Impl&) const override;
- const LayerRenderData* getLayerRenderData(const style::Layer::Impl&) const override;
bool layerPropertiesUpdated(const Immutable<style::LayerProperties>&) override;
void queryRenderedFeatures(
@@ -67,21 +66,23 @@ public:
class LayoutResult {
public:
- std::unordered_map<std::string, LayerRenderData> renderData;
- std::unique_ptr<FeatureIndex> featureIndex;
+ std::unordered_map<std::string, LayerRenderData> layerRenderData;
+ std::shared_ptr<FeatureIndex> featureIndex;
optional<AlphaImage> glyphAtlasImage;
ImageAtlas iconAtlas;
+ LayerRenderData* getLayerRenderData(const style::Layer::Impl&);
+
LayoutResult(std::unordered_map<std::string, LayerRenderData> renderData_,
std::unique_ptr<FeatureIndex> featureIndex_,
optional<AlphaImage> glyphAtlasImage_,
ImageAtlas iconAtlas_)
- : renderData(std::move(renderData_)),
+ : layerRenderData(std::move(renderData_)),
featureIndex(std::move(featureIndex_)),
glyphAtlasImage(std::move(glyphAtlasImage_)),
iconAtlas(std::move(iconAtlas_)) {}
};
- void onLayout(LayoutResult, uint64_t correlationID);
+ void onLayout(std::shared_ptr<LayoutResult>, uint64_t correlationID);
void onError(std::exception_ptr, uint64_t correlationID);
@@ -89,17 +90,13 @@ public:
void markRenderedIdeal() override;
void markRenderedPreviously() override;
void performedFadePlacement() override;
- const optional<ImagePosition> getPattern(const std::string& pattern) const;
- const std::shared_ptr<FeatureIndex> getFeatureIndex() const { return latestFeatureIndex; }
+ const std::shared_ptr<FeatureIndex> getFeatureIndex() const;
const std::string sourceID;
protected:
- const GeometryTileData* getData() {
- return latestFeatureIndex ? latestFeatureIndex->getData() : nullptr;
- }
-
- LayerRenderData* getMutableLayerRenderData(const style::Layer::Impl&);
+ const GeometryTileData* getData() const;
+ LayerRenderData* getLayerRenderData(const style::Layer::Impl&);
private:
void markObsolete();
@@ -116,12 +113,8 @@ private:
uint64_t correlationID = 0;
- std::unordered_map<std::string, LayerRenderData> layerIdToLayerRenderData;
-
- std::shared_ptr<FeatureIndex> latestFeatureIndex;
-
- optional<AlphaImage> glyphAtlasImage;
- ImageAtlas iconAtlas;
+ std::shared_ptr<LayoutResult> layoutResult;
+ std::shared_ptr<TileAtlasTextures> atlasTextures;
const MapMode mode;
@@ -135,9 +128,6 @@ private:
};
FadeState fadeState = FadeState::Loaded;
-public:
- optional<gfx::Texture> glyphAtlasTexture;
- optional<gfx::Texture> iconAtlasTexture;
};
} // namespace mbgl
diff --git a/src/mbgl/tile/geometry_tile_worker.cpp b/src/mbgl/tile/geometry_tile_worker.cpp
index ad9de2c07b..a69825d346 100644
--- a/src/mbgl/tile/geometry_tile_worker.cpp
+++ b/src/mbgl/tile/geometry_tile_worker.cpp
@@ -460,12 +460,12 @@ void GeometryTileWorker::finalizeLayout() {
" Canonical: " << static_cast<int>(id.canonical.z) << "/" << id.canonical.x << "/" << id.canonical.y <<
" Time");
- parent.invoke(&GeometryTile::onLayout, GeometryTile::LayoutResult {
+ parent.invoke(&GeometryTile::onLayout, std::make_shared<GeometryTile::LayoutResult>(
std::move(renderData),
std::move(featureIndex),
std::move(glyphAtlasImage),
std::move(iconAtlas)
- }, correlationID);
+ ), correlationID);
}
} // namespace mbgl
diff --git a/src/mbgl/tile/raster_dem_tile.cpp b/src/mbgl/tile/raster_dem_tile.cpp
index cf70687ffe..c092809130 100644
--- a/src/mbgl/tile/raster_dem_tile.cpp
+++ b/src/mbgl/tile/raster_dem_tile.cpp
@@ -7,6 +7,7 @@
#include <mbgl/storage/resource.hpp>
#include <mbgl/storage/response.hpp>
#include <mbgl/renderer/tile_parameters.hpp>
+#include <mbgl/renderer/tile_render_data.hpp>
#include <mbgl/renderer/buckets/hillshade_bucket.hpp>
#include <mbgl/actor/scheduler.hpp>
@@ -35,6 +36,10 @@ RasterDEMTile::RasterDEMTile(const OverscaledTileID& id_,
RasterDEMTile::~RasterDEMTile() = default;
+std::unique_ptr<TileRenderData> RasterDEMTile::createRenderData() {
+ return std::make_unique<SharedBucketTileRenderData<HillshadeBucket>>(bucket);
+}
+
void RasterDEMTile::setError(std::exception_ptr err) {
loaded = true;
observer->onTileError(*this, err);
@@ -69,15 +74,8 @@ void RasterDEMTile::onError(std::exception_ptr err, const uint64_t resultCorrela
observer->onTileError(*this, err);
}
-void RasterDEMTile::upload(gfx::UploadPass& uploadPass) {
- if (bucket) {
- bucket->upload(uploadPass);
- }
-}
-
-
-Bucket* RasterDEMTile::getBucket(const style::Layer::Impl&) const {
- return bucket.get();
+bool RasterDEMTile::layerPropertiesUpdated(const Immutable<style::LayerProperties>&) {
+ return bool(bucket);
}
HillshadeBucket* RasterDEMTile::getBucket() const {
diff --git a/src/mbgl/tile/raster_dem_tile.hpp b/src/mbgl/tile/raster_dem_tile.hpp
index 165a5b9d2b..e6a6b6f9f5 100644
--- a/src/mbgl/tile/raster_dem_tile.hpp
+++ b/src/mbgl/tile/raster_dem_tile.hpp
@@ -59,21 +59,21 @@ namespace style {
class Layer;
} // namespace style
-class RasterDEMTile : public Tile {
+class RasterDEMTile final : public Tile {
public:
RasterDEMTile(const OverscaledTileID&,
const TileParameters&,
const Tileset&);
~RasterDEMTile() override;
+ std::unique_ptr<TileRenderData> createRenderData() override;
void setNecessity(TileNecessity) final;
void setError(std::exception_ptr);
void setMetadata(optional<Timestamp> modified, optional<Timestamp> expires);
void setData(std::shared_ptr<const std::string> data);
- void upload(gfx::UploadPass&) override;
- Bucket* getBucket(const style::Layer::Impl&) const override;
+ bool layerPropertiesUpdated(const Immutable<style::LayerProperties>& layerProperties) override;
HillshadeBucket* getBucket() const;
void backfillBorder(const RasterDEMTile& borderTile, const DEMTileNeighbors mask);
@@ -98,7 +98,7 @@ private:
// Contains the Bucket object for the tile. Buckets are render
// objects and they get added by tile parsing operations.
- std::unique_ptr<HillshadeBucket> bucket;
+ std::shared_ptr<HillshadeBucket> bucket;
};
diff --git a/src/mbgl/tile/raster_tile.cpp b/src/mbgl/tile/raster_tile.cpp
index 1d8e7f3b3c..50a0d700b8 100644
--- a/src/mbgl/tile/raster_tile.cpp
+++ b/src/mbgl/tile/raster_tile.cpp
@@ -7,6 +7,7 @@
#include <mbgl/storage/resource.hpp>
#include <mbgl/storage/response.hpp>
#include <mbgl/renderer/tile_parameters.hpp>
+#include <mbgl/renderer/tile_render_data.hpp>
#include <mbgl/renderer/buckets/raster_bucket.hpp>
#include <mbgl/actor/scheduler.hpp>
@@ -24,6 +25,10 @@ RasterTile::RasterTile(const OverscaledTileID& id_,
RasterTile::~RasterTile() = default;
+std::unique_ptr<TileRenderData> RasterTile::createRenderData() {
+ return std::make_unique<SharedBucketTileRenderData<RasterBucket>>(bucket);
+}
+
void RasterTile::setError(std::exception_ptr err) {
loaded = true;
observer->onTileError(*this, err);
@@ -58,14 +63,8 @@ void RasterTile::onError(std::exception_ptr err, const uint64_t resultCorrelatio
observer->onTileError(*this, err);
}
-void RasterTile::upload(gfx::UploadPass& uploadPass) {
- if (bucket) {
- bucket->upload(uploadPass);
- }
-}
-
-Bucket* RasterTile::getBucket(const style::Layer::Impl&) const {
- return bucket.get();
+bool RasterTile::layerPropertiesUpdated(const Immutable<style::LayerProperties>&) {
+ return bool(bucket);
}
void RasterTile::setMask(TileMask&& mask) {
diff --git a/src/mbgl/tile/raster_tile.hpp b/src/mbgl/tile/raster_tile.hpp
index f62ddebf57..49ca3239ef 100644
--- a/src/mbgl/tile/raster_tile.hpp
+++ b/src/mbgl/tile/raster_tile.hpp
@@ -15,21 +15,21 @@ namespace style {
class Layer;
} // namespace style
-class RasterTile : public Tile {
+class RasterTile final : public Tile {
public:
RasterTile(const OverscaledTileID&,
const TileParameters&,
const Tileset&);
~RasterTile() override;
+ std::unique_ptr<TileRenderData> createRenderData() override;
void setNecessity(TileNecessity) final;
void setError(std::exception_ptr);
void setMetadata(optional<Timestamp> modified, optional<Timestamp> expires);
void setData(std::shared_ptr<const std::string> data);
- void upload(gfx::UploadPass&) override;
- Bucket* getBucket(const style::Layer::Impl&) const override;
+ bool layerPropertiesUpdated(const Immutable<style::LayerProperties>& layerProperties) override;
void setMask(TileMask&&) override;
@@ -46,7 +46,7 @@ private:
// Contains the Bucket object for the tile. Buckets are render
// objects and they get added by tile parsing operations.
- std::unique_ptr<RasterBucket> bucket;
+ std::shared_ptr<RasterBucket> bucket;
};
} // namespace mbgl
diff --git a/src/mbgl/tile/tile.hpp b/src/mbgl/tile/tile.hpp
index 17a16b4666..4ba8bc1160 100644
--- a/src/mbgl/tile/tile.hpp
+++ b/src/mbgl/tile/tile.hpp
@@ -24,6 +24,7 @@ class LayerRenderData;
class TransformState;
class TileObserver;
class RenderLayer;
+class TileRenderData;
class RenderedQueryOptions;
class SourceQueryOptions;
class CollisionIndex;
@@ -45,6 +46,8 @@ public:
Tile(Kind, OverscaledTileID);
virtual ~Tile();
+ virtual std::unique_ptr<TileRenderData> createRenderData() = 0;
+
void setObserver(TileObserver* observer);
virtual void setNecessity(TileNecessity) {}
@@ -52,12 +55,6 @@ public:
// Mark this tile as no longer needed and cancel any pending work.
virtual void cancel();
- virtual void upload(gfx::UploadPass&) = 0;
- virtual Bucket* getBucket(const style::Layer::Impl&) const = 0;
- virtual const LayerRenderData* getLayerRenderData(const style::Layer::Impl&) const {
- assert(false);
- return nullptr;
- }
// Notifies this tile of the updated layer properties.
//
// Tile implementation should update the contained layer
@@ -65,9 +62,7 @@ public:
//
// Returns `true` if the corresponding render layer data is present in this tile (and i.e. it
// was succesfully updated); returns `false` otherwise.
- virtual bool layerPropertiesUpdated(const Immutable<style::LayerProperties>& layerProperties) {
- return bool(getBucket(*layerProperties->baseImpl));
- }
+ virtual bool layerPropertiesUpdated(const Immutable<style::LayerProperties>& layerProperties) = 0;
virtual void setShowCollisionBoxes(const bool) {}
virtual void setLayers(const std::vector<Immutable<style::LayerProperties>>&) {}
virtual void setMask(TileMask&&) {}
diff --git a/test/tile/custom_geometry_tile.test.cpp b/test/tile/custom_geometry_tile.test.cpp
index 1aed821cd6..fb905ac076 100644
--- a/test/tile/custom_geometry_tile.test.cpp
+++ b/test/tile/custom_geometry_tile.test.cpp
@@ -111,14 +111,14 @@ TEST(CustomGeometryTile, InvokeTileChanged) {
CustomGeometryTile tile(OverscaledTileID(0, 0, 0), "source", test.tileParameters, CustomGeometrySource::TileOptions(),
loaderActor);
+ Immutable<LayerProperties> layerProperties = makeMutable<CircleLayerProperties>(staticImmutableCast<CircleLayer::Impl>(layer.baseImpl));
StubTileObserver observer;
observer.tileChanged = [&] (const Tile&) {
// Once present, the bucket should never "disappear", which would cause
// flickering.
- ASSERT_NE(nullptr, tile.getBucket(*layer.baseImpl));
+ ASSERT_TRUE(tile.layerPropertiesUpdated(layerProperties));
};
- Immutable<LayerProperties> layerProperties = makeMutable<CircleLayerProperties>(staticImmutableCast<CircleLayer::Impl>(layer.baseImpl));
std::vector<Immutable<LayerProperties>> layers { layerProperties };
tile.setLayers(layers);
tile.setObserver(&observer);
diff --git a/test/tile/geojson_tile.test.cpp b/test/tile/geojson_tile.test.cpp
index bf42278e4c..cc2dbfced8 100644
--- a/test/tile/geojson_tile.test.cpp
+++ b/test/tile/geojson_tile.test.cpp
@@ -52,14 +52,14 @@ TEST(GeoJSONTile, Issue7648) {
features.push_back(mapbox::feature::feature<int16_t> { mapbox::geometry::point<int16_t>(0, 0) });
GeoJSONTile tile(OverscaledTileID(0, 0, 0), "source", test.tileParameters, features);
-
+ Immutable<LayerProperties> layerProperties = makeMutable<CircleLayerProperties>(staticImmutableCast<CircleLayer::Impl>(layer.baseImpl));
StubTileObserver observer;
observer.tileChanged = [&] (const Tile&) {
// Once present, the bucket should never "disappear", which would cause
// flickering.
- ASSERT_NE(nullptr, tile.getBucket(*layer.baseImpl));
+ ASSERT_TRUE(tile.layerPropertiesUpdated(layerProperties));
};
- Immutable<LayerProperties> layerProperties = makeMutable<CircleLayerProperties>(staticImmutableCast<CircleLayer::Impl>(layer.baseImpl));
+
std::vector<Immutable<LayerProperties>> layers { layerProperties };
tile.setLayers(layers);
tile.setObserver(&observer);
@@ -95,18 +95,18 @@ TEST(GeoJSONTile, Issue9927) {
}
ASSERT_TRUE(tile.isRenderable());
- ASSERT_NE(nullptr, tile.getBucket(*layer.baseImpl));
+ ASSERT_TRUE(tile.layerPropertiesUpdated(layerProperties));
// Make sure that once we've had a renderable tile and then receive erroneous data, we retain
// the previously rendered data and keep the tile renderable.
tile.setError(std::make_exception_ptr(std::runtime_error("Connection offline")));
ASSERT_TRUE(tile.isRenderable());
- ASSERT_NE(nullptr, tile.getBucket(*layer.baseImpl));
+ ASSERT_TRUE(tile.layerPropertiesUpdated(layerProperties));
// Then simulate a parsing failure and make sure that we keep it renderable in this situation
// as well. We're using 3 as a correlationID since we've done two three calls that increment
// this counter (as part of the GeoJSONTile constructor, setLayers, and setPlacementConfig).
tile.onError(std::make_exception_ptr(std::runtime_error("Parse error")), 3);
ASSERT_TRUE(tile.isRenderable());
- ASSERT_NE(nullptr, tile.getBucket(*layer.baseImpl));
+ ASSERT_TRUE(tile.layerPropertiesUpdated(layerProperties));
}