summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortobrun <tobrun.van.nuland@gmail.com>2019-07-19 11:06:03 +0200
committertobrun <tobrun.van.nuland@gmail.com>2019-08-01 17:33:14 +0300
commit9cf3ddae217975f2ed94ce6fde2e485ebebf29b7 (patch)
tree8c3be73d6efc1a4a61f7bbdeb04640007fedacec
parent04309e01ceaa267becef16ed9db6f91fcea91f59 (diff)
downloadqtlocation-mapboxgl-upstream/tvn-delay-renderthread-creation.tar.gz
[android] delay render thread creation for TextureView implementationupstream/tvn-delay-renderthread-creation
-rw-r--r--platform/android/CHANGELOG.md4
-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/renderer/textureview/MapboxTextureView.java39
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewMapRenderer.java32
-rw-r--r--platform/android/scripts/exclude-activity-gen.json3
5 files changed, 70 insertions, 12 deletions
diff --git a/platform/android/CHANGELOG.md b/platform/android/CHANGELOG.md
index 8e7bd0ed60..5629334c1c 100644
--- a/platform/android/CHANGELOG.md
+++ b/platform/android/CHANGELOG.md
@@ -5,8 +5,8 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to
## master
### Bug fixes
-
-- Fixed an issue where it was possible to set the map’s content insets then tilt the map enough to see the horizon, causing performance issues [#15195](https://github.com/mapbox/mapbox-gl-native/pull/15195)
+ - Delay render thread creation for TextureView implementation [#15173](https://github.com/mapbox/mapbox-gl-native/pull/15173)
+ - Fixed an issue where it was possible to set the map’s content insets then tilt the map enough to see the horizon, causing performance issues [#15195](https://github.com/mapbox/mapbox-gl-native/pull/15195)
## 8.0.2 - July 31, 2019
[Changes](https://github.com/mapbox/mapbox-gl-native/compare/android-v8.0.1...android-v8.0.2) since [Mapbox Maps SDK for Android v8.0.1](https://github.com/mapbox/mapbox-gl-native/releases/tag/android-v8.0.1):
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 1367de8729..e6d7e4ca3f 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
@@ -14,7 +14,6 @@ import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
-import android.view.TextureView;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -30,6 +29,7 @@ import com.mapbox.mapboxsdk.location.LocationComponent;
import com.mapbox.mapboxsdk.maps.renderer.MapRenderer;
import com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.GLSurfaceViewMapRenderer;
import com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.MapboxGLSurfaceView;
+import com.mapbox.mapboxsdk.maps.renderer.textureview.MapboxTextureView;
import com.mapbox.mapboxsdk.maps.renderer.textureview.TextureViewMapRenderer;
import com.mapbox.mapboxsdk.maps.widgets.CompassView;
import com.mapbox.mapboxsdk.net.ConnectivityReceiver;
@@ -284,7 +284,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
private void initialiseDrawingSurface(MapboxMapOptions options) {
String localFontFamily = options.getLocalIdeographFontFamily();
if (options.getTextureMode()) {
- TextureView textureView = new TextureView(getContext());
+ MapboxTextureView textureView = new MapboxTextureView(getContext());
boolean translucentSurface = options.getTranslucentTextureSurface();
mapRenderer = new TextureViewMapRenderer(getContext(),
textureView, localFontFamily, translucentSurface) {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/MapboxTextureView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/MapboxTextureView.java
new file mode 100644
index 0000000000..ab12918852
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/MapboxTextureView.java
@@ -0,0 +1,39 @@
+package com.mapbox.mapboxsdk.maps.renderer.textureview;
+
+import android.content.Context;
+import android.support.annotation.Nullable;
+import android.util.AttributeSet;
+import android.view.TextureView;
+
+/**
+ * {@link android.view.TextureView} extension that notifies a listener when the view is attached to the window,
+ * which is the point we can create the GL thread. Refs #13601
+ */
+public class MapboxTextureView extends TextureView {
+
+ private OnViewAttachedListener listener;
+
+ public MapboxTextureView(Context context) {
+ super(context);
+ }
+
+ public MapboxTextureView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public void setOnViewAttachedListener(@Nullable OnViewAttachedListener listener) {
+ this.listener = listener;
+ }
+
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ if (listener != null) {
+ listener.onViewAttached();
+ }
+ }
+
+ public interface OnViewAttachedListener {
+ void onViewAttached();
+ }
+}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewMapRenderer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewMapRenderer.java
index 46e6463fe8..3cfd659e76 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewMapRenderer.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewMapRenderer.java
@@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.maps.renderer.textureview;
import android.content.Context;
import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import android.view.TextureView;
import com.mapbox.mapboxsdk.maps.renderer.MapRenderer;
@@ -16,6 +17,7 @@ import javax.microedition.khronos.opengles.GL10;
* @see MapRenderer
*/
public class TextureViewMapRenderer extends MapRenderer {
+ @Nullable
private TextureViewRenderThread renderThread;
private boolean translucentSurface;
@@ -25,16 +27,23 @@ public class TextureViewMapRenderer extends MapRenderer {
* @param context the current Context
* @param textureView the TextureView
* @param localIdeographFontFamily the local font family
- * @param translucentSurface the translucency flag
+ * @param translucentSurface the translucency flag
*/
public TextureViewMapRenderer(@NonNull Context context,
- @NonNull TextureView textureView,
+ @NonNull final MapboxTextureView textureView,
String localIdeographFontFamily,
boolean translucentSurface) {
super(context, localIdeographFontFamily);
this.translucentSurface = translucentSurface;
- renderThread = new TextureViewRenderThread(textureView, this);
- renderThread.start();
+ textureView.setOnViewAttachedListener(new MapboxTextureView.OnViewAttachedListener() {
+ @Override
+ public void onViewAttached() {
+ if (renderThread == null) {
+ renderThread = new TextureViewRenderThread(textureView, TextureViewMapRenderer.this);
+ renderThread.start();
+ }
+ }
+ });
}
/**
@@ -74,6 +83,7 @@ public class TextureViewMapRenderer extends MapRenderer {
*/
@Override
public void requestRender() {
+ assert renderThread != null;
renderThread.requestRender();
}
@@ -82,6 +92,7 @@ public class TextureViewMapRenderer extends MapRenderer {
*/
@Override
public void queueEvent(Runnable runnable) {
+ assert renderThread != null;
renderThread.queueEvent(runnable);
}
@@ -90,7 +101,9 @@ public class TextureViewMapRenderer extends MapRenderer {
*/
@Override
public void onStop() {
- renderThread.onPause();
+ if (renderThread != null) {
+ renderThread.onPause();
+ }
}
/**
@@ -98,7 +111,9 @@ public class TextureViewMapRenderer extends MapRenderer {
*/
@Override
public void onStart() {
- renderThread.onResume();
+ if (renderThread != null) {
+ renderThread.onResume();
+ }
}
/**
@@ -106,10 +121,13 @@ public class TextureViewMapRenderer extends MapRenderer {
*/
@Override
public void onDestroy() {
- renderThread.onDestroy();
+ if (renderThread != null) {
+ renderThread.onDestroy();
+ }
}
public boolean isTranslucentSurface() {
return translucentSurface;
}
+
}
diff --git a/platform/android/scripts/exclude-activity-gen.json b/platform/android/scripts/exclude-activity-gen.json
index 0f5bb81b55..e021807e77 100644
--- a/platform/android/scripts/exclude-activity-gen.json
+++ b/platform/android/scripts/exclude-activity-gen.json
@@ -52,5 +52,6 @@
"ChildFragmentMapInDialogActivity",
"PerformanceMeasurementActivity",
"DownloadRegionActivity",
- "CacheManagementActivity"
+ "CacheManagementActivity",
+ "TextureRecyclerViewActivity"
]