Always make sure we get a surface in CanvasData::put_image_data

This commit is contained in:
Anthony Ramine 2018-10-06 10:53:10 +02:00
parent 75e6f5dfaa
commit f13e35b2c5

View file

@ -458,18 +458,18 @@ impl<'a> CanvasData<'a> {
) { ) {
assert_eq!(imagedata_size.area() * 4, imagedata.len() as i32); assert_eq!(imagedata_size.area() * 4, imagedata.len() as i32);
pixels::byte_swap_and_premultiply_inplace(&mut imagedata); pixels::byte_swap_and_premultiply_inplace(&mut imagedata);
if let Some(source_surface) = self.drawtarget.create_source_surface_from_data( let source_surface = self.drawtarget.create_source_surface_from_data(
&imagedata, &imagedata,
imagedata_size, imagedata_size,
imagedata_size.width * 4, imagedata_size.width * 4,
SurfaceFormat::B8G8R8A8) { SurfaceFormat::B8G8R8A8,
).unwrap();
self.drawtarget.copy_surface( self.drawtarget.copy_surface(
source_surface, source_surface,
Rect::from_size(imagedata_size), Rect::from_size(imagedata_size),
offset.to_point(), offset.to_point(),
); );
} }
}
pub fn set_shadow_offset_x(&mut self, value: f64) { pub fn set_shadow_offset_x(&mut self, value: f64) {
self.state.shadow_offset_x = value; self.state.shadow_offset_x = value;