Improve Vulkan Android surface lifecycle (#4323)
This commit is contained in:
@@ -35,7 +35,6 @@ public class MapLibreVulkanSurfaceView extends MapLibreSurfaceView {
|
||||
|
||||
boolean sizeChanged = false;
|
||||
boolean initSurface = false;
|
||||
boolean destroySurface = false;
|
||||
boolean wantRenderNotification = false;
|
||||
boolean doRenderNotification = false;
|
||||
int w = 0;
|
||||
@@ -64,10 +63,10 @@ public class MapLibreVulkanSurfaceView extends MapLibreSurfaceView {
|
||||
// lost surface
|
||||
if (!hasSurface && !waitingForSurface) {
|
||||
MapLibreVulkanSurfaceView view = mSurfaceViewWeakRef.get();
|
||||
if (view != null) {
|
||||
destroySurface = true;
|
||||
graphicsSurfaceCreated = false;
|
||||
if (view != null && graphicsSurfaceCreated) {
|
||||
view.renderer.onSurfaceDestroyed();
|
||||
}
|
||||
graphicsSurfaceCreated = false;
|
||||
waitingForSurface = true;
|
||||
renderThreadManager.notifyAll();
|
||||
}
|
||||
@@ -129,15 +128,6 @@ public class MapLibreVulkanSurfaceView extends MapLibreSurfaceView {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (destroySurface) {
|
||||
MapLibreVulkanSurfaceView view = mSurfaceViewWeakRef.get();
|
||||
if (view != null) {
|
||||
view.renderer.onSurfaceDestroyed();
|
||||
destroySurface = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (initSurface) {
|
||||
MapLibreVulkanSurfaceView view = mSurfaceViewWeakRef.get();
|
||||
if (view != null) {
|
||||
|
||||
@@ -34,7 +34,6 @@ public class VulkanTextureViewRenderThread extends TextureViewRenderThread {
|
||||
while (true) {
|
||||
Runnable event = null;
|
||||
boolean createSurface = false;
|
||||
boolean destroySurface = false;
|
||||
boolean sizeChanged = false;
|
||||
int w = -1;
|
||||
int h = -1;
|
||||
@@ -54,13 +53,15 @@ public class VulkanTextureViewRenderThread extends TextureViewRenderThread {
|
||||
}
|
||||
|
||||
if (this.destroySurface) {
|
||||
destroySurface = true;
|
||||
if (surface != null) {
|
||||
mapRenderer.onSurfaceDestroyed();
|
||||
surface.release();
|
||||
surface = null;
|
||||
}
|
||||
|
||||
this.hasNativeSurface = false;
|
||||
this.destroySurface = false;
|
||||
lock.notifyAll();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -108,16 +109,6 @@ public class VulkanTextureViewRenderThread extends TextureViewRenderThread {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (destroySurface) {
|
||||
mapRenderer.onSurfaceDestroyed();
|
||||
synchronized (lock) {
|
||||
this.hasNativeSurface = false;
|
||||
lock.notifyAll();
|
||||
}
|
||||
destroySurface = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the surface size has changed inform the map renderer.
|
||||
if (sizeChanged) {
|
||||
mapRenderer.onSurfaceChanged(w, h);
|
||||
|
||||
Reference in New Issue
Block a user