Bug 1510376 - Update webrender to commit 323b7ea140ba956af342e4f2660e67e04913e9fb (WR PR #3361). r=kats
authorWR Updater Bot <graphics-team@mozilla.staktrace.com>
Wed, 28 Nov 2018 14:06:08 +0000
changeset 507737 3dcdcddd94ff74e05fb4793e970433772ac99098
parent 507736 f7f8b232d111ba86b0ac3d9c7aa65a7be21f82ea
child 507738 8692990356a7e39a67ee65909ff01f621d0830fb
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1510376
milestone65.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 1510376 - Update webrender to commit 323b7ea140ba956af342e4f2660e67e04913e9fb (WR PR #3361). r=kats https://github.com/servo/webrender/pull/3361 Differential Revision: https://phabricator.services.mozilla.com/D13246
gfx/webrender_bindings/revision.txt
gfx/wr/webrender_api/src/display_item.rs
gfx/wr/webrender_api/src/display_list.rs
--- a/gfx/webrender_bindings/revision.txt
+++ b/gfx/webrender_bindings/revision.txt
@@ -1,1 +1,1 @@
-586af96c22c8b05722534e98703bfb47f1d270a1
+323b7ea140ba956af342e4f2660e67e04913e9fb
--- a/gfx/wr/webrender_api/src/display_item.rs
+++ b/gfx/wr/webrender_api/src/display_item.rs
@@ -61,16 +61,25 @@ pub type ItemTag = (u64, u16);
 pub struct GenericDisplayItem<T> {
     pub item: T,
     pub clip_and_scroll: ClipAndScrollInfo,
     pub info: LayoutPrimitiveInfo,
 }
 
 pub type DisplayItem = GenericDisplayItem<SpecificDisplayItem>;
 
+/// A modified version of DI where every field is borrowed instead of owned.
+/// It allows us to reduce copies during serialization.
+#[derive(Serialize)]
+pub struct SerializedDisplayItem<'a> {
+    pub item: &'a SpecificDisplayItem,
+    pub clip_and_scroll: &'a ClipAndScrollInfo,
+    pub info: &'a LayoutPrimitiveInfo,
+}
+
 #[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
 pub struct PrimitiveInfo<T> {
     pub rect: TypedRect<f32, T>,
     pub clip_rect: TypedRect<f32, T>,
     pub is_backface_visible: bool,
     pub tag: Option<ItemTag>,
 }
 
--- a/gfx/wr/webrender_api/src/display_list.rs
+++ b/gfx/wr/webrender_api/src/display_list.rs
@@ -18,18 +18,19 @@ use {AlphaType, BorderDetails, BorderDis
 use {BoxShadowDisplayItem, ClipAndScrollInfo, ClipChainId, ClipChainItem, ClipDisplayItem, ClipId};
 use {ColorF, ComplexClipRegion, DisplayItem, ExtendMode, ExternalScrollId, FilterOp};
 use {FontInstanceKey, GlyphInstance, GlyphOptions, RasterSpace, Gradient, GradientBuilder};
 use {GradientDisplayItem, GradientStop, IframeDisplayItem, ImageDisplayItem, ImageKey, ImageMask};
 use {ImageRendering, LayoutPoint, LayoutPrimitiveInfo, LayoutRect, LayoutSideOffsets, LayoutSize};
 use {LayoutTransform, LayoutVector2D, LineDisplayItem, LineOrientation, LineStyle, MixBlendMode};
 use {PipelineId, PropertyBinding, PushReferenceFrameDisplayListItem};
 use {PushStackingContextDisplayItem, RadialGradient, RadialGradientDisplayItem};
-use {RectangleDisplayItem, ReferenceFrame, ScrollFrameDisplayItem, ScrollSensitivity, Shadow};
-use {SpecificDisplayItem, StackingContext, StickyFrameDisplayItem, StickyOffsetBounds};
+use {RectangleDisplayItem, ReferenceFrame, ScrollFrameDisplayItem, ScrollSensitivity};
+use {SerializedDisplayItem, Shadow, SpecificDisplayItem};
+use {StackingContext, StickyFrameDisplayItem, StickyOffsetBounds};
 use {TextDisplayItem, TransformStyle, YuvColorSpace, YuvData, YuvImageDisplayItem, ColorDepth};
 
 // We don't want to push a long text-run. If a text-run is too long, split it into several parts.
 // This needs to be set to (renderer::MAX_VERTEX_TEXTURE_WIDTH - VECS_PER_TEXT_RUN) * 2
 pub const MAX_TEXT_RUN_LENGTH: usize = 2040;
 
 // We start at 2, because the root reference is always 0 and the root scroll node is always 1.
 // TODO(mrobinson): It would be a good idea to eliminate the root scroll frame which is only
@@ -686,26 +687,26 @@ impl<'a> Write for SizeCounter {
 }
 
 /// Serializes a value assuming the Serialize impl has a stable size across two
 /// invocations.
 ///
 /// If this assumption is incorrect, the result will be Undefined Behaviour. This
 /// assumption should hold for all derived Serialize impls, which is all we currently
 /// use.
-fn serialize_fast<T: Serialize>(vec: &mut Vec<u8>, e: &T) {
+fn serialize_fast<T: Serialize>(vec: &mut Vec<u8>, e: T) {
     // manually counting the size is faster than vec.reserve(bincode::serialized_size(&e) as usize) for some reason
     let mut size = SizeCounter(0);
-    bincode::serialize_into(&mut size, e).unwrap();
+    bincode::serialize_into(&mut size, &e).unwrap();
     vec.reserve(size.0);
 
     let old_len = vec.len();
     let ptr = unsafe { vec.as_mut_ptr().add(old_len) };
     let mut w = UnsafeVecWriter(ptr);
-    bincode::serialize_into(&mut w, e).unwrap();
+    bincode::serialize_into(&mut w, &e).unwrap();
 
     // fix up the length
     unsafe { vec.set_len(old_len + size.0); }
 
     // make sure we wrote the right amount
     debug_assert_eq!(((w.0 as usize) - (vec.as_ptr() as usize)), vec.len());
 }
 
@@ -959,53 +960,46 @@ impl DisplayListBuilder {
         index
     }
 
     /// Add an item to the display list.
     ///
     /// NOTE: It is usually preferable to use the specialized methods to push
     /// display items. Pushing unexpected or invalid items here may
     /// result in WebRender panicking or behaving in unexpected ways.
-    pub fn push_item(&mut self, item: SpecificDisplayItem, info: &LayoutPrimitiveInfo) {
+    pub fn push_item(&mut self, item: &SpecificDisplayItem, info: &LayoutPrimitiveInfo) {
         serialize_fast(
             &mut self.data,
-            &DisplayItem {
+            SerializedDisplayItem {
                 item,
-                clip_and_scroll: *self.clip_stack.last().unwrap(),
-                info: *info,
+                clip_and_scroll: self.clip_stack.last().unwrap(),
+                info,
             },
         )
     }
 
     fn push_item_with_clip_scroll_info(
         &mut self,
-        item: SpecificDisplayItem,
+        item: &SpecificDisplayItem,
         info: &LayoutPrimitiveInfo,
-        scrollinfo: ClipAndScrollInfo
+        clip_and_scroll: &ClipAndScrollInfo
     ) {
         serialize_fast(
             &mut self.data,
-            &DisplayItem {
+            SerializedDisplayItem {
                 item,
-                clip_and_scroll: scrollinfo,
-                info: *info,
+                clip_and_scroll,
+                info,
             },
         )
     }
 
-    fn push_new_empty_item(&mut self, item: SpecificDisplayItem, clip_and_scroll: &ClipAndScrollInfo) {
-        let info = LayoutPrimitiveInfo::new(LayoutRect::zero());
-        serialize_fast(
-            &mut self.data,
-            &DisplayItem {
-                item,
-                clip_and_scroll: *clip_and_scroll,
-                info,
-            }
-        )
+    fn push_new_empty_item(&mut self, item: &SpecificDisplayItem) {
+        let info = &LayoutPrimitiveInfo::new(LayoutRect::zero());
+        self.push_item(item, info)
     }
 
     fn push_iter_impl<I>(data: &mut Vec<u8>, iter_source: I)
     where
         I: IntoIterator,
         I::IntoIter: ExactSizeIterator + Clone,
         I::Item: Serialize,
     {
@@ -1045,21 +1039,21 @@ impl DisplayListBuilder {
         I::IntoIter: ExactSizeIterator + Clone,
         I::Item: Serialize,
     {
         Self::push_iter_impl(&mut self.data, iter);
     }
 
     pub fn push_rect(&mut self, info: &LayoutPrimitiveInfo, color: ColorF) {
         let item = SpecificDisplayItem::Rectangle(RectangleDisplayItem { color });
-        self.push_item(item, info);
+        self.push_item(&item, info);
     }
 
     pub fn push_clear_rect(&mut self, info: &LayoutPrimitiveInfo) {
-        self.push_item(SpecificDisplayItem::ClearRectangle, info);
+        self.push_item(&SpecificDisplayItem::ClearRectangle, info);
     }
 
     pub fn push_line(
         &mut self,
         info: &LayoutPrimitiveInfo,
         wavy_line_thickness: f32,
         orientation: LineOrientation,
         color: &ColorF,
@@ -1067,17 +1061,17 @@ impl DisplayListBuilder {
     ) {
         let item = SpecificDisplayItem::Line(LineDisplayItem {
             wavy_line_thickness,
             orientation,
             color: *color,
             style,
         });
 
-        self.push_item(item, info);
+        self.push_item(&item, info);
     }
 
     pub fn push_image(
         &mut self,
         info: &LayoutPrimitiveInfo,
         stretch_size: LayoutSize,
         tile_spacing: LayoutSize,
         image_rendering: ImageRendering,
@@ -1089,17 +1083,17 @@ impl DisplayListBuilder {
             image_key: key,
             stretch_size,
             tile_spacing,
             image_rendering,
             alpha_type,
             color,
         });
 
-        self.push_item(item, info);
+        self.push_item(&item, info);
     }
 
     /// Push a yuv image. All planar data in yuv image should use the same buffer type.
     pub fn push_yuv_image(
         &mut self,
         info: &LayoutPrimitiveInfo,
         yuv_data: YuvData,
         color_depth: ColorDepth,
@@ -1107,17 +1101,17 @@ impl DisplayListBuilder {
         image_rendering: ImageRendering,
     ) {
         let item = SpecificDisplayItem::YuvImage(YuvImageDisplayItem {
             yuv_data,
             color_depth,
             color_space,
             image_rendering,
         });
-        self.push_item(item, info);
+        self.push_item(&item, info);
     }
 
     pub fn push_text(
         &mut self,
         info: &LayoutPrimitiveInfo,
         glyphs: &[GlyphInstance],
         font_key: FontInstanceKey,
         color: ColorF,
@@ -1125,17 +1119,17 @@ impl DisplayListBuilder {
     ) {
         let item = SpecificDisplayItem::Text(TextDisplayItem {
             color,
             font_key,
             glyph_options,
         });
 
         for split_glyphs in glyphs.chunks(MAX_TEXT_RUN_LENGTH) {
-            self.push_item(item, info);
+            self.push_item(&item, info);
             self.push_iter(split_glyphs);
         }
     }
 
     /// NOTE: gradients must be pushed in the order they're created
     /// because create_gradient stores the stops in anticipation.
     pub fn create_gradient(
         &mut self,
@@ -1168,17 +1162,17 @@ impl DisplayListBuilder {
     pub fn push_border(
         &mut self,
         info: &LayoutPrimitiveInfo,
         widths: LayoutSideOffsets,
         details: BorderDetails,
     ) {
         let item = SpecificDisplayItem::Border(BorderDisplayItem { details, widths });
 
-        self.push_item(item, info);
+        self.push_item(&item, info);
     }
 
     pub fn push_box_shadow(
         &mut self,
         info: &LayoutPrimitiveInfo,
         box_bounds: LayoutRect,
         offset: LayoutVector2D,
         color: ColorF,
@@ -1192,17 +1186,17 @@ impl DisplayListBuilder {
             offset,
             color,
             blur_radius,
             spread_radius,
             border_radius,
             clip_mode,
         });
 
-        self.push_item(item, info);
+        self.push_item(&item, info);
     }
 
     /// Pushes a linear gradient to be displayed.
     ///
     /// The gradient itself is described in the
     /// `gradient` parameter. It is drawn on
     /// a "tile" with the dimensions from `tile_size`.
     /// These tiles are now repeated to the right and
@@ -1222,17 +1216,17 @@ impl DisplayListBuilder {
         tile_spacing: LayoutSize,
     ) {
         let item = SpecificDisplayItem::Gradient(GradientDisplayItem {
             gradient,
             tile_size,
             tile_spacing,
         });
 
-        self.push_item(item, info);
+        self.push_item(&item, info);
     }
 
     /// Pushes a radial gradient to be displayed.
     ///
     /// See [`push_gradient`](#method.push_gradient) for explanation.
     pub fn push_radial_gradient(
         &mut self,
         info: &LayoutPrimitiveInfo,
@@ -1241,40 +1235,39 @@ impl DisplayListBuilder {
         tile_spacing: LayoutSize,
     ) {
         let item = SpecificDisplayItem::RadialGradient(RadialGradientDisplayItem {
             gradient,
             tile_size,
             tile_spacing,
         });
 
-        self.push_item(item, info);
+        self.push_item(&item, info);
     }
 
     pub fn push_reference_frame(
         &mut self,
         info: &LayoutPrimitiveInfo,
         transform: Option<PropertyBinding<LayoutTransform>>,
         perspective: Option<LayoutTransform>,
     ) -> ClipId {
         let id = self.generate_spatial_index();
         let item = SpecificDisplayItem::PushReferenceFrame(PushReferenceFrameDisplayListItem {
             reference_frame: ReferenceFrame {
                 transform,
                 perspective,
                 id,
             },
         });
-        self.push_item(item, info);
+        self.push_item(&item, info);
         id
     }
 
     pub fn pop_reference_frame(&mut self) {
-        let clip_and_scroll = *self.clip_stack.last().unwrap();
-        self.push_new_empty_item(SpecificDisplayItem::PopReferenceFrame, &clip_and_scroll);
+        self.push_new_empty_item(&SpecificDisplayItem::PopReferenceFrame);
     }
 
     pub fn push_stacking_context(
         &mut self,
         info: &LayoutPrimitiveInfo,
         clip_node_id: Option<ClipId>,
         transform_style: TransformStyle,
         mix_blend_mode: MixBlendMode,
@@ -1285,31 +1278,29 @@ impl DisplayListBuilder {
             stacking_context: StackingContext {
                 transform_style,
                 mix_blend_mode,
                 clip_node_id,
                 raster_space,
             },
         });
 
-        self.push_item(item, info);
+        self.push_item(&item, info);
         self.push_iter(filters);
     }
 
     pub fn pop_stacking_context(&mut self) {
-        let clip_and_scroll = *self.clip_stack.last().unwrap();
-        self.push_new_empty_item(SpecificDisplayItem::PopStackingContext, &clip_and_scroll);
+        self.push_new_empty_item(&SpecificDisplayItem::PopStackingContext);
     }
 
     pub fn push_stops(&mut self, stops: &[GradientStop]) {
         if stops.is_empty() {
             return;
         }
-        let clip_and_scroll = *self.clip_stack.last().unwrap();
-        self.push_new_empty_item(SpecificDisplayItem::SetGradientStops, &clip_and_scroll);
+        self.push_new_empty_item(&SpecificDisplayItem::SetGradientStops);
         self.push_iter(stops);
     }
 
     fn generate_clip_index(&mut self) -> ClipId {
         self.next_clip_index += 1;
         ClipId::Clip(self.next_clip_index - 1, self.pipeline_id)
     }
 
@@ -1367,37 +1358,36 @@ impl DisplayListBuilder {
             clip_id,
             scroll_frame_id,
             external_id,
             image_mask,
             scroll_sensitivity,
         });
 
         self.push_item_with_clip_scroll_info(
-            item,
+            &item,
             &LayoutPrimitiveInfo::with_clip_rect(content_rect, clip_rect),
-            ClipAndScrollInfo::simple(parent),
+            &ClipAndScrollInfo::simple(parent),
         );
         self.push_iter(complex_clips);
 
         scroll_frame_id
     }
 
     pub fn define_clip_chain<I>(
         &mut self,
         parent: Option<ClipChainId>,
         clips: I,
     ) -> ClipChainId
     where
         I: IntoIterator<Item = ClipId>,
         I::IntoIter: ExactSizeIterator + Clone,
     {
         let id = self.generate_clip_chain_id();
-        let clip_and_scroll = *self.clip_stack.last().unwrap();
-        self.push_new_empty_item(SpecificDisplayItem::ClipChain(ClipChainItem { id, parent }), &clip_and_scroll);
+        self.push_new_empty_item(&SpecificDisplayItem::ClipChain(ClipChainItem { id, parent }));
         self.push_iter(clips);
         id
     }
 
     pub fn define_clip<I>(
         &mut self,
         clip_rect: LayoutRect,
         complex_clips: I,
@@ -1449,17 +1439,17 @@ impl DisplayListBuilder {
         let id = self.generate_clip_index();
         let item = SpecificDisplayItem::Clip(ClipDisplayItem {
             id,
             image_mask,
         });
 
         let info = LayoutPrimitiveInfo::new(clip_rect);
 
-        self.push_item_with_clip_scroll_info(item, &info, scrollinfo);
+        self.push_item_with_clip_scroll_info(&item, &info, &scrollinfo);
         self.push_iter(complex_clips);
         id
     }
 
     pub fn define_sticky_frame(
         &mut self,
         frame_rect: LayoutRect,
         margins: SideOffsets2D<Option<f32>>,
@@ -1472,17 +1462,17 @@ impl DisplayListBuilder {
             id,
             margins,
             vertical_offset_bounds,
             horizontal_offset_bounds,
             previously_applied_offset,
         });
 
         let info = LayoutPrimitiveInfo::new(frame_rect);
-        self.push_item(item, &info);
+        self.push_item(&item, &info);
         id
     }
 
     pub fn push_clip_id(&mut self, id: ClipId) {
         self.clip_stack.push(ClipAndScrollInfo::simple(id));
     }
 
     pub fn push_clip_and_scroll_info(&mut self, info: ClipAndScrollInfo) {
@@ -1504,34 +1494,31 @@ impl DisplayListBuilder {
         pipeline_id: PipelineId,
         ignore_missing_pipeline: bool
     ) {
         let item = SpecificDisplayItem::Iframe(IframeDisplayItem {
             clip_id: self.generate_clip_index(),
             pipeline_id,
             ignore_missing_pipeline,
         });
-        self.push_item(item, info);
+        self.push_item(&item, info);
     }
 
     pub fn push_shadow(&mut self, info: &LayoutPrimitiveInfo, shadow: Shadow) {
-        self.push_item(SpecificDisplayItem::PushShadow(shadow), info);
+        self.push_item(&SpecificDisplayItem::PushShadow(shadow), info);
     }
 
     pub fn pop_all_shadows(&mut self) {
-        let clip_and_scroll = *self.clip_stack.last().unwrap();
-        self.push_new_empty_item(SpecificDisplayItem::PopAllShadows, &clip_and_scroll);
+        self.push_new_empty_item(&SpecificDisplayItem::PopAllShadows);
     }
 
     pub fn finalize(self) -> (PipelineId, LayoutSize, BuiltDisplayList) {
         assert!(self.save_state.is_none(), "Finalized DisplayListBuilder with a pending save");
 
         let end_time = precise_time_ns();
-
-
         (
             self.pipeline_id,
             self.content_size,
             BuiltDisplayList {
                 descriptor: BuiltDisplayListDescriptor {
                     builder_start_time: self.builder_start_time,
                     builder_finish_time: end_time,
                     send_start_time: 0,