pub struct MobileEmbedApp {
pub engine: VeloxEngine,
/* private fields */
}Expand description
面向 Android (SurfaceView / ANativeWindow Vulkan / JNI)、iOS (UIView / CAMetalLayer / Swift xcframework)
与鸿蒙 HarmonyOS NEXT (XComponent / OHNativeWindow Vulkan / ArkTS N-API) 嵌入场景的动态分辨率宿主实例。
Fields§
§engine: VeloxEngineImplementations§
Source§impl MobileEmbedApp
impl MobileEmbedApp
Sourcepub fn new(width: i16, height: i16, safe_area: SafeAreaInsets) -> Self
pub fn new(width: i16, height: i16, safe_area: SafeAreaInsets) -> Self
创建一个可嵌入原生移动视图层级的独立引擎实例(默认采用 Wgpu 2D SDF 硬件加速后端)。
Sourcepub fn new_for_os(
os: MobileOs,
width: i16,
height: i16,
safe_area: SafeAreaInsets,
) -> Self
pub fn new_for_os( os: MobileOs, width: i16, height: i16, safe_area: SafeAreaInsets, ) -> Self
按指定移动端操作系统生态(MobileOs)与安全区域创建独立引擎实例。
Sourcepub fn new_android(width: i16, height: i16) -> Self
pub fn new_android(width: i16, height: i16) -> Self
创建搭载 Android 默认竖屏安全区(状态栏 48px、手势导航条 34px)的实例。
Sourcepub fn new_ios(width: i16, height: i16) -> Self
pub fn new_ios(width: i16, height: i16) -> Self
创建搭载 iOS 默认竖屏安全区(灵动岛 59pt、Home Indicator 34pt)的实例。
Sourcepub fn new_harmony(width: i16, height: i16) -> Self
pub fn new_harmony(width: i16, height: i16) -> Self
创建搭载鸿蒙 HarmonyOS NEXT 默认竖屏避让区(状态栏 38vp、导航指示条 28vp)的实例。
Sourcepub fn with_backend(self, backend: DesktopRenderBackend) -> Self
pub fn with_backend(self, backend: DesktopRenderBackend) -> Self
配置移动端渲染后端类型(Wgpu 或 Software)。
Sourcepub fn set_backend(&mut self, backend: DesktopRenderBackend)
pub fn set_backend(&mut self, backend: DesktopRenderBackend)
动态切换移动端渲染后端类型。
Sourcepub const fn backend(&self) -> DesktopRenderBackend
pub const fn backend(&self) -> DesktopRenderBackend
获取当前激活的移动端渲染后端类型。
Sourcepub const fn orientation(&self) -> DeviceOrientation
pub const fn orientation(&self) -> DeviceOrientation
获取当前设备屏幕朝向。
Sourcepub fn set_orientation(&mut self, orientation: DeviceOrientation)
pub fn set_orientation(&mut self, orientation: DeviceOrientation)
切换设备屏幕朝向并自动应用当前移动操作系统(Android / iOS / HarmonyOS)对应朝向的默认安全区域。
Sourcepub fn attach_gpu_window<T>(&mut self, window_handle: T) -> bool
pub fn attach_gpu_window<T>(&mut self, window_handle: T) -> bool
绑定原生移动端窗口句柄(Android ANativeWindow / iOS UIView CAMetalLayer / HarmonyOS OHNativeWindow),
开启轻量级 wgpu (Vulkan / Metal) 2D SDF 120Hz 零拷贝 Swapchain 直通硬件加速渲染。
Sourcepub fn detach_gpu_window(&mut self)
pub fn detach_gpu_window(&mut self)
解绑/挂起移动端 GPU Swapchain 表面。
Sourcepub fn has_active_gpu_window(&self) -> bool
pub fn has_active_gpu_window(&self) -> bool
检查当前是否已挂载并激活硬件 GPU Swapchain 表面。
Sourcepub fn set_dpi_scale(&mut self, scale: i16)
pub fn set_dpi_scale(&mut self, scale: i16)
设置移动端物理像素 HiDPI 缩放倍率。
Sourcepub const fn physical_width(&self) -> i16
pub const fn physical_width(&self) -> i16
获取物理像素帧缓冲宽度(logical_width * dpi_scale)。
Sourcepub const fn physical_height(&self) -> i16
pub const fn physical_height(&self) -> i16
获取物理像素帧缓冲高度(logical_height * dpi_scale)。
Sourcepub fn push_touch(&mut self, touch_id: u32, phase: TouchPhase, x: i16, y: i16)
pub fn push_touch(&mut self, touch_id: u32, phase: TouchPhase, x: i16, y: i16)
注入触摸事件(自动锁定并跟踪主触控手指 touch_id)。
Sourcepub fn handle_back(&mut self) -> bool
pub fn handle_back(&mut self) -> bool
处理系统返回键/返回手势,返回是否被 Velox 视图消费。
Sourcepub fn set_safe_area(&mut self, safe_area: SafeAreaInsets)
pub fn set_safe_area(&mut self, safe_area: SafeAreaInsets)
动态更新异形屏安全区域内边距(状态栏、灵动岛/刘海、底部 Home Indicator)。
Sourcepub fn set_keyboard_inset(&mut self, height_px: i16)
pub fn set_keyboard_inset(&mut self, height_px: i16)
动态更新软键盘弹出高度(像素)。
Sourcepub fn set_async_waker(&mut self, waker: impl Fn() + Send + Sync + 'static)
pub fn set_async_waker(&mut self, waker: impl Fn() + Send + Sync + 'static)
注入原生移动端事件循环唤醒器(例如 Android ALooper_wake / iOS CFRunLoopWakeUp / 鸿蒙 OH_NativeVSync 请求帧),
实现后台异步任务完成与定时器到期时的零轮询精准唤醒。
Sourcepub fn poll_async_tasks(&mut self) -> bool
pub fn poll_async_tasks(&mut self) -> bool
在移动端 UI 主线程排空所有已就绪的前景异步协程与 defer 回调。
Sourcepub fn needs_redraw(&self) -> bool
pub fn needs_redraw(&self) -> bool
检查当前引擎是否存在待重绘脏视图、动画或已就绪异步任务(用于决定 Choreographer / CADisplayLink 是否休眠)。
Sourcepub fn step_frame(&mut self, dt_ms: u16) -> usize
pub fn step_frame(&mut self, dt_ms: u16) -> usize
推进一帧,按当前激活的 backend 单路径执行渲染(消除三重重复渲染),返回本帧重绘的脏矩形数量。
Sourcepub fn rgba_bytes(&self) -> &[u8] ⓘ
pub fn rgba_bytes(&self) -> &[u8] ⓘ
获取 RGBA8888 像素缓冲区的只读字节切片。
Sourcepub fn dirty_rects(&self) -> &[CDirtyRect]
pub fn dirty_rects(&self) -> &[CDirtyRect]
获取本帧脏矩形切片。
Auto Trait Implementations§
impl !Freeze for MobileEmbedApp
impl !RefUnwindSafe for MobileEmbedApp
impl !Send for MobileEmbedApp
impl !Sync for MobileEmbedApp
impl !UnwindSafe for MobileEmbedApp
impl Forget for MobileEmbedApp
impl Move for MobileEmbedApp
impl Unpin for MobileEmbedApp
impl UnsafeUnpin for MobileEmbedApp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FluentBuilder for T
impl<T> FluentBuilder for T
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
condition 为 true 时执行闭包修饰自身,否则原样返回。Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Self
fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self
condition 在两个修饰分支之间二选一。Source§fn when_some<O>(
self,
option: Option<O>,
then: impl FnOnce(Self, O) -> Self,
) -> Self
fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self
option 为 Some(value) 时执行闭包修饰自身,否则原样返回。