Skip to content

Commit

Permalink
Bug 1382128 part 5 - Remove WrGradientStop and WrGradientExtendMode. …
Browse files Browse the repository at this point in the history
…r=kats

MozReview-Commit-ID: 47Rb5jUpCFX
  • Loading branch information
eqrion committed Jul 19, 2017
1 parent b01f925 commit bdc8976
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 99 deletions.
16 changes: 8 additions & 8 deletions gfx/webrender_bindings/WebRenderAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,8 @@ 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)
{
Expand All @@ -685,8 +685,8 @@ 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)
{
Expand Down Expand Up @@ -818,8 +818,8 @@ DisplayListBuilder::PushBorderGradient(const wr::LayoutRect& aBounds,
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,
Expand All @@ -834,8 +834,8 @@ DisplayListBuilder::PushBorderRadialGradient(const wr::LayoutRect& aBounds,
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(
Expand Down
16 changes: 8 additions & 8 deletions gfx/webrender_bindings/WebRenderAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,17 @@ class DisplayListBuilder {
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);

Expand Down Expand Up @@ -253,17 +253,17 @@ class DisplayListBuilder {
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,
Expand Down
1 change: 0 additions & 1 deletion gfx/webrender_bindings/WebRenderTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
namespace mozilla {
namespace wr {

typedef wr::WrGradientExtendMode GradientExtendMode;
typedef wr::WrMixBlendMode MixBlendMode;
typedef wr::WrImageRendering ImageRendering;
typedef wr::WrImageFormat ImageFormat;
Expand Down
55 changes: 12 additions & 43 deletions gfx/webrender_bindings/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,37 +141,6 @@ impl MutByteSlice {
}
}

#[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 {
Expand Down Expand Up @@ -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<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:
Expand All @@ -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<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 {
Expand All @@ -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
Expand All @@ -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
Expand Down
60 changes: 30 additions & 30 deletions gfx/webrender_bindings/webrender_ffi_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -423,37 +423,37 @@ 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 &&
left == aOther.left;
}
};

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 &&
Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions layout/painting/nsCSSRenderingGradients.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1001,13 +1001,13 @@ nsCSSGradientRenderer::Paint(gfxContext& aContext,

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++) {
Expand Down Expand Up @@ -1037,8 +1037,8 @@ nsCSSGradientRenderer::BuildWebRenderDisplayItems(wr::DisplayListBuilder& aBuild
return;
}

wr::WrGradientExtendMode extendMode;
nsTArray<wr::WrGradientStop> stops;
wr::ExtendMode extendMode;
nsTArray<wr::GradientStop> stops;
LayoutDevicePoint lineStart;
LayoutDevicePoint lineEnd;
LayoutDeviceSize gradientRadius;
Expand Down
4 changes: 2 additions & 2 deletions layout/painting/nsCSSRenderingGradients.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class nsCSSGradientRenderer final {
* 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);
Expand Down
4 changes: 2 additions & 2 deletions layout/painting/nsDisplayList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5017,8 +5017,8 @@ nsDisplayBorder::CreateBorderImageWebRenderCommands(mozilla::wr::DisplayListBuil
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;
Expand Down

0 comments on commit bdc8976

Please sign in to comment.