fix resourceLoader
This commit is contained in:
@@ -189,13 +189,9 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
||||
createDisplayLink()
|
||||
result(self.flutterTextureId)
|
||||
// print("texture id \(pixelBufferflutterTextureId)")
|
||||
case "getLoadResourceFn":
|
||||
|
||||
case "getResourceLoader":
|
||||
let callback = make_resource_loader(loadResource, freeResource, Unmanaged.passUnretained(self).toOpaque())
|
||||
|
||||
result(unsafeBitCast(callback, to:Int64.self))
|
||||
case "getFreeResourceFn":
|
||||
result(unsafeBitCast(freeResource, to:Int64.self))
|
||||
case "getGlTextureId":
|
||||
result(FlutterMethodNotImplemented)
|
||||
case "getSurface":
|
||||
|
||||
@@ -95,19 +95,13 @@ class FilamentController {
|
||||
_textureId =
|
||||
await _channel.invokeMethod("createTexture", [size.width, size.height]);
|
||||
_textureIdController.add(_textureId);
|
||||
print("Got texture id $_textureId");
|
||||
|
||||
var glContext =
|
||||
Pointer<Void>.fromAddress(await _channel.invokeMethod("getContext"));
|
||||
final loadResource = Pointer<
|
||||
NativeFunction<ResourceBuffer Function(Pointer<Char>)>>.fromAddress(
|
||||
await _channel.invokeMethod("getLoadResourceFn"));
|
||||
final resourceLoader = Pointer<ResourceLoaderWrapper>.fromAddress(
|
||||
await _channel.invokeMethod("getResourceLoader"));
|
||||
|
||||
var freeResource =
|
||||
Pointer<NativeFunction<Void Function(Uint32)>>.fromAddress(
|
||||
await _channel.invokeMethod("getFreeResourceFn"));
|
||||
_viewer = _nativeLibrary.create_filament_viewer(
|
||||
glContext, loadResource, freeResource);
|
||||
_viewer = _nativeLibrary.create_filament_viewer(glContext, resourceLoader);
|
||||
if (Platform.isLinux) {
|
||||
// don't pass a surface to the SwapChain as we are effectively creating a headless SwapChain that will render into a RenderTarget associated with a texture
|
||||
_nativeLibrary.create_swap_chain(
|
||||
|
||||
@@ -19,51 +19,45 @@ class NativeLibrary {
|
||||
lookup)
|
||||
: _lookup = lookup;
|
||||
|
||||
int init_dart_api_dl(
|
||||
ffi.Pointer<ffi.Void> data,
|
||||
) {
|
||||
return _init_dart_api_dl(
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
late final _init_dart_api_dlPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.IntPtr Function(ffi.Pointer<ffi.Void>)>>(
|
||||
'init_dart_api_dl');
|
||||
late final _init_dart_api_dl =
|
||||
_init_dart_api_dlPtr.asFunction<int Function(ffi.Pointer<ffi.Void>)>();
|
||||
|
||||
ffi.Pointer<ffi.Void> create_filament_viewer(
|
||||
ffi.Pointer<ffi.Void> context,
|
||||
ffi.Pointer<
|
||||
ffi.NativeFunction<ResourceBuffer Function(ffi.Pointer<ffi.Char>)>>
|
||||
loadResource,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Uint32)>> freeResource,
|
||||
ffi.Pointer<ResourceLoaderWrapper> loader,
|
||||
) {
|
||||
return _create_filament_viewer(
|
||||
context,
|
||||
loadResource,
|
||||
freeResource,
|
||||
loader,
|
||||
);
|
||||
}
|
||||
|
||||
late final _create_filament_viewerPtr = _lookup<
|
||||
ffi.NativeFunction<
|
||||
ffi.Pointer<ffi.Void> Function(
|
||||
ffi.Pointer<ffi.Void>,
|
||||
ffi.Pointer<
|
||||
ffi.NativeFunction<
|
||||
ResourceBuffer Function(ffi.Pointer<ffi.Char>)>>,
|
||||
ffi.Pointer<
|
||||
ffi.NativeFunction<ffi.Void Function(ffi.Uint32)>>)>>(
|
||||
'create_filament_viewer');
|
||||
ffi.NativeFunction<
|
||||
ffi.Pointer<ffi.Void> Function(ffi.Pointer<ffi.Void>,
|
||||
ffi.Pointer<ResourceLoaderWrapper>)>>('create_filament_viewer');
|
||||
late final _create_filament_viewer = _create_filament_viewerPtr.asFunction<
|
||||
ffi.Pointer<ffi.Void> Function(
|
||||
ffi.Pointer<ffi.Void>,
|
||||
ffi.Pointer<
|
||||
ffi.NativeFunction<
|
||||
ResourceBuffer Function(ffi.Pointer<ffi.Char>)>>,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Uint32)>>)>();
|
||||
ffi.Pointer<ffi.Void>, ffi.Pointer<ResourceLoaderWrapper>)>();
|
||||
|
||||
ffi.Pointer<ResourceLoaderWrapper> make_resource_loader(
|
||||
LoadResourceFromOwner loadFn,
|
||||
FreeResourceFromOwner freeFn,
|
||||
ffi.Pointer<ffi.Void> owner,
|
||||
) {
|
||||
return _make_resource_loader(
|
||||
loadFn,
|
||||
freeFn,
|
||||
owner,
|
||||
);
|
||||
}
|
||||
|
||||
late final _make_resource_loaderPtr = _lookup<
|
||||
ffi.NativeFunction<
|
||||
ffi.Pointer<ResourceLoaderWrapper> Function(
|
||||
LoadResourceFromOwner,
|
||||
FreeResourceFromOwner,
|
||||
ffi.Pointer<ffi.Void>)>>('make_resource_loader');
|
||||
late final _make_resource_loader = _make_resource_loaderPtr.asFunction<
|
||||
ffi.Pointer<ResourceLoaderWrapper> Function(LoadResourceFromOwner,
|
||||
FreeResourceFromOwner, ffi.Pointer<ffi.Void>)>();
|
||||
|
||||
void delete_filament_viewer(
|
||||
ffi.Pointer<ffi.Void> viewer,
|
||||
@@ -1118,11 +1112,106 @@ class NativeLibrary {
|
||||
ffi.Pointer<ffi.Void>, ffi.Float)>>('set_camera_focus_distance');
|
||||
late final _set_camera_focus_distance = _set_camera_focus_distancePtr
|
||||
.asFunction<void Function(ffi.Pointer<ffi.Void>, double)>();
|
||||
|
||||
void ios_dummy() {
|
||||
return _ios_dummy();
|
||||
}
|
||||
|
||||
late final _ios_dummyPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function()>>('ios_dummy');
|
||||
late final _ios_dummy = _ios_dummyPtr.asFunction<void Function()>();
|
||||
}
|
||||
|
||||
class __fsid_t extends ffi.Struct {
|
||||
@ffi.Array.multi([2])
|
||||
external ffi.Array<ffi.Int> __val;
|
||||
class __mbstate_t extends ffi.Union {
|
||||
@ffi.Array.multi([128])
|
||||
external ffi.Array<ffi.Char> __mbstate8;
|
||||
|
||||
@ffi.LongLong()
|
||||
external int _mbstateL;
|
||||
}
|
||||
|
||||
class __darwin_pthread_handler_rec extends ffi.Struct {
|
||||
external ffi
|
||||
.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>
|
||||
__routine;
|
||||
|
||||
external ffi.Pointer<ffi.Void> __arg;
|
||||
|
||||
external ffi.Pointer<__darwin_pthread_handler_rec> __next;
|
||||
}
|
||||
|
||||
class _opaque_pthread_attr_t extends ffi.Struct {
|
||||
@ffi.Long()
|
||||
external int __sig;
|
||||
|
||||
@ffi.Array.multi([56])
|
||||
external ffi.Array<ffi.Char> __opaque;
|
||||
}
|
||||
|
||||
class _opaque_pthread_cond_t extends ffi.Struct {
|
||||
@ffi.Long()
|
||||
external int __sig;
|
||||
|
||||
@ffi.Array.multi([40])
|
||||
external ffi.Array<ffi.Char> __opaque;
|
||||
}
|
||||
|
||||
class _opaque_pthread_condattr_t extends ffi.Struct {
|
||||
@ffi.Long()
|
||||
external int __sig;
|
||||
|
||||
@ffi.Array.multi([8])
|
||||
external ffi.Array<ffi.Char> __opaque;
|
||||
}
|
||||
|
||||
class _opaque_pthread_mutex_t extends ffi.Struct {
|
||||
@ffi.Long()
|
||||
external int __sig;
|
||||
|
||||
@ffi.Array.multi([56])
|
||||
external ffi.Array<ffi.Char> __opaque;
|
||||
}
|
||||
|
||||
class _opaque_pthread_mutexattr_t extends ffi.Struct {
|
||||
@ffi.Long()
|
||||
external int __sig;
|
||||
|
||||
@ffi.Array.multi([8])
|
||||
external ffi.Array<ffi.Char> __opaque;
|
||||
}
|
||||
|
||||
class _opaque_pthread_once_t extends ffi.Struct {
|
||||
@ffi.Long()
|
||||
external int __sig;
|
||||
|
||||
@ffi.Array.multi([8])
|
||||
external ffi.Array<ffi.Char> __opaque;
|
||||
}
|
||||
|
||||
class _opaque_pthread_rwlock_t extends ffi.Struct {
|
||||
@ffi.Long()
|
||||
external int __sig;
|
||||
|
||||
@ffi.Array.multi([192])
|
||||
external ffi.Array<ffi.Char> __opaque;
|
||||
}
|
||||
|
||||
class _opaque_pthread_rwlockattr_t extends ffi.Struct {
|
||||
@ffi.Long()
|
||||
external int __sig;
|
||||
|
||||
@ffi.Array.multi([16])
|
||||
external ffi.Array<ffi.Char> __opaque;
|
||||
}
|
||||
|
||||
class _opaque_pthread_t extends ffi.Struct {
|
||||
@ffi.Long()
|
||||
external int __sig;
|
||||
|
||||
external ffi.Pointer<__darwin_pthread_handler_rec> __cleanup_stack;
|
||||
|
||||
@ffi.Array.multi([8176])
|
||||
external ffi.Array<ffi.Char> __opaque;
|
||||
}
|
||||
|
||||
class ResourceBuffer extends ffi.Struct {
|
||||
@@ -1135,131 +1224,91 @@ class ResourceBuffer extends ffi.Struct {
|
||||
external int id;
|
||||
}
|
||||
|
||||
class ResourceLoaderWrapper extends ffi.Struct {
|
||||
external ffi.Pointer<ffi.Void> mOwner;
|
||||
|
||||
external LoadResource mLoadResource;
|
||||
|
||||
external FreeResource mFreeResource;
|
||||
|
||||
external LoadResourceFromOwner mLoadResourceFromOwner;
|
||||
|
||||
external FreeResourceFromOwner mFreeResourceFromOwner;
|
||||
}
|
||||
|
||||
typedef LoadResource = ffi.Pointer<
|
||||
ffi.NativeFunction<ResourceBuffer Function(ffi.Pointer<ffi.Char> uri)>>;
|
||||
typedef FreeResource
|
||||
= ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ResourceBuffer)>>;
|
||||
typedef LoadResourceFromOwner = ffi.Pointer<
|
||||
ffi.NativeFunction<
|
||||
ResourceBuffer Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Void>)>>;
|
||||
typedef FreeResourceFromOwner = ffi.Pointer<
|
||||
ffi.NativeFunction<
|
||||
ffi.Void Function(ResourceBuffer, ffi.Pointer<ffi.Void>)>>;
|
||||
typedef EntityId = ffi.Int32;
|
||||
|
||||
const int _STDINT_H = 1;
|
||||
|
||||
const int _FEATURES_H = 1;
|
||||
|
||||
const int _DEFAULT_SOURCE = 1;
|
||||
|
||||
const int __GLIBC_USE_ISOC2X = 1;
|
||||
|
||||
const int __USE_ISOC11 = 1;
|
||||
|
||||
const int __USE_ISOC99 = 1;
|
||||
|
||||
const int __USE_ISOC95 = 1;
|
||||
|
||||
const int _POSIX_SOURCE = 1;
|
||||
|
||||
const int _POSIX_C_SOURCE = 200809;
|
||||
|
||||
const int __USE_POSIX = 1;
|
||||
|
||||
const int __USE_POSIX2 = 1;
|
||||
|
||||
const int __USE_POSIX199309 = 1;
|
||||
|
||||
const int __USE_POSIX199506 = 1;
|
||||
|
||||
const int __USE_XOPEN2K = 1;
|
||||
|
||||
const int __USE_XOPEN2K8 = 1;
|
||||
|
||||
const int _ATFILE_SOURCE = 1;
|
||||
|
||||
const int __USE_MISC = 1;
|
||||
|
||||
const int __USE_ATFILE = 1;
|
||||
|
||||
const int __USE_FORTIFY_LEVEL = 0;
|
||||
|
||||
const int __GLIBC_USE_DEPRECATED_GETS = 0;
|
||||
|
||||
const int __GLIBC_USE_DEPRECATED_SCANF = 0;
|
||||
|
||||
const int _STDC_PREDEF_H = 1;
|
||||
|
||||
const int __STDC_IEC_559__ = 1;
|
||||
|
||||
const int __STDC_IEC_559_COMPLEX__ = 1;
|
||||
|
||||
const int __STDC_ISO_10646__ = 201706;
|
||||
|
||||
const int __GNU_LIBRARY__ = 6;
|
||||
|
||||
const int __GLIBC__ = 2;
|
||||
|
||||
const int __GLIBC_MINOR__ = 33;
|
||||
|
||||
const int _SYS_CDEFS_H = 1;
|
||||
|
||||
const int __THROW = 1;
|
||||
|
||||
const int __THROWNL = 1;
|
||||
|
||||
const int __glibc_c99_flexarr_available = 1;
|
||||
|
||||
const int __WORDSIZE = 64;
|
||||
|
||||
const int __WORDSIZE_TIME64_COMPAT32 = 1;
|
||||
const int __DARWIN_ONLY_64_BIT_INO_T = 1;
|
||||
|
||||
const int __SYSCALL_WORDSIZE = 64;
|
||||
const int __DARWIN_ONLY_UNIX_CONFORMANCE = 1;
|
||||
|
||||
const int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = 0;
|
||||
const int __DARWIN_ONLY_VERS_1050 = 1;
|
||||
|
||||
const int __HAVE_GENERIC_SELECTION = 0;
|
||||
const int __DARWIN_UNIX03 = 1;
|
||||
|
||||
const int __GLIBC_USE_LIB_EXT2 = 1;
|
||||
const int __DARWIN_64_BIT_INO_T = 1;
|
||||
|
||||
const int __GLIBC_USE_IEC_60559_BFP_EXT = 1;
|
||||
const int __DARWIN_VERS_1050 = 1;
|
||||
|
||||
const int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = 1;
|
||||
const int __DARWIN_NON_CANCELABLE = 0;
|
||||
|
||||
const int __GLIBC_USE_IEC_60559_FUNCS_EXT = 1;
|
||||
const String __DARWIN_SUF_EXTSN = '\$DARWIN_EXTSN';
|
||||
|
||||
const int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = 1;
|
||||
const int __DARWIN_C_ANSI = 4096;
|
||||
|
||||
const int __GLIBC_USE_IEC_60559_TYPES_EXT = 1;
|
||||
const int __DARWIN_C_FULL = 900000;
|
||||
|
||||
const int _BITS_TYPES_H = 1;
|
||||
const int __DARWIN_C_LEVEL = 900000;
|
||||
|
||||
const int __TIMESIZE = 64;
|
||||
const int __STDC_WANT_LIB_EXT1__ = 1;
|
||||
|
||||
const int _BITS_TYPESIZES_H = 1;
|
||||
const int __DARWIN_NO_LONG_LONG = 0;
|
||||
|
||||
const int __OFF_T_MATCHES_OFF64_T = 1;
|
||||
const int _DARWIN_FEATURE_64_BIT_INODE = 1;
|
||||
|
||||
const int __INO_T_MATCHES_INO64_T = 1;
|
||||
const int _DARWIN_FEATURE_ONLY_64_BIT_INODE = 1;
|
||||
|
||||
const int __RLIM_T_MATCHES_RLIM64_T = 1;
|
||||
const int _DARWIN_FEATURE_ONLY_VERS_1050 = 1;
|
||||
|
||||
const int __STATFS_MATCHES_STATFS64 = 1;
|
||||
const int _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1;
|
||||
|
||||
const int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = 1;
|
||||
const int _DARWIN_FEATURE_UNIX_CONFORMANCE = 3;
|
||||
|
||||
const int __FD_SETSIZE = 1024;
|
||||
const int __has_ptrcheck = 0;
|
||||
|
||||
const int _BITS_TIME64_H = 1;
|
||||
const int __DARWIN_NULL = 0;
|
||||
|
||||
const int _BITS_WCHAR_H = 1;
|
||||
const int __PTHREAD_SIZE__ = 8176;
|
||||
|
||||
const int __WCHAR_MAX = 2147483647;
|
||||
const int __PTHREAD_ATTR_SIZE__ = 56;
|
||||
|
||||
const int __WCHAR_MIN = -2147483648;
|
||||
const int __PTHREAD_MUTEXATTR_SIZE__ = 8;
|
||||
|
||||
const int _BITS_STDINT_INTN_H = 1;
|
||||
const int __PTHREAD_MUTEX_SIZE__ = 56;
|
||||
|
||||
const int _BITS_STDINT_UINTN_H = 1;
|
||||
const int __PTHREAD_CONDATTR_SIZE__ = 8;
|
||||
|
||||
const int INT8_MIN = -128;
|
||||
const int __PTHREAD_COND_SIZE__ = 40;
|
||||
|
||||
const int INT16_MIN = -32768;
|
||||
const int __PTHREAD_ONCE_SIZE__ = 8;
|
||||
|
||||
const int INT32_MIN = -2147483648;
|
||||
const int __PTHREAD_RWLOCK_SIZE__ = 192;
|
||||
|
||||
const int INT64_MIN = -9223372036854775808;
|
||||
const int __PTHREAD_RWLOCKATTR_SIZE__ = 16;
|
||||
|
||||
const int USER_ADDR_NULL = 0;
|
||||
|
||||
const int INT8_MAX = 127;
|
||||
|
||||
@@ -1269,6 +1318,14 @@ const int INT32_MAX = 2147483647;
|
||||
|
||||
const int INT64_MAX = 9223372036854775807;
|
||||
|
||||
const int INT8_MIN = -128;
|
||||
|
||||
const int INT16_MIN = -32768;
|
||||
|
||||
const int INT32_MIN = -2147483648;
|
||||
|
||||
const int INT64_MIN = -9223372036854775808;
|
||||
|
||||
const int UINT8_MAX = 255;
|
||||
|
||||
const int UINT16_MAX = 65535;
|
||||
@@ -1303,54 +1360,66 @@ const int UINT_LEAST64_MAX = -1;
|
||||
|
||||
const int INT_FAST8_MIN = -128;
|
||||
|
||||
const int INT_FAST16_MIN = -9223372036854775808;
|
||||
const int INT_FAST16_MIN = -32768;
|
||||
|
||||
const int INT_FAST32_MIN = -9223372036854775808;
|
||||
const int INT_FAST32_MIN = -2147483648;
|
||||
|
||||
const int INT_FAST64_MIN = -9223372036854775808;
|
||||
|
||||
const int INT_FAST8_MAX = 127;
|
||||
|
||||
const int INT_FAST16_MAX = 9223372036854775807;
|
||||
const int INT_FAST16_MAX = 32767;
|
||||
|
||||
const int INT_FAST32_MAX = 9223372036854775807;
|
||||
const int INT_FAST32_MAX = 2147483647;
|
||||
|
||||
const int INT_FAST64_MAX = 9223372036854775807;
|
||||
|
||||
const int UINT_FAST8_MAX = 255;
|
||||
|
||||
const int UINT_FAST16_MAX = -1;
|
||||
const int UINT_FAST16_MAX = 65535;
|
||||
|
||||
const int UINT_FAST32_MAX = -1;
|
||||
const int UINT_FAST32_MAX = 4294967295;
|
||||
|
||||
const int UINT_FAST64_MAX = -1;
|
||||
|
||||
const int INTPTR_MIN = -9223372036854775808;
|
||||
|
||||
const int INTPTR_MAX = 9223372036854775807;
|
||||
|
||||
const int UINTPTR_MAX = -1;
|
||||
const int INTPTR_MIN = -9223372036854775808;
|
||||
|
||||
const int INTMAX_MIN = -9223372036854775808;
|
||||
const int UINTPTR_MAX = -1;
|
||||
|
||||
const int INTMAX_MAX = 9223372036854775807;
|
||||
|
||||
const int UINTMAX_MAX = -1;
|
||||
|
||||
const int INTMAX_MIN = -9223372036854775808;
|
||||
|
||||
const int PTRDIFF_MIN = -9223372036854775808;
|
||||
|
||||
const int PTRDIFF_MAX = 9223372036854775807;
|
||||
|
||||
const int SIZE_MAX = -1;
|
||||
|
||||
const int RSIZE_MAX = 9223372036854775807;
|
||||
|
||||
const int WCHAR_MAX = 2147483647;
|
||||
|
||||
const int WCHAR_MIN = -2147483648;
|
||||
|
||||
const int WINT_MIN = -2147483648;
|
||||
|
||||
const int WINT_MAX = 2147483647;
|
||||
|
||||
const int SIG_ATOMIC_MIN = -2147483648;
|
||||
|
||||
const int SIG_ATOMIC_MAX = 2147483647;
|
||||
|
||||
const int SIZE_MAX = -1;
|
||||
const int __DARWIN_WCHAR_MAX = 2147483647;
|
||||
|
||||
const int WCHAR_MIN = -2147483648;
|
||||
const int __DARWIN_WCHAR_MIN = -2147483648;
|
||||
|
||||
const int WCHAR_MAX = 2147483647;
|
||||
const int __DARWIN_WEOF = -1;
|
||||
|
||||
const int WINT_MIN = 0;
|
||||
const int _FORTIFY_SOURCE = 2;
|
||||
|
||||
const int WINT_MAX = 4294967295;
|
||||
const int NULL = 0;
|
||||
|
||||
Reference in New Issue
Block a user