diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2017-07-21 16:15:30 +0300 |
---|---|---|
committer | Ivo van Dongen <ivovandongen@users.noreply.github.com> | 2017-09-22 23:33:56 +0300 |
commit | 347d7c19c0a70f91252163b14e37583eea83fdd5 (patch) | |
tree | c46968ba9fb947be6b6387ab18b10a0fede35f59 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java | |
parent | e780cdc29ee82459a75db5aba2e72c5536a2d1b0 (diff) | |
download | qtlocation-mapboxgl-347d7c19c0a70f91252163b14e37583eea83fdd5.tar.gz |
[android] async rendering
- introduces GLSurfaceView
- introduces Orchestration thread
- renders on the gl thread
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java')
-rwxr-xr-x | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java index 4f5037e4b3..a97b7cc8f2 100755 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java @@ -4,12 +4,12 @@ import android.content.Context; import android.graphics.Bitmap; import android.graphics.PointF; import android.graphics.RectF; +import android.opengl.GLSurfaceView; import android.support.annotation.IntRange; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.text.TextUtils; import android.util.DisplayMetrics; -import android.view.Surface; import com.mapbox.mapboxsdk.LibraryLoader; import com.mapbox.mapboxsdk.annotations.Icon; @@ -35,10 +35,13 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import javax.microedition.khronos.egl.EGLConfig; +import javax.microedition.khronos.opengles.GL10; + import timber.log.Timber; // Class that wraps the native methods for convenience -final class NativeMapView { +final class NativeMapView implements GLSurfaceView.Renderer { // Flag to indicating destroy was called private boolean destroyed = false; @@ -97,20 +100,6 @@ final class NativeMapView { destroyed = true; } - public void createSurface(Surface surface) { - if (isDestroyedOn("createSurface")) { - return; - } - nativeCreateSurface(surface); - } - - public void destroySurface() { - if (isDestroyedOn("destroySurface")) { - return; - } - nativeDestroySurface(); - } - public void update() { if (isDestroyedOn("update")) { return; @@ -156,7 +145,7 @@ final class NativeMapView { nativeResizeView(width, height); } - public void resizeFramebuffer(int fbWidth, int fbHeight) { + private void resizeFramebuffer(int fbWidth, int fbHeight) { if (isDestroyedOn("resizeFramebuffer")) { return; } @@ -1141,6 +1130,32 @@ final class NativeMapView { void addSnapshotCallback(@NonNull MapboxMap.SnapshotReadyCallback callback) { snapshotReadyCallback = callback; scheduleTakeSnapshot(); - render(); + mapView.onInvalidate(); + // TODO. this should do a request render + //render(); + } + + // + // GLSurfaceView.Renderer + // + + @Override + public void onSurfaceCreated(GL10 gl, EGLConfig config) { + Timber.i("[%s] onSurfaceCreated", Thread.currentThread().getName()); + //TODO: callback to map to re-create renderer? + } + + @Override + public void onSurfaceChanged(GL10 gl, int width, int height) { + Timber.i("[%s] onSurfaceChanged %sx%s", Thread.currentThread().getName(), width, height); + // Sets the current view port to the new size. + gl.glViewport(0, 0, width, height); + resizeFramebuffer(width, height); + // resizeView(width, height); Done from MapView#onSizeChanged + } + + @Override + public void onDrawFrame(GL10 gl) { + nativeRender(); } } |