mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Canvas: add clipping path support.
This commit is contained in:
parent
3a1bf45dea
commit
6fd6eefb35
29 changed files with 16 additions and 134 deletions
|
@ -212,6 +212,7 @@ impl<'a> CanvasPaintTask<'a> {
|
|||
Canvas2dMsg::ClosePath => painter.close_path(),
|
||||
Canvas2dMsg::Fill => painter.fill(),
|
||||
Canvas2dMsg::Stroke => painter.stroke(),
|
||||
Canvas2dMsg::Clip => painter.clip(),
|
||||
Canvas2dMsg::DrawImage(imagedata, image_size, dest_rect, source_rect, smoothing_enabled) => {
|
||||
painter.draw_image(imagedata, image_size, dest_rect, source_rect, smoothing_enabled)
|
||||
}
|
||||
|
@ -271,6 +272,7 @@ impl<'a> CanvasPaintTask<'a> {
|
|||
if let Some(state) = self.saved_states.pop() {
|
||||
mem::replace(&mut self.state, state);
|
||||
self.drawtarget.set_transform(&self.state.transform);
|
||||
self.drawtarget.pop_clip();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -325,6 +327,10 @@ impl<'a> CanvasPaintTask<'a> {
|
|||
};
|
||||
}
|
||||
|
||||
fn clip(&self) {
|
||||
self.drawtarget.push_clip(&self.path_builder.finish());
|
||||
}
|
||||
|
||||
fn draw_image(&self, image_data: Vec<u8>, image_size: Size2D<f64>,
|
||||
dest_rect: Rect<f64>, source_rect: Rect<f64>, smoothing_enabled: bool) {
|
||||
// We round up the floating pixel values to draw the pixels
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue