Skip to content
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

Switch from ndk-glue to raw-window-handle crate #1418

Merged
merged 1 commit into from
Jun 7, 2022
Merged

Conversation

MarijnS95
Copy link
Member

winit provides a raw-window-handle specifically for crates to process window pointers/references in a crate-agnostic way. glutin can use it too, to get rid of its ndk-glue dependency which otherwise has a hard versioning dependency as it should be updated in sync with winit.

Over time this should be worked into the other backends, in turn removing winit from the new_windowed() function signature and replacing it with impl HasRawWindowHandle or dyn HasRawWindowHandle. This will also allow Android users to pass generic Surfaces (first converted to a so-called NativeWindow in the NDK through #272, then passed as RawWindowHandle thanks to #274) created in Java / Kotlin / Flutter to render to individual UI elements instead of the entire screen with a NativeActivity (ndk-glue). It'll in turn make the code more generic, too, as raw-window-handle has a variant for every platform / windowing system currently supported by glutin.

CC @jamienicol

  • Tested on all platforms changed
  • Compilation warnings were addressed
  • cargo fmt has been run on this branch
  • cargo doc builds successfully
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality

`winit` provides a `raw-window-handle` specifically for crates to
process window pointers/references in a crate-agnostic way.  `glutin`
can use it too, to get rid of its `ndk-glue` dependency which otherwise
has a hard versioning dependency  as it should be updated in sync with
`winit`.

Over time this should be worked into the other backends, in turn
removing `winit` from the `new_windowed()` function signature and
replacing it with `impl HasRawWindowHandle` or `dyn HasRawWindowHandle`.
This will also allow Android users to pass generic `Surface`s (first
converted to a so-called `NativeWindow` in the NDK through [#272], then
passed as `RawWindowHandle` thanks to [#274]) created in Java / Kotlin /
Flutter to render to individual UI elements instead of the entire screen
with a `NativeActivity` (`ndk-glue`).  It'll in turn make the code more
generic, too, as `raw-window-handle` has a variant for every platform /
windowing system currently supported by glutin.

[#272]: rust-mobile/ndk#272
[#274]: rust-mobile/ndk#274
@jamienicol
Copy link
Contributor

This looks good to me. Removing the direct dependency on the glue will make things easier. 👍

@MarijnS95
Copy link
Member Author

@jamienicol can you give an explicit review approval or should I just merge this in, given that @kchibisov gave me free reign over the Android guts of glutin?

Copy link
Contributor

@jamienicol jamienicol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MarijnS95 MarijnS95 merged commit 3315bd6 into master Jun 7, 2022
@MarijnS95 MarijnS95 deleted the android-rwh branch June 7, 2022 16:48
@maroider
Copy link
Member

maroider commented Jun 7, 2022

winit provides a raw-window-handle specifically for crates to process window pointers/references in a crate-agnostic way. glutin can use it too, to get rid of its ndk-glue dependency which otherwise has a hard versioning dependency as it should be updated in sync with winit.

I've never really been a big fan of the tight coupling between glutin and winit, so it would be neat to see if we can remove that where it makes sense.

@MarijnS95
Copy link
Member Author

MarijnS95 commented Jun 7, 2022

@maroider the same opinion was voiced by @kchibisov. I think we can have isolated cases where glutin provides winit helpers (ie. to deal with events) but those should perhaps reside behind a feature flag and be few and far between.

However, some of this may hinge on Android-specific concerns raised recently, regarding platform divergence.

(Edit: see also the second paragraph: my intention is to get rid of it almost completely anyway)

@maroider
Copy link
Member

maroider commented Jun 7, 2022

Do we have an issue outlining these intentions? If not, then we should probably make one.

@MarijnS95
Copy link
Member Author

I don't think so, as I was planning to just "get it over with in a PR soon/quickly™", but feel free to create one as I don't know when I can (would like to get current open PRs and issues fleshed out, but I do have some in-progress changes to migrate to "pure" RawWindowHandle).

@kchibisov
Copy link
Member

@maroider #1271

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants