Bug 1404955 - Use ComplexClipRegion instead of WrComplexClipRegion. r=kats
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Tue, 03 Oct 2017 17:51:49 -0400
changeset 384340 85d132562707592280ecc474ebbf82970503cd82
parent 384339 6669a57218a0181ec34680fe23caceb2d6e678e7
child 384341 e9cf1a5354ac88a80b32ff3276a7a71229d7db06
push id32626
push userarchaeopteryx@coole-files.de
push dateWed, 04 Oct 2017 09:14:11 +0000
treeherdermozilla-central@294f332a3553 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1404955
milestone58.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 1404955 - Use ComplexClipRegion instead of WrComplexClipRegion. r=kats cbindgen will let us do this now.
gfx/layers/wr/ScrollingLayersHelper.cpp
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_generated.h
layout/painting/DisplayItemClip.cpp
layout/painting/DisplayItemClip.h
--- a/gfx/layers/wr/ScrollingLayersHelper.cpp
+++ b/gfx/layers/wr/ScrollingLayersHelper.cpp
@@ -226,18 +226,18 @@ ScrollingLayersHelper::DefineAndPushChai
     // This item in the chain is a no-op, skip over it
     return;
   }
   if (!clipId || aBuilder.HasMaskClip()) {
     // If we don't have a clip id for this chain item yet, define the clip in WR
     // and save the id
     LayoutDeviceRect clip = LayoutDeviceRect::FromAppUnits(
         aChain->mClip.GetClipRect(), aAppUnitsPerDevPixel);
-    nsTArray<wr::WrComplexClipRegion> wrRoundedRects;
-    aChain->mClip.ToWrComplexClipRegions(aAppUnitsPerDevPixel, aStackingContext, wrRoundedRects);
+    nsTArray<wr::ComplexClipRegion> wrRoundedRects;
+    aChain->mClip.ToComplexClipRegions(aAppUnitsPerDevPixel, aStackingContext, wrRoundedRects);
     clipId = Some(aBuilder.DefineClip(aStackingContext.ToRelativeLayoutRect(clip), &wrRoundedRects));
     if (!aBuilder.HasMaskClip()) {
       aCache[aChain] = clipId.value();
     }
   }
   // Finally, push the clip onto the WR stack
   MOZ_ASSERT(clipId);
   aBuilder.PushClip(clipId.value());
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -678,17 +678,17 @@ void
 DisplayListBuilder::PopStackingContext()
 {
   WRDL_LOG("PopStackingContext\n", mWrState);
   wr_dp_pop_stacking_context(mWrState);
 }
 
 wr::WrClipId
 DisplayListBuilder::DefineClip(const wr::LayoutRect& aClipRect,
-                               const nsTArray<wr::WrComplexClipRegion>* aComplex,
+                               const nsTArray<wr::ComplexClipRegion>* aComplex,
                                const wr::WrImageMask* aMask)
 {
   uint64_t clip_id = wr_dp_define_clip(mWrState, aClipRect,
       aComplex ? aComplex->Elements() : nullptr,
       aComplex ? aComplex->Length() : 0,
       aMask);
   WRDL_LOG("DefineClip id=%" PRIu64 " r=%s m=%p b=%s complex=%zu\n", mWrState,
       clip_id, Stringify(aClipRect).c_str(), aMask,
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -217,17 +217,17 @@ public:
                            wr::TransformStyle aTransformStyle,
                            const gfx::Matrix4x4* aPerspective,
                            const wr::MixBlendMode& aMixBlendMode,
                            const nsTArray<wr::WrFilterOp>& aFilters,
                            bool aIsBackfaceVisible);
   void PopStackingContext();
 
   wr::WrClipId DefineClip(const wr::LayoutRect& aClipRect,
-                          const nsTArray<wr::WrComplexClipRegion>* aComplex = nullptr,
+                          const nsTArray<wr::ComplexClipRegion>* aComplex = nullptr,
                           const wr::WrImageMask* aMask = nullptr);
   void PushClip(const wr::WrClipId& aClipId, bool aMask = false);
   void PopClip(bool aMask = false);
 
   wr::WrStickyId DefineStickyFrame(const wr::LayoutRect& aContentRect,
                                    const wr::StickySideConstraint* aTop,
                                    const wr::StickySideConstraint* aRight,
                                    const wr::StickySideConstraint* aBottom,
--- a/gfx/webrender_bindings/WebRenderTypes.h
+++ b/gfx/webrender_bindings/WebRenderTypes.h
@@ -308,19 +308,19 @@ template<class T>
 static inline wr::LayoutSize ToLayoutSize(const gfx::SizeTyped<T>& size)
 {
   wr::LayoutSize ls;
   ls.width = size.width;
   ls.height = size.height;
   return ls;
 }
 
-static inline wr::WrComplexClipRegion ToWrComplexClipRegion(const RoundedRect& rect)
+static inline wr::ComplexClipRegion ToComplexClipRegion(const RoundedRect& rect)
 {
-  wr::WrComplexClipRegion ret;
+  wr::ComplexClipRegion ret;
   ret.rect               = ToLayoutRect(rect.rect);
   ret.radii.top_left     = ToLayoutSize(rect.corners.radii[mozilla::eCornerTopLeft]);
   ret.radii.top_right    = ToLayoutSize(rect.corners.radii[mozilla::eCornerTopRight]);
   ret.radii.bottom_left  = ToLayoutSize(rect.corners.radii[mozilla::eCornerBottomLeft]);
   ret.radii.bottom_right = ToLayoutSize(rect.corners.radii[mozilla::eCornerBottomRight]);
   return ret;
 }
 
@@ -490,30 +490,30 @@ static inline wr::WrTransformProperty To
 static inline wr::WrOpacityProperty ToWrOpacityProperty(uint64_t id, const float opacity)
 {
   wr::WrOpacityProperty prop;
   prop.id = id;
   prop.opacity = opacity;
   return prop;
 }
 
-static inline wr::WrComplexClipRegion ToWrComplexClipRegion(const wr::LayoutRect& rect,
-                                                            const mozilla::LayerSize& size)
+static inline wr::ComplexClipRegion ToComplexClipRegion(const wr::LayoutRect& rect,
+                                                        const mozilla::LayerSize& size)
 {
-  wr::WrComplexClipRegion complex_clip;
+  wr::ComplexClipRegion complex_clip;
   complex_clip.rect = rect;
   complex_clip.radii = wr::ToUniformBorderRadius(size);
   return complex_clip;
 }
 
 template<class T>
-static inline wr::WrComplexClipRegion ToWrComplexClipRegion(const gfx::RectTyped<T>& rect,
-                                                            const mozilla::LayerSize& size)
+static inline wr::ComplexClipRegion ToComplexClipRegion(const gfx::RectTyped<T>& rect,
+                                                        const mozilla::LayerSize& size)
 {
-  return ToWrComplexClipRegion(wr::ToLayoutRect(rect), size);
+  return ToComplexClipRegion(wr::ToLayoutRect(rect), size);
 }
 
 // Whenever possible, use wr::ExternalImageId instead of manipulating uint64_t.
 inline uint64_t AsUint64(const ExternalImageId& aId) {
   return static_cast<uint64_t>(aId.mHandle);
 }
 
 static inline ExternalImageId ToExternalImageId(uint64_t aID)
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -334,32 +334,16 @@ impl ExternalImageHandler for WrExternal
 
     fn unlock(&mut self,
               id: ExternalImageId,
               channel_index: u8) {
         (self.unlock_func)(self.external_image_obj, id.into(), channel_index);
     }
 }
 
-#[repr(C)]
-#[derive(Debug, Clone, Copy)]
-pub struct WrComplexClipRegion {
-    rect: LayoutRect,
-    radii: BorderRadius,
-}
-
-impl<'a> Into<ComplexClipRegion> for &'a WrComplexClipRegion {
-    fn into(self) -> ComplexClipRegion {
-        ComplexClipRegion {
-            rect: self.rect.into(),
-            radii: self.radii.into(),
-        }
-    }
-}
-
 #[repr(u32)]
 #[derive(Copy, Clone)]
 pub enum WrFilterOpType {
   Blur = 0,
   Brightness = 1,
   Contrast = 2,
   Grayscale = 3,
   HueRotate = 4,
@@ -1182,23 +1166,23 @@ pub extern "C" fn wr_dp_push_stacking_co
 pub extern "C" fn wr_dp_pop_stacking_context(state: &mut WrState) {
     debug_assert!(unsafe { !is_in_render_thread() });
     state.frame_builder.dl_builder.pop_stacking_context();
 }
 
 #[no_mangle]
 pub extern "C" fn wr_dp_define_clip(state: &mut WrState,
                                     clip_rect: LayoutRect,
-                                    complex: *const WrComplexClipRegion,
+                                    complex: *const ComplexClipRegion,
                                     complex_count: usize,
                                     mask: *const WrImageMask)
                                     -> u64 {
     debug_assert!(unsafe { is_in_main_thread() });
     let complex_slice = make_slice(complex, complex_count);
-    let complex_iter = complex_slice.iter().map(|x| x.into());
+    let complex_iter = complex_slice.iter().cloned();
     let mask : Option<ImageMask> = unsafe { mask.as_ref() }.map(|x| x.into());
 
     let clip_id = state.frame_builder.dl_builder.define_clip(None, clip_rect, complex_iter, mask);
     // return the u64 id value from inside the ClipId::Clip(..)
     match clip_id {
         ClipId::Clip(id, nesting_index, pipeline_id) => {
             assert!(pipeline_id == state.pipeline_id);
             assert!(nesting_index == 0);
--- a/gfx/webrender_bindings/webrender_ffi_generated.h
+++ b/gfx/webrender_bindings/webrender_ffi_generated.h
@@ -401,21 +401,23 @@ struct BorderRadius {
   bool operator==(const BorderRadius& aOther) const {
     return top_left == aOther.top_left &&
            top_right == aOther.top_right &&
            bottom_left == aOther.bottom_left &&
            bottom_right == aOther.bottom_right;
   }
 };
 
-struct WrComplexClipRegion {
+struct ComplexClipRegion {
+  // The boundaries of the rectangle.
   LayoutRect rect;
+  // Border radii of this rectangle.
   BorderRadius radii;
 
-  bool operator==(const WrComplexClipRegion& aOther) const {
+  bool operator==(const ComplexClipRegion& aOther) const {
     return rect == aOther.rect &&
            radii == aOther.radii;
   }
 };
 
 struct ImageKey {
   IdNamespace mNamespace;
   uint32_t mHandle;
@@ -848,17 +850,17 @@ WR_FUNC;
 
 WR_INLINE
 void wr_dec_ref_arc(const VecU8 *aArc)
 WR_FUNC;
 
 WR_INLINE
 uint64_t wr_dp_define_clip(WrState *aState,
                            LayoutRect aClipRect,
-                           const WrComplexClipRegion *aComplex,
+                           const ComplexClipRegion *aComplex,
                            size_t aComplexCount,
                            const WrImageMask *aMask)
 WR_FUNC;
 
 WR_INLINE
 void wr_dp_define_scroll_layer(WrState *aState,
                                uint64_t aScrollId,
                                LayoutRect aContentRect,
--- a/layout/painting/DisplayItemClip.cpp
+++ b/layout/painting/DisplayItemClip.cpp
@@ -471,22 +471,22 @@ DisplayItemClip::ToString() const
                        r.mRadii[0], r.mRadii[1], r.mRadii[2], r.mRadii[3],
                        r.mRadii[4], r.mRadii[5], r.mRadii[6], r.mRadii[7]);
     }
   }
   return str;
 }
 
 void
-DisplayItemClip::ToWrComplexClipRegions(int32_t aAppUnitsPerDevPixel,
-                                        const layers::StackingContextHelper& aSc,
-                                        nsTArray<wr::WrComplexClipRegion>& aOutArray) const
+DisplayItemClip::ToComplexClipRegions(int32_t aAppUnitsPerDevPixel,
+                                      const layers::StackingContextHelper& aSc,
+                                      nsTArray<wr::ComplexClipRegion>& aOutArray) const
 {
   for (uint32_t i = 0; i < mRoundedClipRects.Length(); i++) {
-    wr::WrComplexClipRegion* region = aOutArray.AppendElement();
+    wr::ComplexClipRegion* region = aOutArray.AppendElement();
     region->rect = aSc.ToRelativeLayoutRect(LayoutDeviceRect::FromAppUnits(
         mRoundedClipRects[i].mRect, aAppUnitsPerDevPixel));
     const nscoord* radii = mRoundedClipRects[i].mRadii;
     region->radii = wr::ToBorderRadius(
         LayoutDeviceSize::FromAppUnits(nsSize(radii[eCornerTopLeftX], radii[eCornerTopLeftY]), aAppUnitsPerDevPixel),
         LayoutDeviceSize::FromAppUnits(nsSize(radii[eCornerTopRightX], radii[eCornerTopRightY]), aAppUnitsPerDevPixel),
         LayoutDeviceSize::FromAppUnits(nsSize(radii[eCornerBottomLeftX], radii[eCornerBottomLeftY]), aAppUnitsPerDevPixel),
         LayoutDeviceSize::FromAppUnits(nsSize(radii[eCornerBottomRightX], radii[eCornerBottomRightY]), aAppUnitsPerDevPixel));
--- a/layout/painting/DisplayItemClip.h
+++ b/layout/painting/DisplayItemClip.h
@@ -19,17 +19,17 @@ namespace mozilla {
 namespace gfx {
 class DrawTarget;
 class Path;
 } // namespace gfx
 namespace layers {
 class StackingContextHelper;
 } // namespace layers
 namespace wr {
-struct WrComplexClipRegion;
+struct ComplexClipRegion;
 } // namepsace wr
 } // namespace mozilla
 
 namespace mozilla {
 
 /**
  * An DisplayItemClip represents the intersection of an optional rectangle
  * with a list of rounded rectangles (which is often empty), all in appunits.
@@ -175,19 +175,19 @@ public:
    * Find the largest N such that the first N rounded rects in 'this' are
    * equal to the first N rounded rects in aOther, and N <= aMax.
    */
   uint32_t GetCommonRoundedRectCount(const DisplayItemClip& aOther,
                                      uint32_t aMax) const;
   uint32_t GetRoundedRectCount() const { return mRoundedClipRects.Length(); }
   void AppendRoundedRects(nsTArray<RoundedRect>* aArray, uint32_t aCount) const;
 
-  void ToWrComplexClipRegions(int32_t aAppUnitsPerDevPixel,
+  void ToComplexClipRegions(int32_t aAppUnitsPerDevPixel,
                               const layers::StackingContextHelper& aSc,
-                              nsTArray<wr::WrComplexClipRegion>& aOutArray) const;
+                              nsTArray<wr::ComplexClipRegion>& aOutArray) const;
 
   static const DisplayItemClip& NoClip();
 
   static void Shutdown();
 
 private:
   nsRect mClipRect;
   nsTArray<RoundedRect> mRoundedClipRects;