Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to gradients. #16666

Merged
merged 7 commits into from May 7, 2017

Implement radial gradients for borders.

The property border-image-outset is not yet implemented.
Note: Also support repeating-linear-gradients for borders.
  • Loading branch information
pyfisch committed Apr 30, 2017
commit b230be8aaf318fb754cf58e5cd243087df2f7e0f
@@ -976,12 +976,23 @@ pub struct GradientBorder {
pub outset: SideOffsets2D<f32>,
}

/// A border that is made of radial gradient
#[derive(Clone, HeapSizeOf, Deserialize, Serialize)]
pub struct RadialGradientBorder {
/// The gradient info that this border uses, border-image-source.
pub gradient: RadialGradient,

/// Outsets for the border, as per border-image-outset.
pub outset: SideOffsets2D<f32>,
}

/// Specifies the type of border
#[derive(Clone, HeapSizeOf, Deserialize, Serialize)]
pub enum BorderDetails {
Normal(NormalBorder),
Image(ImageBorder),
Gradient(GradientBorder),
RadialGradient(RadialGradientBorder),
}

/// Paints a border.
@@ -1334,8 +1334,24 @@ impl FragmentDisplayListBuilding for Fragment {
}),
}));
}
GradientKind::Radial(_, _) => {
// TODO(#16638): Handle border-image with radial gradient.
GradientKind::Radial(ref shape, ref center) => {
let grad = self.convert_radial_gradient(&bounds,
&gradient.items[..],
shape,
center,
gradient.repeating,
style);
state.add_display_item(DisplayItem::Border(box BorderDisplayItem {
base: base,
border_widths: border.to_physical(style.writing_mode),
details: BorderDetails::RadialGradient(
display_list::RadialGradientBorder {
gradient: grad,

// TODO(gw): Support border-image-outset
outset: SideOffsets2D::zero(),
}),
}));
}
}
}
@@ -352,15 +352,35 @@ impl WebRenderDisplayItemConverter for DisplayItem {
}
}
BorderDetails::Gradient(ref gradient) => {
let extend_mode = if gradient.gradient.repeating {
ExtendMode::Repeat
} else {
ExtendMode::Clamp
};
webrender_traits::BorderDetails::Gradient(webrender_traits::GradientBorder {
gradient: builder.create_gradient(
gradient.gradient.start_point.to_pointf(),
gradient.gradient.end_point.to_pointf(),
gradient.gradient.stops.clone(),
ExtendMode::Clamp),
extend_mode),
outset: gradient.outset,
})
}
BorderDetails::RadialGradient(ref gradient) => {
let extend_mode = if gradient.gradient.repeating {
ExtendMode::Repeat
} else {
ExtendMode::Clamp
};
webrender_traits::BorderDetails::RadialGradient(webrender_traits::RadialGradientBorder {
gradient: builder.create_radial_gradient(
gradient.gradient.center.to_pointf(),
gradient.gradient.radius.to_sizef(),
gradient.gradient.stops.clone(),
extend_mode),
outset: gradient.outset,
})
}
};

builder.push_border(rect, clip, widths, details);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.