From 535e02402020d5a72fcfdb0ac3dc4645bcbdbe18 Mon Sep 17 00:00:00 2001 From: WR Updater Bot Date: Thu, 3 Jan 2019 12:30:07 +0000 Subject: [PATCH] Bug 1517398 - Update webrender to commit 075fd68dfcfa2a2fdc66fefe5520caa408adcfcb (WR PR #3438). r=kats https://github.com/servo/webrender/pull/3438 Differential Revision: https://phabricator.services.mozilla.com/D15648 --HG-- extra : moz-landing-system : lando --- gfx/webrender_bindings/revision.txt | 2 +- gfx/wr/webrender/src/clip.rs | 4 +-- gfx/wr/webrender/src/clip_scroll_tree.rs | 27 ++++++++++++------- .../webrender/src/display_list_flattener.rs | 2 +- gfx/wr/webrender/src/gpu_types.rs | 6 ++--- gfx/wr/webrender/src/hit_test.rs | 12 ++++----- gfx/wr/webrender/src/picture.rs | 4 +-- gfx/wr/webrender/src/prim_store/mod.rs | 8 +++--- gfx/wr/webrender/src/surface.rs | 4 +-- 9 files changed, 38 insertions(+), 31 deletions(-) diff --git a/gfx/webrender_bindings/revision.txt b/gfx/webrender_bindings/revision.txt index 4154ebe8f816..819cc1b4dbde 100644 --- a/gfx/webrender_bindings/revision.txt +++ b/gfx/webrender_bindings/revision.txt @@ -1 +1 @@ -184314dfbb5dbf4a290994753a9712eff1b97e3a +075fd68dfcfa2a2fdc66fefe5520caa408adcfcb diff --git a/gfx/wr/webrender/src/clip.rs b/gfx/wr/webrender/src/clip.rs index 0f576d5769ef..91ad692b8e9f 100644 --- a/gfx/wr/webrender/src/clip.rs +++ b/gfx/wr/webrender/src/clip.rs @@ -1415,8 +1415,8 @@ fn add_clip_node_to_current_chain( clip_scroll_tree: &ClipScrollTree, ) -> bool { let clip_node = &clip_data_store[node.handle]; - let clip_spatial_node = &clip_scroll_tree.spatial_nodes[node.spatial_node_index.0]; - let ref_spatial_node = &clip_scroll_tree.spatial_nodes[spatial_node_index.0]; + let clip_spatial_node = &clip_scroll_tree.spatial_nodes[node.spatial_node_index.0 as usize]; + let ref_spatial_node = &clip_scroll_tree.spatial_nodes[spatial_node_index.0 as usize]; // Determine the most efficient way to convert between coordinate // systems of the primitive and clip node. diff --git a/gfx/wr/webrender/src/clip_scroll_tree.rs b/gfx/wr/webrender/src/clip_scroll_tree.rs index 5e4d9c252708..101ceadec83c 100644 --- a/gfx/wr/webrender/src/clip_scroll_tree.rs +++ b/gfx/wr/webrender/src/clip_scroll_tree.rs @@ -44,11 +44,18 @@ impl CoordinateSystem { #[derive(Debug, Copy, Clone, Eq, Hash, PartialEq, PartialOrd, Ord)] #[cfg_attr(feature = "capture", derive(Serialize))] #[cfg_attr(feature = "replay", derive(Deserialize))] -pub struct SpatialNodeIndex(pub usize); +pub struct SpatialNodeIndex(pub u32); pub const ROOT_SPATIAL_NODE_INDEX: SpatialNodeIndex = SpatialNodeIndex(0); const TOPMOST_SCROLL_NODE_INDEX: SpatialNodeIndex = SpatialNodeIndex(1); +impl SpatialNodeIndex { + pub fn new(index: usize) -> Self { + debug_assert!(index < ::std::u32::MAX as usize); + SpatialNodeIndex(index as u32) + } +} + impl CoordinateSystemId { pub fn root() -> Self { CoordinateSystemId(0) @@ -117,8 +124,8 @@ impl ClipScrollTree { from_node_index: SpatialNodeIndex, to_node_index: SpatialNodeIndex, ) -> Option { - let from_node = &self.spatial_nodes[from_node_index.0]; - let to_node = &self.spatial_nodes[to_node_index.0]; + let from_node = &self.spatial_nodes[from_node_index.0 as usize]; + let to_node = &self.spatial_nodes[to_node_index.0 as usize]; let (child, parent, inverse) = if from_node_index.0 > to_node_index.0 { (from_node, to_node, false) @@ -230,7 +237,7 @@ impl ClipScrollTree { None => return self.topmost_scroll_node_index(), }; - let node = &self.spatial_nodes[index.0]; + let node = &self.spatial_nodes[index.0 as usize]; match node.node_type { SpatialNodeType::ScrollFrame(state) if state.sensitive_to_input_events() => index, _ => self.find_nearest_scrolling_ancestor(node.parent) @@ -246,7 +253,7 @@ impl ClipScrollTree { return false; } let node_index = self.find_nearest_scrolling_ancestor(node_index); - self.spatial_nodes[node_index.0].scroll(scroll_location) + self.spatial_nodes[node_index.0 as usize].scroll(scroll_location) } pub fn update_tree( @@ -280,7 +287,7 @@ impl ClipScrollTree { self.nodes_to_update.push((root_node_index, state)); while let Some((node_index, mut state)) = self.nodes_to_update.pop() { - let node = match self.spatial_nodes.get_mut(node_index.0) { + let node = match self.spatial_nodes.get_mut(node_index.0 as usize) { Some(node) => node, None => continue, }; @@ -375,11 +382,11 @@ impl ClipScrollTree { } pub fn add_spatial_node(&mut self, node: SpatialNode) -> SpatialNodeIndex { - let index = SpatialNodeIndex(self.spatial_nodes.len()); + let index = SpatialNodeIndex::new(self.spatial_nodes.len()); // When the parent node is None this means we are adding the root. if let Some(parent_index) = node.parent { - self.spatial_nodes[parent_index.0].add_child(index); + self.spatial_nodes[parent_index.0 as usize].add_child(index); } self.spatial_nodes.push(node); @@ -395,7 +402,7 @@ impl ClipScrollTree { index: SpatialNodeIndex, pt: &mut T, ) { - let node = &self.spatial_nodes[index.0]; + let node = &self.spatial_nodes[index.0 as usize]; match node.node_type { SpatialNodeType::StickyFrame(ref sticky_frame_info) => { pt.new_level(format!("StickyFrame")); @@ -450,7 +457,7 @@ impl ClipScrollTree { let mut current = spatial_node_index; while current != ROOT_SPATIAL_NODE_INDEX { - let node = &self.spatial_nodes[current.0]; + let node = &self.spatial_nodes[current.0 as usize]; match node.node_type { SpatialNodeType::ReferenceFrame(ref info) => { diff --git a/gfx/wr/webrender/src/display_list_flattener.rs b/gfx/wr/webrender/src/display_list_flattener.rs index 7b98be410ec7..75593fb31af7 100644 --- a/gfx/wr/webrender/src/display_list_flattener.rs +++ b/gfx/wr/webrender/src/display_list_flattener.rs @@ -405,7 +405,7 @@ impl<'a> DisplayListFlattener<'a> { let mut node_index = spatial_node_index; while node_index != ROOT_SPATIAL_NODE_INDEX { - let node = &self.clip_scroll_tree.spatial_nodes[node_index.0]; + let node = &self.clip_scroll_tree.spatial_nodes[node_index.0 as usize]; match node.node_type { SpatialNodeType::ReferenceFrame(..) | SpatialNodeType::StickyFrame(..) => { diff --git a/gfx/wr/webrender/src/gpu_types.rs b/gfx/wr/webrender/src/gpu_types.rs index f1f2c9390830..5f37271fe7d5 100644 --- a/gfx/wr/webrender/src/gpu_types.rs +++ b/gfx/wr/webrender/src/gpu_types.rs @@ -474,7 +474,7 @@ impl TransformPalette { clip_scroll_tree: &ClipScrollTree, ) -> usize { if to_index == ROOT_SPATIAL_NODE_INDEX { - from_index.0 + from_index.0 as usize } else if from_index == to_index { 0 } else { @@ -511,7 +511,7 @@ impl TransformPalette { &self, index: SpatialNodeIndex, ) -> LayoutToWorldTransform { - self.transforms[index.0] + self.transforms[index.0 as usize] .transform .with_destination::() } @@ -520,7 +520,7 @@ impl TransformPalette { &self, index: SpatialNodeIndex, ) -> WorldToLayoutTransform { - self.transforms[index.0] + self.transforms[index.0 as usize] .inv_transform .with_source::() } diff --git a/gfx/wr/webrender/src/hit_test.rs b/gfx/wr/webrender/src/hit_test.rs index 98ec34c86044..56f917b0b21f 100644 --- a/gfx/wr/webrender/src/hit_test.rs +++ b/gfx/wr/webrender/src/hit_test.rs @@ -159,7 +159,7 @@ impl HitTester { self.clip_chains.clear(); for (index, node) in clip_scroll_tree.spatial_nodes.iter().enumerate() { - let index = SpatialNodeIndex(index); + let index = SpatialNodeIndex::new(index); // If we haven't already seen a node for this pipeline, record this one as the root // node. @@ -237,7 +237,7 @@ impl HitTester { let node = &self.clip_chains[clip_chain_node_id.0 as usize].region; let transform = self - .spatial_nodes[spatial_node_index.0] + .spatial_nodes[spatial_node_index.0 as usize] .world_viewport_transform; let transformed_point = match transform .inverse() @@ -264,7 +264,7 @@ impl HitTester { for &HitTestingRun(ref items, ref clip_and_scroll) in self.runs.iter().rev() { let spatial_node_index = clip_and_scroll.spatial_node_index; - let scroll_node = &self.spatial_nodes[spatial_node_index.0]; + let scroll_node = &self.spatial_nodes[spatial_node_index.0 as usize]; let transform = scroll_node.world_content_transform; let point_in_layer = match transform .inverse() @@ -301,7 +301,7 @@ impl HitTester { let mut result = HitTestResult::default(); for &HitTestingRun(ref items, ref clip_and_scroll) in self.runs.iter().rev() { let spatial_node_index = clip_and_scroll.spatial_node_index; - let scroll_node = &self.spatial_nodes[spatial_node_index.0]; + let scroll_node = &self.spatial_nodes[spatial_node_index.0 as usize]; let pipeline_id = scroll_node.pipeline_id; match (test.pipeline_id, pipeline_id) { (Some(id), node_id) if node_id != id => continue, @@ -343,7 +343,7 @@ impl HitTester { // the pipeline of the hit item. If we cannot get a transformed point, we are // in a situation with an uninvertible transformation so we should just skip this // result. - let root_node = &self.spatial_nodes[self.pipeline_root_nodes[&pipeline_id].0]; + let root_node = &self.spatial_nodes[self.pipeline_root_nodes[&pipeline_id].0 as usize]; let point_in_viewport = match root_node.world_viewport_transform .inverse() .and_then(|inverted| inverted.transform_point2d(&point)) @@ -369,7 +369,7 @@ impl HitTester { } pub fn get_pipeline_root(&self, pipeline_id: PipelineId) -> &HitTestSpatialNode { - &self.spatial_nodes[self.pipeline_root_nodes[&pipeline_id].0] + &self.spatial_nodes[self.pipeline_root_nodes[&pipeline_id].0 as usize] } // Reports the CPU heap usage of this HitTester struct. diff --git a/gfx/wr/webrender/src/picture.rs b/gfx/wr/webrender/src/picture.rs index 3ff03ce84870..e125883d3596 100644 --- a/gfx/wr/webrender/src/picture.rs +++ b/gfx/wr/webrender/src/picture.rs @@ -359,7 +359,7 @@ impl TileCache { if let Some(ref mut current) = transform.current { let mapping: CoordinateSpaceMapping = CoordinateSpaceMapping::new( self.spatial_node_index, - SpatialNodeIndex(i), + SpatialNodeIndex::new(i), frame_context.clip_scroll_tree, ).expect("todo: handle invalid mappings"); @@ -1987,7 +1987,7 @@ impl PicturePrimitive { // No point including this cluster if it can't be transformed let spatial_node = &frame_context .clip_scroll_tree - .spatial_nodes[cluster.spatial_node_index.0]; + .spatial_nodes[cluster.spatial_node_index.0 as usize]; if !spatial_node.invertible { continue; } diff --git a/gfx/wr/webrender/src/prim_store/mod.rs b/gfx/wr/webrender/src/prim_store/mod.rs index 0e8493da89d5..a2bae25190c4 100644 --- a/gfx/wr/webrender/src/prim_store/mod.rs +++ b/gfx/wr/webrender/src/prim_store/mod.rs @@ -152,8 +152,8 @@ impl CoordinateSpaceMapping { clip_scroll_tree: &ClipScrollTree, ) -> Option { let spatial_nodes = &clip_scroll_tree.spatial_nodes; - let ref_spatial_node = &spatial_nodes[ref_spatial_node_index.0]; - let target_spatial_node = &spatial_nodes[target_node_index.0]; + let ref_spatial_node = &spatial_nodes[ref_spatial_node_index.0 as usize]; + let target_spatial_node = &spatial_nodes[target_node_index.0 as usize]; if ref_spatial_node_index == target_node_index { Some(CoordinateSpaceMapping::Local) @@ -2214,7 +2214,7 @@ impl PrimitiveStore { let spatial_node = &frame_context .clip_scroll_tree - .spatial_nodes[prim_instance.spatial_node_index.0]; + .spatial_nodes[prim_instance.spatial_node_index.0 as usize]; // TODO(gw): Although constructing these is cheap, they are often // the same for many consecutive primitives, so it may @@ -3325,7 +3325,7 @@ fn test_struct_sizes() { // test expectations and move on. // (b) You made a structure larger. This is not necessarily a problem, but should only // be done with care, and after checking if talos performance regresses badly. - assert_eq!(mem::size_of::(), 120, "PrimitiveInstance size changed"); + assert_eq!(mem::size_of::(), 112, "PrimitiveInstance size changed"); assert_eq!(mem::size_of::(), 40, "PrimitiveInstanceKind size changed"); assert_eq!(mem::size_of::(), 56, "PrimitiveTemplate size changed"); assert_eq!(mem::size_of::(), 20, "PrimitiveTemplateKind size changed"); diff --git a/gfx/wr/webrender/src/surface.rs b/gfx/wr/webrender/src/surface.rs index 2fc532365413..bb0357940d26 100644 --- a/gfx/wr/webrender/src/surface.rs +++ b/gfx/wr/webrender/src/surface.rs @@ -288,8 +288,8 @@ impl SurfaceDescriptor { // coordinate system (which is the common case!) then we are effectively drawing // in a local space anyway, so don't care about that transform for the purposes // of validating the surface cache contents. - let raster_spatial_node = &clip_scroll_tree.spatial_nodes[raster_spatial_node_index.0]; - let surface_spatial_node = &clip_scroll_tree.spatial_nodes[surface_spatial_node_index.0]; + let raster_spatial_node = &clip_scroll_tree.spatial_nodes[raster_spatial_node_index.0 as usize]; + let surface_spatial_node = &clip_scroll_tree.spatial_nodes[surface_spatial_node_index.0 as usize]; let mut key = CoordinateSpaceMapping::::new( raster_spatial_node_index,