Bug 1470125 - Update WR bindings for changes in WR PR 2848. r=Gankro draft
authorMartin Robinson <mrobinson@igalia.com>
Wed, 13 Jun 2018 15:40:13 -0700
changeset 812185 6a0ef8c6d61ab937695c42224eb3acb0a5e531f7
parent 812183 c2543e9925efbdd0249d8f6e306f62455e12ac48
push id114480
push userkgupta@mozilla.com
push dateThu, 28 Jun 2018 18:35:43 +0000
reviewersGankro
bugs1470125
milestone63.0a1
Bug 1470125 - Update WR bindings for changes in WR PR 2848. r=Gankro MozReview-Commit-ID: D2hLIqlnfU6
gfx/webrender_bindings/WebRenderAPI.cpp
gfx/webrender_bindings/WebRenderAPI.h
gfx/webrender_bindings/src/bindings.rs
gfx/webrender_bindings/webrender_ffi_generated.h
layout/painting/nsCSSRenderingBorders.cpp
layout/painting/nsDisplayList.cpp
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -1126,24 +1126,27 @@ DisplayListBuilder::PushBorderImage(cons
                           aRepeatHorizontal, aRepeatVertical);
 }
 
 void
 DisplayListBuilder::PushBorderGradient(const wr::LayoutRect& aBounds,
                                        const wr::LayoutRect& aClip,
                                        bool aIsBackfaceVisible,
                                        const wr::BorderWidths& aWidths,
+                                       const uint32_t aWidth,
+                                       const uint32_t aHeight,
+                                       const wr::SideOffsets2D<uint32_t>& aSlice,
                                        const wr::LayoutPoint& aStartPoint,
                                        const wr::LayoutPoint& aEndPoint,
                                        const nsTArray<wr::GradientStop>& aStops,
                                        wr::ExtendMode aExtendMode,
                                        const wr::SideOffsets2D<float>& aOutset)
 {
   wr_dp_push_border_gradient(mWrState, aBounds, aClip, aIsBackfaceVisible,
-                             aWidths, aStartPoint, aEndPoint,
+                             aWidths, aWidth, aHeight, aSlice, aStartPoint, aEndPoint,
                              aStops.Elements(), aStops.Length(),
                              aExtendMode, aOutset);
 }
 
 void
 DisplayListBuilder::PushBorderRadialGradient(const wr::LayoutRect& aBounds,
                                              const wr::LayoutRect& aClip,
                                              bool aIsBackfaceVisible,
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -415,16 +415,19 @@ public:
                        const wr::SideOffsets2D<float>& aOutset,
                        const wr::RepeatMode& aRepeatHorizontal,
                        const wr::RepeatMode& aRepeatVertical);
 
   void PushBorderGradient(const wr::LayoutRect& aBounds,
                           const wr::LayoutRect& aClip,
                           bool aIsBackfaceVisible,
                           const wr::BorderWidths& aWidths,
+                          const uint32_t aWidth,
+                          const uint32_t aHeight,
+                          const wr::SideOffsets2D<uint32_t>& aSlice,
                           const wr::LayoutPoint& aStartPoint,
                           const wr::LayoutPoint& aEndPoint,
                           const nsTArray<wr::GradientStop>& aStops,
                           wr::ExtendMode aExtendMode,
                           const wr::SideOffsets2D<float>& aOutset);
 
   void PushBorderRadialGradient(const wr::LayoutRect& aBounds,
                                 const wr::LayoutRect& aClip,
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -2133,58 +2133,64 @@ pub extern "C" fn wr_dp_push_border_imag
         fill: false,
         outset: outset.into(),
         repeat_horizontal: repeat_horizontal.into(),
         repeat_vertical: repeat_vertical.into(),
     });
     let mut prim_info = LayoutPrimitiveInfo::with_clip_rect(rect, clip.into());
     prim_info.is_backface_visible = is_backface_visible;
     prim_info.tag = state.current_tag;
