Introduce explicit image::allocate API
This commit is contained in:
parent
6fa54f7f6b
commit
23039e758e
15 changed files with 355 additions and 51 deletions
24
runtime/src/image.rs
Normal file
24
runtime/src/image.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
//! Allocate images explicitly to control presentation.
|
||||
use crate::core::image::Handle;
|
||||
use crate::futures::futures::channel::oneshot;
|
||||
use crate::task::{self, Task};
|
||||
|
||||
pub use crate::core::image::Allocation;
|
||||
|
||||
/// An image action.
|
||||
#[derive(Debug)]
|
||||
pub enum Action {
|
||||
/// Allocates the given [`Handle`].
|
||||
Allocate(Handle, oneshot::Sender<Allocation>),
|
||||
}
|
||||
|
||||
/// Allocates an image [`Handle`].
|
||||
///
|
||||
/// When you obtain an [`Allocation`] explicitly, you get the guarantee
|
||||
/// that using a [`Handle`] will draw the corresponding image immediately
|
||||
/// in the next frame.
|
||||
pub fn allocate(handle: Handle) -> Task<Allocation> {
|
||||
task::oneshot(|sender| {
|
||||
crate::Action::Image(Action::Allocate(handle, sender))
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue