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 直通硬件加速渲染。

绑定成功后会自动释放不再需要的 CPU framebuffer 与离屏渲染器内存。

Source

pub fn detach_gpu_window(&mut self)

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

Source

pub fn trim_memory(&mut self)

后台化或收到系统内存压力回调(onTrimMemory / didReceiveMemoryWarning)时释放闲置 CPU 帧缓冲与 GPU 离屏显存。

Source

pub fn cpu_framebuffer_bytes(&self) -> usize

返回当前移动端实例 CPU 侧 framebuffer 占用的字节容量(原生 GPU Swapchain 路径下为 0)。

Source

pub fn cpu_memory_bytes(&self) -> usize

返回当前移动端实例在 CPU 侧持有的像素缓冲总字节容量(包含 framebuffer 与离屏渲染器内部缓冲)。

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§

§

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
where *const u8 is !null: Unpin, &'static PodVTable: Unpin, *const Element<'static>: Unpin, *mut u8: Unpin, *mut (): Unpin, *const ChunkFooter is !null: Unpin, *const CoreTheme: Unpin, *const PodPool: Unpin, &'static StaticCatalog: Unpin, Arc<DynamicCatalog>: Unpin, Arc<ForegroundShared>: Unpin, Rc<RefCell<ForegroundLocal>>: Unpin, &'static str: Unpin, &'static [u8]: Unpin, &'static dyn Fn(&mut dyn SurfacePainter): Unpin, &'static StyledQuad<'static>: Unpin, &'static LayerSpec<'static>: Unpin, &'static ExternalTextureSpec: Unpin, &'static RichTextSpec<'static>: Unpin, &'static DecodedImageSpec: Unpin, &'static VectorDrawSpec<'static>: Unpin, &'static SceneCanvasSpec<'static>: Unpin, &'static DivInteractivity<'static>: Unpin, *const DrawOp<'static>: Unpin, *const HitRegion<'static>: Unpin, *mut LayoutNode<'static, 'static>: Unpin, Arc<CoreRenderPipeline>: Unpin, Arc<CoreBindGroupLayout>: Unpin, Arc<CoreBindGroup>: Unpin, Arc<CoreBuffer>: Unpin, Arc<Mutex<MapContext>>: Unpin, InternalBitFlags: Unpin, Arc<CoreSampler>: Unpin, Arc<CoreTexture>: Unpin, InternalBitFlags: Unpin, &'static [TextureFormat]: Unpin, Arc<CoreTextureView>: Unpin, Arc<DiskPipelineCache>: Unpin, *mut Counter<Channel<GpuEffectsEngine>>: Unpin, *mut Counter<Channel<GpuEffectsEngine>>: Unpin, *mut Counter<Channel<GpuEffectsEngine>>: Unpin, *mut Counter<Channel<CanvasGpuEngine>>: Unpin, *mut Counter<Channel<CanvasGpuEngine>>: Unpin, *mut Counter<Channel<CanvasGpuEngine>>: Unpin, Arc<CachedTextLayout>: Unpin, Arc<CoreQueue>: Unpin, Arc<CoreDevice>: Unpin, Arc<ContextWgpuCore>: Unpin, Arc<CoreSurface>: Unpin, Align1<u8>: Unpin, Box<dyn WindowHandle>: Unpin,

§

