Bug 1532088. Use ImageMask directly instead of duplicating it as WrImageMask. r=kats
authorJeff Muizelaar <jrmuizel@gmail.com>
Sat, 02 Mar 2019 21:48:06 +0000
changeset 520044 922daa7856228500ecad60dfba4442f8f3707588
parent 520043 9d7e7f0bc3eb64db9db2e816b32f16ab3782cac5
child 520045 86e68f4e34fe93009b122cf92012b1d1efd32817
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1532088
milestone67.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 1532088. Use ImageMask directly instead of duplicating it as WrImageMask. r=kats WrImageMask is a relic from before we had good bindings generation. Differential Revision: https://phabricator.services.mozilla.com/D21845
gfx/layers/wr/WebRenderCommandBuilder.cpp
gfx/layers/wr/WebRenderCommandBuilder.h
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
layout/painting/nsDisplayList.cpp
--- a/gfx/layers/wr/WebRenderCommandBuilder.cpp
+++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp
@@ -2286,17 +2286,17 @@ class WebRenderMaskData : public WebRend
   std::vector<RefPtr<gfx::ScaledFont>> mFonts;
   std::vector<RefPtr<gfx::SourceSurface>> mExternalSurfaces;
   LayerIntRect mItemRect;
   nsPoint mMaskOffset;
   nsStyleImageLayers mMaskStyle;
   gfx::Size mScale;
 };
 
