feat! js_interop improvements
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import 'dart:async';
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'dart:io';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:thermion_dart/thermion_dart.dart';
|
||||
|
||||
import 'package:thermion_dart/src/viewer/src/ffi/src/thermion_viewer_ffi.dart';
|
||||
import 'package:thermion_dart/src/viewer/src/ffi/src/ffi_filament_app.dart';
|
||||
import 'package:thermion_dart/src/filament/src/implementation/ffi_filament_app.dart';
|
||||
|
||||
import 'package:thermion_flutter_platform_interface/thermion_flutter_platform_interface.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
@@ -43,23 +42,22 @@ class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform {
|
||||
return asset.buffer.asUint8List(asset.offsetInBytes);
|
||||
}
|
||||
|
||||
Future<ThermionViewer> createViewer({ThermionFlutterOptions? options}) async {
|
||||
|
||||
Future<ThermionViewer> createViewer() async {
|
||||
var driverPlatform = await channel.invokeMethod("getDriverPlatform");
|
||||
|
||||
var platformPtr = driverPlatform == null
|
||||
? nullptr
|
||||
: Pointer<Void>.fromAddress(driverPlatform);
|
||||
: VoidPointerClass.fromAddress(driverPlatform);
|
||||
|
||||
var sharedContext = await channel.invokeMethod("getSharedContext");
|
||||
|
||||
var sharedContextPtr = sharedContext == null
|
||||
? nullptr
|
||||
: Pointer<Void>.fromAddress(sharedContext);
|
||||
: VoidPointerClass.fromAddress(sharedContext);
|
||||
|
||||
late Backend backend;
|
||||
if (options?.backend != null) {
|
||||
switch (options!.backend) {
|
||||
if (options.backend != null) {
|
||||
switch (options.backend) {
|
||||
case Backend.VULKAN:
|
||||
if (!Platform.isWindows) {
|
||||
throw Exception("Vulkan only supported on Windows");
|
||||
@@ -93,12 +91,12 @@ class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform {
|
||||
resourceLoader: loadAsset,
|
||||
platform: platformPtr,
|
||||
sharedContext: sharedContextPtr,
|
||||
uberArchivePath: options?.uberarchivePath);
|
||||
uberArchivePath: options.uberarchivePath);
|
||||
|
||||
if (FilamentApp.instance == null) {
|
||||
await FFIFilamentApp.create(config: config);
|
||||
FilamentApp.instance!.onDestroy(() async {
|
||||
if(Platform.isWindows) {
|
||||
if (Platform.isWindows) {
|
||||
await channel.invokeMethod("destroyContext");
|
||||
}
|
||||
_swapChain = null;
|
||||
@@ -160,8 +158,9 @@ class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform {
|
||||
|
||||
_swapChain = await FilamentApp.instance!
|
||||
.createHeadlessSwapChain(descriptor.width, descriptor.height);
|
||||
|
||||
_logger.info("Created headless swapchain ${descriptor.width}x${descriptor.height}");
|
||||
|
||||
_logger.info(
|
||||
"Created headless swapchain ${descriptor.width}x${descriptor.height}");
|
||||
|
||||
await FilamentApp.instance!.register(_swapChain!, view);
|
||||
} else if (Platform.isAndroid) {
|
||||
@@ -214,7 +213,7 @@ class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform {
|
||||
PlatformTextureDescriptor texture,
|
||||
View view,
|
||||
int width,
|
||||
int height) async {
|
||||
int height) async {
|
||||
var newTexture = await createTextureAndBindToView(view, width, height);
|
||||
if (newTexture == null) {
|
||||
throw Exception();
|
||||
|
||||
Reference in New Issue
Block a user