New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async scene building. #2362
Merged
+903
−392
Merged
Async scene building. #2362
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
42b9bc2
Add the plumbing for a scene building thread.
nical 5423ee1
Arc scene pipelines to get read access on both the render backend and…
nical b4e030d
Begin patching the necessary information to the scene builder thread.
nical 111cc48
Use Arc instead of Rc for clip chain nodes to make the clip scroll tr…
nical a89270a
Move window_size from frame context to frame builder and update the c…
nical a481a20
Wake the render backend up after building the scene.
nical 4bd5052
Handle the pipeline epoch map properly.
nical c8ee858
Handle removed pipelines.
nical 5df631e
Refactor transactions and forward them to the scene builder thread.
nical e39e0e7
Don't use the scene builder thread by default (yet).
nical 61bb29a
Address some review comments.
nical edf064a
Move dynamic properties into Document.
nical b09c8e4
Keep track of the pending and built scenes separately on the render b…
nical 392c62b
Rename prefix/postfix messages into scene/frame messages.
nical be67702
Move the scene builder to its own file.
nical 272d8db
Apply frame messages after building the scene in the sync path.
nical c3fb656
Address review comments.
nical 6993945
Split DocumentMsg into SceneMsg and FrameMsg.
nical File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Rename prefix/postfix messages into scene/frame messages.
- Loading branch information
commit 392c62b2d00878905bb46cc84005efe81a3a68b6
| @@ -131,10 +131,8 @@ impl ResourceUpdates { | ||
| /// - no redundant work is performed if two commands in the same transaction cause the scene or | ||
| /// the frame to be rebuilt. | ||
| pub struct Transaction { | ||
| // Operations to apply before scene building. | ||
| prefix_ops: Vec<DocumentMsg>, | ||
| // Operations to apply after scene building. | ||
| postfix_ops: Vec<DocumentMsg>, | ||
| scene_ops: Vec<DocumentMsg>, | ||
| frame_ops: Vec<DocumentMsg>, | ||
|
|
||
| // Additional display list data. | ||
| payloads: Vec<Payload>, | ||
| @@ -152,8 +150,8 @@ pub struct Transaction { | ||
| impl Transaction { | ||
| pub fn new() -> Self { | ||
| Transaction { | ||
| prefix_ops: Vec::new(), | ||
| postfix_ops: Vec::new(), | ||
| scene_ops: Vec::new(), | ||
| frame_ops: Vec::new(), | ||
| resource_updates: ResourceUpdates::new(), | ||
| payloads: Vec::new(), | ||
| use_scene_builder_thread: false, // TODO: make this true by default. | ||
| @@ -174,13 +172,13 @@ impl Transaction { | ||
|
|
||
| pub fn is_empty(&self) -> bool { | ||
| !self.generate_frame && | ||
| self.prefix_ops.is_empty() && | ||
| self.postfix_ops.is_empty() && | ||
| self.scene_ops.is_empty() && | ||
| self.frame_ops.is_empty() && | ||
| self.resource_updates.updates.is_empty() | ||
| } | ||
|
|
||
| pub fn update_epoch(&mut self, pipeline_id: PipelineId, epoch: Epoch) { | ||
| self.postfix_ops.push(DocumentMsg::UpdateEpoch(pipeline_id, epoch)); | ||
| self.frame_ops.push(DocumentMsg::UpdateEpoch(pipeline_id, epoch)); | ||
| } | ||
|
|
||
| /// Sets the root pipeline. | ||
| @@ -196,14 +194,14 @@ impl Transaction { | ||
| /// # } | ||
| /// ``` | ||
| pub fn set_root_pipeline(&mut self, pipeline_id: PipelineId) { | ||
| self.prefix_ops.push(DocumentMsg::SetRootPipeline(pipeline_id)); | ||
| self.scene_ops.push(DocumentMsg::SetRootPipeline(pipeline_id)); | ||
| } | ||
|
|
||
| /// Removes data associated with a pipeline from the internal data structures. | ||
| /// If the specified `pipeline_id` is for the root pipeline, the root pipeline | ||
| /// is reset back to `None`. | ||
| pub fn remove_pipeline(&mut self, pipeline_id: PipelineId) { | ||
| self.prefix_ops.push(DocumentMsg::RemovePipeline(pipeline_id)); | ||
| self.scene_ops.push(DocumentMsg::RemovePipeline(pipeline_id)); | ||
| } | ||
|
|
||
| /// Supplies a new frame to WebRender. | ||
| @@ -237,7 +235,7 @@ impl Transaction { | ||
| preserve_frame_state: bool, | ||
| ) { | ||
| let (display_list_data, list_descriptor) = display_list.into_data(); | ||
| self.prefix_ops.push( | ||
| self.scene_ops.push( | ||
| DocumentMsg::SetDisplayList { | ||
| epoch, | ||
| pipeline_id, | ||
| @@ -261,7 +259,7 @@ impl Transaction { | ||
| inner_rect: DeviceUintRect, | ||
| device_pixel_ratio: f32, | ||
| ) { | ||
| self.prefix_ops.push( | ||
| self.scene_ops.push( | ||
| DocumentMsg::SetWindowParameters { | ||
| window_size, | ||
| inner_rect, | ||
| @@ -280,7 +278,7 @@ impl Transaction { | ||
| cursor: WorldPoint, | ||
| phase: ScrollEventPhase, | ||
| ) { | ||
| self.postfix_ops.push(DocumentMsg::Scroll(scroll_location, cursor, phase)); | ||
| self.frame_ops.push(DocumentMsg::Scroll(scroll_location, cursor, phase)); | ||
| } | ||
|
|
||
| pub fn scroll_node_with_id( | ||
| @@ -289,23 +287,23 @@ impl Transaction { | ||
| id: ExternalScrollId, | ||
| clamp: ScrollClamping, | ||
| ) { | ||
| self.postfix_ops.push(DocumentMsg::ScrollNodeWithId(origin, id, clamp)); | ||
| self.frame_ops.push(DocumentMsg::ScrollNodeWithId(origin, id, clamp)); | ||
| } | ||
|
|
||
| pub fn set_page_zoom(&mut self, page_zoom: ZoomFactor) { | ||
| self.prefix_ops.push(DocumentMsg::SetPageZoom(page_zoom)); | ||
| self.scene_ops.push(DocumentMsg::SetPageZoom(page_zoom)); | ||
| } | ||
|
|
||
| pub fn set_pinch_zoom(&mut self, pinch_zoom: ZoomFactor) { | ||
| self.prefix_ops.push(DocumentMsg::SetPinchZoom(pinch_zoom)); | ||
| self.scene_ops.push(DocumentMsg::SetPinchZoom(pinch_zoom)); | ||
| } | ||
|
|
||
| pub fn set_pan(&mut self, pan: DeviceIntPoint) { | ||
| self.postfix_ops.push(DocumentMsg::SetPan(pan)); | ||
| self.frame_ops.push(DocumentMsg::SetPan(pan)); | ||
| } | ||
|
|
||
| pub fn tick_scrolling_bounce_animations(&mut self) { | ||
| self.postfix_ops.push(DocumentMsg::TickScrollingBounce); | ||
| self.frame_ops.push(DocumentMsg::TickScrollingBounce); | ||
| } | ||
|
|
||
| /// Generate a new frame. | ||
| @@ -316,20 +314,20 @@ impl Transaction { | ||
| /// Supply a list of animated property bindings that should be used to resolve | ||
| /// bindings in the current display list. | ||
| pub fn update_dynamic_properties(&mut self, properties: DynamicProperties) { | ||
| self.postfix_ops.push(DocumentMsg::UpdateDynamicProperties(properties)); | ||
| self.frame_ops.push(DocumentMsg::UpdateDynamicProperties(properties)); | ||
| } | ||
|
|
||
| /// Enable copying of the output of this pipeline id to | ||
| /// an external texture for callers to consume. | ||
| pub fn enable_frame_output(&mut self, pipeline_id: PipelineId, enable: bool) { | ||
| self.postfix_ops.push(DocumentMsg::EnableFrameOutput(pipeline_id, enable)); | ||
| self.frame_ops.push(DocumentMsg::EnableFrameOutput(pipeline_id, enable)); | ||
| } | ||
|
|
||
| fn finalize(self) -> (TransactionMsg, Vec<Payload>) { | ||
| ( | ||
| TransactionMsg { | ||
| prefix_ops: self.prefix_ops, | ||
| postfix_ops: self.postfix_ops, | ||
| scene_ops: self.scene_ops, | ||
| frame_ops: self.frame_ops, | ||
| resource_updates: self.resource_updates, | ||
| use_scene_builder_thread: self.use_scene_builder_thread, | ||
| generate_frame: self.generate_frame, | ||
| @@ -342,8 +340,8 @@ impl Transaction { | ||
| /// Represents a transaction in the format sent through the channel. | ||
| #[derive(Clone, Deserialize, Serialize)] | ||
| pub struct TransactionMsg { | ||
| pub prefix_ops: Vec<DocumentMsg>, | ||
| pub postfix_ops: Vec<DocumentMsg>, | ||
| pub scene_ops: Vec<DocumentMsg>, | ||
| pub frame_ops: Vec<DocumentMsg>, | ||
| pub resource_updates: ResourceUpdates, | ||
| pub generate_frame: bool, | ||
| pub use_scene_builder_thread: bool, | ||
| @@ -352,16 +350,16 @@ pub struct TransactionMsg { | ||
| impl TransactionMsg { | ||
| pub fn is_empty(&self) -> bool { | ||
| !self.generate_frame && | ||
| self.prefix_ops.is_empty() && | ||
| self.postfix_ops.is_empty() && | ||
| self.scene_ops.is_empty() && | ||
| self.frame_ops.is_empty() && | ||
| self.resource_updates.updates.is_empty() | ||
| } | ||
|
|
||
| // TODO: We only need this for a few RenderApi methods which we should remove. | ||
| fn single_message(msg: DocumentMsg) -> Self { | ||
| TransactionMsg { | ||
| prefix_ops: Vec::new(), | ||
| postfix_ops: vec![msg], | ||
| scene_ops: Vec::new(), | ||
| frame_ops: vec![msg], | ||
| resource_updates: ResourceUpdates::new(), | ||
| generate_frame: false, | ||
| use_scene_builder_thread: false, | ||
| @@ -432,9 +430,15 @@ pub struct AddFontInstance { | ||
| pub variations: Vec<FontVariation>, | ||
| } | ||
|
|
||
| // TODO: Split this in two emums. | ||
| // I am postponing this because while it is a trivial change, it is a hard one to rebase. | ||
mrobinson
Member
|
||
| #[derive(Clone, Deserialize, Serialize)] | ||
| pub enum DocumentMsg { | ||
| HitTest(Option<PipelineId>, WorldPoint, HitTestFlags, MsgSender<HitTestResult>), | ||
| // Scene messages (apply before building the scene). | ||
| SetPageZoom(ZoomFactor), | ||
| SetPinchZoom(ZoomFactor), | ||
| SetRootPipeline(PipelineId), | ||
| RemovePipeline(PipelineId), | ||
| SetDisplayList { | ||
| list_descriptor: BuiltDisplayListDescriptor, | ||
| epoch: Epoch, | ||
| @@ -444,18 +448,17 @@ pub enum DocumentMsg { | ||
| content_size: LayoutSize, | ||
| preserve_frame_state: bool, | ||
| }, | ||
| UpdateEpoch(PipelineId, Epoch), | ||
| SetPageZoom(ZoomFactor), | ||
| SetPinchZoom(ZoomFactor), | ||
| SetPan(DeviceIntPoint), | ||
| SetRootPipeline(PipelineId), | ||
| RemovePipeline(PipelineId), | ||
| EnableFrameOutput(PipelineId, bool), | ||
| SetWindowParameters { | ||
| window_size: DeviceUintSize, | ||
| inner_rect: DeviceUintRect, | ||
| device_pixel_ratio: f32, | ||
| }, | ||
|
|
||
| // Frame messages (apply after building the scene). | ||
| HitTest(Option<PipelineId>, WorldPoint, HitTestFlags, MsgSender<HitTestResult>), | ||
| UpdateEpoch(PipelineId, Epoch), | ||
| SetPan(DeviceIntPoint), | ||
| EnableFrameOutput(PipelineId, bool), | ||
| Scroll(ScrollLocation, WorldPoint, ScrollEventPhase), | ||
| ScrollNodeWithId(LayoutPoint, ExternalScrollId, ScrollClamping), | ||
| TickScrollingBounce, | ||
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
I think that
transaction_msgmight be a better name here.