-
Notifications
You must be signed in to change notification settings - Fork 56
Add UEFI support #176
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?
Add UEFI support #176
Conversation
notgull
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.
Thanks for the PR! Two things:
raw_window_handleis intended to be a common types crate to be used by higher-level crates, rather than something that implements functionality on its own. So I would rather have it represent aHandleas aNonNull<T>since it's a raw pointer.- From a quick glance at the docs, it seems that
GraphicsOutputhas a framebuffer of its own. So I think it would be better ifGraphicsOutputwas a property of theWindowHandlerather than theDisplayHandle.
src/lib.rs
Outdated
| /// | ||
| /// ## Availability Hints | ||
| /// This variant is used on UEFI. | ||
| #[cfg(target_os = "uefi")] |
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.
| #[cfg(target_os = "uefi")] |
We avoid target conditionals here.
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.
Done
src/lib.rs
Outdated
| from_impl!(RawDisplayHandle, Android, AndroidDisplayHandle); | ||
| from_impl!(RawDisplayHandle, Haiku, HaikuDisplayHandle); | ||
|
|
||
| #[cfg(target_os = "uefi")] |
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.
| #[cfg(target_os = "uefi")] |
Ditto
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.
Done
src/uefi.rs
Outdated
| impl DisplayHandle<'static> { | ||
| /// Create a UEFI-based display handle. | ||
| /// | ||
| /// As no data is borrowed by this handle, it is completely safe to create. This function | ||
| /// may be useful to windowing framework implementations that want to avoid unsafe code. | ||
| /// | ||
| /// # Example | ||
| /// | ||
| /// ``` | ||
| /// # use raw_window_handle::{DisplayHandle, HasDisplayHandle}; | ||
| /// # fn do_something(rwh: impl HasDisplayHandle) { let _ = rwh; } | ||
| /// let handle = DisplayHandle::uefi(); | ||
| /// do_something(handle); | ||
| /// ``` | ||
| pub fn uefi() -> Result<Self, HandleError> { | ||
| let proto = boot::get_handle_for_protocol::<GraphicsOutput>() | ||
| .or_else(|_| Err(HandleError::Unavailable))?; | ||
| // SAFETY: No data is borrowed. | ||
| Ok(unsafe { Self::borrow_raw(UefiDisplayHandle::new(proto).into()) }) | ||
| } | ||
| } |
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.
| impl DisplayHandle<'static> { | |
| /// Create a UEFI-based display handle. | |
| /// | |
| /// As no data is borrowed by this handle, it is completely safe to create. This function | |
| /// may be useful to windowing framework implementations that want to avoid unsafe code. | |
| /// | |
| /// # Example | |
| /// | |
| /// ``` | |
| /// # use raw_window_handle::{DisplayHandle, HasDisplayHandle}; | |
| /// # fn do_something(rwh: impl HasDisplayHandle) { let _ = rwh; } | |
| /// let handle = DisplayHandle::uefi(); | |
| /// do_something(handle); | |
| /// ``` | |
| pub fn uefi() -> Result<Self, HandleError> { | |
| let proto = boot::get_handle_for_protocol::<GraphicsOutput>() | |
| .or_else(|_| Err(HandleError::Unavailable))?; | |
| // SAFETY: No data is borrowed. | |
| Ok(unsafe { Self::borrow_raw(UefiDisplayHandle::new(proto).into()) }) | |
| } | |
| } |
This level of functionality is too high for this crate.
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.
Done
The framebuffer is only available when the Graphics Output Protocol implements a framebuffer mode. Otherwise, you have to use blit mode. |
|
Still, you draw to the |
|
I'm not sure what you mean. When drawing in UEFI, you use a temporary buffer which you render to. Then whenever you present, you copy from that buffer to the memory mapped one if it is available. Otherwise, you use the blit function in the protocol. If the memory mapped buffer is not available, that means the GPU just doesn't give the ability for direct screen access. I was wanting to use this with something like iced and have it like a compositor. Have multiple windows which get drawn and be able to manipulate them. At least in this crate and softbuffer, it shouldn't be anything special to make that possible. |
9a2e5b5 to
ebc69d4
Compare
ebc69d4 to
3187a00
Compare
No description provided.