-Maybe<wr::WrImageMask> WebRenderCommandBuilder::BuildWrMaskImage(
+Maybe<wr::ImageMask> WebRenderCommandBuilder::BuildWrMaskImage(
     nsDisplayMasksAndClipPaths* aMaskItem, wr::DisplayListBuilder& aBuilder,
     wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc,
     nsDisplayListBuilder* aDisplayListBuilder,
     const LayoutDeviceRect& aBounds) {
   RefPtr<WebRenderMaskData> maskData =
       CreateOrRecycleWebRenderUserData<WebRenderMaskData>(aMaskItem);
 
   if (!maskData) {
@@ -2407,17 +2407,17 @@ Maybe<wr::WrImageMask> WebRenderCommandB
     if (paintFinished) {
       maskData->mItemRect = itemRect;
       maskData->mMaskOffset = maskOffset;
       maskData->mScale = scale;
       maskData->mMaskStyle = aMaskItem->Frame()->StyleSVGReset()->mMask;
     }
   }
 
-  wr::WrImageMask imageMask;
+  wr::ImageMask imageMask;
   imageMask.image = wr::AsImageKey(maskData->mBlobKey.value());
   imageMask.rect = wr::ToLayoutRect(imageRect);
   imageMask.repeat = false;
   return Some(imageMask);
 }
 
 bool WebRenderCommandBuilder::PushItemAsImage(
     nsDisplayItem* aItem, wr::DisplayListBuilder& aBuilder,
--- a/gfx/layers/wr/WebRenderCommandBuilder.h
+++ b/gfx/layers/wr/WebRenderCommandBuilder.h
@@ -75,17 +75,17 @@ class WebRenderCommandBuilder {
   }
 
   bool PushImage(nsDisplayItem* aItem, ImageContainer* aContainer,
                  mozilla::wr::DisplayListBuilder& aBuilder,
                  mozilla::wr::IpcResourceUpdateQueue& aResources,
                  const StackingContextHelper& aSc,
                  const LayoutDeviceRect& aRect, const LayoutDeviceRect& aClip);
 
-  Maybe<wr::WrImageMask> BuildWrMaskImage(
+  Maybe<wr::ImageMask> BuildWrMaskImage(
       nsDisplayMasksAndClipPaths* aMaskItem, wr::DisplayListBuilder& aBuilder,
       wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc,
       nsDisplayListBuilder* aDisplayListBuilder,
       const LayoutDeviceRect& aBounds);
 
   bool PushItemAsImage(nsDisplayItem* aItem, wr::DisplayListBuilder& aBuilder,
                        wr::IpcResourceUpdateQueue& aResources,
                        const StackingContextHelper& aSc,
--- a/gfx/layers/wr/WebRenderMessageUtils.h
+++ b/gfx/layers/wr/WebRenderMessageUtils.h
@@ -105,20 +105,16 @@ template <>
 struct ParamTraits<mozilla::wr::LayoutRect>
     : public PlainOldDataSerializer<mozilla::wr::LayoutRect> {};
 
 template <>
 struct ParamTraits<mozilla::wr::LayoutPoint>
     : public PlainOldDataSerializer<mozilla::wr::LayoutPoint> {};
 
 template <>
-struct ParamTraits<mozilla::wr::WrImageMask>
-    : public PlainOldDataSerializer<mozilla::wr::WrImageMask> {};
-
-template <>
 struct ParamTraits<mozilla::wr::ImageRendering>
     : public ContiguousEnumSerializer<mozilla::wr::ImageRendering,
                                       mozilla::wr::ImageRendering::Auto,
                                       mozilla::wr::ImageRendering::Sentinel> {};
 
 template <>
 struct ParamTraits<mozilla::wr::MixBlendMode>
     : public ContiguousEnumSerializer<mozilla::wr::MixBlendMode,
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -704,17 +704,17 @@ wr::WrClipChainId DisplayListBuilder::De
   WRDL_LOG("DefineClipChain id=%" PRIu64 " clips=%zu\n", mWrState, clipchainId,
            aClips.Length());
   return wr::WrClipChainId{clipchainId};
 }
 
 wr::WrClipId DisplayListBuilder::DefineClip(
     const Maybe<wr::WrSpaceAndClip>& aParent, const wr::LayoutRect& aClipRect,
     const nsTArray<wr::ComplexClipRegion>* aComplex,
-    const wr::WrImageMask* aMask) {
+    const wr::ImageMask* aMask) {
   WrClipId clipId;
   if (aParent) {
     clipId = wr_dp_define_clip_with_parent_clip(
         mWrState, aParent.ptr(), aClipRect,
         aComplex ? aComplex->Elements() : nullptr,
         aComplex ? aComplex->Length() : 0, aMask);
   } else {
     clipId = wr_dp_define_clip_with_parent_clip_chain(
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -369,17 +369,17 @@ class DisplayListBuilder {
       const wr::RasterSpace& aRasterSpace);
   void PopStackingContext(bool aIsReferenceFrame);
 
   wr::WrClipChainId DefineClipChain(const nsTArray<wr::WrClipId>& aClips);
 
   wr::WrClipId DefineClip(
       const Maybe<wr::WrSpaceAndClip>& aParent, const wr::LayoutRect& aClipRect,
       const nsTArray<wr::ComplexClipRegion>* aComplex = nullptr,
-      const wr::WrImageMask* aMask = nullptr);
+      const wr::ImageMask* aMask = nullptr);
 
   wr::WrSpatialId DefineStickyFrame(const wr::LayoutRect& aContentRect,
                                     const float* aTopMargin,
                                     const float* aRightMargin,
                                     const float* aBottomMargin,
                                     const float* aLeftMargin,
                                     const StickyOffsetBounds& aVerticalBounds,
                                     const StickyOffsetBounds& aHorizontalBounds,
--- a/gfx/webrender_bindings/WebRenderTypes.h
+++ b/gfx/webrender_bindings/WebRenderTypes.h
@@ -39,17 +39,17 @@ typedef wr::WrPipelineId PipelineId;
 typedef wr::WrImageKey ImageKey;
 typedef wr::WrFontKey FontKey;
 typedef wr::WrFontInstanceKey FontInstanceKey;
 typedef wr::WrEpoch Epoch;
 typedef wr::WrExternalImageId ExternalImageId;
 typedef wr::WrDebugFlags DebugFlags;
 
 typedef mozilla::Maybe<mozilla::wr::IdNamespace> MaybeIdNamespace;
-typedef mozilla::Maybe<mozilla::wr::WrImageMask> MaybeImageMask;
+typedef mozilla::Maybe<mozilla::wr::ImageMask> MaybeImageMask;
 typedef Maybe<ExternalImageId> MaybeExternalImageId;
 
 typedef Maybe<FontInstanceOptions> MaybeFontInstanceOptions;
 typedef Maybe<FontInstancePlatformOptions> MaybeFontInstancePlatformOptions;
 
 struct ExternalImageKeyPair {
   ImageKey key;
   ExternalImageId id;
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -344,52 +344,16 @@ impl MutByteSlice {
     }
 
     pub fn as_mut_slice(&mut self) -> &mut [u8] {
         make_slice_mut(self.buffer, self.len)
     }
 }
 
 #[repr(C)]
-#[derive(Debug, Clone, Copy)]
-pub struct WrImageMask {
-    image: WrImageKey,
-    rect: LayoutRect,
-    repeat: bool,
-}
-
-impl Into<ImageMask> for WrImageMask {
-    fn into(self) -> ImageMask {
-        ImageMask {
-            image: self.image,
-            rect: self.rect.into(),
-            repeat: self.repeat,
-        }
-    }
-}
-impl<'a> Into<ImageMask> for &'a WrImageMask {
-    fn into(self) -> ImageMask {
-        ImageMask {
-            image: self.image,
-            rect: self.rect.into(),
-            repeat: self.repeat,
-        }
-    }
-}
-impl From<ImageMask> for WrImageMask {
-    fn from(image_mask: ImageMask) -> Self {
-        WrImageMask {
-            image: image_mask.image,
-            rect: image_mask.rect.into(),
-            repeat: image_mask.repeat,
-        }
-    }
-}
-
-#[repr(C)]
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
 pub struct WrImageDescriptor {
     pub format: ImageFormat,
     pub width: i32,
     pub height: i32,
     pub stride: i32,
     pub opacity: OpacityType,
 }
@@ -2117,42 +2081,42 @@ pub extern "C" fn wr_dp_define_clipchain
 
 #[no_mangle]
 pub extern "C" fn wr_dp_define_clip_with_parent_clip(
     state: &mut WrState,
     parent: &WrSpaceAndClip,
     clip_rect: LayoutRect,
     complex: *const ComplexClipRegion,
     complex_count: usize,
-    mask: *const WrImageMask,
+    mask: *const ImageMask,
 ) -> WrClipId {
     wr_dp_define_clip_impl(
         &mut state.frame_builder,
         parent.to_webrender(state.pipeline_id),
         clip_rect,
         make_slice(complex, complex_count),
-        unsafe { mask.as_ref() }.map(|m| m.into()),
+        unsafe { mask.as_ref() }.map(|m| *m),
     )
 }
 
 #[no_mangle]
 pub extern "C" fn wr_dp_define_clip_with_parent_clip_chain(
     state: &mut WrState,
     parent: &WrSpaceAndClipChain,
     clip_rect: LayoutRect,
     complex: *const ComplexClipRegion,
     complex_count: usize,
-    mask: *const WrImageMask,
+    mask: *const ImageMask,
 ) -> WrClipId {
     wr_dp_define_clip_impl(
         &mut state.frame_builder,
         parent.to_webrender(state.pipeline_id),
         clip_rect,
         make_slice(complex, complex_count),
-        unsafe { mask.as_ref() }.map(|m| m.into()),
+        unsafe { mask.as_ref() }.map(|m| *m),
     )
 }
 
 fn wr_dp_define_clip_impl(
     frame_builder: &mut WebRenderFrameBuilder,
     parent: SpaceAndClipInfo,
     clip_rect: LayoutRect,
     complex_regions: &[ComplexClipRegion],
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -9183,17 +9183,17 @@ static Maybe<Pair<wr::WrClipId, HandleOp
     nsDisplayMasksAndClipPaths* aDisplayItem, const LayoutDeviceRect& aBounds,
     wr::IpcResourceUpdateQueue& aResources, wr::DisplayListBuilder& aBuilder,
     const StackingContextHelper& aSc, layers::RenderRootStateManager* aManager,
     nsDisplayListBuilder* aDisplayListBuilder) {
   if (auto clip = CreateSimpleClipRegion(*aDisplayItem, aBuilder)) {
     return Some(MakePair(*clip, HandleOpacity::Yes));
   }
 
-  Maybe<wr::WrImageMask> mask = aManager->CommandBuilder().BuildWrMaskImage(
+  Maybe<wr::ImageMask> mask = aManager->CommandBuilder().BuildWrMaskImage(
       aDisplayItem, aBuilder, aResources, aSc, aDisplayListBuilder, aBounds);
   if (!mask) {
     return Nothing();
   }
 
   wr::WrClipId clipId = aBuilder.DefineClip(
       Nothing(), wr::ToRoundedLayoutRect(aBounds), nullptr, mask.ptr());