commit 4e3ca159f42b3095fb12a356354d39df1fc0f548
parent a0100a6229ee32d4ff90e68fa578a4a5c9bfaa65
Author: kernelkind <kernelkind@gmail.com>
Date: Sat, 22 Nov 2025 20:24:19 -0700
feat(gif): new Animation
Signed-off-by: kernelkind <kernelkind@gmail.com>
Diffstat:
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/crates/notedeck/src/imgcache.rs b/crates/notedeck/src/imgcache.rs
@@ -238,6 +238,25 @@ impl AnimationOld {
}
}
+pub struct Animation {
+ pub first_frame: TextureFrame,
+ pub other_frames: Vec<TextureFrame>,
+}
+
+impl Animation {
+ pub fn get_frame(&self, index: usize) -> Option<&TextureFrame> {
+ if index == 0 {
+ Some(&self.first_frame)
+ } else {
+ self.other_frames.get(index - 1)
+ }
+ }
+
+ pub fn num_frames(&self) -> usize {
+ self.other_frames.len() + 1
+ }
+}
+
pub struct TextureFrame {
pub delay: Duration,
pub texture: TextureHandle,
diff --git a/crates/notedeck/src/lib.rs b/crates/notedeck/src/lib.rs
@@ -54,9 +54,9 @@ pub use filter::{FilterState, FilterStates, UnifiedSubscription};
pub use fonts::NamedFontFamily;
pub use i18n::{CacheStats, FluentArgs, FluentValue, LanguageIdentifier, Localization};
pub use imgcache::{
- get_render_state, AnimationOld, GifState, GifStateMap, ImageFrame, Images, LatestTexture,
- LoadableTextureState, MediaCache, MediaCacheType, RenderState, TextureFrame, TextureState,
- TextureStateOld, TexturedImage, TexturesCache,
+ get_render_state, Animation, AnimationOld, GifState, GifStateMap, ImageFrame, Images,
+ LatestTexture, LoadableTextureState, MediaCache, MediaCacheType, RenderState, TextureFrame,
+ TextureState, TextureStateOld, TexturedImage, TexturesCache,
};
pub use jobs::{
BlurhashParams, Job, JobError, JobIdOld, JobParams, JobParamsOwned, JobPool, JobState,