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

Sync changes from mozilla-central gfx/wr #3847

Merged
merged 2 commits into from Feb 3, 2020
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Bug 1606251 - Fix invalidation for elements with inflation factors. r…

  • Loading branch information
Glenn Watson authored and moz-gfx committed Jan 30, 2020
commit 3a91fd300f92f0c2e7f4e3d2cd3283f1e6fc849e
@@ -5,7 +5,7 @@
use api::{ColorF, DebugFlags, DocumentLayer, FontRenderMode, PremultipliedColorF};
use api::units::*;
use crate::batch::{BatchBuilder, AlphaBatchBuilder, AlphaBatchContainer};
use crate::clip::{ClipStore, ClipChainStack};
use crate::clip::{ClipStore, ClipChainStack, ClipDataHandle};
use crate::spatial_tree::{SpatialTree, ROOT_SPATIAL_NODE_INDEX, SpatialNodeIndex, CoordinateSystemId};
use crate::composite::{CompositorKind, CompositeState};
use crate::debug_render::DebugItem;
@@ -132,6 +132,25 @@ pub struct FrameVisibilityState<'a> {
pub clip_chain_stack: ClipChainStack,
pub render_tasks: &'a mut RenderTaskGraph,
pub composite_state: &'a mut CompositeState,
/// A stack of currently active off-screen surfaces during the
/// visibility frame traversal.
pub surface_stack: Vec<SurfaceIndex>,
}

impl<'a> FrameVisibilityState<'a> {
pub fn push_surface(
&mut self,
surface_index: SurfaceIndex,
shared_clips: &[ClipDataHandle]
) {
self.surface_stack.push(surface_index);
self.clip_chain_stack.push_surface(shared_clips);
}

pub fn pop_surface(&mut self) {
self.surface_stack.pop().unwrap();
self.clip_chain_stack.pop_surface();
}
}

pub struct FrameBuildingContext<'a> {
@@ -343,6 +362,9 @@ impl FrameBuilder {
clip_chain_stack: ClipChainStack::new(),
render_tasks,
composite_state,
/// Try to avoid allocating during frame traversal - it's unlikely to have a
/// surface stack depth of > 16 in most cases.
surface_stack: Vec::with_capacity(16),
};

scene.prim_store.update_visibility(
@@ -2299,16 +2299,18 @@ impl TileCacheInstance {
prim_spatial_node_index: SpatialNodeIndex,
prim_clip_chain: Option<&ClipChainInstance>,
local_prim_rect: LayoutRect,
spatial_tree: &SpatialTree,
frame_context: &FrameVisibilityContext,
data_stores: &DataStores,
clip_store: &ClipStore,
pictures: &[PicturePrimitive],
resource_cache: &ResourceCache,
opacity_binding_store: &OpacityBindingStorage,
image_instances: &ImageInstanceStorage,
surface_index: SurfaceIndex,
surface_spatial_node_index: SpatialNodeIndex,
surface_stack: &[SurfaceIndex],
) -> bool {
// This primitive exists on the last element on the current surface stack.
let prim_surface_index = *surface_stack.last().unwrap();

// If the primitive is completely clipped out by the clip chain, there
// is no need to add it to any primitive dependencies.
let prim_clip_chain = match prim_clip_chain {
@@ -2318,7 +2320,7 @@ impl TileCacheInstance {

self.map_local_to_surface.set_target_spatial_node(
prim_spatial_node_index,
spatial_tree,
frame_context.spatial_tree,
);

// Map the primitive local rect into picture space.
@@ -2335,17 +2337,41 @@ impl TileCacheInstance {
// If the primitive is directly drawn onto this picture cache surface, then
// the pic_clip_rect is in the same space. If not, we need to map it from
// the surface space into the picture cache space.
let on_picture_surface = surface_index == self.surface_index;
let on_picture_surface = prim_surface_index == self.surface_index;
let pic_clip_rect = if on_picture_surface {
prim_clip_chain.pic_clip_rect
} else {
self.map_child_pic_to_surface.set_target_spatial_node(
surface_spatial_node_index,
spatial_tree,
);
self.map_child_pic_to_surface
.map(&prim_clip_chain.pic_clip_rect)
.expect("bug: unable to map clip rect to picture cache space")
// We want to get the rect in the tile cache surface space that this primitive
// occupies, in order to enable correct invalidation regions. Each surface
// that exists in the chain between this primitive and the tile cache surface
// may have an arbitrary inflation factor (for example, in the case of a series
// of nested blur elements). To account for this, step through the current
// surface stack, mapping the primitive rect into each surface space, including
// the inflation factor from each intermediate surface.
let mut current_pic_clip_rect = prim_clip_chain.pic_clip_rect;
let mut current_spatial_node_index = frame_context
.surfaces[prim_surface_index.0]
.surface_spatial_node_index;

for surface_index in surface_stack.iter().rev() {
let surface = &frame_context.surfaces[surface_index.0];

let map_local_to_surface = SpaceMapper::new_with_target(
surface.surface_spatial_node_index,
current_spatial_node_index,
surface.rect,
frame_context.spatial_tree,
);

current_pic_clip_rect = map_local_to_surface
.map(&current_pic_clip_rect)
.expect("bug: unable to map")
.inflate(surface.inflation_factor, surface.inflation_factor);

current_spatial_node_index = surface.surface_spatial_node_index;
}

current_pic_clip_rect
};

// Get the tile coordinates in the picture space.
@@ -2531,9 +2557,9 @@ impl TileCacheInstance {
// - Same coord system as picture cache (ensures rects are axis-aligned).
// - No clip masks exist.
let same_coord_system = {
let prim_spatial_node = &spatial_tree
let prim_spatial_node = &frame_context.spatial_tree
.spatial_nodes[prim_spatial_node_index.0 as usize];
let surface_spatial_node = &spatial_tree
let surface_spatial_node = &frame_context.spatial_tree
.spatial_nodes[self.spatial_node_index.0 as usize];

prim_spatial_node.coordinate_system_id == surface_spatial_node.coordinate_system_id
@@ -1909,12 +1909,12 @@ impl PrimitiveStore {

// Push a new surface, supplying the list of clips that should be
// ignored, since they are handled by clipping when drawing this surface.
frame_state.clip_chain_stack.push_surface(&tile_cache.shared_clips);
frame_state.push_surface(surface_index, &tile_cache.shared_clips);
frame_state.tile_cache = Some(tile_cache);
}
_ => {
if is_composite {
frame_state.clip_chain_stack.push_surface(&[]);
frame_state.push_surface(surface_index, &[]);
}
}
}
@@ -2133,15 +2133,14 @@ impl PrimitiveStore {
cluster.spatial_node_index,
clip_chain.as_ref(),
prim_local_rect,
frame_context.spatial_tree,
frame_context,
frame_state.data_stores,
frame_state.clip_store,
&self.pictures,
frame_state.resource_cache,
&self.opacity_bindings,
&self.images,
surface_index,
surface.surface_spatial_node_index,
&frame_state.surface_stack,
) {
prim_instance.visibility_info = PrimitiveVisibilityIndex::INVALID;
// Ensure the primitive clip is popped - perhaps we can use
@@ -2292,7 +2291,7 @@ impl PrimitiveStore {

// Similar to above, pop either the clip chain or root entry off the current clip stack.
if is_composite {
frame_state.clip_chain_stack.pop_surface();
frame_state.pop_surface();
}

let pic = &mut self.pictures[pic_index.0];
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.