aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/canvas/canvas_paint_task.rs66
-rw-r--r--components/gfx/paint_context.rs8
-rw-r--r--components/servo/Cargo.lock2
-rw-r--r--ports/cef/Cargo.lock2
-rw-r--r--ports/gonk/Cargo.lock2
-rw-r--r--tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.gradient.interpolate.zerosize.fillRect.html.ini5
6 files changed, 49 insertions, 36 deletions
diff --git a/components/canvas/canvas_paint_task.rs b/components/canvas/canvas_paint_task.rs
index dfe262d27f7..c09dc021579 100644
--- a/components/canvas/canvas_paint_task.rs
+++ b/components/canvas/canvas_paint_task.rs
@@ -250,6 +250,10 @@ impl<'a> CanvasPaintTask<'a> {
}
fn fill_rect(&self, rect: &Rect<f32>) {
+ if is_zero_size_gradient(&self.state.fill_style) {
+ return; // Paint nothing if gradient size is zero.
+ }
+
let draw_rect = Rect::new(rect.origin,
match self.state.fill_style {
Pattern::Surface(ref surface) => {
@@ -281,14 +285,19 @@ impl<'a> CanvasPaintTask<'a> {
}
fn stroke_rect(&self, rect: &Rect<f32>) {
- match self.state.stroke_style {
- Pattern::Color(ref color) => {
- self.drawtarget.stroke_rect(rect, color, &self.state.stroke_opts, &self.state.draw_options)
- }
- _ => {
- // TODO(pcwalton)
- }
- };
+ if is_zero_size_gradient(&self.state.stroke_style) {
+ return; // Paint nothing if gradient size is zero.
+ }
+
+ if self.need_to_draw_shadow() {
+ self.draw_with_shadow(&rect, |new_draw_target: &DrawTarget| {
+ new_draw_target.stroke_rect(rect, self.state.stroke_style.to_pattern_ref(),
+ &self.state.stroke_opts, &self.state.draw_options);
+ });
+ } else {
+ self.drawtarget.stroke_rect(rect, self.state.stroke_style.to_pattern_ref(),
+ &self.state.stroke_opts, &self.state.draw_options);
+ }
}
fn begin_path(&mut self) {
@@ -300,26 +309,24 @@ impl<'a> CanvasPaintTask<'a> {
}
fn fill(&self) {
- match self.state.fill_style {
- Pattern::Color(ref color) => {
- self.drawtarget.fill(&self.path_builder.finish(), color, &self.state.draw_options);
- }
- _ => {
- // TODO(pcwalton)
- }
- };
+ if is_zero_size_gradient(&self.state.fill_style) {
+ return; // Paint nothing if gradient size is zero.
+ }
+
+ self.drawtarget.fill(&self.path_builder.finish(),
+ self.state.fill_style.to_pattern_ref(),
+ &self.state.draw_options);
}
fn stroke(&self) {
- match self.state.stroke_style {
- Pattern::Color(ref color) => {
- self.drawtarget.stroke(&self.path_builder.finish(),
- color, &self.state.stroke_opts, &self.state.draw_options);
- }
- _ => {
- // TODO
- }
- };
+ if is_zero_size_gradient(&self.state.stroke_style) {
+ return; // Paint nothing if gradient size is zero.
+ }
+
+ self.drawtarget.stroke(&self.path_builder.finish(),
+ self.state.stroke_style.to_pattern_ref(),
+ &self.state.stroke_opts,
+ &self.state.draw_options);
}
fn clip(&self) {
@@ -733,6 +740,15 @@ fn write_pixels(draw_target: &DrawTarget,
draw_options);
}
+fn is_zero_size_gradient(pattern: &Pattern) -> bool {
+ if let &Pattern::LinearGradient(ref gradient) = pattern {
+ if gradient.is_zero_size() {
+ return true;
+ }
+ }
+ return false;
+}
+
pub trait SizeToi32 {
fn to_i32(&self) -> Size2D<i32>;
}
diff --git a/components/gfx/paint_context.rs b/components/gfx/paint_context.rs
index 16564f6e44a..04551f08170 100644
--- a/components/gfx/paint_context.rs
+++ b/components/gfx/paint_context.rs
@@ -19,7 +19,7 @@ use azure::azure_hl::{DrawOptions, DrawSurfaceOptions, DrawTarget, ExtendMode, F
use azure::azure_hl::{GaussianBlurAttribute, StrokeOptions, SurfaceFormat};
use azure::azure_hl::{GaussianBlurInput, GradientStop, Filter, FilterNode, LinearGradientPattern};
use azure::azure_hl::{JoinStyle, CapStyle};
-use azure::azure_hl::{PatternRef, Path, PathBuilder, CompositionOp, AntialiasMode};
+use azure::azure_hl::{Pattern, PatternRef, Path, PathBuilder, CompositionOp, AntialiasMode};
use azure::scaled_font::ScaledFont;
use azure::{AzFloat, struct__AzDrawOptions, struct__AzGlyph};
use azure::{struct__AzGlyphBuffer, struct__AzPoint, AzDrawTargetFillGlyphs};
@@ -291,7 +291,9 @@ impl<'a> PaintContext<'a> {
let mut path_builder = self.draw_target.create_path_builder();
self.create_border_path_segment(&mut path_builder, bounds, direction, border, radii);
let draw_options = DrawOptions::new(1.0, CompositionOp::Over, AntialiasMode::None);
- self.draw_target.fill(&path_builder.finish(), &ColorPattern::new(color), &draw_options);
+ self.draw_target.fill(&path_builder.finish(),
+ Pattern::Color(ColorPattern::new(color)).to_pattern_ref(),
+ &draw_options);
}
fn push_rounded_rect_clip(&self, bounds: &Rect<f32>, radii: &BorderRadii<AzFloat>) {
@@ -1023,7 +1025,7 @@ impl<'a> PaintContext<'a> {
// Draw the shadow, and blur if we need to.
temporary_draw_target.draw_target.fill(&path,
- &ColorPattern::new(color),
+ Pattern::Color(ColorPattern::new(color)).to_pattern_ref(),
&DrawOptions::new(1.0, CompositionOp::Over, AntialiasMode::None));
self.blur_if_necessary(temporary_draw_target, blur_radius);
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index 7d97181ec65..c074e40ac8d 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -42,7 +42,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "azure"
version = "0.1.0"
-source = "git+https://github.com/servo/rust-azure#b9bb83c733507f3f57e2c334499f38432056e26c"
+source = "git+https://github.com/servo/rust-azure#0e864697513c9e31bbe2213957d5713fd6139e69"
dependencies = [
"core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock
index af051f09583..a03fb6e68a0 100644
--- a/ports/cef/Cargo.lock
+++ b/ports/cef/Cargo.lock
@@ -41,7 +41,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "azure"
version = "0.1.0"
-source = "git+https://github.com/servo/rust-azure#b9bb83c733507f3f57e2c334499f38432056e26c"
+source = "git+https://github.com/servo/rust-azure#0e864697513c9e31bbe2213957d5713fd6139e69"
dependencies = [
"core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock
index 0177a67c77c..5ccb5bf53c8 100644
--- a/ports/gonk/Cargo.lock
+++ b/ports/gonk/Cargo.lock
@@ -28,7 +28,7 @@ dependencies = [
[[package]]
name = "azure"
version = "0.1.0"
-source = "git+https://github.com/servo/rust-azure#b9bb83c733507f3f57e2c334499f38432056e26c"
+source = "git+https://github.com/servo/rust-azure#0e864697513c9e31bbe2213957d5713fd6139e69"
dependencies = [
"core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.gradient.interpolate.zerosize.fillRect.html.ini b/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.gradient.interpolate.zerosize.fillRect.html.ini
deleted file mode 100644
index c00de83efcd..00000000000
--- a/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.gradient.interpolate.zerosize.fillRect.html.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[2d.gradient.interpolate.zerosize.fillRect.html]
- type: testharness
- [Canvas test: 2d.gradient.interpolate.zerosize.fillRect]
- expected: FAIL
-