mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -04:00
Make individual egui_extras image loaders public (#7551)
This was initially a PR to add kitdiff, but this now lives in it's own crate: https://github.com/rerun-io/kitdiff I needed to make the image loaders public, this way it's possible to compose image loaders together (which allowed me to create a image diff loader that uses two other image loaders). But you can't use the `ctx.try_load_image` since that would deadlock, so you have to store a reference to the other loader in the wrapping loader.
This commit is contained in:
@@ -387,7 +387,7 @@ pub type ImageLoadResult = Result<ImagePoll>;
|
||||
/// An `ImageLoader` decodes raw bytes into a [`ColorImage`].
|
||||
///
|
||||
/// Implementations are expected to cache at least each `URI`.
|
||||
pub trait ImageLoader {
|
||||
pub trait ImageLoader: std::any::Any {
|
||||
/// Unique ID of this loader.
|
||||
///
|
||||
/// To reduce the chance of collisions, include `module_path!()` as part of this ID.
|
||||
@@ -517,6 +517,16 @@ impl TexturePoll {
|
||||
Self::Ready { texture } => Some(texture.id),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_pending(&self) -> bool {
|
||||
matches!(self, Self::Pending { .. })
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_ready(&self) -> bool {
|
||||
matches!(self, Self::Ready { .. })
|
||||
}
|
||||
}
|
||||
|
||||
pub type TextureLoadResult = Result<TexturePoll>;
|
||||
|
||||
Reference in New Issue
Block a user