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

Fix a picture caching race condition. #3424

Merged
merged 3 commits into from
Dec 17, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion webrender/src/frame_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,9 @@ impl FrameBuilder {
&mut z_generator,
);

if let RenderPassKind::OffScreen { ref texture_cache, .. } = pass.kind {
if let RenderPassKind::OffScreen { ref texture_cache, ref color, .. } = pass.kind {
has_texture_cache_tasks |= !texture_cache.is_empty();
has_texture_cache_tasks |= color.must_be_drawn();
}
}

Expand Down
26 changes: 18 additions & 8 deletions webrender/src/picture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,13 +732,23 @@ impl TileCache {

let prim_data = &resources.as_common_data(&prim_instance);

let prim_rect = LayoutRect::new(
prim_instance.prim_origin,
prim_data.prim_size,
);
let clip_rect = prim_data
.prim_relative_clip_rect
.translate(&prim_instance.prim_origin.to_vector());
let (prim_rect, clip_rect) = match prim_instance.kind {
PrimitiveInstanceKind::Picture { pic_index, .. } => {
let pic = &pictures[pic_index.0];
(pic.local_rect, LayoutRect::max_rect())
}
_ => {
let prim_rect = LayoutRect::new(
prim_instance.prim_origin,
prim_data.prim_size,
);
let clip_rect = prim_data
.prim_relative_clip_rect
.translate(&prim_instance.prim_origin.to_vector());

(prim_rect, clip_rect)
}
};

// Map the primitive local rect into the picture space.
// TODO(gw): We should maybe store this in the primitive template
Expand Down Expand Up @@ -850,7 +860,7 @@ impl TileCache {
// We only care about clip nodes that have transforms that are children
// of the surface, since clips that are positioned by parents will be
// handled by the clip collector when these tiles are composited.
if clip_chain_node.spatial_node_index > surface_spatial_node_index {
if clip_chain_node.spatial_node_index >= surface_spatial_node_index {
clip_chain_spatial_nodes.push(clip_chain_node.spatial_node_index);
clip_chain_uids.push(clip_chain_node.handle.uid());
}
Expand Down
13 changes: 13 additions & 0 deletions webrender/src/tiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ pub trait RenderTarget {
);

fn needs_depth(&self) -> bool;
fn must_be_drawn(&self) -> bool;

fn used_rect(&self) -> DeviceIntRect;
fn add_used(&mut self, rect: DeviceIntRect);
Expand Down Expand Up @@ -258,6 +259,10 @@ impl<T: RenderTarget> RenderTargetList<T> {
self.targets.iter().any(|target| target.needs_depth())
}

pub fn must_be_drawn(&self) -> bool {
self.targets.iter().any(|target| target.must_be_drawn())
}

pub fn check_ready(&self, t: &Texture) {
let dimensions = t.get_dimensions();
assert!(dimensions.width >= self.max_dynamic_size.width);
Expand Down Expand Up @@ -544,6 +549,10 @@ impl RenderTarget for ColorRenderTarget {
}
}

fn must_be_drawn(&self) -> bool {
!self.tile_blits.is_empty()
}

fn needs_depth(&self) -> bool {
self.alpha_batch_containers.iter().any(|ab| {
!ab.opaque_batches.is_empty()
Expand Down Expand Up @@ -674,6 +683,10 @@ impl RenderTarget for AlphaRenderTarget {
false
}

fn must_be_drawn(&self) -> bool {
false
}

fn used_rect(&self) -> DeviceIntRect {
self.used_rect
}
Expand Down