servo: Merge #5302 - Canvas: Added stroke support (from mmatyas:canvas_stroke); r=jdm

This is the servo side patch of servo/rust-azure#149.

Source-Repo: https://github.com/servo/servo
Source-Revision: f29ea4e4ef633c023a43f47f7fc8c6b46e51b8df
This commit is contained in:
Mátyás Mustoha 2015-03-25 07:54:50 -06:00
Родитель 3cb06b56a1
Коммит 34409fd616
6 изменённых файлов: 23 добавлений и 4 удалений

Просмотреть файл

@ -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);

Просмотреть файл

@ -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<()> {

Просмотреть файл

@ -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);

2
servo/components/servo/Cargo.lock сгенерированный
Просмотреть файл

@ -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)",

2
servo/ports/cef/Cargo.lock сгенерированный
Просмотреть файл

@ -36,7 +36,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)",

2
servo/ports/gonk/Cargo.lock сгенерированный
Просмотреть файл

@ -23,7 +23,7 @@ dependencies = [
[[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)",