Permalink
Browse files

Avoid a byte swap roundtrip

  • Loading branch information...
nox committed Sep 14, 2018
1 parent 93fbc15 commit fef04c65f6c7fd9d48b28752820f0b5b0c7df962
Showing with 3 additions and 6 deletions.
  1. +1 −3 components/canvas/canvas_data.rs
  2. +2 −3 components/canvas/canvas_paint_thread.rs
@@ -729,7 +729,7 @@ fn crop_image(
/// smoothing_enabled: It determines if smoothing is applied to the image result
fn write_image(
draw_target: &DrawTarget,
mut image_data: Vec<u8>,
image_data: Vec<u8>,
image_size: Size2D<f64>,
dest_rect: Rect<f64>,
smoothing_enabled: bool,
@@ -740,8 +740,6 @@ fn write_image(
return
}
let image_rect = Rect::new(Point2D::zero(), image_size);
// rgba -> bgra
byte_swap(&mut image_data);
// 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
@@ -132,12 +132,13 @@ impl<'a> CanvasPaintThread <'a> {
self.canvas(canvas_id).is_point_in_path(x, y, fill_rule, chan)
},
Canvas2dMsg::DrawImage(
imagedata,
mut imagedata,
image_size,
dest_rect,
source_rect,
smoothing_enabled,
) => {
byte_swap(&mut imagedata);
self.canvas(canvas_id).draw_image(
imagedata.into(),
image_size,
@@ -169,8 +170,6 @@ impl<'a> CanvasPaintThread <'a> {
let mut image_data = self.canvas(canvas_id).read_pixels(
source_rect.to_i32(),
image_size);
// TODO: avoid double byte_swap.
byte_swap(&mut image_data);
self.canvas(other_canvas_id).draw_image(
image_data.into(),
source_rect.size,

0 comments on commit fef04c6

Please sign in to comment.