diff --git a/gfx/webrender_bindings/WebRenderAPI.cpp b/gfx/webrender_bindings/WebRenderAPI.cpp index a494ef2319649..968f8fcbdbfda 100644 --- a/gfx/webrender_bindings/WebRenderAPI.cpp +++ b/gfx/webrender_bindings/WebRenderAPI.cpp @@ -667,8 +667,8 @@ DisplayListBuilder::PushLinearGradient(const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip, const wr::LayoutPoint& aStartPoint, const wr::LayoutPoint& aEndPoint, - const nsTArray& aStops, - wr::GradientExtendMode aExtendMode, + const nsTArray& aStops, + wr::ExtendMode aExtendMode, const wr::LayoutSize aTileSize, const wr::LayoutSize aTileSpacing) { @@ -685,8 +685,8 @@ DisplayListBuilder::PushRadialGradient(const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip, const wr::LayoutPoint& aCenter, const wr::LayoutSize& aRadius, - const nsTArray& aStops, - wr::GradientExtendMode aExtendMode, + const nsTArray& aStops, + wr::ExtendMode aExtendMode, const wr::LayoutSize aTileSize, const wr::LayoutSize aTileSpacing) { @@ -818,8 +818,8 @@ DisplayListBuilder::PushBorderGradient(const wr::LayoutRect& aBounds, const wr::WrBorderWidths& aWidths, const wr::LayoutPoint& aStartPoint, const wr::LayoutPoint& aEndPoint, - const nsTArray& aStops, - wr::GradientExtendMode aExtendMode, + const nsTArray& aStops, + wr::ExtendMode aExtendMode, const wr::SideOffsets2D_f32& aOutset) { wr_dp_push_border_gradient(mWrState, aBounds, aClip, @@ -834,8 +834,8 @@ DisplayListBuilder::PushBorderRadialGradient(const wr::LayoutRect& aBounds, const wr::WrBorderWidths& aWidths, const wr::LayoutPoint& aCenter, const wr::LayoutSize& aRadius, - const nsTArray& aStops, - wr::GradientExtendMode aExtendMode, + const nsTArray& aStops, + wr::ExtendMode aExtendMode, const wr::SideOffsets2D_f32& aOutset) { wr_dp_push_border_radial_gradient( diff --git a/gfx/webrender_bindings/WebRenderAPI.h b/gfx/webrender_bindings/WebRenderAPI.h index 6e0d1e5cda6ab..676d0e01c1840 100644 --- a/gfx/webrender_bindings/WebRenderAPI.h +++ b/gfx/webrender_bindings/WebRenderAPI.h @@ -181,8 +181,8 @@ class DisplayListBuilder { const wr::LayoutRect& aClip, const wr::LayoutPoint& aStartPoint, const wr::LayoutPoint& aEndPoint, - const nsTArray& aStops, - wr::GradientExtendMode aExtendMode, + const nsTArray& aStops, + wr::ExtendMode aExtendMode, const wr::LayoutSize aTileSize, const wr::LayoutSize aTileSpacing); @@ -190,8 +190,8 @@ class DisplayListBuilder { const wr::LayoutRect& aClip, const wr::LayoutPoint& aCenter, const wr::LayoutSize& aRadius, - const nsTArray& aStops, - wr::GradientExtendMode aExtendMode, + const nsTArray& aStops, + wr::ExtendMode aExtendMode, const wr::LayoutSize aTileSize, const wr::LayoutSize aTileSpacing); @@ -253,8 +253,8 @@ class DisplayListBuilder { const wr::WrBorderWidths& aWidths, const wr::LayoutPoint& aStartPoint, const wr::LayoutPoint& aEndPoint, - const nsTArray& aStops, - wr::GradientExtendMode aExtendMode, + const nsTArray& aStops, + wr::ExtendMode aExtendMode, const wr::SideOffsets2D_f32& aOutset); void PushBorderRadialGradient(const wr::LayoutRect& aBounds, @@ -262,8 +262,8 @@ class DisplayListBuilder { const wr::WrBorderWidths& aWidths, const wr::LayoutPoint& aCenter, const wr::LayoutSize& aRadius, - const nsTArray& aStops, - wr::GradientExtendMode aExtendMode, + const nsTArray& aStops, + wr::ExtendMode aExtendMode, const wr::SideOffsets2D_f32& aOutset); void PushText(const wr::LayoutRect& aBounds, diff --git a/gfx/webrender_bindings/WebRenderTypes.h b/gfx/webrender_bindings/WebRenderTypes.h index 28f030488b03d..4a9c6f62645b4 100644 --- a/gfx/webrender_bindings/WebRenderTypes.h +++ b/gfx/webrender_bindings/WebRenderTypes.h @@ -20,7 +20,6 @@ namespace mozilla { namespace wr { -typedef wr::WrGradientExtendMode GradientExtendMode; typedef wr::WrMixBlendMode MixBlendMode; typedef wr::WrImageRendering ImageRendering; typedef wr::WrImageFormat ImageFormat; diff --git a/gfx/webrender_bindings/src/bindings.rs b/gfx/webrender_bindings/src/bindings.rs index 4edf717c6f35d..e4c84301ebd61 100644 --- a/gfx/webrender_bindings/src/bindings.rs +++ b/gfx/webrender_bindings/src/bindings.rs @@ -141,37 +141,6 @@ impl MutByteSlice { } } -#[repr(u32)] -pub enum WrGradientExtendMode { - Clamp, - Repeat, -} - -impl Into for WrGradientExtendMode { - fn into(self) -> ExtendMode { - match self { - WrGradientExtendMode::Clamp => ExtendMode::Clamp, - WrGradientExtendMode::Repeat => ExtendMode::Repeat, - } - } -} - -#[repr(C)] -#[derive(Debug, Clone, Copy)] -pub struct WrGradientStop { - offset: f32, - color: ColorF, -} - -impl<'a> Into for &'a WrGradientStop { - fn into(self) -> GradientStop { - GradientStop { - offset: self.offset, - color: self.color.into(), - } - } -} - #[repr(C)] #[derive(Debug, Clone, Copy)] pub struct WrBorderSide { @@ -1381,14 +1350,14 @@ pub extern "C" fn wr_dp_push_border_gradient(state: &mut WrState, widths: WrBorderWidths, start_point: LayoutPoint, end_point: LayoutPoint, - stops: *const WrGradientStop, + stops: *const GradientStop, stops_count: usize, - extend_mode: WrGradientExtendMode, + extend_mode: ExtendMode, outset: SideOffsets2D) { assert!(unsafe { is_in_main_thread() }); let stops_slice = make_slice(stops, stops_count); - let stops_vector = stops_slice.iter().map(|x| x.into()).collect(); + let stops_vector = stops_slice.to_owned(); let border_details = BorderDetails::Gradient(GradientBorder { gradient: @@ -1415,14 +1384,14 @@ pub extern "C" fn wr_dp_push_border_radial_gradient(state: &mut WrState, widths: WrBorderWidths, center: LayoutPoint, radius: LayoutSize, - stops: *const WrGradientStop, + stops: *const GradientStop, stops_count: usize, - extend_mode: WrGradientExtendMode, + extend_mode: ExtendMode, outset: SideOffsets2D) { assert!(unsafe { is_in_main_thread() }); let stops_slice = make_slice(stops, stops_count); - let stops_vector = stops_slice.iter().map(|x| x.into()).collect(); + let stops_vector = stops_slice.to_owned(); let border_details = BorderDetails::RadialGradient(RadialGradientBorder { @@ -1449,15 +1418,15 @@ pub extern "C" fn wr_dp_push_linear_gradient(state: &mut WrState, clip: LayoutRect, start_point: LayoutPoint, end_point: LayoutPoint, - stops: *const WrGradientStop, + stops: *const GradientStop, stops_count: usize, - extend_mode: WrGradientExtendMode, + extend_mode: ExtendMode, tile_size: LayoutSize, tile_spacing: LayoutSize) { assert!(unsafe { is_in_main_thread() }); let stops_slice = make_slice(stops, stops_count); - let stops_vector = stops_slice.iter().map(|x| x.into()).collect(); + let stops_vector = stops_slice.to_owned(); let gradient = state.frame_builder .dl_builder @@ -1480,15 +1449,15 @@ pub extern "C" fn wr_dp_push_radial_gradient(state: &mut WrState, clip: LayoutRect, center: LayoutPoint, radius: LayoutSize, - stops: *const WrGradientStop, + stops: *const GradientStop, stops_count: usize, - extend_mode: WrGradientExtendMode, + extend_mode: ExtendMode, tile_size: LayoutSize, tile_spacing: LayoutSize) { assert!(unsafe { is_in_main_thread() }); let stops_slice = make_slice(stops, stops_count); - let stops_vector = stops_slice.iter().map(|x| x.into()).collect(); + let stops_vector = stops_slice.to_owned(); let gradient = state.frame_builder .dl_builder diff --git a/gfx/webrender_bindings/webrender_ffi_generated.h b/gfx/webrender_bindings/webrender_ffi_generated.h index a6ab104b76082..f66b34906f89d 100644 --- a/gfx/webrender_bindings/webrender_ffi_generated.h +++ b/gfx/webrender_bindings/webrender_ffi_generated.h @@ -2,7 +2,7 @@ * 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/. */ -/* Generated with cbindgen:0.1.16 */ +/* Generated with cbindgen:0.1.18 */ /* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen. * To generate this file: @@ -19,6 +19,13 @@ extern "C" { namespace mozilla { namespace wr { +enum class ExtendMode : uint32_t { + Clamp = 0, + Repeat = 1, + + Sentinel /* this must be last for serialization purposes. */ +}; + enum class WrBorderStyle : uint32_t { None = 0, Solid = 1, @@ -72,13 +79,6 @@ enum class WrFilterOpType : uint32_t { Sentinel /* this must be last for serialization purposes. */ }; -enum class WrGradientExtendMode : uint32_t { - Clamp = 0, - Repeat = 1, - - Sentinel /* this must be last for serialization purposes. */ -}; - enum class WrImageFormat : uint32_t { Invalid = 0, A8 = 1, @@ -423,23 +423,23 @@ struct LayoutPoint { } }; -struct WrGradientStop { +struct GradientStop { float offset; ColorF color; - bool operator==(const WrGradientStop& aOther) const { + bool operator==(const GradientStop& aOther) const { return offset == aOther.offset && color == aOther.color; } }; -struct SideOffsets2D_u32 { - uint32_t top; - uint32_t right; - uint32_t bottom; - uint32_t left; +struct SideOffsets2D_f32 { + float top; + float right; + float bottom; + float left; - bool operator==(const SideOffsets2D_u32& aOther) const { + bool operator==(const SideOffsets2D_f32& aOther) const { return top == aOther.top && right == aOther.right && bottom == aOther.bottom && @@ -447,13 +447,13 @@ struct SideOffsets2D_u32 { } }; -struct SideOffsets2D_f32 { - float top; - float right; - float bottom; - float left; +struct SideOffsets2D_u32 { + uint32_t top; + uint32_t right; + uint32_t bottom; + uint32_t left; - bool operator==(const SideOffsets2D_f32& aOther) const { + bool operator==(const SideOffsets2D_u32& aOther) const { return top == aOther.top && right == aOther.right && bottom == aOther.bottom && @@ -756,9 +756,9 @@ void wr_dp_push_border_gradient(WrState *aState, WrBorderWidths aWidths, LayoutPoint aStartPoint, LayoutPoint aEndPoint, - const WrGradientStop *aStops, + const GradientStop *aStops, size_t aStopsCount, - WrGradientExtendMode aExtendMode, + ExtendMode aExtendMode, SideOffsets2D_f32 aOutset) WR_FUNC; @@ -781,9 +781,9 @@ void wr_dp_push_border_radial_gradient(WrState *aState, WrBorderWidths aWidths, LayoutPoint aCenter, LayoutSize aRadius, - const WrGradientStop *aStops, + const GradientStop *aStops, size_t aStopsCount, - WrGradientExtendMode aExtendMode, + ExtendMode aExtendMode, SideOffsets2D_f32 aOutset) WR_FUNC; @@ -842,9 +842,9 @@ void wr_dp_push_linear_gradient(WrState *aState, LayoutRect aClip, LayoutPoint aStartPoint, LayoutPoint aEndPoint, - const WrGradientStop *aStops, + const GradientStop *aStops, size_t aStopsCount, - WrGradientExtendMode aExtendMode, + ExtendMode aExtendMode, LayoutSize aTileSize, LayoutSize aTileSpacing) WR_FUNC; @@ -855,9 +855,9 @@ void wr_dp_push_radial_gradient(WrState *aState, LayoutRect aClip, LayoutPoint aCenter, LayoutSize aRadius, - const WrGradientStop *aStops, + const GradientStop *aStops, size_t aStopsCount, - WrGradientExtendMode aExtendMode, + ExtendMode aExtendMode, LayoutSize aTileSize, LayoutSize aTileSpacing) WR_FUNC; diff --git a/layout/painting/nsCSSRenderingGradients.cpp b/layout/painting/nsCSSRenderingGradients.cpp index b3b22560e613d..9a3001cb6cf02 100644 --- a/layout/painting/nsCSSRenderingGradients.cpp +++ b/layout/painting/nsCSSRenderingGradients.cpp @@ -1001,13 +1001,13 @@ nsCSSGradientRenderer::Paint(gfxContext& aContext, void nsCSSGradientRenderer::BuildWebRenderParameters(float aOpacity, - wr::WrGradientExtendMode& aMode, - nsTArray& aStops, + wr::ExtendMode& aMode, + nsTArray& aStops, LayoutDevicePoint& aLineStart, LayoutDevicePoint& aLineEnd, LayoutDeviceSize& aGradientRadius) { - aMode = mGradient->mRepeating ? wr::WrGradientExtendMode::Repeat : wr::WrGradientExtendMode::Clamp; + aMode = mGradient->mRepeating ? wr::ExtendMode::Repeat : wr::ExtendMode::Clamp; aStops.SetLength(mStops.Length()); for(uint32_t i = 0; i < mStops.Length(); i++) { @@ -1037,8 +1037,8 @@ nsCSSGradientRenderer::BuildWebRenderDisplayItems(wr::DisplayListBuilder& aBuild return; } - wr::WrGradientExtendMode extendMode; - nsTArray stops; + wr::ExtendMode extendMode; + nsTArray stops; LayoutDevicePoint lineStart; LayoutDevicePoint lineEnd; LayoutDeviceSize gradientRadius; diff --git a/layout/painting/nsCSSRenderingGradients.h b/layout/painting/nsCSSRenderingGradients.h index b59dd08382cf1..ac70f4a118895 100644 --- a/layout/painting/nsCSSRenderingGradients.h +++ b/layout/painting/nsCSSRenderingGradients.h @@ -65,8 +65,8 @@ class nsCSSGradientRenderer final { * Collect the gradient parameters */ void BuildWebRenderParameters(float aOpacity, - wr::WrGradientExtendMode& aMode, - nsTArray& aStops, + wr::ExtendMode& aMode, + nsTArray& aStops, LayoutDevicePoint& aLineStart, LayoutDevicePoint& aLineEnd, LayoutDeviceSize& aGradientRadius); diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index b9a4bd25ea553..943688cd56e40 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -5017,8 +5017,8 @@ nsDisplayBorder::CreateBorderImageWebRenderCommands(mozilla::wr::DisplayListBuil nsCSSGradientRenderer::Create(mFrame->PresContext(), gradientData, mBorderImageRenderer->mImageSize); - wr::WrGradientExtendMode extendMode; - nsTArray stops; + wr::ExtendMode extendMode; + nsTArray stops; LayoutDevicePoint lineStart; LayoutDevicePoint lineEnd; LayoutDeviceSize gradientRadius;