Skip to content

Commit

Permalink
Auto merge of #3302 - gw3583:pic-state, r=kvark
Browse files Browse the repository at this point in the history
Remove local_rect_changed from PictureState.

This can now be handled internally, and removes one more need
for the PictureState structure during the main traversal.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/3302)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Nov 13, 2018
2 parents e48cb90 + 27cc9ec commit fc1da8a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
1 change: 0 additions & 1 deletion webrender/src/frame_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ pub struct PictureContext {
/// the children are processed.
pub struct PictureState {
pub is_cacheable: bool,
pub local_rect_changed: bool,
pub map_local_to_pic: SpaceMapper<LayoutPixel, PicturePixel>,
pub map_pic_to_world: SpaceMapper<PicturePixel, WorldPixel>,
pub map_pic_to_raster: SpaceMapper<PicturePixel, RasterPixel>,
Expand Down
34 changes: 17 additions & 17 deletions webrender/src/picture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,6 @@ impl PicturePrimitive {

let state = PictureState {
is_cacheable: true,
local_rect_changed: false,
map_local_to_pic,
map_pic_to_world,
map_pic_to_raster,
Expand Down Expand Up @@ -607,25 +606,35 @@ impl PicturePrimitive {
context: PictureContext,
state: PictureState,
frame_state: &mut FrameBuildingState,
) -> (bool, Option<ClipNodeCollector>) {
) -> Option<ClipNodeCollector> {
self.prim_list = prim_list;
self.state = Some((state, context));

match self.raster_config {
Some(ref raster_config) => {
let local_rect = frame_state.surfaces[raster_config.surface_index.0].rect;
let local_rect = LayoutRect::from_untyped(&local_rect.to_untyped());
let local_rect_changed = local_rect != self.local_rect;
self.local_rect = local_rect;

if local_rect_changed {
frame_state.gpu_cache.invalidate(&mut self.gpu_location);
// If the local rect changed (due to transforms in child primitives) then
// invalidate the GPU cache location to re-upload the new local rect
// and stretch size. Drop shadow filters also depend on the local rect
// size for the extra GPU cache data handle.
// TODO(gw): In future, if we support specifying a flag which gets the
// stretch size from the segment rect in the shaders, we can
// remove this invalidation here completely.
if self.local_rect != local_rect {
frame_state.gpu_cache.invalidate(&self.gpu_location);
if let PictureCompositeMode::Filter(FilterOp::DropShadow(..)) = raster_config.composite_mode {
frame_state.gpu_cache.invalidate(&self.extra_gpu_data_handle);
}
}

(local_rect_changed, Some(frame_state.clip_store.pop_surface()))
self.local_rect = local_rect;

Some(frame_state.clip_store.pop_surface())
}
None => {
(false, None)
None
}
}
}
Expand Down Expand Up @@ -957,7 +966,6 @@ impl PicturePrimitive {
prim_instance: &PrimitiveInstance,
prim_local_rect: &LayoutRect,
surface_index: SurfaceIndex,
pic_state: &mut PictureState,
frame_context: &FrameBuildingContext,
frame_state: &mut FrameBuildingState,
) -> bool {
Expand Down Expand Up @@ -1198,14 +1206,6 @@ impl PicturePrimitive {
let render_task_id = frame_state.render_tasks.add(blur_render_task);
surfaces[surface_index.0].tasks.push(render_task_id);

// If the local rect of the contents changed, force the cache handle
// to be invalidated so that the primitive data below will get
// uploaded to the GPU this frame. This can occur during property
// animation.
if pic_state.local_rect_changed {
frame_state.gpu_cache.invalidate(&mut self.extra_gpu_data_handle);
}

if let Some(mut request) = frame_state.gpu_cache.request(&mut self.extra_gpu_data_handle) {
// TODO(gw): This is very hacky code below! It stores an extra
// brush primitive below for the special case of a
Expand Down
5 changes: 1 addition & 4 deletions webrender/src/prim_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2200,7 +2200,7 @@ impl PrimitiveStore {
}

// Restore the dependencies (borrow check dance)
let (local_rect_changed, clip_node_collector) = self
let clip_node_collector = self
.pictures[pic_context_for_children.pic_index.0]
.restore_context(
prim_list,
Expand All @@ -2209,8 +2209,6 @@ impl PrimitiveStore {
frame_state,
);

pic_state.local_rect_changed |= local_rect_changed;

(is_passthrough, clip_node_collector)
}
None => {
Expand Down Expand Up @@ -2364,7 +2362,6 @@ impl PrimitiveStore {
prim_instance,
&prim_local_rect,
pic_context.surface_index,
pic_state,
frame_context,
frame_state,
) {
Expand Down

0 comments on commit fc1da8a

Please sign in to comment.