mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
parent
6d2f70a4fd
commit
be2cb665de
19 changed files with 315 additions and 68 deletions
|
@ -27,6 +27,7 @@ use layers::rendergl;
|
|||
use layers::scene::Scene;
|
||||
use msg::compositor_msg::{Epoch, LayerId};
|
||||
use msg::compositor_msg::{ReadyState, PaintState, ScrollPolicy};
|
||||
use msg::constellation_msg::AnimationState;
|
||||
use msg::constellation_msg::Msg as ConstellationMsg;
|
||||
use msg::constellation_msg::{ConstellationChan, NavigationDirection};
|
||||
use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData};
|
||||
|
@ -166,8 +167,11 @@ struct PipelineDetails {
|
|||
/// The status of this pipeline's PaintTask.
|
||||
paint_state: PaintState,
|
||||
|
||||
/// Whether animations are running.
|
||||
/// Whether animations are running
|
||||
animations_running: bool,
|
||||
|
||||
/// Whether there are animation callbacks
|
||||
animation_callbacks_running: bool,
|
||||
}
|
||||
|
||||
impl PipelineDetails {
|
||||
|
@ -177,6 +181,7 @@ impl PipelineDetails {
|
|||
ready_state: ReadyState::Blank,
|
||||
paint_state: PaintState::Painting,
|
||||
animations_running: false,
|
||||
animation_callbacks_running: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -278,9 +283,9 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
self.change_paint_state(pipeline_id, paint_state);
|
||||
}
|
||||
|
||||
(Msg::ChangeRunningAnimationsState(pipeline_id, running_animations),
|
||||
(Msg::ChangeRunningAnimationsState(pipeline_id, animation_state),
|
||||
ShutdownState::NotShuttingDown) => {
|
||||
self.change_running_animations_state(pipeline_id, running_animations);
|
||||
self.change_running_animations_state(pipeline_id, animation_state);
|
||||
}
|
||||
|
||||
(Msg::ChangePageTitle(pipeline_id, title), ShutdownState::NotShuttingDown) => {
|
||||
|
@ -422,11 +427,22 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
/// recomposite if necessary.
|
||||
fn change_running_animations_state(&mut self,
|
||||
pipeline_id: PipelineId,
|
||||
animations_running: bool) {
|
||||
self.get_or_create_pipeline_details(pipeline_id).animations_running = animations_running;
|
||||
|
||||
if animations_running {
|
||||
self.composite_if_necessary(CompositingReason::Animation);
|
||||
animation_state: AnimationState) {
|
||||
match animation_state {
|
||||
AnimationState::AnimationsPresent => {
|
||||
self.get_or_create_pipeline_details(pipeline_id).animations_running = true;
|
||||
self.composite_if_necessary(CompositingReason::Animation);
|
||||
}
|
||||
AnimationState::AnimationCallbacksPresent => {
|
||||
self.get_or_create_pipeline_details(pipeline_id).animation_callbacks_running = true;
|
||||
self.composite_if_necessary(CompositingReason::Animation);
|
||||
}
|
||||
AnimationState::NoAnimationsPresent => {
|
||||
self.get_or_create_pipeline_details(pipeline_id).animations_running = false;
|
||||
}
|
||||
AnimationState::NoAnimationCallbacksPresent => {
|
||||
self.get_or_create_pipeline_details(pipeline_id).animation_callbacks_running = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -921,10 +937,11 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
/// If there are any animations running, dispatches appropriate messages to the constellation.
|
||||
fn process_animations(&mut self) {
|
||||
for (pipeline_id, pipeline_details) in self.pipeline_details.iter() {
|
||||
if !pipeline_details.animations_running {
|
||||
continue
|
||||
if pipeline_details.animations_running ||
|
||||
pipeline_details.animation_callbacks_running {
|
||||
|
||||
self.constellation_chan.0.send(ConstellationMsg::TickAnimation(*pipeline_id)).unwrap();
|
||||
}
|
||||
self.constellation_chan.0.send(ConstellationMsg::TickAnimation(*pipeline_id)).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ use layers::platform::surface::{NativeCompositingGraphicsContext, NativeGraphics
|
|||
use layers::layers::LayerBufferSet;
|
||||
use msg::compositor_msg::{Epoch, LayerId, LayerMetadata, ReadyState};
|
||||
use msg::compositor_msg::{PaintListener, PaintState, ScriptListener, ScrollPolicy};
|
||||
use msg::constellation_msg::{ConstellationChan, PipelineId};
|
||||
use msg::constellation_msg::{AnimationState, ConstellationChan, PipelineId};
|
||||
use msg::constellation_msg::{Key, KeyState, KeyModifiers};
|
||||
use profile_traits::mem;
|
||||
use profile_traits::time;
|
||||
|
@ -202,7 +202,7 @@ pub enum Msg {
|
|||
/// Alerts the compositor that the current page has changed its URL.
|
||||
ChangePageUrl(PipelineId, Url),
|
||||
/// Alerts the compositor that the given pipeline has changed whether it is running animations.
|
||||
ChangeRunningAnimationsState(PipelineId, bool),
|
||||
ChangeRunningAnimationsState(PipelineId, AnimationState),
|
||||
/// Alerts the compositor that a `PaintMsg` has been discarded.
|
||||
PaintMsgDiscarded,
|
||||
/// Replaces the current frame tree, typically called during main frame navigation.
|
||||
|
|
|
@ -14,6 +14,7 @@ use gfx::font_cache_task::FontCacheTask;
|
|||
use layout_traits::{LayoutControlMsg, LayoutTaskFactory};
|
||||
use libc;
|
||||
use msg::compositor_msg::LayerId;
|
||||
use msg::constellation_msg::AnimationState;
|
||||
use msg::constellation_msg::Msg as ConstellationMsg;
|
||||
use msg::constellation_msg::{FrameId, PipelineExitType, PipelineId};
|
||||
use msg::constellation_msg::{IFrameSandboxState, MozBrowserEvent, NavigationDirection};
|
||||
|
@ -344,8 +345,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
sandbox);
|
||||
}
|
||||
ConstellationMsg::SetCursor(cursor) => self.handle_set_cursor_msg(cursor),
|
||||
ConstellationMsg::ChangeRunningAnimationsState(pipeline_id, animations_running) => {
|
||||
self.handle_change_running_animations_state(pipeline_id, animations_running)
|
||||
ConstellationMsg::ChangeRunningAnimationsState(pipeline_id, animation_state) => {
|
||||
self.handle_change_running_animations_state(pipeline_id, animation_state)
|
||||
}
|
||||
ConstellationMsg::TickAnimation(pipeline_id) => {
|
||||
self.handle_tick_animation(pipeline_id)
|
||||
|
@ -560,9 +561,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
|
||||
fn handle_change_running_animations_state(&mut self,
|
||||
pipeline_id: PipelineId,
|
||||
animations_running: bool) {
|
||||
animation_state: AnimationState) {
|
||||
self.compositor_proxy.send(CompositorMsg::ChangeRunningAnimationsState(pipeline_id,
|
||||
animations_running))
|
||||
animation_state))
|
||||
}
|
||||
|
||||
fn handle_tick_animation(&mut self, pipeline_id: PipelineId) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue