Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement Source::Surface for FillOrStrokeStyle with raqote
  • Loading branch information
Eijebong committed Aug 21, 2019
1 parent 8a57876 commit 168a526
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion components/canvas/raqote_backend.rs
Expand Up @@ -554,6 +554,7 @@ pub trait ToRaqoteSource<'a> {
}

impl<'a> ToRaqoteSource<'a> for FillOrStrokeStyle {
#[allow(unsafe_code)]
fn to_raqote_source(self) -> Option<raqote::Source<'a>> {
use canvas_traits::canvas::FillOrStrokeStyle::*;

Expand All @@ -566,7 +567,19 @@ impl<'a> ToRaqoteSource<'a> for FillOrStrokeStyle {
})),
LinearGradient(_) => unimplemented!(),
RadialGradient(_) => unimplemented!(),
Surface(_) => unimplemented!(),
Surface(ref surface) => {
let data = &surface.surface_data[..];
Some(raqote::Source::Image(
raqote::Image {
data: unsafe { std::slice::from_raw_parts(data.as_ptr() as *const u32, data.len() / 4) },
width: surface.surface_size.width as i32,
height: surface.surface_size.height as i32,
},
raqote::ExtendMode::Repeat, // TODO: repeat-x, repeat-y ?
raqote::FilterMode::Bilinear,
raqote::Transform::identity(),
))
},
}
}
}
Expand Down

0 comments on commit 168a526

Please sign in to comment.