mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Release TextureView surface within FlutterTextureView when disconnected. (#48535) (flutter/engine#15899)
This commit is contained in:
parent
74cbca7c98
commit
fbd6f7a1f9
@ -38,6 +38,8 @@ public class FlutterTextureView extends TextureView implements RenderSurface {
|
||||
private boolean isAttachedToFlutterRenderer = false;
|
||||
@Nullable
|
||||
private FlutterRenderer flutterRenderer;
|
||||
@Nullable
|
||||
private Surface renderSurface;
|
||||
|
||||
// Connects the {@code SurfaceTexture} beneath this {@code TextureView} with Flutter's native code.
|
||||
// Callbacks are received by this Object and then those messages are forwarded to our
|
||||
@ -172,7 +174,8 @@ public class FlutterTextureView extends TextureView implements RenderSurface {
|
||||
throw new IllegalStateException("connectSurfaceToRenderer() should only be called when flutterRenderer and getSurfaceTexture() are non-null.");
|
||||
}
|
||||
|
||||
flutterRenderer.startRenderingToSurface(new Surface(getSurfaceTexture()));
|
||||
renderSurface = new Surface(getSurfaceTexture());
|
||||
flutterRenderer.startRenderingToSurface(renderSurface);
|
||||
}
|
||||
|
||||
// FlutterRenderer must be non-null.
|
||||
@ -192,5 +195,7 @@ public class FlutterTextureView extends TextureView implements RenderSurface {
|
||||
}
|
||||
|
||||
flutterRenderer.stopRenderingToSurface();
|
||||
renderSurface.release();
|
||||
renderSurface = null;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user