diff options
author | TIN TUN AUNG <62133983+rayguo17@users.noreply.github.com> | 2025-03-29 07:19:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-28 23:19:49 +0000 |
commit | ed3dd8fbe03f41ee816cbe87c898a0cdc71d1115 (patch) | |
tree | 823700876b510f00ee1972c352dc1e5dbd644b15 /components/shared/script_layout | |
parent | 53f7c7b1dec3dfaa215e4a3c678e5e42214b4f05 (diff) | |
download | servo-ed3dd8fbe03f41ee816cbe87c898a0cdc71d1115.tar.gz servo-ed3dd8fbe03f41ee816cbe87c898a0cdc71d1115.zip |
Animation: Aggregate Animated Image Info to Document (#36141)
Signed-off-by: rayguo17 <rayguo17@gmail.com>
Diffstat (limited to 'components/shared/script_layout')
-rw-r--r-- | components/shared/script_layout/Cargo.toml | 1 | ||||
-rw-r--r-- | components/shared/script_layout/lib.rs | 28 |
2 files changed, 29 insertions, 0 deletions
diff --git a/components/shared/script_layout/Cargo.toml b/components/shared/script_layout/Cargo.toml index ddb4017c21c..13d50e4fafe 100644 --- a/components/shared/script_layout/Cargo.toml +++ b/components/shared/script_layout/Cargo.toml @@ -21,6 +21,7 @@ euclid = { workspace = true } fnv = { workspace = true } fonts = { path = "../../fonts" } fonts_traits = { workspace = true } +fxhash = { workspace = true } html5ever = { workspace = true } ipc-channel = { workspace = true } libc = { workspace = true } diff --git a/components/shared/script_layout/lib.rs b/components/shared/script_layout/lib.rs index 9c70394b0fd..3001f9ce77d 100644 --- a/components/shared/script_layout/lib.rs +++ b/components/shared/script_layout/lib.rs @@ -24,10 +24,12 @@ use euclid::Size2D; use euclid::default::{Point2D, Rect}; use fnv::FnvHashMap; use fonts::{FontContext, SystemFontServiceProxy}; +use fxhash::FxHashMap; use ipc_channel::ipc::IpcSender; use libc::c_void; use malloc_size_of_derive::MallocSizeOf; use net_traits::image_cache::{ImageCache, PendingImageId}; +use pixels::Image; use profile_traits::mem::Report; use profile_traits::time; use script_traits::{InitialScriptState, LoadData, Painter, ScriptThreadMessage}; @@ -400,6 +402,8 @@ pub struct ReflowResult { /// to communicate them with the Constellation and also the `Window` /// element of their content pages. pub iframe_sizes: IFrameSizes, + /// The mapping of node to animated image, need to be returned to ImageAnimationManager + pub node_to_image_animation_map: FxHashMap<OpaqueNode, ImageAnimationState>, } /// Information needed for a script-initiated reflow. @@ -427,6 +431,8 @@ pub struct ReflowRequest { pub animation_timeline_value: f64, /// The set of animations for this document. pub animations: DocumentAnimationSet, + /// The set of image animations. + pub node_to_image_animation_map: FxHashMap<OpaqueNode, ImageAnimationState>, /// The theme for the window pub theme: PrefersColorScheme, } @@ -501,3 +507,25 @@ pub fn node_id_from_scroll_id(id: usize) -> Option<usize> { } None } + +#[derive(Clone, Debug, MallocSizeOf)] +pub struct ImageAnimationState { + #[ignore_malloc_size_of = "Arc is hard"] + image: Arc<Image>, + active_frame: usize, + last_update_time: f64, +} + +impl ImageAnimationState { + pub fn new(image: Arc<Image>) -> Self { + Self { + image, + active_frame: 0, + last_update_time: 0., + } + } + + pub fn image_key(&self) -> Option<ImageKey> { + self.image.id + } +} |