From 48c24f84925affa51cc1729fe5230cb7548deda0 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Sat, 8 Aug 2015 04:50:55 -0400 Subject: [PATCH 1/5] Pass a Rect instead of an Option to PutImageData --- components/canvas/canvas_paint_task.rs | 13 ++----------- components/canvas_traits/lib.rs | 2 +- components/script/dom/canvasrenderingcontext2d.rs | 4 ++-- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/components/canvas/canvas_paint_task.rs b/components/canvas/canvas_paint_task.rs index c2921561c49..28a3a22b563 100644 --- a/components/canvas/canvas_paint_task.rs +++ b/components/canvas/canvas_paint_task.rs @@ -594,7 +594,7 @@ impl<'a> CanvasPaintTask<'a> { fn put_image_data(&mut self, mut imagedata: Vec, image_data_rect: Rect, - dirty_rect: Option>) { + dirty_rect: Rect) { if image_data_rect.size.width <= 0.0 || image_data_rect.size.height <= 0.0 { return @@ -604,18 +604,9 @@ impl<'a> CanvasPaintTask<'a> { // rgba -> bgra byte_swap(&mut imagedata); - let image_rect = Rect::new(Point2D::zero(), - Size2D::new(image_data_rect.size.width, image_data_rect.size.height)); - // Dirty rectangle defines the area of the source image to be copied // on the destination canvas - let source_rect = match dirty_rect { - Some(dirty_rect) => - self.calculate_dirty_rect(dirty_rect, image_data_rect), - // If no dirty area is provided we consider the whole source image - // as the area to be copied to the canvas - None => image_rect, - }; + let source_rect = self.calculate_dirty_rect(dirty_rect, image_data_rect); // 5) If either dirtyWidth or dirtyHeight is negative or zero, // stop without affecting any bitmaps diff --git a/components/canvas_traits/lib.rs b/components/canvas_traits/lib.rs index 48cabed045c..f7abcb49dee 100644 --- a/components/canvas_traits/lib.rs +++ b/components/canvas_traits/lib.rs @@ -91,7 +91,7 @@ pub enum Canvas2dMsg { GetImageData(Rect, Size2D, IpcSender>), LineTo(Point2D), MoveTo(Point2D), - PutImageData(Vec, Rect, Option>), + PutImageData(Vec, Rect, Rect), QuadraticCurveTo(Point2D, Point2D), Rect(Rect), RestoreContext, diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index c9f8da05bff..89ec6a66119 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -929,8 +929,8 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D { let image_data_rect = Rect::new(Point2D::new(*dx, *dy), Size2D::new(imagedata.Width() as f64, imagedata.Height() as f64)); - let dirty_rect = Some(Rect::new(Point2D::new(*dirtyX, *dirtyY), - Size2D::new(*dirtyWidth, *dirtyHeight))); + let dirty_rect = Rect::new(Point2D::new(*dirtyX, *dirtyY), + Size2D::new(*dirtyWidth, *dirtyHeight)); let msg = CanvasMsg::Canvas2d(Canvas2dMsg::PutImageData(data, image_data_rect, dirty_rect)); self.ipc_renderer.send(msg).unwrap(); self.mark_as_dirty(); From 7bcb911cea63715541c6103773e4630d85455351 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Sat, 8 Aug 2015 04:55:23 -0400 Subject: [PATCH 2/5] Inline dirty rect computation --- components/canvas/canvas_paint_task.rs | 104 +++++++++++-------------- 1 file changed, 46 insertions(+), 58 deletions(-) diff --git a/components/canvas/canvas_paint_task.rs b/components/canvas/canvas_paint_task.rs index 28a3a22b563..2a3646bbaef 100644 --- a/components/canvas/canvas_paint_task.rs +++ b/components/canvas/canvas_paint_task.rs @@ -56,55 +56,6 @@ impl<'a> CanvasPaintTask<'a> { image_data } - - /// dirty_rect: original dirty_rect provided by the putImageData call - /// image_data_rect: the area of the image to be copied - /// Result: It retuns the modified dirty_rect by the rules described in - /// the spec https://html.spec.whatwg.org/#dom-context-2d-putimagedata - fn calculate_dirty_rect(&self, - mut dirty_rect: Rect, - image_data_rect: Rect) -> Rect{ - // 1) If dirtyWidth is negative, - // let dirtyX be dirtyX+dirtyWidth, - // and let dirtyWidth be equal to the absolute magnitude of dirtyWidth. - if dirty_rect.size.width < 0.0f64 { - dirty_rect.origin.x = dirty_rect.origin.x + dirty_rect.size.width; - dirty_rect.size.width = -dirty_rect.size.width; - } - - // 2) If dirtyHeight is negative, let dirtyY be dirtyY+dirtyHeight, - // and let dirtyHeight be equal to the absolute magnitude of dirtyHeight. - if dirty_rect.size.height < 0.0f64 { - dirty_rect.origin.y = dirty_rect.origin.y + dirty_rect.size.height; - dirty_rect.size.height = -dirty_rect.size.height; - } - - // 3) If dirtyX is negative, let dirtyWidth be dirtyWidth+dirtyX, and let dirtyX be zero. - if dirty_rect.origin.x < 0.0f64 { - dirty_rect.size.width += dirty_rect.origin.x; - dirty_rect.origin.x = 0.0f64; - } - - // 3) If dirtyY is negative, let dirtyHeight be dirtyHeight+dirtyY, and let dirtyY be zero. - if dirty_rect.origin.y < 0.0f64 { - dirty_rect.size.height += dirty_rect.origin.y; - dirty_rect.origin.y = 0.0f64; - } - - // 4) If dirtyX+dirtyWidth is greater than the width attribute of the imagedata argument, - // let dirtyWidth be the value of that width attribute, minus the value of dirtyX. - if dirty_rect.origin.x + dirty_rect.size.width > image_data_rect.size.width { - dirty_rect.size.width = image_data_rect.size.width - dirty_rect.origin.x; - } - - // 4) If dirtyY+dirtyHeight is greater than the height attribute of the imagedata argument, - // let dirtyHeight be the value of that height attribute, minus the value of dirtyY. - if dirty_rect.origin.y + dirty_rect.size.height > image_data_rect.size.height { - dirty_rect.size.height = image_data_rect.size.height - dirty_rect.origin.y; - } - - dirty_rect - } } pub struct CanvasPaintTask<'a> { @@ -594,7 +545,8 @@ impl<'a> CanvasPaintTask<'a> { fn put_image_data(&mut self, mut imagedata: Vec, image_data_rect: Rect, - dirty_rect: Rect) { + mut dirty_rect: Rect) { + if image_data_rect.size.width <= 0.0 || image_data_rect.size.height <= 0.0 { return @@ -604,13 +556,49 @@ impl<'a> CanvasPaintTask<'a> { // rgba -> bgra byte_swap(&mut imagedata); - // Dirty rectangle defines the area of the source image to be copied - // on the destination canvas - let source_rect = self.calculate_dirty_rect(dirty_rect, image_data_rect); + // 1) If dirtyWidth is negative, + // let dirtyX be dirtyX+dirtyWidth, + // and let dirtyWidth be equal to the absolute magnitude of dirtyWidth. + if dirty_rect.size.width < 0.0f64 { + dirty_rect.origin.x = dirty_rect.origin.x + dirty_rect.size.width; + dirty_rect.size.width = -dirty_rect.size.width; + } + + // 2) If dirtyHeight is negative, let dirtyY be dirtyY+dirtyHeight, + // and let dirtyHeight be equal to the absolute magnitude of dirtyHeight. + if dirty_rect.size.height < 0.0f64 { + dirty_rect.origin.y = dirty_rect.origin.y + dirty_rect.size.height; + dirty_rect.size.height = -dirty_rect.size.height; + } + + // 3) If dirtyX is negative, let dirtyWidth be dirtyWidth+dirtyX, and let dirtyX be zero. + if dirty_rect.origin.x < 0.0f64 { + dirty_rect.size.width += dirty_rect.origin.x; + dirty_rect.origin.x = 0.0f64; + } + + // 3) If dirtyY is negative, let dirtyHeight be dirtyHeight+dirtyY, and let dirtyY be zero. + if dirty_rect.origin.y < 0.0f64 { + dirty_rect.size.height += dirty_rect.origin.y; + dirty_rect.origin.y = 0.0f64; + } + + // 4) If dirtyX+dirtyWidth is greater than the width attribute of the imagedata argument, + // let dirtyWidth be the value of that width attribute, minus the value of dirtyX. + if dirty_rect.origin.x + dirty_rect.size.width > image_data_rect.size.width { + dirty_rect.size.width = image_data_rect.size.width - dirty_rect.origin.x; + } + + // 4) If dirtyY+dirtyHeight is greater than the height attribute of the imagedata argument, + // let dirtyHeight be the value of that height attribute, minus the value of dirtyY. + if dirty_rect.origin.y + dirty_rect.size.height > image_data_rect.size.height { + dirty_rect.size.height = image_data_rect.size.height - dirty_rect.origin.y; + } + // 5) If either dirtyWidth or dirtyHeight is negative or zero, // stop without affecting any bitmaps - if source_rect.size.width <= 0.0 || source_rect.size.height <= 0.0 { + if dirty_rect.size.width <= 0.0 || dirty_rect.size.height <= 0.0 { return } @@ -621,11 +609,11 @@ impl<'a> CanvasPaintTask<'a> { // (dx+x, dy+y) in the rendering context's scratch bitmap. // It also clips the destination rectangle to the canvas area let dest_rect = Rect::new( - Point2D::new(image_data_rect.origin.x + source_rect.origin.x, - image_data_rect.origin.y + source_rect.origin.y), - Size2D::new(source_rect.size.width, source_rect.size.height)); + Point2D::new(image_data_rect.origin.x + dirty_rect.origin.x, + image_data_rect.origin.y + dirty_rect.origin.y), + Size2D::new(dirty_rect.size.width, dirty_rect.size.height)); - write_pixels(&self.drawtarget, &imagedata, image_data_rect.size, source_rect, + write_pixels(&self.drawtarget, &imagedata, image_data_rect.size, dirty_rect, dest_rect, true, self.state.draw_options.composition, self.state.draw_options.alpha) } From 9a88348978fb2a120f07eef669dd568fc0636704 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Sat, 8 Aug 2015 05:00:37 -0400 Subject: [PATCH 3/5] Clean up dirty rect computation --- components/canvas/canvas_paint_task.rs | 31 +++++++++++--------------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/components/canvas/canvas_paint_task.rs b/components/canvas/canvas_paint_task.rs index 2a3646bbaef..f5c2a05ed50 100644 --- a/components/canvas/canvas_paint_task.rs +++ b/components/canvas/canvas_paint_task.rs @@ -556,46 +556,41 @@ impl<'a> CanvasPaintTask<'a> { // rgba -> bgra byte_swap(&mut imagedata); - // 1) If dirtyWidth is negative, - // let dirtyX be dirtyX+dirtyWidth, - // and let dirtyWidth be equal to the absolute magnitude of dirtyWidth. + let image_data_size = image_data_rect.size; + + // Step 1. TODO (neutered data) + + // Step 2. if dirty_rect.size.width < 0.0f64 { - dirty_rect.origin.x = dirty_rect.origin.x + dirty_rect.size.width; + dirty_rect.origin.x += dirty_rect.size.width; dirty_rect.size.width = -dirty_rect.size.width; } - // 2) If dirtyHeight is negative, let dirtyY be dirtyY+dirtyHeight, - // and let dirtyHeight be equal to the absolute magnitude of dirtyHeight. if dirty_rect.size.height < 0.0f64 { - dirty_rect.origin.y = dirty_rect.origin.y + dirty_rect.size.height; + dirty_rect.origin.y += dirty_rect.size.height; dirty_rect.size.height = -dirty_rect.size.height; } - // 3) If dirtyX is negative, let dirtyWidth be dirtyWidth+dirtyX, and let dirtyX be zero. + // Step 3. if dirty_rect.origin.x < 0.0f64 { dirty_rect.size.width += dirty_rect.origin.x; dirty_rect.origin.x = 0.0f64; } - // 3) If dirtyY is negative, let dirtyHeight be dirtyHeight+dirtyY, and let dirtyY be zero. if dirty_rect.origin.y < 0.0f64 { dirty_rect.size.height += dirty_rect.origin.y; dirty_rect.origin.y = 0.0f64; } - // 4) If dirtyX+dirtyWidth is greater than the width attribute of the imagedata argument, - // let dirtyWidth be the value of that width attribute, minus the value of dirtyX. - if dirty_rect.origin.x + dirty_rect.size.width > image_data_rect.size.width { - dirty_rect.size.width = image_data_rect.size.width - dirty_rect.origin.x; + // Step 4. + if dirty_rect.max_x() > image_data_size.width { + dirty_rect.size.width = image_data_size.width - dirty_rect.origin.x; } - // 4) If dirtyY+dirtyHeight is greater than the height attribute of the imagedata argument, - // let dirtyHeight be the value of that height attribute, minus the value of dirtyY. - if dirty_rect.origin.y + dirty_rect.size.height > image_data_rect.size.height { - dirty_rect.size.height = image_data_rect.size.height - dirty_rect.origin.y; + if dirty_rect.max_y() > image_data_size.height { + dirty_rect.size.height = image_data_size.height - dirty_rect.origin.y; } - // 5) If either dirtyWidth or dirtyHeight is negative or zero, // stop without affecting any bitmaps if dirty_rect.size.width <= 0.0 || dirty_rect.size.height <= 0.0 { From 51938d579fa82cdb3fb5b564ccb97431dcd5b34b Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Sat, 8 Aug 2015 05:14:04 -0400 Subject: [PATCH 4/5] Switch PutImageData to using CopySurface --- components/canvas/canvas_paint_task.rs | 75 +++++++++++++------ components/canvas_traits/lib.rs | 2 +- .../script/dom/canvasrenderingcontext2d.rs | 9 ++- components/servo/Cargo.lock | 2 +- ports/cef/Cargo.lock | 2 +- ports/gonk/Cargo.lock | 2 +- .../2d.imageData.get.unaffected.html.ini | 5 -- .../2d.imageData.put.clip.html.ini | 5 -- .../2d.imageData.put.unaffected.html.ini | 5 -- 9 files changed, 61 insertions(+), 46 deletions(-) delete mode 100644 tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.get.unaffected.html.ini delete mode 100644 tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.put.clip.html.ini delete mode 100644 tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.put.unaffected.html.ini diff --git a/components/canvas/canvas_paint_task.rs b/components/canvas/canvas_paint_task.rs index f5c2a05ed50..bfa86a618be 100644 --- a/components/canvas/canvas_paint_task.rs +++ b/components/canvas/canvas_paint_task.rs @@ -172,8 +172,8 @@ impl<'a> CanvasPaintTask<'a> { Canvas2dMsg::SetGlobalComposition(op) => painter.set_global_composition(op), Canvas2dMsg::GetImageData(dest_rect, canvas_size, chan) => painter.get_image_data(dest_rect, canvas_size, chan), - Canvas2dMsg::PutImageData(imagedata, image_data_rect, dirty_rect) - => painter.put_image_data(imagedata, image_data_rect, dirty_rect), + Canvas2dMsg::PutImageData(imagedata, offset, image_data_size, dirty_rect) + => painter.put_image_data(imagedata, offset, image_data_size, dirty_rect), Canvas2dMsg::SetShadowOffsetX(value) => painter.set_shadow_offset_x(value), Canvas2dMsg::SetShadowOffsetY(value) => painter.set_shadow_offset_y(value), Canvas2dMsg::SetShadowBlur(value) => painter.set_shadow_blur(value), @@ -543,20 +543,17 @@ impl<'a> CanvasPaintTask<'a> { chan.send(dest_data).unwrap(); } - fn put_image_data(&mut self, mut imagedata: Vec, - image_data_rect: Rect, + // https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata + fn put_image_data(&mut self, imagedata: Vec, + offset: Point2D, + image_data_size: Size2D, mut dirty_rect: Rect) { - - if image_data_rect.size.width <= 0.0 || image_data_rect.size.height <= 0.0 { + if image_data_size.width <= 0.0 || image_data_size.height <= 0.0 { return } - assert!(image_data_rect.size.width * image_data_rect.size.height * 4.0 == imagedata.len() as f64); - // rgba -> bgra - byte_swap(&mut imagedata); - - let image_data_size = image_data_rect.size; + assert!(image_data_size.width * image_data_size.height * 4.0 == imagedata.len() as f64); // Step 1. TODO (neutered data) @@ -597,19 +594,40 @@ impl<'a> CanvasPaintTask<'a> { return } - // 6) For all integer values of x and y where dirtyX ≤ x < dirty - // X+dirtyWidth and dirtyY ≤ y < dirtyY+dirtyHeight, copy the - // four channels of the pixel with coordinate (x, y) in the imagedata - // data structure's Canvas Pixel ArrayBuffer to the pixel with coordinate - // (dx+x, dy+y) in the rendering context's scratch bitmap. - // It also clips the destination rectangle to the canvas area - let dest_rect = Rect::new( - Point2D::new(image_data_rect.origin.x + dirty_rect.origin.x, - image_data_rect.origin.y + dirty_rect.origin.y), - Size2D::new(dirty_rect.size.width, dirty_rect.size.height)); + // Step 6. + let dest_rect = dirty_rect.translate(&offset).to_i32(); - write_pixels(&self.drawtarget, &imagedata, image_data_rect.size, dirty_rect, - dest_rect, true, self.state.draw_options.composition, self.state.draw_options.alpha) + // azure_hl operates with integers. We need to cast the image size + let image_size = image_data_size.to_i32(); + + let first_pixel = dest_rect.origin - offset.to_i32(); + let mut src_line = (first_pixel.y * (image_size.width * 4) + first_pixel.x * 4) as usize; + + let mut dest = + Vec::with_capacity((dest_rect.size.width * dest_rect.size.height * 4) as usize); + + for _ in 0 .. dest_rect.size.height { + let mut src_offset = src_line; + for _ in 0 .. dest_rect.size.width { + // Premultiply alpha and swap RGBA -> BGRA. + // TODO: may want a precomputed premultiply table to make this fast. (#6969) + let alpha = imagedata[src_offset + 3] as f32 / 255.; + dest.push((imagedata[src_offset + 2] as f32 * alpha) as u8); + dest.push((imagedata[src_offset + 1] as f32 * alpha) as u8); + dest.push((imagedata[src_offset + 0] as f32 * alpha) as u8); + dest.push(imagedata[src_offset + 3]); + src_offset += 4; + } + src_line += (image_size.width * 4) as usize; + } + + let source_surface = self.drawtarget.create_source_surface_from_data( + &dest, + dest_rect.size, dest_rect.size.width * 4, SurfaceFormat::B8G8R8A8); + + self.drawtarget.copy_surface(source_surface, + Rect::new(Point2D::new(0, 0), dest_rect.size), + dest_rect.origin); } fn set_shadow_offset_x(&mut self, value: f64) { @@ -766,6 +784,17 @@ fn is_zero_size_gradient(pattern: &Pattern) -> bool { return false; } +pub trait PointToi32 { + fn to_i32(&self) -> Point2D; +} + +impl PointToi32 for Point2D { + fn to_i32(&self) -> Point2D { + Point2D::new(self.x.to_i32().unwrap(), + self.y.to_i32().unwrap()) + } +} + pub trait SizeToi32 { fn to_i32(&self) -> Size2D; } diff --git a/components/canvas_traits/lib.rs b/components/canvas_traits/lib.rs index f7abcb49dee..9d4ebc09ce5 100644 --- a/components/canvas_traits/lib.rs +++ b/components/canvas_traits/lib.rs @@ -91,7 +91,7 @@ pub enum Canvas2dMsg { GetImageData(Rect, Size2D, IpcSender>), LineTo(Point2D), MoveTo(Point2D), - PutImageData(Vec, Rect, Rect), + PutImageData(Vec, Point2D, Size2D, Rect), QuadraticCurveTo(Point2D, Point2D), Rect(Rect), RestoreContext, diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index 89ec6a66119..793dd144e75 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -926,12 +926,13 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D { fn PutImageData_(self, imagedata: &ImageData, dx: Finite, dy: Finite, dirtyX: Finite, dirtyY: Finite, dirtyWidth: Finite, dirtyHeight: Finite) { let data = imagedata.get_data_array(&self.global.root().r()); - let image_data_rect = Rect::new(Point2D::new(*dx, *dy), - Size2D::new(imagedata.Width() as f64, - imagedata.Height() as f64)); + let offset = Point2D::new(*dx, *dy); + let image_data_size = Size2D::new(imagedata.Width() as f64, + imagedata.Height() as f64); + let dirty_rect = Rect::new(Point2D::new(*dirtyX, *dirtyY), Size2D::new(*dirtyWidth, *dirtyHeight)); - let msg = CanvasMsg::Canvas2d(Canvas2dMsg::PutImageData(data, image_data_rect, dirty_rect)); + let msg = CanvasMsg::Canvas2d(Canvas2dMsg::PutImageData(data, offset, image_data_size, dirty_rect)); self.ipc_renderer.send(msg).unwrap(); self.mark_as_dirty(); } diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 6c02e2d8ae0..9a4f1cc6d38 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -64,7 +64,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "azure" version = "0.1.0" -source = "git+https://github.com/servo/rust-azure#a6d3af35eafe9a02af3fa58b1f1d30eb9cb57ccd" +source = "git+https://github.com/servo/rust-azure#53e7b7d07bd43199b136d869b1605016ed882cbc" dependencies = [ "core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "core-graphics 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 969f42caf1d..ac94e096b08 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -63,7 +63,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "azure" version = "0.1.0" -source = "git+https://github.com/servo/rust-azure#a6d3af35eafe9a02af3fa58b1f1d30eb9cb57ccd" +source = "git+https://github.com/servo/rust-azure#53e7b7d07bd43199b136d869b1605016ed882cbc" dependencies = [ "core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "core-graphics 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index f6842f46d33..20e7904b41d 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -50,7 +50,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "azure" version = "0.1.0" -source = "git+https://github.com/servo/rust-azure#a6d3af35eafe9a02af3fa58b1f1d30eb9cb57ccd" +source = "git+https://github.com/servo/rust-azure#53e7b7d07bd43199b136d869b1605016ed882cbc" dependencies = [ "core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "core-graphics 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.get.unaffected.html.ini b/tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.get.unaffected.html.ini deleted file mode 100644 index 957c4342e8e..00000000000 --- a/tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.get.unaffected.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.imageData.get.unaffected.html] - type: testharness - [getImageData() is not affected by context state] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.put.clip.html.ini b/tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.put.clip.html.ini deleted file mode 100644 index cd173c1349d..00000000000 --- a/tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.put.clip.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.imageData.put.clip.html] - type: testharness - [putImageData() is not affected by clipping regions] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.put.unaffected.html.ini b/tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.put.unaffected.html.ini deleted file mode 100644 index c94f03f47b6..00000000000 --- a/tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.put.unaffected.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.imageData.put.unaffected.html] - type: testharness - [putImageData() is not affected by context state] - expected: FAIL - From 05c78fbd48dc4bbcd9db38aafe5758f8c4ef7f30 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Sat, 8 Aug 2015 05:15:20 -0400 Subject: [PATCH 5/5] Inline write_pixels --- components/canvas/canvas_paint_task.rs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/components/canvas/canvas_paint_task.rs b/components/canvas/canvas_paint_task.rs index bfa86a618be..5719bf808db 100644 --- a/components/canvas/canvas_paint_task.rs +++ b/components/canvas/canvas_paint_task.rs @@ -732,23 +732,7 @@ fn write_image(draw_target: &DrawTarget, let image_rect = Rect::new(Point2D::zero(), image_size); // rgba -> bgra byte_swap(&mut image_data); - write_pixels(&draw_target, &image_data, image_size, image_rect, - dest_rect, smoothing_enabled, composition_op, global_alpha); -} -/// It writes image data to the target -/// draw_target: the destination target where the imagedata will be copied -/// source_rect: the area of the image data to be written -/// dest_rect: The area of the target where the imagedata will be copied -/// smoothing_enabled: if smoothing is applied to the copied pixels -fn write_pixels(draw_target: &DrawTarget, - image_data: &[u8], - image_size: Size2D, - source_rect: Rect, - dest_rect: Rect, - smoothing_enabled: bool, - composition_op: CompositionOp, - global_alpha: f32) { // From spec https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage // When scaling up, if the imageSmoothingEnabled attribute is set to true, the user agent should attempt // to apply a smoothing algorithm to the image data when it is scaled. @@ -770,7 +754,7 @@ fn write_pixels(draw_target: &DrawTarget, draw_target.draw_surface(source_surface, dest_rect.to_azfloat(), - source_rect.to_azfloat(), + image_rect.to_azfloat(), draw_surface_options, draw_options); }