Bug 1337715 - Part1. Add WrBorderRadius for WebRenderBorderLayer. r=kats
authorEthan Lin <ethlin@mozilla.com>
Thu, 09 Feb 2017 16:49:37 +0800
changeset 342212 a15741e122680fad6fafe360a7f08ea0b0128ea6
parent 342211 193461498ba3421dae805cb1c0c774b9712b7677
child 342213 6acfa0db546d0181f5a2f073b753f648d47614ed
push id31345
push userkwierso@gmail.com
push dateFri, 10 Feb 2017 20:35:09 +0000
treeherdermozilla-central@a288fe35e494 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1337715
milestone54.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 1337715 - Part1. Add WrBorderRadius for WebRenderBorderLayer. r=kats
gfx/layers/ipc/WebRenderMessages.ipdlh
gfx/layers/wr/WebRenderBorderLayer.cpp
gfx/layers/wr/WebRenderBridgeParent.cpp
gfx/layers/wr/WebRenderMessageUtils.h
gfx/webrender_bindings/WebRenderAPI.cpp
gfx/webrender_bindings/WebRenderAPI.h
gfx/webrender_bindings/WebRenderTypes.h
gfx/webrender_bindings/src/bindings.rs
gfx/webrender_bindings/webrender_ffi.h
--- a/gfx/layers/ipc/WebRenderMessages.ipdlh
+++ b/gfx/layers/ipc/WebRenderMessages.ipdlh
@@ -4,16 +4,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 include LayersSurfaces;
 include LayersMessages;
 include protocol PTexture;
 
+using WrBorderRadius from "mozilla/webrender/webrender_ffi.h";
 using WrBorderSide from "mozilla/webrender/webrender_ffi.h";
 using WrImageKey from "mozilla/webrender/webrender_ffi.h";
 using WrTextureFilter from "mozilla/webrender/webrender_ffi.h";
 using WrLayoutSize from "mozilla/webrender/webrender_ffi.h";
 using WrRect from "mozilla/webrender/webrender_ffi.h";
 using WrGlyphArray from "mozilla/webrender/webrender_ffi.h";
 using WrMixBlendMode from "mozilla/webrender/webrender_ffi.h";
 using MaybeImageMask from "mozilla/webrender/WebRenderTypes.h";
@@ -49,20 +50,17 @@ struct OpDPPushRect {
 
 struct OpDPPushBorder {
   WrRect bounds;
   WrRect clip;
   WrBorderSide top;
   WrBorderSide right;
   WrBorderSide bottom;
   WrBorderSide left;
-  WrLayoutSize top_left_radius;
-  WrLayoutSize top_right_radius;
-  WrLayoutSize bottom_left_radius;
-  WrLayoutSize bottom_right_radius;
+  WrBorderRadius radius;
 };
 
 struct OpDPPushImage {
   WrRect bounds;
   WrRect clip;
   MaybeImageMask mask;
   WrTextureFilter filter;
   WrImageKey key;
--- a/gfx/layers/wr/WebRenderBorderLayer.cpp
+++ b/gfx/layers/wr/WebRenderBorderLayer.cpp
@@ -53,17 +53,14 @@ WebRenderBorderLayer::RenderLayer()
                               WrMixBlendMode::Normal,
                               FrameMetrics::NULL_SCROLL_ID));
   WrBridge()->AddWebRenderCommand(
     OpDPPushBorder(wr::ToWrRect(rect), wr::ToWrRect(clip),
                    wr::ToWrBorderSide(mWidths[0], mColors[0]),
                    wr::ToWrBorderSide(mWidths[1], mColors[1]),
                    wr::ToWrBorderSide(mWidths[2], mColors[2]),
                    wr::ToWrBorderSide(mWidths[3], mColors[3]),
-                   wr::ToWrLayoutSize(mCorners[0]),
-                   wr::ToWrLayoutSize(mCorners[1]),
-                   wr::ToWrLayoutSize(mCorners[3]),
-                   wr::ToWrLayoutSize(mCorners[2])));
+                   wr::ToWrBorderRadius(mCorners[0], mCorners[1], mCorners[3], mCorners[2])));
   WrBridge()->AddWebRenderCommand(OpDPPopStackingContext());
 }
 
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -323,18 +323,17 @@ WebRenderBridgeParent::ProcessWebrenderC
         builder.PushRect(op.bounds(), op.clip(),
                          gfx::Color(op.r(), op.g(), op.b(), op.a()));
         break;
       }
       case WebRenderCommand::TOpDPPushBorder: {
         const OpDPPushBorder& op = cmd.get_OpDPPushBorder();
         builder.PushBorder(op.bounds(), op.clip(),
                            op.top(), op.right(), op.bottom(), op.left(),
-                           op.top_left_radius(), op.top_right_radius(),
-                           op.bottom_left_radius(), op.bottom_right_radius());
+                           op.radius());
         break;
       }
       case WebRenderCommand::TOpDPPushImage: {
         const OpDPPushImage& op = cmd.get_OpDPPushImage();
         builder.PushImage(op.bounds(), op.clip(),
                           op.mask().ptrOr(nullptr), op.filter(), wr::ImageKey(op.key()));
         break;
       }
--- a/gfx/layers/wr/WebRenderMessageUtils.h
+++ b/gfx/layers/wr/WebRenderMessageUtils.h
@@ -217,16 +217,38 @@ struct ParamTraits<WrLayoutSize>
   Read(const Message* aMsg, PickleIterator* aIter, WrLayoutSize* aResult)
   {
     return ReadParam(aMsg, aIter, &aResult->width)
         && ReadParam(aMsg, aIter, &aResult->height);
   }
 };
 
 template<>
+struct ParamTraits<WrBorderRadius>
+{
+  static void
+  Write(Message* aMsg, const WrBorderRadius& aParam)
+  {
+    WriteParam(aMsg, aParam.top_left);
+    WriteParam(aMsg, aParam.top_right);
+    WriteParam(aMsg, aParam.bottom_left);
+    WriteParam(aMsg, aParam.bottom_right);
+  }
+
+  static bool
+  Read(const Message* aMsg, PickleIterator* aIter, WrBorderRadius* aResult)
+  {
+    return ReadParam(aMsg, aIter, &aResult->top_left)
+        && ReadParam(aMsg, aIter, &aResult->top_right)
+        && ReadParam(aMsg, aIter, &aResult->bottom_left)
+        && ReadParam(aMsg, aIter, &aResult->bottom_right);
+  }
+};
+
+template<>
 struct ParamTraits<WrRect>
 {
   static void
   Write(Message* aMsg, const WrRect& aParam)
   {
     WriteParam(aMsg, aParam.x);
     WriteParam(aMsg, aParam.y);
     WriteParam(aMsg, aParam.width);
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -385,25 +385,21 @@ DisplayListBuilder::PushIFrame(const WrR
 
 void
 DisplayListBuilder::PushBorder(const WrRect& aBounds,
                                const WrRect& aClip,
                                const WrBorderSide& aTop,
                                const WrBorderSide& aRight,
                                const WrBorderSide& aBottom,
                                const WrBorderSide& aLeft,
-                               const WrLayoutSize& aTopLeftRadius,
-                               const WrLayoutSize& aTopRightRadius,
-                               const WrLayoutSize& aBottomLeftRadius,
-                               const WrLayoutSize& aBottomRightRadius)
+                               const WrBorderRadius& aRadius)
 {
   wr_dp_push_border(mWrState, aBounds, aClip,
                     aTop, aRight, aBottom, aLeft,
-                    aTopLeftRadius, aTopRightRadius,
-                    aBottomLeftRadius, aBottomRightRadius);
+                    aRadius);
 }
 
 void
 DisplayListBuilder::PushText(const WrRect& aBounds,
                              const WrRect& aClip,
                              const gfx::Color& aColor,
                              wr::FontKey aFontKey,
                              Range<const WrGlyphInstance> aGlyphBuffer,
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -123,26 +123,23 @@ public:
                  const WrImageMask* aMask,
                  const WrTextureFilter aFilter,
                  wr::ImageKey aImage);
 
   void PushIFrame(const WrRect& aBounds,
                   const WrRect& aClip,
                   wr::PipelineId aPipeline);
 
-  void PushBorder(const WrRect& bounds,
-                  const WrRect& clip,
-                  const WrBorderSide& top,
-                  const WrBorderSide& right,
-                  const WrBorderSide& bottom,
-                  const WrBorderSide& left,
-                  const WrLayoutSize& top_left_radius,
-                  const WrLayoutSize& top_right_radius,
-                  const WrLayoutSize& bottom_left_radius,
-                  const WrLayoutSize& bottom_right_radius);
+  void PushBorder(const WrRect& aBounds,
+                  const WrRect& aClip,
+                  const WrBorderSide& aTop,
+                  const WrBorderSide& aRight,
+                  const WrBorderSide& aBbottom,
+                  const WrBorderSide& aLeft,
+                  const WrBorderRadius& aRadius);
 
   void PushText(const WrRect& aBounds,
                 const WrRect& aClip,
                 const gfx::Color& aColor,
                 wr::FontKey aFontKey,
                 Range<const WrGlyphInstance> aGlyphBuffer,
                 float aGlyphSize);
 
--- a/gfx/webrender_bindings/WebRenderTypes.h
+++ b/gfx/webrender_bindings/WebRenderTypes.h
@@ -90,16 +90,27 @@ static inline WrBorderSide ToWrBorderSid
 static inline WrLayoutSize ToWrLayoutSize(const LayerSize size)
 {
   WrLayoutSize ls;
   ls.width = size.width;
   ls.height = size.height;
   return ls;
 }
 
+static inline WrBorderRadius ToWrBorderRadius(const LayerSize& topLeft, const LayerSize& topRight,
+                                              const LayerSize& bottomLeft, const LayerSize& bottomRight)
+{
+  WrBorderRadius br;
+  br.top_left = ToWrLayoutSize(topLeft);
+  br.top_right = ToWrLayoutSize(topRight);
+  br.bottom_left = ToWrLayoutSize(bottomLeft);
+  br.bottom_right = ToWrLayoutSize(bottomRight);
+  return br;
+}
+
 template<class T>
 static inline WrRect ToWrRect(const gfx::RectTyped<T>& rect)
 {
   WrRect r;
   r.x = rect.x;
   r.y = rect.y;
   r.width = rect.width;
   r.height = rect.height;
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -753,32 +753,27 @@ pub extern fn wr_dp_push_rect(state: &mu
                                     rect.to_rect(),
                                     clip_region,
                                     ColorF::new(r, g, b, a));
 }
 
 #[no_mangle]
 pub extern fn wr_dp_push_border(state: &mut WrState, rect: WrRect, clip: WrRect,
                                 top: WrBorderSide, right: WrBorderSide, bottom: WrBorderSide, left: WrBorderSide,
-                                top_left_radius: WrLayoutSize, top_right_radius: WrLayoutSize,
-                                bottom_left_radius: WrLayoutSize, bottom_right_radius: WrLayoutSize) {
+                                radius: WrBorderRadius) {
     assert!( unsafe { is_in_compositor_thread() });
     let clip_region = state.frame_builder.dl_builder.new_clip_region(&clip.to_rect(), Vec::new(), None);
-    let radius = BorderRadius { top_left: top_left_radius.to_layout_size(),
-                                top_right: top_right_radius.to_layout_size(),
-                                bottom_left: bottom_left_radius.to_layout_size(),
-                                bottom_right: bottom_right_radius.to_layout_size() };
     state.frame_builder.dl_builder.push_border(
                                     rect.to_rect(),
                                     clip_region,
                                     left.to_border_side(),
                                     top.to_border_side(),
                                     right.to_border_side(),
                                     bottom.to_border_side(),
-                                    radius);
+                                    radius.to_border_radius());
 }
 
 #[no_mangle]
 pub extern fn wr_window_dp_push_iframe(window: &mut WrWindowState, state: &mut WrState, rect: WrRect, clip: WrRect, layers_id: u64) {
     assert!( unsafe { is_in_compositor_thread() });
 
     let clip_region = state.frame_builder.dl_builder.new_clip_region(&clip.to_rect(),
                                                                      Vec::new(),
@@ -816,16 +811,35 @@ impl WrColor
 {
     pub fn to_color(&self) -> ColorF
     {
         ColorF::new(self.r, self.g, self.b, self.a)
     }
 }
 
 #[repr(C)]
+pub struct WrBorderRadius {
+    pub top_left: WrLayoutSize,
+    pub top_right: WrLayoutSize,
+    pub bottom_left: WrLayoutSize,
+    pub bottom_right: WrLayoutSize,
+}
+
+impl WrBorderRadius
+{
+    pub fn to_border_radius(&self) -> BorderRadius
+    {
+        BorderRadius { top_left: self.top_left.to_layout_size(),
+                       top_right: self.top_right.to_layout_size(),
+                       bottom_left: self.bottom_left.to_layout_size(),
+                       bottom_right: self.bottom_right.to_layout_size() }
+    }
+}
+
+#[repr(C)]
 pub struct WrBorderSide
 {
     width: f32,
     color: WrColor,
     style: BorderStyle
 }
 
 impl WrBorderSide
--- a/gfx/webrender_bindings/webrender_ffi.h
+++ b/gfx/webrender_bindings/webrender_ffi.h
@@ -197,16 +197,29 @@ struct WrLayoutSize
   float height;
 
   bool operator==(const WrLayoutSize& aRhs) const
   {
     return width == aRhs.width && height == aRhs.height;
   }
 };
 
+struct WrBorderRadius {
+  WrLayoutSize top_left;
+  WrLayoutSize top_right;
+  WrLayoutSize bottom_left;
+  WrLayoutSize bottom_right;
+
+  bool operator==(const WrBorderRadius& aRhs) const
+  {
+    return top_left == aRhs.top_left && top_right == aRhs.top_right &&
+           bottom_left == aRhs.bottom_left && bottom_right == aRhs.bottom_right;
+  }
+};
+
 struct WrRect
 {
   float x;
   float y;
   float width;
   float height;
 
   bool operator==(const WrRect& aRhs) const
@@ -469,18 +482,17 @@ WR_INLINE void
 wr_dp_push_text(WrState* wrState, WrRect bounds, WrRect clip, WrColor color,
                 WrFontKey font_Key, const WrGlyphInstance* glyphs,
                 uint32_t glyph_count, float glyph_size)
 WR_FUNC;
 
 WR_INLINE void
 wr_dp_push_border(WrState* wrState, WrRect bounds, WrRect clip,
                   WrBorderSide top, WrBorderSide right, WrBorderSide bottom, WrBorderSide left,
-                  WrLayoutSize top_left_radius, WrLayoutSize top_right_radius,
-                  WrLayoutSize bottom_left_radius, WrLayoutSize bottom_right_radius)
+                  WrBorderRadius radius)
 WR_FUNC;
 
 WR_INLINE void
 wr_dp_push_image(WrState* wrState, WrRect bounds, WrRect clip,
                  const WrImageMask* mask, WrTextureFilter filter, WrImageKey key)
 WR_FUNC;
 
 // TODO: Remove.