impl UnsafeUnpin for MobileEmbedApp
where *const u8 is !null: UnsafeUnpin, PhantomData<PodSlot>: UnsafeUnpin, PhantomData<PodId>: UnsafeUnpin, PhantomData<*mut ()>: UnsafeUnpin, *const ChunkFooter is !null: UnsafeUnpin, *const CoreTheme: UnsafeUnpin, *const PodPool: UnsafeUnpin, &'static StaticCatalog: UnsafeUnpin, *const ArcInner<DynamicCatalog> is !null: UnsafeUnpin, PhantomData<ArcInner<DynamicCatalog>>: UnsafeUnpin, *const ArcInner<ForegroundShared> is !null: UnsafeUnpin, PhantomData<ArcInner<ForegroundShared>>: UnsafeUnpin, *const RcInner<RefCell<ForegroundLocal>> is !null: UnsafeUnpin, PhantomData<RcInner<RefCell<ForegroundLocal>>>: UnsafeUnpin, PhantomData<ActiveTransition>: UnsafeUnpin, PhantomData<ScrollEntry>: UnsafeUnpin, PhantomData<GhostEntry>: UnsafeUnpin, PhantomData<Region>: UnsafeUnpin, PhantomData<DrawOpSnapshot>: UnsafeUnpin, PhantomData<DrawOp<'static>>: UnsafeUnpin, PhantomData<HitRegion<'static>>: UnsafeUnpin, *const DrawOp<'static>: UnsafeUnpin, *const HitRegion<'static>: UnsafeUnpin, *mut LayoutNode<'static, 'static>: UnsafeUnpin, PhantomData<PathBuf>: UnsafeUnpin, PhantomData<KeyBinding>: UnsafeUnpin, PhantomData<Rgba8888>: UnsafeUnpin, PhantomData<CDirtyRect>: UnsafeUnpin, PhantomData<GpuPrimitive>: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const ArcInner<CoreRenderPipeline> is !null: UnsafeUnpin, PhantomData<ArcInner<CoreRenderPipeline>>: UnsafeUnpin, *const ArcInner<CoreBindGroupLayout> is !null: UnsafeUnpin, PhantomData<ArcInner<CoreBindGroupLayout>>: UnsafeUnpin, *const ArcInner<CoreBindGroup> is !null: UnsafeUnpin, PhantomData<ArcInner<CoreBindGroup>>: UnsafeUnpin, *const ArcInner<CoreBuffer> is !null: UnsafeUnpin, PhantomData<ArcInner<CoreBuffer>>: UnsafeUnpin, *const ArcInner<Mutex<MapContext>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<MapContext>>>: UnsafeUnpin, InternalBitFlags: UnsafeUnpin, PhantomData<AlignedViewportSlot>: UnsafeUnpin, *const ArcInner<CoreSampler> is !null: UnsafeUnpin, PhantomData<ArcInner<CoreSampler>>: UnsafeUnpin, *const ArcInner<CoreTexture> is !null: UnsafeUnpin, PhantomData<ArcInner<CoreTexture>>: UnsafeUnpin, &'static str: UnsafeUnpin, InternalBitFlags: UnsafeUnpin, &'static [TextureFormat]: UnsafeUnpin, *const ArcInner<CoreTextureView> is !null: UnsafeUnpin, PhantomData<ArcInner<CoreTextureView>>: UnsafeUnpin, PhantomData<[u32; 4]>: UnsafeUnpin, PhantomData<((char, u16), GlyphAtlasEntry)>: UnsafeUnpin, PhantomData<(SpriteCacheKey, [f32; 4])>: UnsafeUnpin, PhantomData<(u64, u32)>: UnsafeUnpin, PhantomData<((u64, u64, u64, u64), BindGroup)>: UnsafeUnpin, PhantomData<((u64, u64, u64), BindGroup)>: UnsafeUnpin, PhantomData<PooledTarget>: UnsafeUnpin, PhantomData<(u64, CachedPathMask)>: UnsafeUnpin, PhantomData<EffectUniform>: UnsafeUnpin, PhantomData<GpuPassStep>: UnsafeUnpin, PhantomData<CanvasUniformData>: UnsafeUnpin, PhantomData<(StaticSceneId, CachedGpuScene)>: UnsafeUnpin, PhantomData<SlugCurve>: UnsafeUnpin, PhantomData<u32>: UnsafeUnpin, PhantomData<SlugBand>: UnsafeUnpin, PhantomData<SlugGlyphInstance>: UnsafeUnpin, PhantomData<((u64, u16, u64), CachedSlugGlyph)>: UnsafeUnpin, PhantomData<(u32, u32, u32, u32)>: UnsafeUnpin, *const ArcInner<DiskPipelineCache> is !null: UnsafeUnpin, PhantomData<ArcInner<DiskPipelineCache>>: UnsafeUnpin, *mut Counter<Channel<GpuEffectsEngine>>: UnsafeUnpin, *mut Counter<Channel<GpuEffectsEngine>>: UnsafeUnpin, *mut Counter<Channel<GpuEffectsEngine>>: UnsafeUnpin, *mut Counter<Channel<CanvasGpuEngine>>: UnsafeUnpin, *mut Counter<Channel<CanvasGpuEngine>>: UnsafeUnpin, *mut Counter<Channel<CanvasGpuEngine>>: UnsafeUnpin, PhantomData<(ExternalTextureId, ExternalTextureEntry)>: UnsafeUnpin, PhantomData<(TextLayoutKey, Arc<CachedTextLayout>)>: UnsafeUnpin, *const ArcInner<CoreQueue> is !null: UnsafeUnpin, PhantomData<ArcInner<CoreQueue>>: UnsafeUnpin, *const ArcInner<CoreDevice> is !null: UnsafeUnpin, PhantomData<ArcInner<CoreDevice>>: UnsafeUnpin, *const ArcInner<ContextWgpuCore> is !null: UnsafeUnpin, PhantomData<ArcInner<ContextWgpuCore>>: UnsafeUnpin, *const ArcInner<CoreSurface> is !null: UnsafeUnpin, PhantomData<ArcInner<CoreSurface>>: UnsafeUnpin, Align1<u8>: UnsafeUnpin, PhantomData<TextureFormat>: UnsafeUnpin, *const dyn WindowHandle is !null: UnsafeUnpin, PhantomData<dyn WindowHandle>: UnsafeUnpin,

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.