-
Notifications
You must be signed in to change notification settings - Fork 65
feat: add OpenHarmony platform support #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Android? 👀
| // 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 ).