aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Gal <andreas.gal@gmail.com>2015-02-20 01:45:54 -0800
committerAndreas Gal <andreas.gal@gmail.com>2015-02-20 14:56:23 -0800
commitad5671bc143c5c02fd6b3d0ea7b5f314d85c9cc3 (patch)
tree210c41f3178434333a5d1bf84e8b5c10d4a28b88
parent49ff6b2ccc43ab657814a1b4584122411a4b2acb (diff)
downloadservo-ad5671bc143c5c02fd6b3d0ea7b5f314d85c9cc3.tar.gz
servo-ad5671bc143c5c02fd6b3d0ea7b5f314d85c9cc3.zip
Use cleaner StrokeOptions interface introduced by https://github.com/servo/rust-azure/pull/145.
-rw-r--r--components/canvas/canvas_paint_task.rs12
-rw-r--r--components/gfx/paint_context.rs23
-rw-r--r--components/servo/Cargo.lock2
-rw-r--r--ports/cef/Cargo.lock2
-rw-r--r--ports/gonk/Cargo.lock2
5 files changed, 18 insertions, 23 deletions
diff --git a/components/canvas/canvas_paint_task.rs b/components/canvas/canvas_paint_task.rs
index 982861b0637..095a8d76aca 100644
--- a/components/canvas/canvas_paint_task.rs
+++ b/components/canvas/canvas_paint_task.rs
@@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use azure::azure_hl::{DrawTarget, SurfaceFormat, BackendType, StrokeOptions, DrawOptions};
-use azure::azure_hl::{ColorPattern, PatternRef};
+use azure::azure_hl::{ColorPattern, PatternRef, JoinStyle, CapStyle};
use geom::rect::Rect;
use geom::size::Size2D;
use gfx::color;
@@ -22,20 +22,20 @@ pub enum CanvasMsg {
Close,
}
-pub struct CanvasPaintTask {
+pub struct CanvasPaintTask<'a> {
drawtarget: DrawTarget,
fill_color: ColorPattern,
stroke_color: ColorPattern,
- stroke_opts: StrokeOptions,
+ stroke_opts: StrokeOptions<'a>,
}
-impl CanvasPaintTask {
- fn new(size: Size2D<i32>) -> CanvasPaintTask {
+impl<'a> CanvasPaintTask<'a> {
+ fn new(size: Size2D<i32>) -> CanvasPaintTask<'a> {
CanvasPaintTask {
drawtarget: CanvasPaintTask::create(size),
fill_color: ColorPattern::new(color::black()),
stroke_color: ColorPattern::new(color::black()),
- stroke_opts: StrokeOptions::new(1.0, 1.0),
+ stroke_opts: StrokeOptions::new(1.0, JoinStyle::MiterOrBevel, CapStyle::Butt, 1.0, &[]),
}
}
diff --git a/components/gfx/paint_context.rs b/components/gfx/paint_context.rs
index 566dd48b030..d831a01d7ec 100644
--- a/components/gfx/paint_context.rs
+++ b/components/gfx/paint_context.rs
@@ -10,8 +10,9 @@ use azure::azure_hl::{DrawOptions, DrawSurfaceOptions, DrawTarget, ExtendMode, F
use azure::azure_hl::{GaussianBlurInput, GradientStop, Filter, LinearGradientPattern};
use azure::azure_hl::{PatternRef, Path, PathBuilder, CompositionOp};
use azure::azure_hl::{GaussianBlurAttribute, StrokeOptions, SurfaceFormat};
+use azure::azure_hl::{JoinStyle, CapStyle};
use azure::scaled_font::ScaledFont;
-use azure::{AZ_CAP_BUTT, AzFloat, struct__AzDrawOptions, struct__AzGlyph};
+use azure::{AzFloat, struct__AzDrawOptions, struct__AzGlyph};
use azure::{struct__AzGlyphBuffer, struct__AzPoint, AzDrawTargetFillGlyphs};
use color;
use display_list::TextOrientation::{SidewaysLeft, SidewaysRight, Upright};
@@ -23,7 +24,6 @@ use geom::point::Point2D;
use geom::rect::Rect;
use geom::side_offsets::SideOffsets2D;
use geom::size::Size2D;
-use libc::size_t;
use libc::types::common::c99::{uint16_t, uint32_t};
use png::PixelsByColorType;
use net::image::base::Image;
@@ -608,24 +608,19 @@ impl<'a> PaintContext<'a> {
dash_size: DashSize) {
let rect = bounds.to_azure_rect();
let draw_opts = DrawOptions::new(1u as AzFloat, 0 as uint16_t);
- let mut stroke_opts = StrokeOptions::new(0u as AzFloat, 10u as AzFloat);
- let mut dash: [AzFloat; 2] = [0u as AzFloat, 0u as AzFloat];
-
- stroke_opts.set_cap_style(AZ_CAP_BUTT as u8);
-
let border_width = match direction {
Direction::Top => border.top,
Direction::Left => border.left,
Direction::Right => border.right,
Direction::Bottom => border.bottom
};
-
- stroke_opts.line_width = border_width;
- dash[0] = border_width * (dash_size as int) as AzFloat;
- dash[1] = border_width * (dash_size as int) as AzFloat;
- stroke_opts.mDashPattern = dash.as_mut_ptr();
- stroke_opts.mDashLength = dash.len() as size_t;
-
+ let dash_pattern = [border_width * (dash_size as int) as AzFloat,
+ border_width * (dash_size as int) as AzFloat];
+ let stroke_opts = StrokeOptions::new(border_width as AzFloat,
+ JoinStyle::MiterOrBevel,
+ CapStyle::Butt,
+ 10u as AzFloat,
+ &dash_pattern);
let (start, end) = match direction {
Direction::Top => {
let y = rect.origin.y + border.top * 0.5;
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index abf404d4cbf..e2cf7c06a77 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -36,7 +36,7 @@ dependencies = [
[[package]]
name = "azure"
version = "0.1.0"
-source = "git+https://github.com/servo/rust-azure#ec5fddfe96f889e35cc83abd2255f8325f2ec147"
+source = "git+https://github.com/servo/rust-azure#2c60291733afe631eba90105e9ac9c8847e89cac"
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)",
diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock
index d8f08c7fbdc..39bfc67463c 100644
--- a/ports/cef/Cargo.lock
+++ b/ports/cef/Cargo.lock
@@ -39,7 +39,7 @@ dependencies = [
[[package]]
name = "azure"
version = "0.1.0"
-source = "git+https://github.com/servo/rust-azure#ec5fddfe96f889e35cc83abd2255f8325f2ec147"
+source = "git+https://github.com/servo/rust-azure#2c60291733afe631eba90105e9ac9c8847e89cac"
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)",
diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock
index 4190fd31474..35e4d1277c1 100644
--- a/ports/gonk/Cargo.lock
+++ b/ports/gonk/Cargo.lock
@@ -18,7 +18,7 @@ dependencies = [
[[package]]
name = "azure"
version = "0.1.0"
-source = "git+https://github.com/servo/rust-azure#ec5fddfe96f889e35cc83abd2255f8325f2ec147"
+source = "git+https://github.com/servo/rust-azure#2c60291733afe631eba90105e9ac9c8847e89cac"
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)",