mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Remove Canvas2dMsg::DrawImageSelf
Now that all canvas share the same thread, it's useless to have a separate message for that.
This commit is contained in:
parent
9f7b746430
commit
36c8cd229e
4 changed files with 11 additions and 51 deletions
|
@ -85,21 +85,6 @@ impl<'a> CanvasData<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_image_self(
|
|
||||||
&self,
|
|
||||||
image_size: Size2D<f64>,
|
|
||||||
dest_rect: Rect<f64>,
|
|
||||||
source_rect: Rect<f64>,
|
|
||||||
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.to_i32(), image_size);
|
|
||||||
|
|
||||||
// The dimensions of image_data are source_rect.size
|
|
||||||
self.draw_image(image_data, source_rect.size, dest_rect, source_rect, smoothing_enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn save_context_state(&mut self) {
|
pub fn save_context_state(&mut self) {
|
||||||
self.saved_states.push(self.state.clone());
|
self.saved_states.push(self.state.clone());
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,19 +153,6 @@ impl<'a> CanvasPaintThread <'a> {
|
||||||
smoothing_enabled,
|
smoothing_enabled,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
Canvas2dMsg::DrawImageSelf(
|
|
||||||
image_size,
|
|
||||||
dest_rect,
|
|
||||||
source_rect,
|
|
||||||
smoothing_enabled
|
|
||||||
) => {
|
|
||||||
self.canvas(canvas_id).draw_image_self(
|
|
||||||
image_size,
|
|
||||||
dest_rect,
|
|
||||||
source_rect,
|
|
||||||
smoothing_enabled
|
|
||||||
)
|
|
||||||
},
|
|
||||||
Canvas2dMsg::DrawImageInOther(
|
Canvas2dMsg::DrawImageInOther(
|
||||||
other_canvas_id,
|
other_canvas_id,
|
||||||
image_size,
|
image_size,
|
||||||
|
@ -173,9 +160,10 @@ impl<'a> CanvasPaintThread <'a> {
|
||||||
source_rect,
|
source_rect,
|
||||||
smoothing
|
smoothing
|
||||||
) => {
|
) => {
|
||||||
let mut image_data = self.canvas(canvas_id).read_pixels(
|
let image_data = self.canvas(canvas_id).read_pixels(
|
||||||
source_rect.to_i32(),
|
source_rect.to_i32(),
|
||||||
image_size);
|
image_size,
|
||||||
|
);
|
||||||
self.canvas(other_canvas_id).draw_image(
|
self.canvas(other_canvas_id).draw_image(
|
||||||
image_data.into(),
|
image_data.into(),
|
||||||
source_rect.size,
|
source_rect.size,
|
||||||
|
|
|
@ -39,7 +39,6 @@ pub enum Canvas2dMsg {
|
||||||
Arc(Point2D<f32>, f32, f32, f32, bool),
|
Arc(Point2D<f32>, f32, f32, f32, bool),
|
||||||
ArcTo(Point2D<f32>, Point2D<f32>, f32),
|
ArcTo(Point2D<f32>, Point2D<f32>, f32),
|
||||||
DrawImage(Option<ByteBuf>, Size2D<f64>, Rect<f64>, Rect<f64>, bool),
|
DrawImage(Option<ByteBuf>, Size2D<f64>, Rect<f64>, Rect<f64>, bool),
|
||||||
DrawImageSelf(Size2D<f64>, Rect<f64>, Rect<f64>, bool),
|
|
||||||
DrawImageInOther(
|
DrawImageInOther(
|
||||||
CanvasId, Size2D<f64>, Rect<f64>, Rect<f64>, bool),
|
CanvasId, Size2D<f64>, Rect<f64>, Rect<f64>, bool),
|
||||||
BeginPath,
|
BeginPath,
|
||||||
|
|
|
@ -361,25 +361,13 @@ impl CanvasRenderingContext2D {
|
||||||
if let Some(context) = canvas.context() {
|
if let Some(context) = canvas.context() {
|
||||||
match *context {
|
match *context {
|
||||||
CanvasContext::Context2d(ref context) => {
|
CanvasContext::Context2d(ref context) => {
|
||||||
if self.canvas.as_ref().map_or(false, |c| &**c == canvas) {
|
context.send_canvas_2d_msg(Canvas2dMsg::DrawImageInOther(
|
||||||
self.send_canvas_2d_msg(Canvas2dMsg::DrawImageSelf(
|
self.get_canvas_id(),
|
||||||
image_size,
|
image_size,
|
||||||
dest_rect,
|
dest_rect,
|
||||||
source_rect,
|
source_rect,
|
||||||
smoothing_enabled,
|
smoothing_enabled,
|
||||||
));
|
));
|
||||||
} else {
|
|
||||||
context.get_ipc_renderer().send(CanvasMsg::Canvas2d(
|
|
||||||
Canvas2dMsg::DrawImageInOther(
|
|
||||||
self.get_canvas_id(),
|
|
||||||
image_size,
|
|
||||||
dest_rect,
|
|
||||||
source_rect,
|
|
||||||
smoothing_enabled,
|
|
||||||
),
|
|
||||||
context.get_canvas_id(),
|
|
||||||
)).unwrap();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
_ => return Err(Error::InvalidState),
|
_ => return Err(Error::InvalidState),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue