summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
diff options
context:
space:
mode:
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.java66
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());
}