Bug 1347469 - Add bindings for gradient border. r=kats
authorMorris Tseng <mtseng@mozilla.com>
Mon, 10 Apr 2017 17:27:30 +0800
changeset 400879 350d77ec1b74f2c1bbd39aab6f9e7de33f0ce2d0
parent 400878 09534c0cda7cab07bcdd1a08b097b468cbce9059
child 400880 b47985cfad21e8afb2bc3915483cd233424efa35
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1347469
milestone55.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 1347469 - Add bindings for gradient border. r=kats MozReview-Commit-ID: H6OwWaeBYWY
gfx/webrender_bindings/WebRenderAPI.cpp
gfx/webrender_bindings/WebRenderAPI.h
gfx/webrender_bindings/src/bindings.rs
gfx/webrender_bindings/webrender_ffi.h
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -660,16 +660,48 @@ DisplayListBuilder::PushBorderImage(cons
                                     const WrRepeatMode& aRepeatVertical)
 {
   wr_dp_push_border_image(mWrState, aBounds, aClip,
                           aWidths, aImage, aPatch, aOutset,
                           aRepeatHorizontal, aRepeatVertical);
 }
 
 void
+DisplayListBuilder::PushBorderGradient(const WrRect& aBounds,
+                                       const WrClipRegion& aClip,
+                                       const WrBorderWidths& aWidths,
+                                       const WrPoint& aStartPoint,
+                                       const WrPoint& aEndPoint,
+                                       const nsTArray<WrGradientStop>& aStops,
+                                       wr::GradientExtendMode aExtendMode,
+                                       const WrSideOffsets2Df32& aOutset)
+{
+  wr_dp_push_border_gradient(mWrState, aBounds, aClip,
+                             aWidths, aStartPoint, aEndPoint,
+                             aStops.Elements(), aStops.Length(),
+                             aExtendMode, aOutset);
+}
+
+void
+DisplayListBuilder::PushBorderRadialGradient(const WrRect& aBounds,
+                                             const WrClipRegion& aClip,
+                                             const WrBorderWidths& aWidths,
+                                             const WrPoint& aCenter,
+                                             const WrSize& aRadius,
+                                             const nsTArray<WrGradientStop>& aStops,
+                                             wr::GradientExtendMode aExtendMode,
+                                             const WrSideOffsets2Df32& aOutset)
+{
+  wr_dp_push_border_radial_gradient(
+    mWrState, aBounds, aClip, aWidths, aCenter,
+    aRadius, aStops.Elements(), aStops.Length(),
+    aExtendMode, aOutset);
+}
+
+void
 DisplayListBuilder::PushText(const WrRect& aBounds,
                              const WrClipRegion& aClip,
                              const gfx::Color& aColor,
                              wr::FontKey aFontKey,
                              Range<const WrGlyphInstance> aGlyphBuffer,
                              float aGlyphSize)
 {
   wr_dp_push_text(mWrState, aBounds, aClip,
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -202,16 +202,34 @@ public:
                        const WrClipRegion& aClip,
                        const WrBorderWidths& aWidths,
                        wr::ImageKey aImage,
                        const WrNinePatchDescriptor& aPatch,
                        const WrSideOffsets2Df32& aOutset,
                        const WrRepeatMode& aRepeatHorizontal,
                        const WrRepeatMode& aRepeatVertical);
 
+  void PushBorderGradient(const WrRect& aBounds,
+                          const WrClipRegion& aClip,
+                          const WrBorderWidths& aWidths,
+                          const WrPoint& aStartPoint,
+                          const WrPoint& aEndPoint,
+                          const nsTArray<WrGradientStop>& aStops,
+                          wr::GradientExtendMode aExtendMode,
+                          const WrSideOffsets2Df32& aOutset);
+
+  void PushBorderRadialGradient(const WrRect& aBounds,
+                                const WrClipRegion& aClip,
+                                const WrBorderWidths& aWidths,
+                                const WrPoint& aCenter,
+                                const WrSize& aRadius,
+                                const nsTArray<WrGradientStop>& aStops,
+                                wr::GradientExtendMode aExtendMode,
+                                const WrSideOffsets2Df32& aOutset);
+
   void PushText(const WrRect& aBounds,
                 const WrClipRegion& aClip,
                 const gfx::Color& aColor,
                 wr::FontKey aFontKey,
                 Range<const WrGlyphInstance> aGlyphBuffer,
                 float aGlyphSize);
 
   void PushBoxShadow(const WrRect& aRect,
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -1243,16 +1243,64 @@ pub extern "C" fn wr_dp_push_border_imag
     state.frame_builder.dl_builder.push_border(
                                     rect.to_rect(),
                                     clip.to_clip_region(),
                                     widths.to_border_widths(),
                                     border_details);
 }
 
 #[no_mangle]
+pub extern "C" fn wr_dp_push_border_gradient(state: &mut WrState, rect: WrRect, clip: WrRect,
+                                             widths: WrBorderWidths,
+                                             start_point: WrPoint, end_point: WrPoint,
+                                             stops: *const WrGradientStop, stops_count: usize,
+                                             extend_mode: WrGradientExtendMode,
+                                             outset: WrSideOffsets2D<f32>) {
+    assert!( unsafe { is_in_main_thread() });
+    let stops = WrGradientStop::to_gradient_stops(unsafe { slice::from_raw_parts(stops, stops_count) });
+    let clip_region = state.frame_builder.dl_builder.new_clip_region(&clip.to_rect(), Vec::new(), None);
+    let border_details = BorderDetails::Gradient(GradientBorder {
+        gradient: state.frame_builder.dl_builder.create_gradient(
+                      start_point.to_point(), end_point.to_point(),
+                      stops, extend_mode.to_gradient_extend_mode()),
+        outset: outset.to_side_offsets_2d(),
+    });
+    state.frame_builder.dl_builder.push_border(
+                                    rect.to_rect(),
+                                    clip_region,
+                                    widths.to_border_widths(),
+                                    border_details);
+}
+
+#[no_mangle]
+pub extern "C" fn wr_dp_push_border_radial_gradient(state: &mut WrState, rect: WrRect, clip: WrRect,
+                                                    widths: WrBorderWidths,
+                                                    center: WrPoint,
+                                                    radius: WrSize,
+                                                    stops: *const WrGradientStop, stops_count: usize,
+                                                    extend_mode: WrGradientExtendMode,
+                                                    outset: WrSideOffsets2D<f32>) {
+    assert!( unsafe { is_in_main_thread() });
+    let stops = WrGradientStop::to_gradient_stops(unsafe { slice::from_raw_parts(stops, stops_count) });
+    let clip_region = state.frame_builder.dl_builder.new_clip_region(&clip.to_rect(), Vec::new(), None);
+    let border_details = BorderDetails::RadialGradient(RadialGradientBorder {
+        gradient: state.frame_builder.dl_builder.create_radial_gradient(center.to_point(),
+                                                                        radius.to_size(),
+                                                                        stops,
+                                                                        extend_mode.to_gradient_extend_mode()),
+        outset: outset.to_side_offsets_2d(),
+    });
+    state.frame_builder.dl_builder.push_border(
+                                    rect.to_rect(),
+                                    clip_region,
+                                    widths.to_border_widths(),
+                                    border_details);
+}
+
+#[no_mangle]
 pub extern "C" fn wr_dp_push_linear_gradient(state: &mut WrState,
                                              rect: WrRect,
                                              clip: WrClipRegion,
                                              start_point: WrPoint,
                                              end_point: WrPoint,
                                              stops: *const WrGradientStop,
                                              stops_count: usize,
                                              extend_mode: WrGradientExtendMode) {
--- a/gfx/webrender_bindings/webrender_ffi.h
+++ b/gfx/webrender_bindings/webrender_ffi.h
@@ -681,16 +681,34 @@ WR_INLINE void
 wr_dp_push_border_image(WrState* wrState, WrRect bounds, WrClipRegion clip,
                         WrBorderWidths widths,
                         WrImageKey image, WrNinePatchDescriptor patch, WrSideOffsets2Df32 outset,
                         WrRepeatMode repeat_horizontal,
                         WrRepeatMode repeat_vertical)
 WR_FUNC;
 
 WR_INLINE void
+wr_dp_push_border_gradient(WrState* wrState, WrRect bounds, WrClipRegion clip,
+                           WrBorderWidths widths,
+                           WrPoint startPoint, WrPoint endPoint,
+                           const WrGradientStop* stops, size_t stopsCount,
+                           WrGradientExtendMode extendMode,
+                           WrSideOffsets2Df32 outset)
+WR_FUNC;
+
+WR_INLINE void
+wr_dp_push_border_radial_gradient(WrState* wrState, WrRect bounds, WrClipRegion clip,
+                                  WrBorderWidths widths,
+                                  WrPoint center, WrSize radius,
+                                  const WrGradientStop* stops, size_t stopsCount,
+                                  WrGradientExtendMode extendMode,
+                                  WrSideOffsets2Df32 outset)
+WR_FUNC;
+
+WR_INLINE void
 wr_dp_push_linear_gradient(WrState* wrState, WrRect bounds, WrClipRegion clip,
                            WrPoint startPoint, WrPoint endPoint,
                            const WrGradientStop* stops, size_t stopsCount,
                            WrGradientExtendMode extendMode)
 WR_FUNC;
 
 WR_INLINE void
 wr_dp_push_radial_gradient(WrState* wrState, WrRect bounds, WrClipRegion clip,