fix: addDestroySwapchain argument to createViewer() (true by default). This is only used on iOS/macOS where a single swapchain is shared between all render targets
This commit is contained in:
@@ -11,8 +11,8 @@ import 'package:thermion_flutter_platform_interface/thermion_flutter_platform_in
|
|||||||
class ThermionFlutterPlugin {
|
class ThermionFlutterPlugin {
|
||||||
ThermionFlutterPlugin._();
|
ThermionFlutterPlugin._();
|
||||||
|
|
||||||
static Future<ThermionViewer> createViewer() {
|
static Future<ThermionViewer> createViewer({bool destroySwapchain = true}) {
|
||||||
return ThermionFlutterPlatform.instance.createViewer();
|
return ThermionFlutterPlatform.instance.createViewer(destroySwapchain: destroySwapchain);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform {
|
|||||||
return asset.buffer.asUint8List(asset.offsetInBytes);
|
return asset.buffer.asUint8List(asset.offsetInBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ThermionViewer> createViewer() async {
|
Future<ThermionViewer> createViewer({bool destroySwapchain = true}) async {
|
||||||
var driverPlatform = await channel.invokeMethod("getDriverPlatform");
|
var driverPlatform = await channel.invokeMethod("getDriverPlatform");
|
||||||
|
|
||||||
var platformPtr = driverPlatform == null
|
var platformPtr = driverPlatform == null
|
||||||
@@ -118,7 +118,13 @@ class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform {
|
|||||||
// TODO - see if we can use `renderStandaloneView` in FilamentViewer to
|
// TODO - see if we can use `renderStandaloneView` in FilamentViewer to
|
||||||
// avoid this
|
// avoid this
|
||||||
if (Platform.isMacOS || Platform.isIOS) {
|
if (Platform.isMacOS || Platform.isIOS) {
|
||||||
_swapChain = await FilamentApp.instance!.createHeadlessSwapChain(1, 1, hasStencilBuffer: true);
|
if(destroySwapchain && _swapChain != null) {
|
||||||
|
await FilamentApp.instance!.destroySwapChain(_swapChain!);
|
||||||
|
_swapChain = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_swapChain ??= await FilamentApp.instance!
|
||||||
|
.createHeadlessSwapChain(1, 1, hasStencilBuffer: true);
|
||||||
await FilamentApp.instance!.register(_swapChain!, viewer.view);
|
await FilamentApp.instance!.register(_swapChain!, viewer.view);
|
||||||
await viewer.view.setRenderable(true);
|
await viewer.view.setRenderable(true);
|
||||||
}
|
}
|
||||||
@@ -179,10 +185,8 @@ class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_swapChain = await FilamentApp.instance!.createHeadlessSwapChain(
|
_swapChain = await FilamentApp.instance!.createHeadlessSwapChain(
|
||||||
descriptor.width,
|
descriptor.width, descriptor.height,
|
||||||
descriptor.height,
|
hasStencilBuffer: true);
|
||||||
hasStencilBuffer: true
|
|
||||||
);
|
|
||||||
|
|
||||||
_logger.info(
|
_logger.info(
|
||||||
"Created headless swapchain ${descriptor.width}x${descriptor.height}",
|
"Created headless swapchain ${descriptor.width}x${descriptor.height}",
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ abstract class ThermionFlutterPlatform extends PlatformInterface {
|
|||||||
///
|
///
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
Future<ThermionViewer> createViewer() {
|
Future<ThermionViewer> createViewer({bool destroySwapchain = true}) {
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user