diff options
author | RazrFalcon <razrfalcon@gmail.com> | 2018-06-05 13:54:56 +0300 |
---|---|---|
committer | RazrFalcon <razrfalcon@gmail.com> | 2018-06-05 13:54:56 +0300 |
commit | 3fc9907a988333bdc33fabf2e1e3f14b8ff5287c (patch) | |
tree | 7bf21428dfeacd3a313d277deca6c7ccf4c402bd /src | |
parent | bb4e3cae53b84d563cde13e344184f2e648f19df (diff) |
Added comments with test names.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend_cairo/clippath.rs | 13 | ||||
-rw-r--r-- | src/backend_cairo/fill.rs | 8 | ||||
-rw-r--r-- | src/backend_cairo/gradient.rs | 4 | ||||
-rw-r--r-- | src/backend_cairo/mask.rs | 2 | ||||
-rw-r--r-- | src/backend_cairo/mod.rs | 6 | ||||
-rw-r--r-- | src/backend_cairo/pattern.rs | 2 | ||||
-rw-r--r-- | src/backend_cairo/stroke.rs | 7 | ||||
-rw-r--r-- | src/backend_cairo/text.rs | 22 | ||||
-rw-r--r-- | src/backend_qt/clippath.rs | 9 | ||||
-rw-r--r-- | src/backend_qt/fill.rs | 2 | ||||
-rw-r--r-- | src/backend_qt/gradient.rs | 4 | ||||
-rw-r--r-- | src/backend_qt/mask.rs | 2 | ||||
-rw-r--r-- | src/backend_qt/mod.rs | 6 | ||||
-rw-r--r-- | src/backend_qt/path.rs | 6 | ||||
-rw-r--r-- | src/backend_qt/pattern.rs | 2 | ||||
-rw-r--r-- | src/backend_qt/stroke.rs | 7 | ||||
-rw-r--r-- | src/backend_qt/text.rs | 22 | ||||
-rw-r--r-- | src/backend_utils/text.rs | 5 |
18 files changed, 129 insertions, 0 deletions
diff --git a/src/backend_cairo/clippath.rs b/src/backend_cairo/clippath.rs index 0f14cd1..0f8a2c5 100644 --- a/src/backend_cairo/clippath.rs +++ b/src/backend_cairo/clippath.rs @@ -26,15 +26,22 @@ pub fn apply( layers: &mut CairoLayers, cr: &cairo::Context, ) { + // a-clip-path-001.svg + // e-clipPath-001.svg + let clip_surface = try_opt!(layers.get(), ()); let clip_surface = clip_surface.borrow_mut(); let clip_cr = cairo::Context::new(&*clip_surface); clip_cr.set_source_rgba(0.0, 0.0, 0.0, 1.0); clip_cr.paint(); + // e-clipPath-006.svg + // e-clipPath-007.svg clip_cr.set_matrix(cr.get_matrix()); + // e-clipPath-008.svg clip_cr.transform(cp.transform.to_native()); + // e-clipPath-005.svg if cp.units == usvg::Units::ObjectBoundingBox { let m = cairo::Matrix::from_bbox(bbox); clip_cr.transform(m); @@ -43,6 +50,8 @@ pub fn apply( clip_cr.set_operator(cairo::Operator::Clear); let matrix = clip_cr.get_matrix(); + // e-clipPath-015.svg + // e-clipPath-017.svg for node in node.children() { clip_cr.transform(node.transform().to_native()); @@ -51,6 +60,10 @@ pub fn apply( path::draw(&node.tree(), p, opt, &clip_cr); } usvg::NodeKind::Text(ref text) => { + // e-clipPath-009.svg + // e-clipPath-010.svg + // e-clipPath-011.svg + // e-clipPath-012.svg text::draw(&node.tree(), text, opt, &clip_cr); } _ => {} diff --git a/src/backend_cairo/fill.rs b/src/backend_cairo/fill.rs index 55eb5cb..96b7549 100644 --- a/src/backend_cairo/fill.rs +++ b/src/backend_cairo/fill.rs @@ -26,11 +26,17 @@ pub fn apply( match fill.paint { usvg::Paint::Color(c) => { // a-fill-opacity-001.svg + // a-fill-opacity-002.svg + // a-fill-opacity-006.svg cr.set_source_color(&c, fill.opacity); } usvg::Paint::Link(ref id) => { // a-fill-opacity-003.svg // a-fill-opacity-004.svg + // a-fill-031.svg + // a-fill-032.svg + // a-fill-033.svg + if let Some(node) = tree.defs_by_id(id) { match *node.borrow() { usvg::NodeKind::LinearGradient(ref lg) => { @@ -50,6 +56,8 @@ pub fn apply( // a-fill-rule-001.svg // a-fill-rule-002.svg + // e-clipPath-013.svg + // e-clipPath-014.svg match fill.rule { usvg::FillRule::NonZero => cr.set_fill_rule(cairo::FillRule::Winding), usvg::FillRule::EvenOdd => cr.set_fill_rule(cairo::FillRule::EvenOdd), diff --git a/src/backend_cairo/gradient.rs b/src/backend_cairo/gradient.rs index 3e592ae..119b62d 100644 --- a/src/backend_cairo/gradient.rs +++ b/src/backend_cairo/gradient.rs @@ -58,6 +58,10 @@ fn prepare_base( matrix.invert(); grad.set_matrix(matrix); + // a-fill-opacity-003.svg + // a-stop-color-001.svg + // a-stop-opacity-001.svg + // a-stroke-opacity-003.svg for stop in &g.stops { grad.add_color_stop_rgba( *stop.offset, diff --git a/src/backend_cairo/mask.rs b/src/backend_cairo/mask.rs index f211c88..147c771 100644 --- a/src/backend_cairo/mask.rs +++ b/src/backend_cairo/mask.rs @@ -23,6 +23,8 @@ pub fn apply( layers: &mut CairoLayers, cr: &cairo::Context, ) { + // a-mask-001.svg + let mask_surface = try_opt!(layers.get(), ()); let mut mask_surface = mask_surface.borrow_mut(); diff --git a/src/backend_cairo/mod.rs b/src/backend_cairo/mod.rs index 51cafed..c2113b9 100644 --- a/src/backend_cairo/mod.rs +++ b/src/backend_cairo/mod.rs @@ -269,6 +269,10 @@ fn render_group( let mut g_bbox = Rect::new_bbox(); for node in parent.children() { + // a-transform-001.svg + // a-transform-010.svg + // a-transform-016.svg + // e-line-009.svg cr.transform(node.transform().to_native()); let bbox = render_node(&node, opt, layers, cr); @@ -319,6 +323,8 @@ fn render_group_impl( } } } else { + // a-opacity-001.svg + // a-stroke-opacity-002.svg if let Some(opacity) = g.opacity { cr.paint_with_alpha(*opacity); } else { diff --git a/src/backend_cairo/pattern.rs b/src/backend_cairo/pattern.rs index cc99517..0e64c51 100644 --- a/src/backend_cairo/pattern.rs +++ b/src/backend_cairo/pattern.rs @@ -68,6 +68,8 @@ pub fn apply( // If `opacity` isn't `1` then we have to make image semitransparent. // The only way to do this is by making a new image and rendering // the pattern on it with transparency. + // + // a-stroke-opacity-004.svg let surface2 = try_create_surface!(img_size, ()); let sub_cr2 = cairo::Context::new(&surface2); diff --git a/src/backend_cairo/stroke.rs b/src/backend_cairo/stroke.rs index 5b2eaaf..3aa1feb 100644 --- a/src/backend_cairo/stroke.rs +++ b/src/backend_cairo/stroke.rs @@ -25,12 +25,18 @@ pub fn apply( Some(ref stroke) => { match stroke.paint { usvg::Paint::Color(c) => { + // a-stroke-opacity-001.svg + // a-stroke-opacity-002.svg + // a-stroke-opacity-006.svg cr.set_source_color(&c, stroke.opacity); } usvg::Paint::Link(ref id) => { // a-stroke-002.svg // a-stroke-003.svg // a-stroke-004.svg + // a-stroke-007.svg + // a-stroke-008.svg + // a-stroke-009.svg if let Some(node) = tree.defs_by_id(id) { match *node.borrow() { usvg::NodeKind::LinearGradient(ref lg) => { @@ -80,6 +86,7 @@ pub fn apply( // a-stroke-miterlimit-002.svg cr.set_miter_limit(stroke.miterlimit); + // a-stroke-width-002.svg cr.set_line_width(stroke.width); } None => { diff --git a/src/backend_cairo/text.rs b/src/backend_cairo/text.rs index 365e5be..1dc4835 100644 --- a/src/backend_cairo/text.rs +++ b/src/backend_cairo/text.rs @@ -136,6 +136,9 @@ fn draw_block( // Draw underline. // // Should be drawn before/under text. + // + // a-text-decoration-001.svg + // a-text-decoration-009.svg if let Some(ref style) = block.decoration.underline { line_rect.y = bbox.y + baseline_offset - fm.get_underline_position().scale(); draw_line(tree, line_rect, &style.fill, &style.stroke, opt, cr); @@ -144,6 +147,8 @@ fn draw_block( // Draw overline. // // Should be drawn before/under text. + // + // a-text-decoration-002.svg if let Some(ref style) = block.decoration.overline { line_rect.y = bbox.y + fm.get_underline_thickness().scale(); draw_line(tree, line_rect, &style.fill, &style.stroke, opt, cr); @@ -165,6 +170,8 @@ fn draw_block( // Draw line-through. // // Should be drawn after/over text. + // + // a-text-decoration-003.svg if let Some(ref style) = block.decoration.line_through { line_rect.y = bbox.y + baseline_offset - fm.get_strikethrough_position().scale(); line_rect.height = fm.get_strikethrough_thickness().scale(); @@ -177,8 +184,20 @@ fn draw_block( fn init_font(dom_font: &usvg::Font, dpi: f64) -> pango::FontDescription { let mut font = pango::FontDescription::new(); + // a-font-family-001.svg + // a-font-family-002.svg + // a-font-family-003.svg + // a-font-family-004.svg + // a-font-family-005.svg + // a-font-family-006.svg + // a-font-family-007.svg + // a-font-family-008.svg + // a-font-family-009.svg + // a-font-family-010.svg font.set_family(&dom_font.family); + // a-font-style-001.svg + // a-font-style-002.svg let font_style = match dom_font.style { usvg::FontStyle::Normal => pango::Style::Normal, usvg::FontStyle::Italic => pango::Style::Italic, @@ -186,12 +205,14 @@ fn init_font(dom_font: &usvg::Font, dpi: f64) -> pango::FontDescription { }; font.set_style(font_style); + // a-font-variant-001.svg let font_variant = match dom_font.variant { usvg::FontVariant::Normal => pango::Variant::Normal, usvg::FontVariant::SmallCaps => pango::Variant::SmallCaps, }; font.set_variant(font_variant); + // a-font-weight-009.svg let font_weight = match dom_font.weight { usvg::FontWeight::W100 => pango::Weight::Thin, usvg::FontWeight::W200 => pango::Weight::Ultralight, @@ -205,6 +226,7 @@ fn init_font(dom_font: &usvg::Font, dpi: f64) -> pango::FontDescription { }; font.set_weight(font_weight); + // a-font-stretch-001.svg let font_stretch = match dom_font.stretch { usvg::FontStretch::Normal => pango::Stretch::Normal, usvg::FontStretch::Narrower | diff --git a/src/backend_qt/clippath.rs b/src/backend_qt/clippath.rs index 62ff3ec..9dc5cb8 100644 --- a/src/backend_qt/clippath.rs +++ b/src/backend_qt/clippath.rs @@ -23,14 +23,21 @@ pub fn apply( layers: &mut QtLayers, p: &qt::Painter, ) { + // a-clip-path-001.svg + // e-clipPath-001.svg + let clip_img = try_opt!(layers.get(), ()); let mut clip_img = clip_img.borrow_mut(); clip_img.fill(0, 0, 0, 255); let clip_p = qt::Painter::new(&clip_img); + // e-clipPath-006.svg + // e-clipPath-007.svg clip_p.set_transform(&p.get_transform()); + // e-clipPath-008.svg clip_p.apply_transform(&cp.transform.to_native()); + // e-clipPath-005.svg if cp.units == usvg::Units::ObjectBoundingBox { clip_p.apply_transform(&qt::Transform::from_bbox(bbox)); } @@ -38,6 +45,8 @@ pub fn apply( clip_p.set_composition_mode(qt::CompositionMode::CompositionMode_Clear); let ts = clip_p.get_transform(); + // e-clipPath-015.svg + // e-clipPath-017.svg for node in node.children() { clip_p.apply_transform(&node.transform().to_native()); diff --git a/src/backend_qt/fill.rs b/src/backend_qt/fill.rs index a643854..35ff887 100644 --- a/src/backend_qt/fill.rs +++ b/src/backend_qt/fill.rs @@ -29,6 +29,8 @@ pub fn apply( match fill.paint { usvg::Paint::Color(c) => { // a-fill-opacity-001.svg + // a-fill-opacity-002.svg + // a-fill-opacity-006.svg let a = f64_bound(0.0, *opacity * 255.0, 255.0) as u8; brush.set_color(c.red, c.green, c.blue, a); } diff --git a/src/backend_qt/gradient.rs b/src/backend_qt/gradient.rs index 2726d6f..c3c9758 100644 --- a/src/backend_qt/gradient.rs +++ b/src/backend_qt/gradient.rs @@ -48,6 +48,10 @@ fn prepare_base( }; grad.set_spread(spread_method); + // a-fill-opacity-003.svg + // a-stop-color-001.svg + // a-stop-opacity-001.svg + // a-stroke-opacity-003.svg for stop in &g.stops { grad.set_color_at( *stop.offset, diff --git a/src/backend_qt/mask.rs b/src/backend_qt/mask.rs index e486f13..1d85579 100644 --- a/src/backend_qt/mask.rs +++ b/src/backend_qt/mask.rs @@ -20,6 +20,8 @@ pub fn apply( sub_p: &qt::Painter, p: &qt::Painter, ) { + // a-mask-001.svg + let mask_img = try_opt!(layers.get(), ()); let mut mask_img = mask_img.borrow_mut(); diff --git a/src/backend_qt/mod.rs b/src/backend_qt/mod.rs index 247cbcf..236cc5d 100644 --- a/src/backend_qt/mod.rs +++ b/src/backend_qt/mod.rs @@ -245,6 +245,10 @@ fn render_group( let mut g_bbox = Rect::new_bbox(); for node in parent.children() { + // a-transform-001.svg + // a-transform-010.svg + // a-transform-016.svg + // e-line-009.svg p.apply_transform(&node.transform().to_native()); let bbox = render_node(&node, opt, layers, p); @@ -292,6 +296,8 @@ fn render_group_impl( sub_p.end(); + // a-opacity-001.svg + // a-stroke-opacity-002.svg if let Some(opacity) = g.opacity { p.set_opacity(*opacity); } diff --git a/src/backend_qt/path.rs b/src/backend_qt/path.rs index 05c54e9..1efee97 100644 --- a/src/backend_qt/path.rs +++ b/src/backend_qt/path.rs @@ -51,6 +51,10 @@ pub fn convert_path( // // 'A closed path has coinciding start and end points.' // https://doc.qt.io/qt-5/qpainterpath.html#details + // + // a-stroke-linecap-007.svg + // a-stroke-linecap-008.svg + // a-stroke-linecap-009.svg let mut prev_mx = 0.0; let mut prev_my = 0.0; @@ -111,6 +115,8 @@ pub fn convert_path( // a-fill-rule-001.svg // a-fill-rule-002.svg + // e-clipPath-013.svg + // e-clipPath-014.svg match rule { usvg::FillRule::NonZero => p_path.set_fill_rule(qt::FillRule::WindingFill), usvg::FillRule::EvenOdd => p_path.set_fill_rule(qt::FillRule::OddEvenFill), diff --git a/src/backend_qt/pattern.rs b/src/backend_qt/pattern.rs index c637c0d..6eb40bf 100644 --- a/src/backend_qt/pattern.rs +++ b/src/backend_qt/pattern.rs @@ -62,6 +62,8 @@ pub fn apply( // If `opacity` isn't `1` then we have to make image semitransparent. // The only way to do this is by making a new image and rendering // the pattern on it with transparency. + // + // a-stroke-opacity-004.svg let mut img2 = try_create_image!(img_size, ()); img2.fill(0, 0, 0, 0); diff --git a/src/backend_qt/stroke.rs b/src/backend_qt/stroke.rs index 636f443..692169d 100644 --- a/src/backend_qt/stroke.rs +++ b/src/backend_qt/stroke.rs @@ -28,6 +28,9 @@ pub fn apply( match stroke.paint { usvg::Paint::Color(c) => { + // a-stroke-opacity-001.svg + // a-stroke-opacity-002.svg + // a-stroke-opacity-006.svg let a = f64_bound(0.0, *opacity * 255.0, 255.0) as u8; pen.set_color(c.red, c.green, c.blue, a); } @@ -35,6 +38,9 @@ pub fn apply( // a-stroke-002.svg // a-stroke-003.svg // a-stroke-004.svg + // a-stroke-007.svg + // a-stroke-008.svg + // a-stroke-009.svg let mut brush = qt::Brush::new(); if let Some(node) = tree.defs_by_id(id) { @@ -79,6 +85,7 @@ pub fn apply( // a-stroke-miterlimit-002.svg pen.set_miter_limit(stroke.miterlimit); + // a-stroke-width-002.svg pen.set_width(stroke.width); // a-stroke-dasharray-001.svg diff --git a/src/backend_qt/text.rs b/src/backend_qt/text.rs index 53baecf..e0d3589 100644 --- a/src/backend_qt/text.rs +++ b/src/backend_qt/text.rs @@ -88,6 +88,9 @@ fn draw_block( // Draw underline. // // Should be drawn before/under text. + // + // a-text-decoration-001.svg + // a-text-decoration-009.svg if let Some(ref style) = block.decoration.underline { line_rect.y = bbox.y + font_metrics.height() - font_metrics.underline_pos(); draw_line(tree, line_rect, &style.fill, &style.stroke, opt, p); @@ -96,6 +99,8 @@ fn draw_block( // Draw overline. // // Should be drawn before/under text. + // + // a-text-decoration-002.svg if let Some(ref style) = block.decoration.overline { line_rect.y = bbox.y + font_metrics.height() - font_metrics.overline_pos(); draw_line(tree, line_rect, &style.fill, &style.stroke, opt, p); @@ -110,6 +115,8 @@ fn draw_block( // Draw line-through. // // Should be drawn after/over text. + // + // a-text-decoration-003.svg if let Some(ref style) = block.decoration.line_through { line_rect.y = bbox.y + font_metrics.ascent() - font_metrics.strikeout_pos(); draw_line(tree, line_rect, &style.fill, &style.stroke, opt, p); @@ -121,8 +128,20 @@ fn draw_block( fn init_font(dom_font: &usvg::Font) -> qt::Font { let mut font = qt::Font::new(); + // a-font-family-001.svg + // a-font-family-002.svg + // a-font-family-003.svg + // a-font-family-004.svg + // a-font-family-005.svg + // a-font-family-006.svg + // a-font-family-007.svg + // a-font-family-008.svg + // a-font-family-009.svg + // a-font-family-010.svg font.set_family(&dom_font.family); + // a-font-style-001.svg + // a-font-style-002.svg let font_style = match dom_font.style { usvg::FontStyle::Normal => qt::FontStyle::StyleNormal, usvg::FontStyle::Italic => qt::FontStyle::StyleItalic, @@ -130,10 +149,12 @@ fn init_font(dom_font: &usvg::Font) -> qt::Font { }; font.set_style(font_style); + // a-font-variant-001.svg if dom_font.variant == usvg::FontVariant::SmallCaps { font.set_small_caps(true); } + // a-font-weight-009.svg let font_weight = match dom_font.weight { usvg::FontWeight::W100 => qt::FontWeight::Thin, usvg::FontWeight::W200 => qt::FontWeight::ExtraLight, @@ -147,6 +168,7 @@ fn init_font(dom_font: &usvg::Font) -> qt::Font { }; font.set_weight(font_weight); + // a-font-stretch-001.svg let font_stretch = match dom_font.stretch { usvg::FontStretch::Normal => qt::FontStretch::Unstretched, usvg::FontStretch::Narrower | diff --git a/src/backend_utils/text.rs b/src/backend_utils/text.rs index fc17b35..0c01b35 100644 --- a/src/backend_utils/text.rs +++ b/src/backend_utils/text.rs @@ -143,6 +143,11 @@ fn prepare_blocks<Font>( chunk_w += blocks[i].bbox.width; } + // a-text-anchor-001.svg + // a-text-anchor-002.svg + // a-text-anchor-003.svg + // a-text-anchor-005.svg + // a-text-anchor-006.svg let adx = process_text_anchor(chunk.anchor, chunk_w); for i in start_idx..blocks.len() { blocks[i].bbox.x -= adx; |