Implement create_gradient_stops()

This commit is contained in:
pylbrecht 2019-08-29 14:17:03 +02:00
parent 89b8bd516f
commit 7c81d20869
2 changed files with 16 additions and 4 deletions

View file

@ -302,14 +302,14 @@ pub enum GradientStop {
#[cfg(feature = "canvas2d-azure")]
Azure(azure::AzGradientStop),
#[cfg(feature = "canvas2d-raqote")]
Raqote(()),
Raqote(raqote::GradientStop),
}
pub enum GradientStops {
#[cfg(feature = "canvas2d-azure")]
Azure(azure::azure_hl::GradientStops),
#[cfg(feature = "canvas2d-raqote")]
Raqote(()),
Raqote(Vec<raqote::GradientStop>),
}
#[derive(Clone)]

View file

@ -246,10 +246,14 @@ impl GenericDrawTarget for raqote::DrawTarget {
}
fn create_gradient_stops(
&self,
_gradient_stops: Vec<GradientStop>,
gradient_stops: Vec<GradientStop>,
_extend_mode: ExtendMode,
) -> GradientStops {
unimplemented!();
let stops = gradient_stops
.into_iter()
.map(|item| item.as_raqote().clone())
.collect();
GradientStops::Raqote(stops)
}
fn create_path_builder(&self) -> Box<dyn GenericPathBuilder> {
Box::new(PathBuilder::new())
@ -679,3 +683,11 @@ impl SourceSurface {
}
}
}
impl GradientStop {
fn as_raqote(&self) -> &raqote::GradientStop {
match self {
GradientStop::Raqote(s) => s,
}
}
}