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, BeginPath,
ClosePath, ClosePath,
Fill, Fill,
Stroke,
DrawImage(Vec<u8>, Rect<i32>, Rect<i32>, bool), DrawImage(Vec<u8>, Rect<i32>, Rect<i32>, bool),
DrawImageSelf(Size2D<i32>, Rect<i32>, Rect<i32>, bool), DrawImageSelf(Size2D<i32>, Rect<i32>, Rect<i32>, bool),
MoveTo(Point2D<f32>), MoveTo(Point2D<f32>),
@ -211,6 +212,7 @@ impl<'a> CanvasPaintTask<'a> {
CanvasMsg::BeginPath => painter.begin_path(), CanvasMsg::BeginPath => painter.begin_path(),
CanvasMsg::ClosePath => painter.close_path(), CanvasMsg::ClosePath => painter.close_path(),
CanvasMsg::Fill => painter.fill(), CanvasMsg::Fill => painter.fill(),
CanvasMsg::Stroke => painter.stroke(),
CanvasMsg::DrawImage(imagedata, dest_rect, source_rect, smoothing_enabled) => { CanvasMsg::DrawImage(imagedata, dest_rect, source_rect, smoothing_enabled) => {
painter.draw_image(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>, fn draw_image(&self, imagedata: Vec<u8>, dest_rect: Rect<i32>,
source_rect: Rect<i32>, smoothing_enabled: bool) { source_rect: Rect<i32>, smoothing_enabled: bool) {
self.write_image(imagedata, source_rect, dest_rect, smoothing_enabled); 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(); 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 // https://html.spec.whatwg.org/multipage/scripting.html#dom-context-2d-drawimage
fn DrawImage(self, image: HTMLCanvasElementOrCanvasRenderingContext2D, fn DrawImage(self, image: HTMLCanvasElementOrCanvasRenderingContext2D,
dx: f64, dy: f64) -> Fallible<()> { dx: f64, dy: f64) -> Fallible<()> {

View file

@ -82,7 +82,7 @@ interface CanvasRenderingContext2D {
void beginPath(); void beginPath();
void fill(optional CanvasWindingRule fillRule = "nonzero"); void fill(optional CanvasWindingRule fillRule = "nonzero");
//void fill(Path2D path, optional CanvasWindingRule fillRule = "nonzero"); //void fill(Path2D path, optional CanvasWindingRule fillRule = "nonzero");
//void stroke(); void stroke();
//void stroke(Path2D path); //void stroke(Path2D path);
//void drawSystemFocusRing(Element element); //void drawSystemFocusRing(Element element);
//void drawSystemFocusRing(Path2D path, 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]] [[package]]
name = "azure" name = "azure"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/servo/rust-azure#110b98c7d39a275513c654644311f26b7eb75580" source = "git+https://github.com/servo/rust-azure#9aae2113fb19a34a67a82b7ec6a5e0b34e290d29"
dependencies = [ dependencies = [
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", "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)", "core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)",

2
ports/cef/Cargo.lock generated
View file

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

2
ports/gonk/Cargo.lock generated
View file

@ -23,7 +23,7 @@ dependencies = [
[[package]] [[package]]
name = "azure" name = "azure"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/servo/rust-azure#110b98c7d39a275513c654644311f26b7eb75580" source = "git+https://github.com/servo/rust-azure#9aae2113fb19a34a67a82b7ec6a5e0b34e290d29"
dependencies = [ dependencies = [
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", "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)", "core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)",

View file

@ -1,5 +0,0 @@
[2d.line.cap.butt.html]
type: testharness
[lineCap \'butt\' is rendered correctly]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.line.cap.closed.html]
type: testharness
[Line caps are not drawn at the corners of an unclosed rectangle]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.line.cross.html]
type: testharness
[Canvas test: 2d.line.cross]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.line.join.open.html]
type: testharness
[Line joins are not drawn at the corner of an unclosed rectangle]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.line.miter.exceeded.html]
type: testharness
[Miter joins are not drawn when the miter limit is exceeded]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.line.miter.rightangle.html]
type: testharness
[Miter joins are not drawn when the miter limit is exceeded, on exact right angles]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.line.width.scaledefault.html]
type: testharness
[Default lineWidth strokes are affected by scale transformations]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.arc.empty.html]
type: testharness
[arc() with an empty path does not draw a straight line to the start point]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.arc.end.html]
type: testharness
[arc() adds the end point of the arc to the subpath]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.arc.nonempty.html]
type: testharness
[arc() with a non-empty path does draw a straight line to the start point]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.arc.selfintersect.1.html]
type: testharness
[arc() with lineWidth > 2*radius is drawn sensibly]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.arc.shape.1.html]
type: testharness
[arc() from 0 to pi does not draw anything in the wrong half]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.arc.shape.3.html]
type: testharness
[arc() from 0 to -pi/2 does not draw anything in the wrong quadrant]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.arc.shape.5.html]
type: testharness
[arc() from 0 to 5pi does not draw crazy things]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.arc.twopie.1.html]
type: testharness
[arc() draws nothing when end = start + 2pi-e and anticlockwise]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.arc.zero.1.html]
type: testharness
[arc() draws nothing when startAngle = endAngle and anticlockwise]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.arc.zero.2.html]
type: testharness
[arc() draws nothing when startAngle = endAngle and clockwise]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.arc.zeroradius.html]
type: testharness
[arc() with zero radius draws a line to the start point]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.bezierCurveTo.basic.html]
type: testharness
[Canvas test: 2d.path.bezierCurveTo.basic]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.bezierCurveTo.ensuresubpath.1.html]
type: testharness
[If there is no subpath, the first control point is added (and nothing is drawn up to it)]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.bezierCurveTo.scaled.html]
type: testharness
[Canvas test: 2d.path.bezierCurveTo.scaled]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.closePath.newline.html]
type: testharness
[Canvas test: 2d.path.closePath.newline]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.closePath.nextpoint.html]
type: testharness
[Canvas test: 2d.path.closePath.nextpoint]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.lineTo.basic.html]
type: testharness
[Canvas test: 2d.path.lineTo.basic]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.lineTo.ensuresubpath.1.html]
type: testharness
[If there is no subpath, the point is added and nothing is drawn]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.lineTo.ensuresubpath.2.html]
type: testharness
[If there is no subpath, the point is added and used for subsequent drawing]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.lineTo.nextpoint.html]
type: testharness
[Canvas test: 2d.path.lineTo.nextpoint]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.moveTo.multiple.html]
type: testharness
[Canvas test: 2d.path.moveTo.multiple]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.quadraticCurveTo.basic.html]
type: testharness
[Canvas test: 2d.path.quadraticCurveTo.basic]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.quadraticCurveTo.ensuresubpath.1.html]
type: testharness
[If there is no subpath, the first control point is added (and nothing is drawn up to it)]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.quadraticCurveTo.scaled.html]
type: testharness
[Canvas test: 2d.path.quadraticCurveTo.scaled]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.stroke.empty.html]
type: testharness
[Empty subpaths are not stroked]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.stroke.prune.closed.html]
type: testharness
[Zero-length line segments from closed paths are removed before stroking]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.stroke.prune.corner.html]
type: testharness
[Zero-length line segments are removed before stroking with miters]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.stroke.prune.curve.html]
type: testharness
[Zero-length line segments from quadraticCurveTo and bezierCurveTo are removed before stroking]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.path.stroke.prune.line.html]
type: testharness
[Zero-length line segments from lineTo are removed before stroking]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.shadow.stroke.cap.1.html]
type: testharness
[Shadows are not drawn for areas outside stroke caps]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.shadow.stroke.join.1.html]
type: testharness
[Shadows are not drawn for areas outside stroke joins]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.shadow.stroke.join.3.html]
type: testharness
[Shadows are drawn for stroke joins respecting miter limit]
expected: FAIL

