Commit d956bd85 authored by RazrFalcon's avatar RazrFalcon

Fixed invisible elements processing.

parent f87e7b02
......@@ -24,6 +24,7 @@ This changelog also contains important changes in dependencies.
- (cairo-backend) Rendering of a zero length subpath with a square cap.
- (resvg) Recursive SVG images via `image` tag.
- (resvg) Bbox calculation of the text with rotate.
- (resvg) Invisible elements processing.
- (qt-api) SVG from QByteArray loading when data is invalid.
- (usvg) `display` attribute processing.
- (usvg) Recursive `mask` resolving.
......
......@@ -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 = "d0c0502" }
usvg = { git = "https://github.com/RazrFalcon/usvg", rev = "14342a5" }
#usvg = { path = "../usvg" }
unicode-segmentation = "1.2.1"
# cairo backend
......
......@@ -21,6 +21,10 @@ pub fn draw(
opt: &Options,
cr: &cairo::Context,
) -> Rect {
if image.visibility != usvg::Visibility::Visible {
return image.view_box.rect;
}
if image.format == usvg::ImageFormat::SVG {
draw_svg(image, opt, cr);
} else {
......
......@@ -29,6 +29,10 @@ pub fn draw(
let bbox = utils::path_bbox(&path.segments, None, &usvg::Transform::default());
if path.visibility != usvg::Visibility::Visible {
return bbox;
}
fill::apply(tree, &path.fill, opt, bbox, cr);
if path.stroke.is_some() {
cr.fill_preserve();
......@@ -47,6 +51,9 @@ fn draw_path(
is_square_cap: bool,
cr: &cairo::Context,
) {
// Reset path, in case something was left from the previous paint pass.
cr.new_path();
let mut i = 0;
loop {
let subpath = get_subpath(i, segments);
......
......@@ -16,6 +16,10 @@ pub fn draw(
opt: &Options,
p: &qt::Painter,
) -> Rect {
if image.visibility != usvg::Visibility::Visible {
return image.view_box.rect;
}
if image.format == usvg::ImageFormat::SVG {
draw_svg(image, opt, p);
} else {
......
......@@ -32,6 +32,10 @@ pub fn draw(
let bbox = utils::path_bbox(&path.segments, None, &usvg::Transform::default());
if path.visibility != usvg::Visibility::Visible {
return bbox;
}
fill::apply(tree, &path.fill, opt, bbox, p);
stroke::apply(tree, &path.stroke, opt, bbox, p);
......
......@@ -12,6 +12,7 @@ use geom::*;
pub struct TextBlock<Font> {
pub text: String,
pub is_visible: bool,
pub bbox: Rect,
pub rotate: f64,
pub fill: Option<usvg::Fill>,
......@@ -41,7 +42,10 @@ pub fn draw_blocks<Font, Draw>(
let mut bbox = Rect::new_bbox();
for block in blocks {
bbox.expand(block.bbox);
draw(&block);
if block.is_visible {
draw(&block);
}
}
bbox
......@@ -126,6 +130,7 @@ fn prepare_blocks<Font>(
blocks.push(TextBlock {
text: c.to_string(),
is_visible: tspan.visibility == usvg::Visibility::Visible,
bbox,
rotate,
fill: tspan.fill.clone(),
......
a-opacity-002.svg
a-visibility-003.svg
a-visibility-004.svg
a-visibility-005.svg
a-visibility-006.svg
a-visibility-007.svg
e-use-022.svg
a-opacity-002.svg
a-visibility-003.svg
a-visibility-004.svg
a-visibility-005.svg
a-visibility-006.svg
a-visibility-007.svg
e-use-022.svg
......@@ -3,7 +3,9 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#[allow(unused_imports)] // for Rust >= 1.30
#[macro_use] extern crate gumdrop;
#[macro_use]
extern crate gumdrop;
extern crate fern;
extern crate log;
extern crate resvg;
......
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