Skip to content

Commit

Permalink
Remove some condition in CanvasData::write_image
Browse files Browse the repository at this point in the history
The surface creation should never fail.
  • Loading branch information
nox committed Oct 9, 2018
1 parent 6c469b9 commit 2bf4fcd
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions components/canvas/canvas_data.rs
Expand Up @@ -639,23 +639,23 @@ fn write_image(
} else {
Filter::Point
};
// azure_hl operates with integers. We need to cast the image size
let image_size = image_size.to_i32();

if let Some(source_surface) =
draw_target.create_source_surface_from_data(&image_data,
image_size,
image_size.width * 4,
SurfaceFormat::B8G8R8A8) {
let draw_surface_options = DrawSurfaceOptions::new(filter, true);
let draw_options = DrawOptions::new(global_alpha, composition_op, AntialiasMode::None);

draw_target.draw_surface(source_surface,
dest_rect.to_azure_style(),
image_rect.to_azure_style(),
draw_surface_options,
draw_options);
}
let source_surface = draw_target.create_source_surface_from_data(
&image_data,
image_size,
image_size.width * 4,
SurfaceFormat::B8G8R8A8,
).unwrap();
let draw_surface_options = DrawSurfaceOptions::new(filter, true);
let draw_options = DrawOptions::new(global_alpha, composition_op, AntialiasMode::None);
draw_target.draw_surface(
source_surface,
dest_rect.to_azure_style(),
image_rect.to_azure_style(),
draw_surface_options,
draw_options,
);
}

pub trait PointToi32 {
Expand Down

0 comments on commit 2bf4fcd

Please sign in to comment.