diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2017-10-31 18:12:04 +0200 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2017-11-03 09:19:39 -0700 |
commit | 3b2bd7ce4f7087f51f2aeace22fe60c5c83ee1d9 (patch) | |
tree | 6e7b25bca673728a432e1ec6ee10a86a5d7d40fb /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java | |
parent | e9bb4d1582dafcb4ca87bdfc6bb58bac2d405954 (diff) | |
download | qtlocation-mapboxgl-3b2bd7ce4f7087f51f2aeace22fe60c5c83ee1d9.tar.gz |
[android] bring back texture view
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 | 66 |
1 files changed, 45 insertions, 21 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 b5546f2cc4..ba09df2cbe 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 @@ -15,6 +15,7 @@ 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.view.ViewGroup; import android.view.ViewTreeObserver; @@ -29,6 +30,7 @@ import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.constants.Style; import com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.GLSurfaceViewMapRenderer; import com.mapbox.mapboxsdk.maps.renderer.MapRenderer; +import com.mapbox.mapboxsdk.maps.renderer.textureview.TextureViewMapRenderer; import com.mapbox.mapboxsdk.maps.widgets.CompassView; import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings; @@ -139,7 +141,7 @@ public class MapView extends FrameLayout { } else { getViewTreeObserver().removeGlobalOnLayoutListener(this); } - initialiseDrawingSurface(); + initialiseDrawingSurface(options); } }); } @@ -289,31 +291,53 @@ public class MapView extends FrameLayout { } } - private void initialiseDrawingSurface() { - GLSurfaceView glSurfaceView = (GLSurfaceView) findViewById(R.id.surfaceView); - glSurfaceView.setZOrderMediaOverlay(mapboxMapOptions.getRenderSurfaceOnTop()); + private void initialiseDrawingSurface(MapboxMapOptions options) { + if (options.getTextureMode()) { + TextureView textureView = new TextureView(getContext()); + mapRenderer = new TextureViewMapRenderer(getContext(), textureView) { + @Override + protected void onSurfaceCreated(GL10 gl, EGLConfig config) { + MapView.this.post(new Runnable() { + @Override + public void run() { + // Initialise only once + if (mapboxMap == null) { + initialiseMap(); + mapboxMap.onStart(); + } + } + }); - GLSurfaceViewMapRenderer mapRenderer = new GLSurfaceViewMapRenderer(getContext(), glSurfaceView) { - @Override - public void onSurfaceCreated(GL10 gl, EGLConfig config) { - MapView.this.post(new Runnable() { - @Override - public void run() { - // Initialise only once - if (mapboxMap == null) { - initialiseMap(); - mapboxMap.onStart(); + super.onSurfaceCreated(gl, config); + } + }; + addView(textureView, 0); + } else { + GLSurfaceView glSurfaceView = (GLSurfaceView) findViewById(R.id.surfaceView); + glSurfaceView.setZOrderMediaOverlay(mapboxMapOptions.getRenderSurfaceOnTop()); + + mapRenderer = new GLSurfaceViewMapRenderer(getContext(), glSurfaceView) { + @Override + public void onSurfaceCreated(GL10 gl, EGLConfig config) { + MapView.this.post(new Runnable() { + @Override + public void run() { + // Initialise only once + if (mapboxMap == null) { + initialiseMap(); + mapboxMap.onStart(); + } } - } - }); + }); - super.onSurfaceCreated(gl, config); - } - }; + super.onSurfaceCreated(gl, config); + } + }; - glSurfaceView.setVisibility(View.VISIBLE); + glSurfaceView.setVisibility(View.VISIBLE); + + } - this.mapRenderer = mapRenderer; nativeMapView = new NativeMapView(this, mapRenderer); nativeMapView.resizeView(getMeasuredWidth(), getMeasuredHeight()); } |