From 168a52622133b01bd1e912d9f6135cbb1c5a52dd Mon Sep 17 00:00:00 2001 From: Bastien Orivel Date: Wed, 21 Aug 2019 19:07:50 +0200 Subject: [PATCH] Implement Source::Surface for FillOrStrokeStyle with raqote --- components/canvas/raqote_backend.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/components/canvas/raqote_backend.rs b/components/canvas/raqote_backend.rs index 4b789aac30ab..a3ae8eb67ead 100644 --- a/components/canvas/raqote_backend.rs +++ b/components/canvas/raqote_backend.rs @@ -554,6 +554,7 @@ pub trait ToRaqoteSource<'a> { } impl<'a> ToRaqoteSource<'a> for FillOrStrokeStyle { + #[allow(unsafe_code)] fn to_raqote_source(self) -> Option> { use canvas_traits::canvas::FillOrStrokeStyle::*; @@ -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(), + )) + }, } } }