diff options
author | Tobrun <tobrun@mapbox.com> | 2017-04-18 16:12:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-18 16:12:27 +0200 |
commit | 8e9eaaabfc2d1947e63d502116f9d27d2cc645f7 (patch) | |
tree | 19152df9bbc21e3e1d67b5ea5c40bfaadf381ee3 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java | |
parent | ddecdeca9493ac1caaae2301eb822bdbf2f75ff9 (diff) | |
download | qtlocation-mapboxgl-8e9eaaabfc2d1947e63d502116f9d27d2cc645f7.tar.gz |
[android] - synchronize display and context initalisation with create surface to avoid EGL bad surface (#8759)
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java | 34 |
1 files changed, 18 insertions, 16 deletions
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); + } } /** |