Skip to content

Commit

Permalink
Implement create_gradient_stops()
Browse files Browse the repository at this point in the history
  • Loading branch information
pylbrecht committed Aug 29, 2019
1 parent 89b8bd5 commit 7c81d20
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions components/canvas/canvas_data.rs
Expand Up @@ -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)]
Expand Down
16 changes: 14 additions & 2 deletions components/canvas/raqote_backend.rs
Expand Up @@ -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())
Expand Down Expand Up @@ -679,3 +683,11 @@ impl SourceSurface {
}
}
}

impl GradientStop {
fn as_raqote(&self) -> &raqote::GradientStop {
match self {
GradientStop::Raqote(s) => s,
}
}
}

0 comments on commit 7c81d20

Please sign in to comment.