Skip to content
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

Add new scene building hooks for the start and end of scene builder so #3303

Merged
merged 1 commit into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions webrender/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4555,6 +4555,8 @@ pub trait SceneBuilderHooks {
/// This is called exactly once, when the scene builder thread is started
/// and before it processes anything.
fn register(&self);
/// This is called before each scene build starts.
fn pre_scene_build(&self);
/// This is called before each scene swap occurs.
fn pre_scene_swap(&self, scenebuild_time: u64);
/// This is called after each scene swap occurs. The PipelineInfo contains
Expand All @@ -4565,6 +4567,11 @@ pub trait SceneBuilderHooks {
/// thread, in the case where resource updates were applied without a scene
/// build.
fn post_resource_update(&self);
/// This is called after a scene build completes without any changes being
/// made. We guarantee that each pre_scene_build call will be matched with
/// exactly one of post_scene_swap, post_resource_update or
/// post_empty_scene_build.
fn post_empty_scene_build(&self);
/// This is a generic callback which provides an opportunity to run code
/// on the scene builder thread. This is called as part of the main message
/// loop of the scene builder thread, but outside of any specific message
Expand Down
7 changes: 7 additions & 0 deletions webrender/src/scene_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ impl SceneBuilder {

/// Do the bulk of the work of the scene builder thread.
fn process_transaction(&mut self, txn: &mut Transaction) -> Box<BuiltTransaction> {
if let &Some(ref hooks) = &self.hooks {
hooks.pre_scene_build();
}

let scene_build_start_time = precise_time_ns();

Expand Down Expand Up @@ -537,6 +540,10 @@ impl SceneBuilder {
if let &Some(ref hooks) = &self.hooks {
hooks.post_resource_update();
}
} else {
if let &Some(ref hooks) = &self.hooks {
hooks.post_empty_scene_build();
}
}
}
}
Expand Down