diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-08-09 06:32:30 -0600 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-08-09 06:32:30 -0600 |
commit | dbce4c5bd8ec005ba78ac8c2f8754bd137c87f25 (patch) | |
tree | 2dfef259efc1a8b1f36e3835b6e07b6a23770a83 /components/canvas/canvas_paint_task.rs | |
parent | abf73995f9d0cc3fd000657fac90e2c426c132dc (diff) | |
parent | 2f47bdff4b9e2181426742231f2a45f340bf1ca1 (diff) | |
download | servo-dbce4c5bd8ec005ba78ac8c2f8754bd137c87f25.tar.gz servo-dbce4c5bd8ec005ba78ac8c2f8754bd137c87f25.zip |
Auto merge of #6975 - dzbarsky:get-tiny, r=jdm
Fix getImageData with sizes < 1 pixel
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6975)
<!-- Reviewable:end -->
Diffstat (limited to 'components/canvas/canvas_paint_task.rs')
-rw-r--r-- | components/canvas/canvas_paint_task.rs | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/components/canvas/canvas_paint_task.rs b/components/canvas/canvas_paint_task.rs index c2921561c49..cfaa55542b5 100644 --- a/components/canvas/canvas_paint_task.rs +++ b/components/canvas/canvas_paint_task.rs @@ -29,8 +29,7 @@ impl<'a> CanvasPaintTask<'a> { /// It reads image data from the canvas /// canvas_size: The size of the canvas we're reading from /// read_rect: The area of the canvas we want to read from - fn read_pixels(&self, read_rect: Rect<f64>, canvas_size: Size2D<f64>) -> Vec<u8>{ - let read_rect = read_rect.to_i32(); + fn read_pixels(&self, read_rect: Rect<i32>, canvas_size: Size2D<f64>) -> Vec<u8>{ let canvas_size = canvas_size.to_i32(); let canvas_rect = Rect::new(Point2D::new(0i32, 0i32), canvas_size); let src_read_rect = canvas_rect.intersection(&read_rect).unwrap_or(Rect::zero()); @@ -396,7 +395,7 @@ impl<'a> CanvasPaintTask<'a> { smoothing_enabled: bool) { // Reads pixels from source image // In this case source and target are the same canvas - let image_data = self.read_pixels(source_rect, image_size); + let image_data = self.read_pixels(source_rect.to_i32(), image_size); if self.need_to_draw_shadow() { let rect = Rect::new(Point2D::new(dest_rect.origin.x as f32, dest_rect.origin.y as f32), @@ -567,24 +566,9 @@ impl<'a> CanvasPaintTask<'a> { } fn get_image_data(&self, - mut dest_rect: Rect<f64>, + dest_rect: Rect<i32>, canvas_size: Size2D<f64>, chan: IpcSender<Vec<u8>>) { - if dest_rect.size.width < 0.0 { - dest_rect.size.width = -dest_rect.size.width; - dest_rect.origin.x -= dest_rect.size.width; - } - if dest_rect.size.height < 0.0 { - dest_rect.size.height = -dest_rect.size.height; - dest_rect.origin.y -= dest_rect.size.height; - } - if dest_rect.size.width == 0.0 { - dest_rect.size.width = 1.0; - } - if dest_rect.size.height == 0.0 { - dest_rect.size.height = 1.0; - } - let mut dest_data = self.read_pixels(dest_rect, canvas_size); // bgra -> rgba |