mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Respect the source rectangle when drawing a canvas to another canvas.
This commit is contained in:
parent
a07c718895
commit
57440549d8
4 changed files with 61 additions and 8 deletions
|
@ -96,20 +96,20 @@ impl<'a> CanvasData<'a> {
|
|||
// In this case source and target are the same canvas
|
||||
let image_data = self.read_pixels(source_rect.to_i32(), image_size);
|
||||
|
||||
let writer = |draw_target: &DrawTarget| {
|
||||
write_image(draw_target, image_data, source_rect.size, dest_rect,
|
||||
smoothing_enabled, self.state.draw_options.composition,
|
||||
self.state.draw_options.alpha);
|
||||
};
|
||||
|
||||
if self.need_to_draw_shadow() {
|
||||
let rect = Rect::new(Point2D::new(dest_rect.origin.x as f32, dest_rect.origin.y as f32),
|
||||
Size2D::new(dest_rect.size.width as f32, dest_rect.size.height as f32));
|
||||
|
||||
self.draw_with_shadow(&rect, |new_draw_target: &DrawTarget| {
|
||||
write_image(&new_draw_target, image_data, source_rect.size, dest_rect,
|
||||
smoothing_enabled, self.state.draw_options.composition,
|
||||
self.state.draw_options.alpha);
|
||||
});
|
||||
self.draw_with_shadow(&rect, writer);
|
||||
} else {
|
||||
// Writes on target canvas
|
||||
write_image(&self.drawtarget, image_data, image_size, dest_rect,
|
||||
smoothing_enabled, self.state.draw_options.composition,
|
||||
self.state.draw_options.alpha);
|
||||
writer(&self.drawtarget);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue