mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Use cleaner StrokeOptions interface introduced by https://github.com/servo/rust-azure/pull/145.
This commit is contained in:
parent
49ff6b2ccc
commit
ad5671bc14
5 changed files with 18 additions and 23 deletions
|
@ -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, &[]),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
2
components/servo/Cargo.lock
generated
2
components/servo/Cargo.lock
generated
|
@ -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)",
|
||||
|
|
2
ports/cef/Cargo.lock
generated
2
ports/cef/Cargo.lock
generated
|
@ -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)",
|
||||
|
|
2
ports/gonk/Cargo.lock
generated
2
ports/gonk/Cargo.lock
generated
|
@ -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)",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue