feat: add OpenHarmony platform support#261
feat: add OpenHarmony platform support#261richerfu wants to merge 1 commit intorust-windowing:masterfrom
Conversation
|
Thanks for the draft PR, is it useful to see how OpenHarmony is used! CC rust-windowing/winit#4081, we shouldn't merge this before the Winit side is resolved. |
|
I'm planning to use it with |
madsmtm
left a comment
There was a problem hiding this comment.
Given the response in rust-windowing/winit#4081 (comment), I'd be fine with merging this before Winit support.
48ca611 to
8b2dc97
Compare
| // Install the Android event loop extension if necessary. | ||
| builder.with_openharmony_app(app); |
| // Swizzle colors from RGBX to BGR | ||
| let [b, g, r, _] = pixel.to_le_bytes(); | ||
| output[i * 4].write(b); | ||
| output[i * 4 + 1].write(g); | ||
| output[i * 4 + 2].write(r); |
There was a problem hiding this comment.
Since this entire module was copied from Android, keep in mind that I recently fixed some typos in this borked swizzle: ae1565b
|
|
||
|
|
||
| # OpenHarmony | ||
| /src/ohos.rs @richerfu No newline at end of file |
There was a problem hiding this comment.
One newline please, and an empty one at the end to satisfy GitHub:
| # OpenHarmony | |
| /src/ohos.rs @richerfu | |
| # OpenHarmony | |
| /src/ohos.rs @richerfu |
| } | ||
|
|
||
| #[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))] | ||
| #[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64", target_env = "ohos")))] |
There was a problem hiding this comment.
This needs to be in the cfg above as well; but there's no exception for Android so OHOS likely doesn't need one either?
|
|
||
| [target.'cfg(all(unix, not(any(target_vendor = "apple", target_os = "android", target_os = "redox"))))'.dependencies] | ||
| [target.'cfg(target_env = "ohos")'.dependencies] | ||
| ohos-native-window-binding = { version = "0.1" } |
There was a problem hiding this comment.
| ohos-native-window-binding = { version = "0.1" } | |
| ohos-native-window-binding = "0.1" |
Same below perhaps?
| winit::platform::web::EventLoopExtWebSys::spawn_app(event_loop, app); | ||
|
|
||
| #[cfg(target_env = "ohos")] | ||
| winit::platform::ohos::EventLoopExtOpenHarmony::spawn_app(event_loop, app); |
There was a problem hiding this comment.
Do you know why OHOS doesn't support run_app()? Maybe I need to investigate the same for Android which also isn't required to run a blocking loop (that's pretty bad for the ANativeActivity_onCreate() entrypoint too, which is why wrapper crates like android-activity execute the users' entrypoint in a new thread).
This is the first draft PR to support openharmony for softbuffer. There are two things need to do:
Resumedevent and softbuffer example will crash( Maybe fix it in 2025.06 ).