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

Avoid redundant frame builds (take two). #3092

Merged
merged 4 commits into from Sep 26, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Avoid re-building the frame when we only need the hit tester.

  • Loading branch information
nical committed Sep 20, 2018
commit 62d4c140dd703895b19c52a4baa47aab1cc3296f
@@ -365,14 +365,12 @@ impl Document {

struct DocumentOps {
scroll: bool,
build_frame: bool,
}

impl DocumentOps {
fn nop() -> Self {
DocumentOps {
scroll: false,
build_frame: false,
}
}
}
@@ -633,7 +631,6 @@ impl RenderBackend {
txn.clip_updates.take(),
replace(&mut txn.frame_ops, Vec::new()),
replace(&mut txn.notifications, Vec::new()),
txn.build_frame,
txn.render_frame,
&mut frame_counter,
&mut profile_counters,
@@ -903,7 +900,6 @@ impl RenderBackend {
rasterized_blobs: Vec::new(),
notifications: transaction_msg.notifications,
set_root_pipeline: None,
build_frame: transaction_msg.generate_frame,
render_frame: transaction_msg.generate_frame,
});

@@ -939,7 +935,6 @@ impl RenderBackend {
None,
replace(&mut txn.frame_ops, Vec::new()),
replace(&mut txn.notifications, Vec::new()),
txn.build_frame,
txn.render_frame,
frame_counter,
profile_counters,
@@ -977,7 +972,6 @@ impl RenderBackend {
clip_updates: Option<ClipDataUpdateList>,
mut frame_ops: Vec<FrameMsg>,
mut notifications: Vec<NotificationRequest>,
mut build_frame: bool,
mut render_frame: bool,
frame_counter: &mut u32,
profile_counters: &mut BackendProfileCounters,
@@ -990,7 +984,7 @@ impl RenderBackend {
// fiddle with things after a potentially long scene build, but just
// before rendering. This is useful for rendering with the latest
// async transforms.
if build_frame {
if requested_frame {
if let Some(ref sampler) = self.sampler {
frame_ops.append(&mut sampler.sample());
}
@@ -1010,7 +1004,6 @@ impl RenderBackend {
for frame_msg in frame_ops {
let _timer = profile_counters.total_time.timer();
let op = doc.process_frame_msg(frame_msg);
build_frame |= op.build_frame;
scroll |= op.scroll;
}

@@ -1025,31 +1018,20 @@ impl RenderBackend {
&mut profile_counters.resources,
);

// After applying the new scene we need to
// rebuild the hit-tester, so we trigger a frame generation
// step.
//
// TODO: We could avoid some the cost of building the frame by only
// building the information required for hit-testing (See #2807).
build_frame |= has_built_scene;

if doc.dynamic_properties.flush_pending_updates() {
doc.frame_is_valid = false;
doc.hit_tester_is_valid = false;
build_frame = true;
}

if !doc.can_render() {
// TODO: this happens if we are building the first scene asynchronously and
// scroll at the same time. we should keep track of the fact that we skipped
// composition here and do it as soon as we receive the scene.
build_frame = false;
render_frame = false;
}

if doc.frame_is_valid {
build_frame = false;
}
// Avoid re-building the frame if the current built frame is still valid.
let build_frame = render_frame && !doc.frame_is_valid;

let mut frame_build_time = None;
if build_frame && doc.has_pixels() {
@@ -1114,6 +1096,10 @@ impl RenderBackend {
if requested_frame {
self.notifier.new_frame_ready(document_id, scroll, render_frame, frame_build_time);
}

if !doc.hit_tester_is_valid {
doc.rebuild_hit_tester();
}
}

#[cfg(not(feature = "debugger"))]
@@ -39,7 +39,6 @@ pub struct Transaction {
pub frame_ops: Vec<FrameMsg>,
pub notifications: Vec<NotificationRequest>,
pub set_root_pipeline: Option<PipelineId>,
pub build_frame: bool,
pub render_frame: bool,
}

@@ -73,7 +72,6 @@ pub struct BuiltTransaction {
pub clip_updates: Option<ClipDataUpdateList>,
pub scene_build_start_time: u64,
pub scene_build_end_time: u64,
pub build_frame: bool,
pub render_frame: bool,
}

@@ -307,7 +305,6 @@ impl SceneBuilder {

let txn = Box::new(BuiltTransaction {
document_id: item.document_id,
build_frame: true,
render_frame: item.build_frame,
built_scene,
resource_updates: Vec::new(),
@@ -408,7 +405,6 @@ impl SceneBuilder {

Box::new(BuiltTransaction {
document_id: txn.document_id,
build_frame: txn.build_frame || built_scene.is_some(),
render_frame: txn.render_frame,
built_scene,
rasterized_blobs,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.