Commit f87e7b02 authored by RazrFalcon's avatar RazrFalcon

Test comments removed.

parent d432954a
......@@ -30,7 +30,7 @@ travis-ci = { repository = "RazrFalcon/resvg" }
[dependencies]
log = "0.4.5"
#usvg = "0.2"
usvg = { git = "https://github.com/RazrFalcon/usvg", rev = "485a0fb" }
usvg = { git = "https://github.com/RazrFalcon/usvg", rev = "d0c0502" }
#usvg = { path = "../usvg" }
unicode-segmentation = "1.2.1"
# cairo backend
......
......@@ -26,22 +26,15 @@ 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);
......@@ -50,8 +43,6 @@ 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());
......@@ -60,10 +51,6 @@ 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);
}
usvg::NodeKind::Group(ref g) => {
......
......@@ -25,18 +25,9 @@ pub fn apply(
Some(ref fill) => {
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) => {
......@@ -54,17 +45,12 @@ 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),
}
}
None => {
// reset fill properties
cr.reset_source_rgba();
cr.set_fill_rule(cairo::FillRule::Winding);
}
......
......@@ -58,10 +58,6 @@ fn prepare_base<G>(
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,
......
......@@ -23,8 +23,6 @@ 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();
......
......@@ -270,10 +270,6 @@ 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);
......@@ -324,8 +320,6 @@ 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 {
......
......@@ -68,8 +68,6 @@ 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);
......
......@@ -25,18 +25,9 @@ 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) => {
......@@ -54,9 +45,6 @@ pub fn apply(
}
}
// a-stroke-linecap-001.svg
// a-stroke-linecap-002.svg
// a-stroke-linecap-003.svg
let linecap = match stroke.linecap {
usvg::LineCap::Butt => cairo::LineCap::Butt,
usvg::LineCap::Round => cairo::LineCap::Round,
......@@ -64,9 +52,6 @@ pub fn apply(
};
cr.set_line_cap(linecap);
// a-stroke-linejoin-001.svg
// a-stroke-linejoin-002.svg
// a-stroke-linejoin-003.svg
let linejoin = match stroke.linejoin {
usvg::LineJoin::Miter => cairo::LineJoin::Miter,
usvg::LineJoin::Round => cairo::LineJoin::Round,
......@@ -74,24 +59,15 @@ pub fn apply(
};
cr.set_line_join(linejoin);
// a-stroke-dasharray-001.svg
// a-stroke-dasharray-002.svg
// a-stroke-dashoffset-001.svg
// a-stroke-dashoffset-002.svg
// a-stroke-dashoffset-006.svg
match stroke.dasharray {
Some(ref list) => cr.set_dash(list, stroke.dashoffset),
None => cr.set_dash(&[], 0.0),
}
// a-stroke-miterlimit-002.svg
cr.set_miter_limit(stroke.miterlimit);
// a-stroke-width-002.svg
cr.set_line_width(stroke.width.value());
}
None => {
// a-stroke-006.svg
// reset stroke properties
cr.reset_source_rgba();
cr.set_line_cap(cairo::LineCap::Butt);
......
......@@ -136,9 +136,6 @@ 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);
......@@ -147,8 +144,6 @@ 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);
......@@ -170,8 +165,6 @@ 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();
......@@ -184,20 +177,8 @@ 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,
......@@ -205,14 +186,12 @@ 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,
......@@ -226,7 +205,6 @@ 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 |
......@@ -242,7 +220,6 @@ fn init_font(dom_font: &usvg::Font, dpi: f64) -> pango::FontDescription {
};
font.set_stretch(font_stretch);
// a-font-size-001.svg
let font_size = dom_font.size * (pango::SCALE as f64) / dpi * 72.0;
font.set_size(font_size as i32);
......
......@@ -23,21 +23,14 @@ 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));
}
......@@ -45,8 +38,6 @@ 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());
......
......@@ -28,15 +28,10 @@ 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);
}
usvg::Paint::Link(ref id) => {
// a-fill-opacity-003.svg
// a-fill-opacity-004.svg
if let Some(node) = tree.defs_by_id(id) {
match *node.borrow() {
usvg::NodeKind::LinearGradient(ref lg) => {
......
......@@ -48,10 +48,6 @@ 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,
......
......@@ -20,8 +20,6 @@ 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();
......
......@@ -245,10 +245,6 @@ 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);
......@@ -296,8 +292,6 @@ 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);
}
......
......@@ -51,10 +51,6 @@ 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;
......@@ -113,10 +109,6 @@ fn convert_path(
i += 1;
}
// 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),
......
......@@ -62,8 +62,6 @@ 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);
......
......@@ -28,19 +28,10 @@ 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);
}
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
let mut brush = qt::Brush::new();
if let Some(node) = tree.defs_by_id(id) {
......@@ -63,9 +54,6 @@ pub fn apply(
}
}
// a-stroke-linecap-001.svg
// a-stroke-linecap-002.svg
// a-stroke-linecap-003.svg
let linecap = match stroke.linecap {
usvg::LineCap::Butt => qt::LineCap::FlatCap,
usvg::LineCap::Round => qt::LineCap::RoundCap,
......@@ -73,9 +61,6 @@ pub fn apply(
};
pen.set_line_cap(linecap);
// a-stroke-linejoin-001.svg
// a-stroke-linejoin-002.svg
// a-stroke-linejoin-003.svg
let linejoin = match stroke.linejoin {
usvg::LineJoin::Miter => qt::LineJoin::MiterJoin,
usvg::LineJoin::Round => qt::LineJoin::RoundJoin,
......@@ -83,16 +68,9 @@ pub fn apply(
};
pen.set_line_join(linejoin);
// a-stroke-miterlimit-002.svg
pen.set_miter_limit(stroke.miterlimit);
// a-stroke-width-002.svg
pen.set_width(stroke.width.value());
// a-stroke-dasharray-001.svg
// a-stroke-dasharray-002.svg
// a-stroke-dashoffset-001.svg
// a-stroke-dashoffset-002.svg
// a-stroke-dashoffset-006.svg
if let Some(ref list) = stroke.dasharray {
pen.set_dash_offset(stroke.dashoffset);
pen.set_dash_array(list);
......@@ -101,7 +79,6 @@ pub fn apply(
p.set_pen(pen);
}
None => {
// a-stroke-006.svg
p.reset_pen();
}
}
......
......@@ -88,9 +88,6 @@ 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);
......@@ -99,8 +96,6 @@ 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);
......@@ -115,8 +110,6 @@ 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);
......@@ -128,20 +121,8 @@ 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,
......@@ -149,12 +130,10 @@ 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,
......@@ -168,7 +147,6 @@ 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 |
......@@ -184,7 +162,6 @@ fn init_font(dom_font: &usvg::Font) -> qt::Font {
};
font.set_stretch(font_stretch);
// a-font-size-001.svg
font.set_size(dom_font.size);
font
......
......@@ -145,11 +145,6 @@ 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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment