-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add OpenHarmony OS support #164
Conversation
src/ohos.rs
Outdated
#[non_exhaustive] | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
pub struct OhosNdkWindowHandle { | ||
pub xcomponent: NonNull<c_void>, |
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.
When you create EGLDisplay
what you pass to it? I'd assume the xcomponent
, but not a native_window
? Or how does it work?
src/ohos.rs
Outdated
pub xcomponent: NonNull<c_void>, | ||
pub native_window: NonNull<c_void>, |
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.
Maybe you could link to documentation about these?
And can you get one from the other? If so, then I'd strongly prefer that we only store one of these pointers.
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.
Yes, please link documentation. This would be an entirely new target.
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.
I added some documentation to the module, including links to the relevant OpenHarmony documentation pages.
And can you get one from the other? If so, then I'd strongly prefer that we only store one of these pointers.
Not as far as I know. The native window and the xcomponent belong together, and are received via a callback when the XComponent is created.
Sorry for the slow reply. I believe I was mistaken with my previous statement that the The latest version of the XComponent Guidelines available in English, seems to be Native XComponent Guidelines 4.0 (English). To summarize the workflow (with the C++ examples in the documentation):
The API provided by OHNativeWindow is quite low level, and missing the following APIs compared
I'm currently leaning towards it being fine if the |
Add support for the [OpenHarmony] operating system, which is a [tier-2 target] in Rust starting with Rust 1.79. On OpenHarmony [ArkUI] is used to develop applications. ArkUI provides the [XComponent] type, which allows native code (e.g. Rust) to use EGL / OpenGL ES to render directly to a native window. [tier-2 target]: https://doc.rust-lang.org/nightly/rustc/platform-support/openharmony.html [OpenHarmony]: https://gitee.com/openharmony/docs/blob/master/en/OpenHarmony-Overview.md [ArkUI]: https://gitee.com/openharmony/docs/blob/master/en/application-dev/ui/arkui-overview.md [XComponent]: https://gitee.com/openharmony/docs/blob/master/en/application-dev/ui/arkts-common-components-xcomponent.md
I spent a few minutes trying to read the docs, and I still have no idea what an "XComponent" actually is? As in, what does it correspond to visually? Is it the top-level window itself? Or can components be nested like subsurfaces/subviews? If I tried to do some GUI development in OpenHarmony, and I wanted to place a button on the screen somewhere, would that button be a "subclass" (or similar) of XComponent, of OHNativeWindow, or of something entirely different? |
On OpenHarmony ArkTS is the usual language apps including their UI are written in. ArkTS is a flavor of typescript, which adds some restrictions, like forcing initialization of variables and requiring that all types are known at compile time (i.e. The ArkTS XComponent can be used in the ArkTS UI code to obtain a surface, that the native C++ (or in our case Rust) code can render to using OpenGL. The size and position of the XComponent is determined by the ArkTS UI layout. In this example the ArkTS UI definition is simply one Textbox (which is used as a URL bar) and beneath that an
See also Introduction to ArkUI
You would use the ArkTS Button builtin. The XComponent (surface type) is used when rendering directly from native code via OpenGL. |
Can you query the size of the surface from just |
Yes, one can use
|
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.
Cool, then I think this makes sense as-is, and if we later find that the XComponent is actually needed, then we can always add an optional field.
Co-authored-by: Mads Marquart <mads@marquart.dk>
Is there anything I still need to do before this can be merged? Should I squash? |
I can squash-merge |
Add support for the OpenHarmony operating system, which is a tier-2 target in Rust starting with
Rust 1.78.
On OpenHarmony ArkUI is used to develop
applications. ArkUI provides the XComponent
type, which allows native code (e.g. Rust) to use
EGL / OpenGL ES to render directly to a native
window.