-    state.frame_builder
-         .dl_builder
-         .push_border(&prim_info,
-                      widths.into(),
-                      border_details);
+    state.frame_builder .dl_builder
+         .push_border(&prim_info, widths.into(), border_details);
 }
 
 #[no_mangle]
 pub extern "C" fn wr_dp_push_border_gradient(state: &mut WrState,
                                              rect: LayoutRect,
                                              clip: LayoutRect,
                                              is_backface_visible: bool,
                                              widths: BorderWidths,
+                                             width: u32,
+                                             height: u32,
+                                             slice: SideOffsets2D<u32>,
                                              start_point: LayoutPoint,
                                              end_point: LayoutPoint,
                                              stops: *const GradientStop,
                                              stops_count: usize,
                                              extend_mode: ExtendMode,
                                              outset: SideOffsets2D<f32>) {
     debug_assert!(unsafe { is_in_main_thread() });
 
     let stops_slice = make_slice(stops, stops_count);
     let stops_vector = stops_slice.to_owned();
 
-    let border_details = BorderDetails::Gradient(GradientBorder {
-                                                     gradient:
-                                                         state.frame_builder
-                                                              .dl_builder
-                                                              .create_gradient(start_point.into(),
-                                                                               end_point.into(),
-                                                                               stops_vector,
-                                                                               extend_mode.into()),
-                                                     outset: outset.into(),
-                                                 });
+    let gradient = state.frame_builder.dl_builder.create_gradient(
+        start_point.into(),
+        end_point.into(),
+        stops_vector,
+        extend_mode.into()
+    );
+
+    let border_details = BorderDetails::NinePatch(NinePatchBorder {
+        source: NinePatchBorderSource::Gradient(gradient),
+        width,
+        height,
+        slice,
+        fill: false,
+        outset: outset.into(),
+        repeat_horizontal: RepeatMode::Stretch,
+        repeat_vertical: RepeatMode::Stretch,
+    });
+
     let mut prim_info = LayoutPrimitiveInfo::with_clip_rect(rect, clip.into());
     prim_info.is_backface_visible = is_backface_visible;
     prim_info.tag = state.current_tag;
     state.frame_builder
          .dl_builder
-         .push_border(&prim_info,
-                      widths.into(),
-                      border_details);
+         .push_border(&prim_info, widths.into(), border_details);
 }
 
 #[no_mangle]
 pub extern "C" fn wr_dp_push_border_radial_gradient(state: &mut WrState,
                                                     rect: LayoutRect,
                                                     clip: LayoutRect,
                                                     is_backface_visible: bool,
                                                     widths: BorderWidths,
@@ -2194,35 +2200,46 @@ pub extern "C" fn wr_dp_push_border_radi
                                                     stops_count: usize,
                                                     extend_mode: ExtendMode,
                                                     outset: SideOffsets2D<f32>) {
     debug_assert!(unsafe { is_in_main_thread() });
 
     let stops_slice = make_slice(stops, stops_count);
     let stops_vector = stops_slice.to_owned();
 
-    let border_details =
-        BorderDetails::RadialGradient(RadialGradientBorder {
-                                          gradient:
-                                              state.frame_builder
-                                                   .dl_builder
-                                                   .create_radial_gradient(center.into(),
-                                                                           radius.into(),
-                                                                           stops_vector,
-                                                                           extend_mode.into()),
-                                          outset: outset.into(),
-                                      });
+    let slice = SideOffsets2D::new(
+        widths.top as u32,
+        widths.right as u32,
+        widths.bottom as u32,
+        widths.left as u32,
+    );
+
+    let gradient = state.frame_builder.dl_builder.create_radial_gradient(
+        center.into(),
+        radius.into(),
+        stops_vector,
+        extend_mode.into()
+    );
+
+    let border_details = BorderDetails::NinePatch(NinePatchBorder {
+        source: NinePatchBorderSource::RadialGradient(gradient),
+        width: rect.size.width as u32,
+        height: rect.size.height as u32,
+        slice,
+        fill: false,
+        outset: outset.into(),
+        repeat_horizontal: RepeatMode::Stretch,
+        repeat_vertical: RepeatMode::Stretch,
+    });
     let mut prim_info = LayoutPrimitiveInfo::with_clip_rect(rect, clip.into());
     prim_info.is_backface_visible = is_backface_visible;
     prim_info.tag = state.current_tag;
     state.frame_builder
          .dl_builder
-         .push_border(&prim_info,
-                      widths.into(),
-                      border_details);
+         .push_border(&prim_info, widths.into(), border_details);
 }
 
 #[no_mangle]
 pub extern "C" fn wr_dp_push_linear_gradient(state: &mut WrState,
                                              rect: LayoutRect,
                                              clip: LayoutRect,
                                              is_backface_visible: bool,
                                              start_point: LayoutPoint,
--- a/gfx/webrender_bindings/webrender_ffi_generated.h
+++ b/gfx/webrender_bindings/webrender_ffi_generated.h
@@ -1164,16 +1164,19 @@ void wr_dp_push_border(WrState *aState,
 WR_FUNC;
 
 WR_INLINE
 void wr_dp_push_border_gradient(WrState *aState,
                                 LayoutRect aRect,
                                 LayoutRect aClip,
                                 bool aIsBackfaceVisible,
                                 BorderWidths aWidths,
+                                uint32_t aWidth,
+                                uint32_t aHeight,
+                                SideOffsets2D<uint32_t> aSlice,
                                 LayoutPoint aStartPoint,
                                 LayoutPoint aEndPoint,
                                 const GradientStop *aStops,
                                 uintptr_t aStopsCount,
                                 ExtendMode aExtendMode,
                                 SideOffsets2D<float> aOutset)
 WR_FUNC;
 
--- a/layout/painting/nsCSSRenderingBorders.cpp
+++ b/layout/painting/nsCSSRenderingBorders.cpp
@@ -3766,16 +3766,19 @@ nsCSSBorderImageRenderer::CreateWebRende
       if (gradientData->mShape == NS_STYLE_GRADIENT_SHAPE_LINEAR) {
         LayoutDevicePoint startPoint = LayoutDevicePoint(dest.origin.x, dest.origin.y) + lineStart;
         LayoutDevicePoint endPoint = LayoutDevicePoint(dest.origin.x, dest.origin.y) + lineEnd;
 
         aBuilder.PushBorderGradient(dest,
                                     clip,
                                     !aItem->BackfaceIsHidden(),
                                     wr::ToBorderWidths(widths[0], widths[1], widths[2], widths[3]),
+                                    (float)(mImageSize.width) / appUnitsPerDevPixel,
+                                    (float)(mImageSize.height) / appUnitsPerDevPixel,
+                                    wr::ToSideOffsets2D_u32(slice[0], slice[1], slice[2], slice[3]),
                                     wr::ToLayoutPoint(startPoint),
                                     wr::ToLayoutPoint(endPoint),
                                     stops,
                                     extendMode,
                                     wr::ToSideOffsets2D_f32(outset[0], outset[1], outset[2], outset[3]));
       } else {
         aBuilder.PushBorderRadialGradient(dest,
                                           clip,
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -5456,16 +5456,19 @@ nsDisplayBorder::CreateBorderImageWebRen
       if (gradientData->mShape == NS_STYLE_GRADIENT_SHAPE_LINEAR) {
         LayoutDevicePoint startPoint = LayoutDevicePoint(dest.origin.x, dest.origin.y) + lineStart;
         LayoutDevicePoint endPoint = LayoutDevicePoint(dest.origin.x, dest.origin.y) + lineEnd;
 
         aBuilder.PushBorderGradient(dest,
                                     clip,
                                     !BackfaceIsHidden(),
                                     wr::ToBorderWidths(widths[0], widths[1], widths[2], widths[3]),
+                                    (float)(mBorderImageRenderer->mImageSize.width) / appUnitsPerDevPixel,
+                                    (float)(mBorderImageRenderer->mImageSize.height) / appUnitsPerDevPixel,
+                                    wr::ToSideOffsets2D_u32(slice[0], slice[1], slice[2], slice[3]),
                                     wr::ToLayoutPoint(startPoint),
                                     wr::ToLayoutPoint(endPoint),
                                     stops,
                                     extendMode,
                                     wr::ToSideOffsets2D_f32(outset[0], outset[1], outset[2], outset[3]));
       } else {
         aBuilder.PushBorderRadialGradient(dest,
                                           clip,