--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -662,36 +662,36 @@ DisplayListBuilder::PushRect(const wr::L
wr_dp_push_rect(mWrState, aBounds, aClip, aColor);
}
void
DisplayListBuilder::PushLinearGradient(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::LayoutPoint& aStartPoint,
const wr::LayoutPoint& aEndPoint,
- const nsTArray<wr::WrGradientStop>& aStops,
- wr::GradientExtendMode aExtendMode,
+ const nsTArray<wr::GradientStop>& aStops,
+ wr::ExtendMode aExtendMode,
const wr::LayoutSize aTileSize,
const wr::LayoutSize aTileSpacing)
{
wr_dp_push_linear_gradient(mWrState,
aBounds, aClip,
aStartPoint, aEndPoint,
aStops.Elements(), aStops.Length(),
aExtendMode,
aTileSize, aTileSpacing);
}
void
DisplayListBuilder::PushRadialGradient(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::LayoutPoint& aCenter,
const wr::LayoutSize& aRadius,
- const nsTArray<wr::WrGradientStop>& aStops,
- wr::GradientExtendMode aExtendMode,
+ const nsTArray<wr::GradientStop>& aStops,
+ wr::ExtendMode aExtendMode,
const wr::LayoutSize aTileSize,
const wr::LayoutSize aTileSpacing)
{
wr_dp_push_radial_gradient(mWrState,
aBounds, aClip,
aCenter, aRadius,
aStops.Elements(), aStops.Length(),
aExtendMode,
@@ -813,34 +813,34 @@ DisplayListBuilder::PushBorderImage(cons
}
void
DisplayListBuilder::PushBorderGradient(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::WrBorderWidths& aWidths,
const wr::LayoutPoint& aStartPoint,
const wr::LayoutPoint& aEndPoint,
- const nsTArray<wr::WrGradientStop>& aStops,
- wr::GradientExtendMode aExtendMode,
+ const nsTArray<wr::GradientStop>& aStops,
+ wr::ExtendMode aExtendMode,
const wr::SideOffsets2D_f32& aOutset)
{
wr_dp_push_border_gradient(mWrState, aBounds, aClip,
aWidths, aStartPoint, aEndPoint,
aStops.Elements(), aStops.Length(),
aExtendMode, aOutset);
}
void
DisplayListBuilder::PushBorderRadialGradient(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::WrBorderWidths& aWidths,
const wr::LayoutPoint& aCenter,
const wr::LayoutSize& aRadius,
- const nsTArray<wr::WrGradientStop>& aStops,
- wr::GradientExtendMode aExtendMode,
+ const nsTArray<wr::GradientStop>& aStops,
+ wr::ExtendMode aExtendMode,
const wr::SideOffsets2D_f32& aOutset)
{
wr_dp_push_border_radial_gradient(
mWrState, aBounds, aClip, aWidths, aCenter,
aRadius, aStops.Elements(), aStops.Length(),
aExtendMode, aOutset);
}
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -176,27 +176,27 @@ public:
void PushRect(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::ColorF& aColor);
void PushLinearGradient(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::LayoutPoint& aStartPoint,
const wr::LayoutPoint& aEndPoint,
- const nsTArray<wr::WrGradientStop>& aStops,
- wr::GradientExtendMode aExtendMode,
+ const nsTArray<wr::GradientStop>& aStops,
+ wr::ExtendMode aExtendMode,
const wr::LayoutSize aTileSize,
const wr::LayoutSize aTileSpacing);
void PushRadialGradient(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::LayoutPoint& aCenter,
const wr::LayoutSize& aRadius,
- const nsTArray<wr::WrGradientStop>& aStops,
- wr::GradientExtendMode aExtendMode,
+ const nsTArray<wr::GradientStop>& aStops,
+ wr::ExtendMode aExtendMode,
const wr::LayoutSize aTileSize,
const wr::LayoutSize aTileSpacing);
void PushImage(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageRendering aFilter,
wr::ImageKey aImage);
@@ -248,27 +248,27 @@ public:
const wr::WrRepeatMode& aRepeatHorizontal,
const wr::WrRepeatMode& aRepeatVertical);
void PushBorderGradient(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::WrBorderWidths& aWidths,
const wr::LayoutPoint& aStartPoint,
const wr::LayoutPoint& aEndPoint,
- const nsTArray<wr::WrGradientStop>& aStops,
- wr::GradientExtendMode aExtendMode,
+ const nsTArray<wr::GradientStop>& aStops,
+ wr::ExtendMode aExtendMode,
const wr::SideOffsets2D_f32& aOutset);
void PushBorderRadialGradient(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::WrBorderWidths& aWidths,
const wr::LayoutPoint& aCenter,
const wr::LayoutSize& aRadius,
- const nsTArray<wr::WrGradientStop>& aStops,
- wr::GradientExtendMode aExtendMode,
+ const nsTArray<wr::GradientStop>& aStops,
+ wr::ExtendMode aExtendMode,
const wr::SideOffsets2D_f32& aOutset);
void PushText(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const gfx::Color& aColor,
wr::FontKey aFontKey,
Range<const wr::GlyphInstance> aGlyphBuffer,
float aGlyphSize);
--- a/gfx/webrender_bindings/WebRenderTypes.h
+++ b/gfx/webrender_bindings/WebRenderTypes.h
@@ -15,17 +15,16 @@
#include "mozilla/Range.h"
#include "Units.h"
#include "RoundedRect.h"
#include "nsStyleConsts.h"
namespace mozilla {
namespace wr {
-typedef wr::WrGradientExtendMode GradientExtendMode;
typedef wr::WrMixBlendMode MixBlendMode;
typedef wr::WrImageRendering ImageRendering;
typedef wr::WrImageFormat ImageFormat;
typedef wr::WrWindowId WindowId;
typedef wr::WrPipelineId PipelineId;
typedef wr::WrImageKey ImageKey;
typedef wr::WrFontKey FontKey;
typedef wr::WrEpoch Epoch;
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -136,47 +136,16 @@ impl MutByteSlice {
}
}
pub fn as_mut_slice(&mut self) -> &mut [u8] {
make_slice_mut(self.buffer, self.len)
}
}
-#[repr(u32)]
-pub enum WrGradientExtendMode {
- Clamp,
- Repeat,
-}
-
-impl Into<ExtendMode> 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<GradientStop> for &'a WrGradientStop {
- fn into(self) -> GradientStop {
- GradientStop {
- offset: self.offset,
- color: self.color.into(),
- }
- }
-}
-
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct WrBorderSide {
color: ColorF,
style: WrBorderStyle,
}
impl Into<BorderSide> for WrBorderSide {
@@ -1376,24 +1345,24 @@ pub extern "C" fn wr_dp_push_border_imag
#[no_mangle]
pub extern "C" fn wr_dp_push_border_gradient(state: &mut WrState,
rect: LayoutRect,
clip: LayoutRect,
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<f32>) {
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:
state.frame_builder
.dl_builder
.create_gradient(start_point.into(),
end_point.into(),
stops_vector,
@@ -1410,24 +1379,24 @@ pub extern "C" fn wr_dp_push_border_grad
#[no_mangle]
pub extern "C" fn wr_dp_push_border_radial_gradient(state: &mut WrState,
rect: LayoutRect,
clip: LayoutRect,
widths: WrBorderWidths,
center: LayoutPoint,
radius: LayoutSize,
- stops: *const WrGradientStop,
+ stops: *const GradientStop,
stops_count: usize,
- extend_mode: WrGradientExtendMode,
+ extend_mode: ExtendMode,
outset: SideOffsets2D<f32>) {
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 {
gradient:
state.frame_builder
.dl_builder
.create_radial_gradient(center.into(),
radius.into(),
@@ -1444,25 +1413,25 @@ pub extern "C" fn wr_dp_push_border_radi
}
#[no_mangle]
pub extern "C" fn wr_dp_push_linear_gradient(state: &mut WrState,
rect: LayoutRect,
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
.create_gradient(start_point.into(),
end_point.into(),
stops_vector,
extend_mode.into());
state.frame_builder
@@ -1475,25 +1444,25 @@ pub extern "C" fn wr_dp_push_linear_grad
}
#[no_mangle]
pub extern "C" fn wr_dp_push_radial_gradient(state: &mut WrState,
rect: LayoutRect,
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
.create_radial_gradient(center.into(),
radius.into(),
stops_vector,
extend_mode.into());
state.frame_builder
--- a/gfx/webrender_bindings/webrender_ffi_generated.h
+++ b/gfx/webrender_bindings/webrender_ffi_generated.h
@@ -1,29 +1,36 @@
/* 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/. */
-/* 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:
* 1. Get the latest cbindgen using `cargo install --force cbindgen`
* a. Alternatively, you can clone `https://github.com/rlhunt/cbindgen` and use a tagged release
* 2. Run `cbindgen toolkit/library/rust/ --crate webrender_bindings -o gfx/webrender_bindings/webrender_ffi_generated.h`
*/
#include <cstdint>
#include <cstdlib>
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,
Double = 2,
Dotted = 3,
Dashed = 4,
Hidden = 5,
Groove = 6,
@@ -67,23 +74,16 @@ enum class WrFilterOpType : uint32_t {
Invert = 5,
Opacity = 6,
Saturate = 7,
Sepia = 8,
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,
RGB8 = 2,
BGRA8 = 3,
RGBAF32 = 4,
RG8 = 5,
@@ -418,54 +418,54 @@ struct LayoutPoint {
float y;
bool operator==(const LayoutPoint& aOther) const {
return x == aOther.x &&
y == aOther.y;
}
};
-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_f32 {
+ float top;
+ float right;
+ float bottom;
+ float left;
+
+ bool operator==(const SideOffsets2D_f32& aOther) const {
+ return top == aOther.top &&
+ right == aOther.right &&
+ bottom == aOther.bottom &&
+ left == aOther.left;
+ }
+};
+
struct SideOffsets2D_u32 {
uint32_t top;
uint32_t right;
uint32_t bottom;
uint32_t left;
bool operator==(const SideOffsets2D_u32& aOther) const {
return top == aOther.top &&
right == aOther.right &&
bottom == aOther.bottom &&
left == aOther.left;
}
};
-struct SideOffsets2D_f32 {
- float top;
- float right;
- float bottom;
- float left;
-
- bool operator==(const SideOffsets2D_f32& aOther) const {
- return top == aOther.top &&
- right == aOther.right &&
- bottom == aOther.bottom &&
- left == aOther.left;
- }
-};
-
struct WrNinePatchDescriptor {
uint32_t width;
uint32_t height;
SideOffsets2D_u32 slice;
bool operator==(const WrNinePatchDescriptor& aOther) const {
return width == aOther.width &&
height == aOther.height &&
@@ -751,19 +751,19 @@ WR_FUNC;
WR_INLINE
void wr_dp_push_border_gradient(WrState *aState,
LayoutRect aRect,
LayoutRect aClip,
WrBorderWidths aWidths,
LayoutPoint aStartPoint,
LayoutPoint aEndPoint,
- const WrGradientStop *aStops,
+ const GradientStop *aStops,
size_t aStopsCount,
- WrGradientExtendMode aExtendMode,
+ ExtendMode aExtendMode,
SideOffsets2D_f32 aOutset)
WR_FUNC;
WR_INLINE
void wr_dp_push_border_image(WrState *aState,
LayoutRect aRect,
LayoutRect aClip,
WrBorderWidths aWidths,
@@ -776,19 +776,19 @@ WR_FUNC;
WR_INLINE
void wr_dp_push_border_radial_gradient(WrState *aState,
LayoutRect aRect,
LayoutRect aClip,
WrBorderWidths aWidths,
LayoutPoint aCenter,
LayoutSize aRadius,
- const WrGradientStop *aStops,
+ const GradientStop *aStops,
size_t aStopsCount,
- WrGradientExtendMode aExtendMode,
+ ExtendMode aExtendMode,
SideOffsets2D_f32 aOutset)
WR_FUNC;
WR_INLINE
void wr_dp_push_box_shadow(WrState *aState,
LayoutRect aRect,
LayoutRect aClip,
LayoutRect aBoxBounds,
@@ -837,32 +837,32 @@ void wr_dp_push_image(WrState *aState,
WR_FUNC;
WR_INLINE
void wr_dp_push_linear_gradient(WrState *aState,
LayoutRect aRect,
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;
WR_INLINE
void wr_dp_push_radial_gradient(WrState *aState,
LayoutRect aRect,
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;
WR_INLINE
void wr_dp_push_rect(WrState *aState,
LayoutRect aRect,
LayoutRect aClip,
--- a/layout/painting/nsCSSRenderingGradients.cpp
+++ b/layout/painting/nsCSSRenderingGradients.cpp
@@ -996,23 +996,23 @@ nsCSSGradientRenderer::Paint(gfxContext&
aContext.Fill();
aContext.SetMatrix(ctm);
}
}
}
void
nsCSSGradientRenderer::BuildWebRenderParameters(float aOpacity,
- wr::WrGradientExtendMode& aMode,
- nsTArray<wr::WrGradientStop>& aStops,
+ wr::ExtendMode& aMode,
+ nsTArray<wr::GradientStop>& 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++) {
aStops[i].color.r = mStops[i].mColor.r;
aStops[i].color.g = mStops[i].mColor.g;
aStops[i].color.b = mStops[i].mColor.b;
aStops[i].color.a = mStops[i].mColor.a * aOpacity;
aStops[i].offset = mStops[i].mPosition;
@@ -1032,18 +1032,18 @@ nsCSSGradientRenderer::BuildWebRenderDis
const nsSize& aRepeatSize,
const CSSIntRect& aSrc,
float aOpacity)
{
if (aDest.IsEmpty() || aFillArea.IsEmpty()) {
return;
}
- wr::WrGradientExtendMode extendMode;
- nsTArray<wr::WrGradientStop> stops;
+ wr::ExtendMode extendMode;
+ nsTArray<wr::GradientStop> stops;
LayoutDevicePoint lineStart;
LayoutDevicePoint lineEnd;
LayoutDeviceSize gradientRadius;
BuildWebRenderParameters(aOpacity, extendMode, stops, lineStart, lineEnd, gradientRadius);
nscoord appUnitsPerDevPixel = mPresContext->AppUnitsPerDevPixel();
nsPoint firstTile = nsPoint(FindTileStart(aFillArea.x, aDest.x, aRepeatSize.width),
--- a/layout/painting/nsCSSRenderingGradients.h
+++ b/layout/painting/nsCSSRenderingGradients.h
@@ -60,18 +60,18 @@ public:
const mozilla::CSSIntRect& aSrc,
const nsRect& aDirtyRect,
float aOpacity = 1.0);
/**
* Collect the gradient parameters
*/
void BuildWebRenderParameters(float aOpacity,
- wr::WrGradientExtendMode& aMode,
- nsTArray<wr::WrGradientStop>& aStops,
+ wr::ExtendMode& aMode,
+ nsTArray<wr::GradientStop>& aStops,
LayoutDevicePoint& aLineStart,
LayoutDevicePoint& aLineEnd,
LayoutDeviceSize& aGradientRadius);
/**
* Build display items for the gradient
* aLayer - the layer to make this display item relative to
* aDest - where the first tile of gradient is
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -5012,18 +5012,18 @@ nsDisplayBorder::CreateBorderImageWebRen
}
case eStyleImageType_Gradient:
{
RefPtr<nsStyleGradient> gradientData = mBorderImageRenderer->mImageRenderer.GetGradientData();
nsCSSGradientRenderer renderer =
nsCSSGradientRenderer::Create(mFrame->PresContext(), gradientData,
mBorderImageRenderer->mImageSize);
- wr::WrGradientExtendMode extendMode;
- nsTArray<wr::WrGradientStop> stops;
+ wr::ExtendMode extendMode;
+ nsTArray<wr::GradientStop> stops;
LayoutDevicePoint lineStart;
LayoutDevicePoint lineEnd;
LayoutDeviceSize gradientRadius;
renderer.BuildWebRenderParameters(1.0, extendMode, stops, lineStart, lineEnd, gradientRadius);
if (gradientData->mShape == NS_STYLE_GRADIENT_SHAPE_LINEAR) {
LayerPoint startPoint = LayerPoint(dest.origin.x, dest.origin.y);
startPoint = startPoint + ViewAs<LayerPixel>(lineStart, PixelCastJustification::WebRenderHasUnitResolution);