pub struct HarmonyPlatform { /* private fields */ }Expand description
Unified HarmonyOS / OpenHarmony platform backend bridging ArkUI XComponent, OHNativeWindow, EGL/GLES3/Vulkan, and NAPI.
Implementations§
Source§impl HarmonyPlatform
ArkUI XComponent binding, avoidArea safe-area, foldable transition, touch/key/IME, and UIAbility lifecycle hooks for HarmonyPlatform.
impl HarmonyPlatform
ArkUI XComponent binding, avoidArea safe-area, foldable transition, touch/key/IME, and UIAbility lifecycle hooks for HarmonyPlatform.
Sourcepub fn for_device_type(device_type: HarmonyDeviceType) -> Self
pub fn for_device_type(device_type: HarmonyDeviceType) -> Self
Sourcepub fn with_capture_last_frame(self, enabled: bool) -> Self
pub fn with_capture_last_frame(self, enabled: bool) -> Self
Sourcepub fn last_framebuffer(&self, id: WindowId) -> Option<&Framebuffer>
pub fn last_framebuffer(&self, id: WindowId) -> Option<&Framebuffer>
Sourcepub fn on_vsync_frame(&mut self, timestamp_ns: i64) -> f32
pub fn on_vsync_frame(&mut self, timestamp_ns: i64) -> f32
Sourcepub fn request_native_vsync_frame(
&self,
callback: unsafe extern "C" fn(i64, usize),
user_data: usize,
) -> bool
pub fn request_native_vsync_frame( &self, callback: unsafe extern "C" fn(i64, usize), user_data: usize, ) -> bool
Schedules the next native OH_NativeVSync frame callback using callback and opaque user_data.
§Arguments
unsafe extern "C" fn(i64, usize)- Native C callback receiving(timestamp_ns, user_data).usize- Opaque context pointer forwarded tocallback.
§Returns
bool-trueifOH_NativeVSync_RequestFrameaccepted the request.
Sourcepub fn destroy_native_vsync(&mut self)
pub fn destroy_native_vsync(&mut self)
Releases the native OH_NativeVSync* handle if active.
Sourcepub fn primary_window_id(&self) -> Option<WindowId>
pub fn primary_window_id(&self) -> Option<WindowId>
Sourcepub fn attach_xcomponent(
&mut self,
native_window: usize,
xcomponent: usize,
phys_width: u32,
phys_height: u32,
)
pub fn attach_xcomponent( &mut self, native_window: usize, xcomponent: usize, phys_width: u32, phys_height: u32, )
Attaches live ArkUI OHNativeWindow* and OH_NativeXComponent* handles received from OnSurfaceCreatedCB.
§Arguments
&Self- Mutable HarmonyOS platform.usize- RawOHNativeWindow*pointer.usize- RawOH_NativeXComponent*pointer.u32- Physical surface width in pixels.u32- Physical surface height in pixels.
Sourcepub fn detach_xcomponent(&mut self)
pub fn detach_xcomponent(&mut self)
Detaches ArkUI OHNativeWindow* safely on OnSurfaceDestroyedCB and cancels dangling touches.
§Arguments
&Self- Mutable HarmonyOS platform.
Sourcepub fn update_avoid_area(&mut self, avoid: HarmonyAvoidArea)
pub fn update_avoid_area(&mut self, avoid: HarmonyAvoidArea)
Updates HarmonyOS window.AvoidArea insets and emits SafeAreaChanged plus KeyboardVisibilityChanged.
§Arguments
&Self- Mutable HarmonyOS platform.HarmonyAvoidArea- Physical-pixel avoid area from@ohos.window.
Sourcepub fn handle_lifecycle_hook(
&mut self,
hook: HarmonyLifecycleHook,
) -> Vec<WindowEvent>
pub fn handle_lifecycle_hook( &mut self, hook: HarmonyLifecycleHook, ) -> Vec<WindowEvent>
Translates a Stage-Model HarmonyLifecycleHook into canonical EUV SystemEvents and Freeze/Resume/Destroy transitions.
§Arguments
&Self- Mutable HarmonyOS platform.HarmonyLifecycleHook- Native ArkTS UIAbility / WindowStage callback payload.
§Returns
Vec<WindowEvent>- Normalized events also enqueued forpoll_events().
Sourcepub fn handle_touch_event(
&mut self,
touch_type: i32,
raw_id: i32,
phys_x: f32,
phys_y: f32,
) -> Vec<WindowEvent>
pub fn handle_touch_event( &mut self, touch_type: i32, raw_id: i32, phys_x: f32, phys_y: f32, ) -> Vec<WindowEvent>
Translates an OpenHarmony OH_NativeXComponent touch contact action into normalized EUV pointer events.
§Arguments
&Self- Mutable HarmonyOS platform.i32- OpenHarmony touch action (HARMONY_TOUCH_DOWN..HARMONY_TOUCH_CANCEL).i32- Raw contact identifier.f32- Component-local physical X coordinate.f32- Component-local physical Y coordinate.
§Returns
Vec<WindowEvent>- Normalized pointer events.
Sourcepub fn handle_key_event(
&mut self,
ohos_code: i32,
down: bool,
) -> Option<WindowEvent>
pub fn handle_key_event( &mut self, ohos_code: i32, down: bool, ) -> Option<WindowEvent>
Sourcepub fn handle_ime_commit(&mut self, text: String)
pub fn handle_ime_commit(&mut self, text: String)
Dispatches committed HarmonyOS IME UTF-8 text into WindowEvent::TextInput.
§Arguments
&Self- Mutable HarmonyOS platform.String- Committed UTF-8 text.
Source§impl HarmonyPlatform
Unified host-channel capability and visual-equivalence queries for HarmonyPlatform.
impl HarmonyPlatform
Unified host-channel capability and visual-equivalence queries for HarmonyPlatform.
Sourcepub fn host_channel_capabilities(&self) -> HostChannelCapabilities
pub fn host_channel_capabilities(&self) -> HostChannelCapabilities
Returns the truthful HostChannelCapabilities for this HarmonyOS instance.
Off-device / simulated profiles ALWAYS set simulated_profile = true and direct_gpu_verified_on_device = false.
§Returns
HostChannelCapabilities- Declared HarmonyOS channels, visual gate, and real-device GPU verification flags.
Sourcepub fn select_render_channel(
&self,
requested: Option<HostRenderChannel>,
) -> HostChannelSelection
pub fn select_render_channel( &self, requested: Option<HostRenderChannel>, ) -> HostChannelSelection
Source§impl HarmonyPlatform
impl HarmonyPlatform
pub fn get_profile(&self) -> HarmonyDeviceProfile
pub fn get_mut_profile(&mut self) -> &mut HarmonyDeviceProfile
pub fn set_profile(&mut self, val: HarmonyDeviceProfile) -> &mut Self
pub fn get_fold_state(&self) -> HarmonyFoldState
pub fn get_mut_fold_state(&mut self) -> &mut HarmonyFoldState
pub fn set_fold_state(&mut self, val: HarmonyFoldState) -> &mut Self
pub fn get_attached_native_window(&self) -> usize
pub fn get_mut_attached_native_window(&mut self) -> &mut usize
pub fn set_attached_native_window(&mut self, val: usize) -> &mut Self
pub fn get_attached_xcomponent(&self) -> usize
pub fn get_mut_attached_xcomponent(&mut self) -> &mut usize
pub fn set_attached_xcomponent(&mut self, val: usize) -> &mut Self
pub fn get_safe_area(&self) -> SafeAreaInsets
pub fn get_mut_safe_area(&mut self) -> &mut SafeAreaInsets
pub fn set_safe_area(&mut self, val: SafeAreaInsets) -> &mut Self
pub fn get_lifecycle(&self) -> &MobileSessionLifecycle
pub fn get_mut_lifecycle(&mut self) -> &mut MobileSessionLifecycle
pub fn set_lifecycle(&mut self, val: MobileSessionLifecycle) -> &mut Self
pub fn get_mut_primary_window(&mut self) -> &mut Option<WindowId>
pub fn set_primary_window(&mut self, val: Option<WindowId>) -> &mut Self
pub fn get_windows(&self) -> &HashMap<WindowId, HarmonyWindowRecord>
pub fn get_mut_windows(&mut self) -> &mut HashMap<WindowId, HarmonyWindowRecord>
pub fn set_windows( &mut self, val: HashMap<WindowId, HarmonyWindowRecord>, ) -> &mut Self
pub fn get_pending_events(&self) -> &Vec<WindowEvent>
pub fn get_mut_pending_events(&mut self) -> &mut Vec<WindowEvent>
pub fn set_pending_events(&mut self, val: Vec<WindowEvent>) -> &mut Self
pub fn get_mut_clipboard(&mut self) -> &mut Option<String>
pub fn set_clipboard(&mut self, val: Option<String>) -> &mut Self
pub fn get_storage(&self) -> &HashMap<String, String>
pub fn get_mut_storage(&mut self) -> &mut HashMap<String, String>
pub fn set_storage(&mut self, val: HashMap<String, String>) -> &mut Self
pub fn get_route_stack(&self) -> &Vec<String>
pub fn get_mut_route_stack(&mut self) -> &mut Vec<String>
pub fn set_route_stack(&mut self, val: Vec<String>) -> &mut Self
pub fn get_theme(&self) -> ThemeMode
pub fn get_mut_theme(&mut self) -> &mut ThemeMode
pub fn set_theme(&mut self, val: ThemeMode) -> &mut Self
pub fn get_pump_paused(&self) -> bool
pub fn get_mut_pump_paused(&mut self) -> &mut bool
pub fn set_pump_paused(&mut self, val: bool) -> &mut Self
pub fn get_capture_last_frame(&self) -> bool
pub fn get_mut_capture_last_frame(&mut self) -> &mut bool
pub fn set_capture_last_frame(&mut self, val: bool) -> &mut Self
pub fn get_vsync_handle(&self) -> usize
pub fn get_mut_vsync_handle(&mut self) -> &mut usize
pub fn set_vsync_handle(&mut self, val: usize) -> &mut Self
pub fn get_last_vsync_timestamp_ns(&self) -> i64
pub fn get_mut_last_vsync_timestamp_ns(&mut self) -> &mut i64
pub fn set_last_vsync_timestamp_ns(&mut self, val: i64) -> &mut Self
Trait Implementations§
Source§impl Clone for HarmonyPlatform
impl Clone for HarmonyPlatform
Source§impl Debug for HarmonyPlatform
impl Debug for HarmonyPlatform
Source§impl Default for HarmonyPlatform
Default HarmonyPlatform configured for HarmonyDeviceType::Phone.
impl Default for HarmonyPlatform
Default HarmonyPlatform configured for HarmonyDeviceType::Phone.
Source§impl PlatformBackend for HarmonyPlatform
PlatformBackend implementation for HarmonyPlatform.
impl PlatformBackend for HarmonyPlatform
PlatformBackend implementation for HarmonyPlatform.
Source§fn kind(&self) -> PlatformKind
fn kind(&self) -> PlatformKind
Source§fn capabilities(&self) -> PlatformCapabilities
fn capabilities(&self) -> PlatformCapabilities
Source§fn create_window(
&mut self,
config: &WindowConfig,
) -> Result<WindowState, PlatformError>
fn create_window( &mut self, config: &WindowConfig, ) -> Result<WindowState, PlatformError>
Source§fn window_state(&self, id: WindowId) -> Option<WindowState>
fn window_state(&self, id: WindowId) -> Option<WindowState>
Source§fn raw_window_handle(&self, id: WindowId) -> RawWindowHandle
fn raw_window_handle(&self, id: WindowId) -> RawWindowHandle
Source§fn poll_events(&mut self) -> Vec<WindowEvent>
fn poll_events(&mut self) -> Vec<WindowEvent>
Source§fn set_frame_pump_paused(&mut self, paused: bool)
fn set_frame_pump_paused(&mut self, paused: bool)
Pauses or resumes the HarmonyOS OH_NativeVSync frame pump flag.
§Arguments
&Self- Mutable HarmonyOS platform.bool-trueto pause for background freeze.
Source§fn is_frame_pump_paused(&self) -> bool
fn is_frame_pump_paused(&self) -> bool
Source§fn present_framebuffer(
&mut self,
id: WindowId,
framebuffer: &Framebuffer,
) -> Result<(), PlatformError>
fn present_framebuffer( &mut self, id: WindowId, framebuffer: &Framebuffer, ) -> Result<(), PlatformError>
Source§fn present_framebuffer_region(
&mut self,
id: WindowId,
framebuffer: &Framebuffer,
damage: DamageRegion,
) -> Result<(), PlatformError>
fn present_framebuffer_region( &mut self, id: WindowId, framebuffer: &Framebuffer, damage: DamageRegion, ) -> Result<(), PlatformError>
Presents framebuffer (or only damage) to the attached OHNativeWindow* buffer without cloning when capture is disabled.
§Arguments
WindowId- Window identifier.&Framebuffer- Rendered RGBA8 framebuffer.DamageRegion- Damaged pixel region updated this frame.
§Returns
Result<(), PlatformError>- Presentation status.
Source§fn read_clipboard(&self) -> Option<String>
fn read_clipboard(&self) -> Option<String>
Source§fn write_clipboard(&mut self, text: &str) -> Result<(), PlatformError>
fn write_clipboard(&mut self, text: &str) -> Result<(), PlatformError>
Source§fn system_theme(&self) -> ThemeMode
fn system_theme(&self) -> ThemeMode
Source§fn display_refresh_rate_hz(&self) -> f32
fn display_refresh_rate_hz(&self) -> f32
Source§fn wait_for_events(&mut self) -> Vec<WindowEvent>
fn wait_for_events(&mut self) -> Vec<WindowEvent>
Source§impl PlatformHostAdapter for HarmonyPlatform
PlatformHostAdapter implementation for HarmonyPlatform.
impl PlatformHostAdapter for HarmonyPlatform
PlatformHostAdapter implementation for HarmonyPlatform.
Source§fn device_form_factor(&self) -> DeviceFormFactor
fn device_form_factor(&self) -> DeviceFormFactor
Source§impl PlatformLifecycleBridge for HarmonyPlatform
PlatformLifecycleBridge implementation for HarmonyPlatform.
impl PlatformLifecycleBridge for HarmonyPlatform
PlatformLifecycleBridge implementation for HarmonyPlatform.
Source§fn freeze_surface(&mut self) -> Vec<WindowEvent>
fn freeze_surface(&mut self) -> Vec<WindowEvent>
Source§fn resume_surface(&mut self) -> Vec<WindowEvent>
fn resume_surface(&mut self) -> Vec<WindowEvent>
Source§fn destroy_surface(&mut self) -> Vec<WindowEvent>
fn destroy_surface(&mut self) -> Vec<WindowEvent>
Source§impl PlatformStorage for HarmonyPlatform
PlatformStorage implementation for HarmonyPlatform.
impl PlatformStorage for HarmonyPlatform
PlatformStorage implementation for HarmonyPlatform.
Source§fn storage_set(&mut self, key: &str, value: &str) -> Result<(), PlatformError>
fn storage_set(&mut self, key: &str, value: &str) -> Result<(), PlatformError>
Source§fn storage_remove(&mut self, key: &str) -> Result<(), PlatformError>
fn storage_remove(&mut self, key: &str) -> Result<(), PlatformError>
Source§fn storage_clear(&mut self) -> Result<(), PlatformError>
fn storage_clear(&mut self) -> Result<(), PlatformError>
Source§impl WindowController for HarmonyPlatform
WindowController implementation for HarmonyPlatform.
impl WindowController for HarmonyPlatform
WindowController implementation for HarmonyPlatform.