mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Clean up ToAzurePattern for FillOrStrokeStyle
This commit is contained in:
parent
435d4d9f25
commit
426067069c
1 changed files with 21 additions and 18 deletions
|
@ -901,9 +901,9 @@ pub trait ToAzurePattern {
|
|||
|
||||
impl ToAzurePattern for FillOrStrokeStyle {
|
||||
fn to_azure_pattern(&self, drawtarget: &DrawTarget) -> Option<Pattern> {
|
||||
match *self {
|
||||
Some(match *self {
|
||||
FillOrStrokeStyle::Color(ref color) => {
|
||||
Some(Pattern::Color(ColorPattern::new(color.to_azure_style())))
|
||||
Pattern::Color(ColorPattern::new(color.to_azure_style()))
|
||||
},
|
||||
FillOrStrokeStyle::LinearGradient(ref linear_gradient_style) => {
|
||||
let gradient_stops: Vec<GradientStop> = linear_gradient_style.stops.iter().map(|s| {
|
||||
|
@ -913,11 +913,12 @@ impl ToAzurePattern for FillOrStrokeStyle {
|
|||
}
|
||||
}).collect();
|
||||
|
||||
Some(Pattern::LinearGradient(LinearGradientPattern::new(
|
||||
Pattern::LinearGradient(LinearGradientPattern::new(
|
||||
&Point2D::new(linear_gradient_style.x0 as AzFloat, linear_gradient_style.y0 as AzFloat),
|
||||
&Point2D::new(linear_gradient_style.x1 as AzFloat, linear_gradient_style.y1 as AzFloat),
|
||||
drawtarget.create_gradient_stops(&gradient_stops, ExtendMode::Clamp),
|
||||
&Transform2D::identity())))
|
||||
&Transform2D::identity(),
|
||||
))
|
||||
},
|
||||
FillOrStrokeStyle::RadialGradient(ref radial_gradient_style) => {
|
||||
let gradient_stops: Vec<GradientStop> = radial_gradient_style.stops.iter().map(|s| {
|
||||
|
@ -927,27 +928,29 @@ impl ToAzurePattern for FillOrStrokeStyle {
|
|||
}
|
||||
}).collect();
|
||||
|
||||
Some(Pattern::RadialGradient(RadialGradientPattern::new(
|
||||
Pattern::RadialGradient(RadialGradientPattern::new(
|
||||
&Point2D::new(radial_gradient_style.x0 as AzFloat, radial_gradient_style.y0 as AzFloat),
|
||||
&Point2D::new(radial_gradient_style.x1 as AzFloat, radial_gradient_style.y1 as AzFloat),
|
||||
radial_gradient_style.r0 as AzFloat, radial_gradient_style.r1 as AzFloat,
|
||||
drawtarget.create_gradient_stops(&gradient_stops, ExtendMode::Clamp),
|
||||
&Transform2D::identity())))
|
||||
&Transform2D::identity(),
|
||||
))
|
||||
},
|
||||
FillOrStrokeStyle::Surface(ref surface_style) => {
|
||||
drawtarget.create_source_surface_from_data(&surface_style.surface_data,
|
||||
surface_style.surface_size,
|
||||
surface_style.surface_size.width * 4,
|
||||
SurfaceFormat::B8G8R8A8)
|
||||
.map(|source_surface| {
|
||||
Pattern::Surface(SurfacePattern::new(
|
||||
source_surface.azure_source_surface,
|
||||
surface_style.repeat_x,
|
||||
surface_style.repeat_y,
|
||||
&Transform2D::identity()))
|
||||
})
|
||||
let source_surface = drawtarget.create_source_surface_from_data(
|
||||
&surface_style.surface_data,
|
||||
surface_style.surface_size,
|
||||
surface_style.surface_size.width * 4,
|
||||
SurfaceFormat::B8G8R8A8,
|
||||
)?;
|
||||
Pattern::Surface(SurfacePattern::new(
|
||||
source_surface.azure_source_surface,
|
||||
surface_style.repeat_x,
|
||||
surface_style.repeat_y,
|
||||
&Transform2D::identity(),
|
||||
))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue