summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobrun <tobrun@mapbox.com>2017-04-18 16:12:27 +0200
committerGitHub <noreply@github.com>2017-04-18 16:12:27 +0200
commit8e9eaaabfc2d1947e63d502116f9d27d2cc645f7 (patch)
tree19152df9bbc21e3e1d67b5ea5c40bfaadf381ee3
parentddecdeca9493ac1caaae2301eb822bdbf2f75ff9 (diff)
downloadqtlocation-mapboxgl-8e9eaaabfc2d1947e63d502116f9d27d2cc645f7.tar.gz
[android] - synchronize display and context initalisation with create surface to avoid EGL bad surface (#8759)
-rw-r--r--platform/android/CHANGELOG.md1
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java34
2 files changed, 19 insertions, 16 deletions
diff --git a/platform/android/CHANGELOG.md b/platform/android/CHANGELOG.md
index 2d3660faaf..8dcdcb296d 100644
--- a/platform/android/CHANGELOG.md
+++ b/platform/android/CHANGELOG.md
@@ -17,6 +17,7 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to
* OfflineRegion are validated if the bounds is found in the world bounds, else onError will be invoked [#8517](https://github.com/mapbox/mapbox-gl-native/pull/8517)
* Polygon holes [#8557](https://github.com/mapbox/mapbox-gl-native/pull/8557) and [#8722](https://github.com/mapbox/mapbox-gl-native/pull/8722)
* Custom location source [#8710](https://github.com/mapbox/mapbox-gl-native/pull/8710)
+* Ensure surface is created after display and context [#8759](https://github.com/mapbox/mapbox-gl-native/pull/8759)
## 5.0.2 - April 3, 2017
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 46db93fa28..fc7042f386 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
@@ -62,6 +62,7 @@ import java.util.List;
public class MapView extends FrameLayout {
private NativeMapView nativeMapView;
+ private boolean textureMode;
private boolean destroyed;
private boolean hasSurface;
@@ -105,12 +106,14 @@ public class MapView extends FrameLayout {
return;
}
+ // determine render surface
+ textureMode = options.getTextureMode();
+
// inflate view
View view = LayoutInflater.from(context).inflate(R.layout.mapbox_mapview_internal, this);
CompassView compassView = (CompassView) view.findViewById(R.id.compassView);
MyLocationView myLocationView = (MyLocationView) view.findViewById(R.id.userLocationView);
ImageView attrView = (ImageView) view.findViewById(R.id.attributionView);
- initalizeDrawingSurface(context, options);
// add accessibility support
setContentDescription(context.getString(R.string.mapbox_mapActionDescription));
@@ -167,18 +170,6 @@ public class MapView extends FrameLayout {
mapboxMap.initialise(context, options);
}
- private void initalizeDrawingSurface(Context context, MapboxMapOptions options) {
- if (options.getTextureMode()) {
- TextureView textureView = new TextureView(context);
- textureView.setSurfaceTextureListener(new SurfaceTextureListener());
- addView(textureView, 0);
- } else {
- SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
- surfaceView.getHolder().addCallback(new SurfaceCallback());
- surfaceView.setVisibility(View.VISIBLE);
- }
- }
-
//
// Lifecycle events
//
@@ -202,11 +193,22 @@ public class MapView extends FrameLayout {
mapboxMap.onRestoreInstanceState(savedInstanceState);
}
- // Initialize EGL
+ initialiseDrawingSurface(textureMode);
+ addOnMapChangedListener(mapCallback = new MapCallback(mapboxMap));
+ }
+
+ private void initialiseDrawingSurface(boolean textureMode) {
nativeMapView.initializeDisplay();
nativeMapView.initializeContext();
-
- addOnMapChangedListener(mapCallback = new MapCallback(mapboxMap));
+ if (textureMode) {
+ TextureView textureView = new TextureView(getContext());
+ textureView.setSurfaceTextureListener(new SurfaceTextureListener());
+ addView(textureView, 0);
+ } else {
+ SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
+ surfaceView.getHolder().addCallback(new SurfaceCallback());
+ surfaceView.setVisibility(View.VISIBLE);
+ }
}
/**