auto merge of #5302 : mmatyas/servo/canvas_stroke, r=jdm

This is the servo side patch of servo/rust-azure#149.
This commit is contained in:
bors-servo 2015-03-25 07:54:50 -06:00
commit f29ea4e4ef
46 changed files with 23 additions and 208 deletions

View file

@ -26,6 +26,7 @@ pub enum CanvasMsg {
BeginPath,
ClosePath,
Fill,
Stroke,
DrawImage(Vec<u8>, Rect<i32>, Rect<i32>, bool),
DrawImageSelf(Size2D<i32>, Rect<i32>, Rect<i32>, bool),
MoveTo(Point2D<f32>),
@ -211,6 +212,7 @@ impl<'a> CanvasPaintTask<'a> {
CanvasMsg::BeginPath => painter.begin_path(),
CanvasMsg::ClosePath => painter.close_path(),
CanvasMsg::Fill => painter.fill(),
CanvasMsg::Stroke => painter.stroke(),
CanvasMsg::DrawImage(imagedata, dest_rect, source_rect, smoothing_enabled) => {
painter.draw_image(imagedata, dest_rect, source_rect, smoothing_enabled)
}
@ -284,6 +286,19 @@ impl<'a> CanvasPaintTask<'a> {
};
}
fn stroke(&self) {
let draw_options = DrawOptions::new(1.0, 0);
match self.stroke_style {
Pattern::Color(ref color) => {
self.drawtarget.stroke(&self.path_builder.finish(),
color, &self.stroke_opts, &draw_options);
}
_ => {
// TODO
}
};
}
fn draw_image(&self, imagedata: Vec<u8>, dest_rect: Rect<i32>,
source_rect: Rect<i32>, smoothing_enabled: bool) {
self.write_image(imagedata, source_rect, dest_rect, smoothing_enabled);

View file

@ -311,6 +311,10 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
self.renderer.send(CanvasMsg::Fill).unwrap();
}
fn Stroke(self) {
self.renderer.send(CanvasMsg::Stroke).unwrap();
}
// https://html.spec.whatwg.org/multipage/scripting.html#dom-context-2d-drawimage
fn DrawImage(self, image: HTMLCanvasElementOrCanvasRenderingContext2D,
dx: f64, dy: f64) -> Fallible<()> {

View file

@ -82,7 +82,7 @@ interface CanvasRenderingContext2D {
void beginPath();
void fill(optional CanvasWindingRule fillRule = "nonzero");
//void fill(Path2D path, optional CanvasWindingRule fillRule = "nonzero");
//void stroke();
void stroke();
//void stroke(Path2D path);
//void drawSystemFocusRing(Element element);
//void drawSystemFocusRing(Path2D path, Element element);

View file

@ -31,7 +31,7 @@ source = "git+https://github.com/tomaka/android-rs-glue#5a68056599fb498b0cf3715f
[[package]]
name = "azure"
version = "0.1.0"
source = "git+https://github.com/servo/rust-azure#110b98c7d39a275513c654644311f26b7eb75580"
source = "git+https://github.com/servo/rust-azure#9aae2113fb19a34a67a82b7ec6a5e0b34e290d29"
dependencies = [
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)",