Skip to main content

MobileEmbedApp

Struct MobileEmbedApp 

Source
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: VeloxEngine

Implementations§

Source§

impl MobileEmbedApp

Source

pub fn new(width: i16, height: i16, safe_area: SafeAreaInsets) -> Self

创建一个可嵌入原生移动视图层级的独立引擎实例(默认采用 Wgpu 2D SDF 硬件加速后端)。

Source

pub fn new_for_os( os: MobileOs, width: i16, height: i16, safe_area: SafeAreaInsets, ) -> Self

按指定移动端操作系统生态(MobileOs)与安全区域创建独立引擎实例。

Source

pub fn new_android(width: i16, height: i16) -> Self

创建搭载 Android 默认竖屏安全区(状态栏 48px、手势导航条 34px)的实例。

Source

pub fn new_ios(width: i16, height: i16) -> Self

创建搭载 iOS 默认竖屏安全区(灵动岛 59pt、Home Indicator 34pt)的实例。

Source

pub fn new_harmony(width: i16, height: i16) -> Self

创建搭载鸿蒙 HarmonyOS NEXT 默认竖屏避让区(状态栏 38vp、导航指示条 28vp)的实例。

Source

pub const fn with_os(self, os: MobileOs) -> Self

配置当前实例所属的移动操作系统生态类型。

Source

pub const fn os(&self) -> MobileOs

获取当前实例所属的移动操作系统生态类型。

Source

pub fn with_backend(self, backend: DesktopRenderBackend) -> Self

配置移动端渲染后端类型(Wgpu 或 Software)。

Source

pub fn set_backend(&mut self, backend: DesktopRenderBackend)

动态切换移动端渲染后端类型。

Source

pub const fn backend(&self) -> DesktopRenderBackend

获取当前激活的移动端渲染后端类型。

Source

pub const fn orientation(&self) -> DeviceOrientation

获取当前设备屏幕朝向。

Source

pub fn set_orientation(&mut self, orientation: DeviceOrientation)

切换设备屏幕朝向并自动应用当前移动操作系统(Android / iOS / HarmonyOS)对应朝向的默认安全区域。

Source

pub fn gpu_scene(&self) -> Option<&WgpuScene>

获取最近一帧离屏渲染编译生成的轻量级 2D SDF GPU 场景图元统计引用。

Source

pub fn attach_gpu_window<T>(&mut self, window_handle: T) -> bool
where T: Into<SurfaceTarget<'static>> + Clone,

绑定原生移动端窗口句柄(Android ANativeWindow / iOS UIView CAMetalLayer / HarmonyOS OHNativeWindow), 开启轻量级 wgpu (Vulkan / Metal) 2D SDF 120Hz 零拷贝 Swapchain 直通硬件加速渲染。

Source

pub fn detach_gpu_window(&mut self)

解绑/挂起移动端 GPU Swapchain 表面。

Source

pub fn has_active_gpu_window(&self) -> bool

检查当前是否已挂载并激活硬件 GPU Swapchain 表面。

Source

pub fn set_dpi_scale(&mut self, scale: i16)

设置移动端物理像素 HiDPI 缩放倍率。

Source

pub const fn dpi_scale(&self) -> i16

获取当前 HiDPI 缩放倍率。

Source

pub const fn physical_width(&self) -> i16

获取物理像素帧缓冲宽度(logical_width * dpi_scale)。

Source

pub const fn physical_height(&self) -> i16

获取物理像素帧缓冲高度(logical_height * dpi_scale)。

Source

pub fn resize(&mut self, width: i16, height: i16)

调整视图逻辑宽高(如屏幕旋转或分屏窗口大小改变),保留全部组件状态。

Source

pub fn push_touch(&mut self, touch_id: u32, phase: TouchPhase, x: i16, y: i16)

注入触摸事件(自动锁定并跟踪主触控手指 touch_id)。

Source

pub fn handle_back(&mut self) -> bool

处理系统返回键/返回手势,返回是否被 Velox 视图消费。

Source

pub fn set_safe_area(&mut self, safe_area: SafeAreaInsets)

动态更新异形屏安全区域内边距(状态栏、灵动岛/刘海、底部 Home Indicator)。

Source

pub fn set_keyboard_inset(&mut self, height_px: i16)

动态更新软键盘弹出高度(像素)。

Source

pub fn set_async_waker(&mut self, waker: impl Fn() + Send + Sync + 'static)

注入原生移动端事件循环唤醒器(例如 Android ALooper_wake / iOS CFRunLoopWakeUp / 鸿蒙 OH_NativeVSync 请求帧), 实现后台异步任务完成与定时器到期时的零轮询精准唤醒。

Source

pub fn poll_async_tasks(&mut self) -> bool

在移动端 UI 主线程排空所有已就绪的前景异步协程与 defer 回调。

Source

pub fn needs_redraw(&self) -> bool

检查当前引擎是否存在待重绘脏视图、动画或已就绪异步任务(用于决定 Choreographer / CADisplayLink 是否休眠)。

Source

pub fn step_frame(&mut self, dt_ms: u16) -> usize

推进一帧,按当前激活的 backend 单路径执行渲染(消除三重重复渲染),返回本帧重绘的脏矩形数量。

Source

pub fn rgba_bytes(&self) -> &[u8] ⓘ

获取 RGBA8888 像素缓冲区的只读字节切片。

Source

pub fn dirty_rects(&self) -> &[CDirtyRect]

获取本帧脏矩形切片。

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> FluentBuilder for T

Source§

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

根据 condition 在两个修饰分支之间二选一。
Source§

fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self

当 option 为 Some(value) 时执行闭包修饰自身,否则原样返回。
Source§

fn when_none<O>( self, option: &Option<O>, then: impl FnOnce(Self) -> Self, ) -> Self

当 option 为 None 时执行闭包修饰自身,否则原样返回。
Source§

fn apply<U>(self, f: impl FnOnce(Self) -> U) -> U

通用管道映射变换(避免与 Iterator::map / Option::map 重名)。
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.