mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Animation: Aggregate Animated Image Info to Document (#36141)
Signed-off-by: rayguo17 <rayguo17@gmail.com>
This commit is contained in:
parent
53f7c7b1de
commit
ed3dd8fbe0
10 changed files with 145 additions and 9 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue