call method channel destroyContext
This commit is contained in:
@@ -44,16 +44,10 @@ class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<ThermionViewer> createViewer({ThermionFlutterOptions? options}) async {
|
Future<ThermionViewer> createViewer({ThermionFlutterOptions? options}) async {
|
||||||
var resourceLoader = Pointer<Void>.fromAddress(
|
|
||||||
await channel.invokeMethod("getResourceLoaderWrapper"));
|
|
||||||
|
|
||||||
if (resourceLoader == nullptr) {
|
|
||||||
throw Exception("Failed to get resource loader");
|
|
||||||
}
|
|
||||||
|
|
||||||
var driverPlatform = await channel.invokeMethod("getDriverPlatform");
|
var driverPlatform = await channel.invokeMethod("getDriverPlatform");
|
||||||
|
|
||||||
var driverPtr = driverPlatform == null
|
var platformPtr = driverPlatform == null
|
||||||
? nullptr
|
? nullptr
|
||||||
: Pointer<Void>.fromAddress(driverPlatform);
|
: Pointer<Void>.fromAddress(driverPlatform);
|
||||||
|
|
||||||
@@ -97,12 +91,17 @@ class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform {
|
|||||||
final config = FFIFilamentConfig(
|
final config = FFIFilamentConfig(
|
||||||
backend: backend,
|
backend: backend,
|
||||||
resourceLoader: loadAsset,
|
resourceLoader: loadAsset,
|
||||||
driver: driverPtr,
|
platform: platformPtr,
|
||||||
platform: nullptr,
|
|
||||||
sharedContext: sharedContextPtr,
|
sharedContext: sharedContextPtr,
|
||||||
uberArchivePath: options?.uberarchivePath);
|
uberArchivePath: options?.uberarchivePath);
|
||||||
|
|
||||||
await FFIFilamentApp.create(config: config);
|
if (FilamentApp.instance == null) {
|
||||||
|
await FFIFilamentApp.create(config: config);
|
||||||
|
FilamentApp.instance!.onDestroy(() async {
|
||||||
|
await channel.invokeMethod("destroyContext");
|
||||||
|
_swapChain = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
final viewer = ThermionViewerFFI(
|
final viewer = ThermionViewerFFI(
|
||||||
loadAssetFromUri: loadAsset,
|
loadAssetFromUri: loadAsset,
|
||||||
@@ -110,8 +109,6 @@ class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform {
|
|||||||
|
|
||||||
await viewer.initialized;
|
await viewer.initialized;
|
||||||
|
|
||||||
viewer.onDispose(() async {});
|
|
||||||
|
|
||||||
// this implementation renders directly into a texture/render target
|
// this implementation renders directly into a texture/render target
|
||||||
// for some reason we still need to create a (headless) swapchain, but the
|
// for some reason we still need to create a (headless) swapchain, but the
|
||||||
// actual dimensions don't matter
|
// actual dimensions don't matter
|
||||||
@@ -213,6 +210,7 @@ class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform {
|
|||||||
View view,
|
View view,
|
||||||
int width,
|
int width,
|
||||||
int height) async {
|
int height) async {
|
||||||
|
|
||||||
var newTexture = await createTextureAndBindToView(view, width, height);
|
var newTexture = await createTextureAndBindToView(view, width, height);
|
||||||
if (newTexture == null) {
|
if (newTexture == null) {
|
||||||
throw Exception();
|
throw Exception();
|
||||||
|
|||||||
Reference in New Issue
Block a user