View file

@ -6993,9 +6993,6 @@
[CanvasRenderingContext2D interface: operation fill(CanvasFillRule)] [CanvasRenderingContext2D interface: operation fill(CanvasFillRule)]
expected: FAIL expected: FAIL
[CanvasRenderingContext2D interface: operation stroke()]
expected: FAIL
[CanvasRenderingContext2D interface: operation stroke(Path2D)] [CanvasRenderingContext2D interface: operation stroke(Path2D)]
expected: FAIL expected: FAIL
@ -7173,12 +7170,6 @@
[CanvasRenderingContext2D interface: calling fill(Path2D,CanvasFillRule) on document.createElement("canvas").getContext("2d") with too few arguments must throw TypeError] [CanvasRenderingContext2D interface: calling fill(Path2D,CanvasFillRule) on document.createElement("canvas").getContext("2d") with too few arguments must throw TypeError]
expected: FAIL expected: FAIL
[CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "stroke" with the proper type (31)]
expected: FAIL
[CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "stroke" with the proper type (32)]
expected: FAIL
[CanvasRenderingContext2D interface: calling stroke(Path2D) on document.createElement("canvas").getContext("2d") with too few arguments must throw TypeError] [CanvasRenderingContext2D interface: calling stroke(Path2D) on document.createElement("canvas").getContext("2d") with too few arguments must throw TypeError]
expected: FAIL expected: FAIL