Bug 1605380 - Avoid calculating snapped bounds for some display items twice r=aosmond
☠☠ backed out by e94a014eb27e ☠ ☠
authorMiko Mynttinen <mikokm@gmail.com>
Fri, 20 Dec 2019 15:41:06 +0000
changeset 508026 c9cbe7b9ad94d9b1e488bc4e650b053d3e06a646
parent 508025 94edb5d8488724b414452f7cca193d59609fb6a6
child 508027 bb77bb2231f3dc3058ec88b42a65d23216018fdb
push id36936
push usercbrindusan@mozilla.com
push dateFri, 20 Dec 2019 21:54:48 +0000
treeherdermozilla-central@e94a014eb27e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaosmond
bugs1605380
milestone73.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1605380 - Avoid calculating snapped bounds for some display items twice r=aosmond Differential Revision: https://phabricator.services.mozilla.com/D57976
gfx/wr/webrender/src/scene_building.rs
--- a/gfx/wr/webrender/src/scene_building.rs
+++ b/gfx/wr/webrender/src/scene_building.rs
@@ -989,59 +989,64 @@ impl<'a> SceneBuilder<'a> {
                 ClipChainId::INVALID
             },
         )
     }
 
     fn process_common_properties(
         &mut self,
         common: &CommonItemProperties,
-        apply_pipeline_clip: bool
-    ) -> (LayoutPrimitiveInfo, ScrollNodeAndClipChain) {
-        let (layout, _, clip_and_scroll) = self.process_common_properties_with_bounds(
-            common,
-            &common.clip_rect,
-            apply_pipeline_clip,
-        );
-        (layout, clip_and_scroll)
-    }
-
-    fn process_common_properties_with_bounds(
-        &mut self,
-        common: &CommonItemProperties,
-        bounds: &LayoutRect,
-        apply_pipeline_clip: bool
+        bounds: Option<&LayoutRect>,
+        apply_pipeline_clip: bool,
     ) -> (LayoutPrimitiveInfo, LayoutRect, ScrollNodeAndClipChain) {
         let clip_and_scroll = self.get_clip_and_scroll(
             &common.clip_id,
             &common.spatial_id,
             apply_pipeline_clip
         );
 
         let current_offset = self.current_offset(clip_and_scroll.spatial_node_index);
 
         let snap_to_device = &mut self.sc_stack.last_mut().unwrap().snap_to_device;
         snap_to_device.set_target_spatial_node(
             clip_and_scroll.spatial_node_index,
             &self.clip_scroll_tree
         );
 
-        let clip_rect = common.clip_rect.translate(current_offset);
-        let rect = bounds.translate(current_offset);
+        let clip_rect = snap_to_device.snap_rect(
+            &common.clip_rect.translate(current_offset)
+        );
+
+        let rect = bounds.map_or(clip_rect, |bounds| {
+            snap_to_device.snap_rect(&bounds.translate(current_offset))
+        });
 
         let layout = LayoutPrimitiveInfo {
-            rect: snap_to_device.snap_rect(&rect),
-            clip_rect: snap_to_device.snap_rect(&clip_rect),
+            rect,
+            clip_rect,
             flags: common.flags,
             hit_info: common.hit_info,
         };
 
         (layout, rect, clip_and_scroll)
     }
 
+    fn process_common_properties_with_bounds(
+        &mut self,
+        common: &CommonItemProperties,
+        bounds: &LayoutRect,
+        apply_pipeline_clip: bool,
+    ) -> (LayoutPrimitiveInfo, LayoutRect, ScrollNodeAndClipChain) {
+        self.process_common_properties(
+            common,
+            Some(bounds),
+            apply_pipeline_clip,
+        )
+    }
+
     pub fn snap_rect(
         &mut self,
         rect: &LayoutRect,
         target_spatial_node: SpatialNodeIndex,
     ) -> LayoutRect {
         let snap_to_device = &mut self.sc_stack.last_mut().unwrap().snap_to_device;
         snap_to_device.set_target_spatial_node(
             target_spatial_node,
@@ -1136,42 +1141,45 @@ impl<'a> SceneBuilder<'a> {
                     &layout,
                     &info.font_key,
                     &info.color,
                     item.glyphs(),
                     info.glyph_options,
                 );
             }
             DisplayItem::Rectangle(ref info) => {
-                let (layout, clip_and_scroll) = self.process_common_properties(
+                let (layout, _, clip_and_scroll) = self.process_common_properties(
                     &info.common,
+                    None,
                     apply_pipeline_clip,
                 );
 
                 self.add_solid_rectangle(
                     clip_and_scroll,
                     &layout,
                     info.color,
                 );
             }
             DisplayItem::HitTest(ref info) => {
-                let (layout, clip_and_scroll) = self.process_common_properties(
+                let (layout, _, clip_and_scroll) = self.process_common_properties(
                     &info.common,
+                    None,
                     apply_pipeline_clip,
                 );
 
                 self.add_solid_rectangle(
                     clip_and_scroll,
                     &layout,
                     ColorF::TRANSPARENT,
                 );
             }
             DisplayItem::ClearRectangle(ref info) => {
-                let (layout, clip_and_scroll) = self.process_common_properties(
+                let (layout, _, clip_and_scroll) = self.process_common_properties(
                     &info.common,
+                    None,
                     apply_pipeline_clip,
                 );
 
                 self.add_clear_rectangle(
                     clip_and_scroll,
                     &layout,
                 );
             }
@@ -1414,18 +1422,19 @@ impl<'a> SceneBuilder<'a> {
             DisplayItem::StickyFrame(ref info) => {
                 let parent_space = self.get_space(&info.parent_spatial_id);
                 self.build_sticky_frame(
                     info,
                     parent_space,
                 );
             }
             DisplayItem::BackdropFilter(ref info) => {
-                let (layout, clip_and_scroll) = self.process_common_properties(
+                let (layout, _, clip_and_scroll) = self.process_common_properties(
                     &info.common,
+                    None,
                     apply_pipeline_clip,
                 );
 
                 let filters = filter_ops_for_compositing(item.filters());
                 let filter_datas = filter_datas_for_compositing(item.filter_datas());
                 let filter_primitives = filter_primitives_for_compositing(item.filter_primitives());
 
                 self.add_backdrop_filter(