Commit e08ad166 authored by RazrFalcon's avatar RazrFalcon

Fixed 'filter' apply order.

parent 35400e5c
......@@ -21,14 +21,13 @@ pub fn apply(
bbox: Rect,
layers: &mut CairoLayers,
sub_cr: &cairo::Context,
cr: &cairo::Context,
) {
let mask_surface = try_opt!(layers.get(), ());
let mut mask_surface = mask_surface.borrow_mut();
{
let mask_cr = cairo::Context::new(&*mask_surface);
mask_cr.set_matrix(cr.get_matrix());
mask_cr.set_matrix(sub_cr.get_matrix());
let r = if mask.units == usvg::Units::ObjectBoundingBox {
mask.rect.transform(usvg::Transform::from_bbox(bbox))
......
......@@ -297,14 +297,30 @@ fn render_group_impl(
let sub_surface = layers.get()?;
let mut sub_surface = sub_surface.borrow_mut();
let sub_cr = cairo::Context::new(&*sub_surface);
sub_cr.set_matrix(cr.get_matrix());
let curr_ts = cr.get_matrix();
let bbox = {
let sub_cr = cairo::Context::new(&*sub_surface);
sub_cr.set_matrix(curr_ts);
let bbox = render_group(node, opt, layers, &sub_cr);
render_group(node, opt, layers, &sub_cr)
};
if let Some(ref id) = g.filter {
if let Some(filter_node) = node.tree().defs_by_id(id) {
if let usvg::NodeKind::Filter(ref filter) = *filter_node.borrow() {
let ts = usvg::Transform::from_native(&curr_ts);
filter::apply(filter, bbox, &ts, &mut *sub_surface);
}
}
}
if let Some(ref id) = g.clip_path {
if let Some(clip_node) = node.tree().defs_by_id(id) {
if let usvg::NodeKind::ClipPath(ref cp) = *clip_node.borrow() {
let sub_cr = cairo::Context::new(&*sub_surface);
sub_cr.set_matrix(curr_ts);
clippath::apply(&clip_node, cp, opt, bbox, layers, &sub_cr);
}
}
......@@ -313,16 +329,10 @@ fn render_group_impl(
if let Some(ref id) = g.mask {
if let Some(mask_node) = node.tree().defs_by_id(id) {
if let usvg::NodeKind::Mask(ref mask) = *mask_node.borrow() {
mask::apply(&mask_node, mask, opt, bbox, layers, &sub_cr, cr);
}
}
}
let sub_cr = cairo::Context::new(&*sub_surface);
sub_cr.set_matrix(curr_ts);
if let Some(ref id) = g.filter {
if let Some(filter_node) = node.tree().defs_by_id(id) {
if let usvg::NodeKind::Filter(ref filter) = *filter_node.borrow() {
let ts = usvg::Transform::from_native(&cr.get_matrix());
filter::apply(filter, bbox, &ts, &mut *sub_surface);
mask::apply(&mask_node, mask, opt, bbox, layers, &sub_cr);
}
}
}
......
......@@ -18,14 +18,13 @@ pub fn apply(
bbox: Rect,
layers: &mut QtLayers,
sub_p: &mut qt::Painter,
p: &qt::Painter,
) {
let mask_img = try_opt!(layers.get(), ());
let mut mask_img = mask_img.borrow_mut();
{
let mut mask_p = qt::Painter::new(&mut mask_img);
mask_p.set_transform(&p.get_transform());
mask_p.set_transform(&sub_p.get_transform());
let r = if mask.units == usvg::Units::ObjectBoundingBox {
mask.rect.transform(usvg::Transform::from_bbox(bbox))
......
......@@ -272,14 +272,30 @@ fn render_group_impl(
let sub_img = layers.get()?;
let mut sub_img = sub_img.borrow_mut();
let mut sub_p = qt::Painter::new(&mut sub_img);
sub_p.set_transform(&p.get_transform());
let curr_ts = p.get_transform();
let bbox = {
let mut sub_p = qt::Painter::new(&mut sub_img);
sub_p.set_transform(&curr_ts);
let bbox = render_group(node, opt, layers, &mut sub_p);
render_group(node, opt, layers, &mut sub_p)
};
if let Some(ref id) = g.filter {
if let Some(filter_node) = node.tree().defs_by_id(id) {
if let usvg::NodeKind::Filter(ref filter) = *filter_node.borrow() {
let ts = usvg::Transform::from_native(&curr_ts);
filter::apply(filter, bbox, &ts, &mut sub_img);
}
}
}
if let Some(ref id) = g.clip_path {
if let Some(clip_node) = node.tree().defs_by_id(id) {
if let usvg::NodeKind::ClipPath(ref cp) = *clip_node.borrow() {
let mut sub_p = qt::Painter::new(&mut sub_img);
sub_p.set_transform(&curr_ts);
clippath::apply(&clip_node, cp, opt, bbox, layers, &mut sub_p);
}
}
......@@ -288,18 +304,10 @@ fn render_group_impl(
if let Some(ref id) = g.mask {
if let Some(mask_node) = node.tree().defs_by_id(id) {
if let usvg::NodeKind::Mask(ref mask) = *mask_node.borrow() {
mask::apply(&mask_node, mask, opt, bbox, layers, &mut sub_p, p);
}
}
}
let mut sub_p = qt::Painter::new(&mut sub_img);
sub_p.set_transform(&curr_ts);
sub_p.end();
if let Some(ref id) = g.filter {
if let Some(filter_node) = node.tree().defs_by_id(id) {
if let usvg::NodeKind::Filter(ref filter) = *filter_node.borrow() {
let ts = usvg::Transform::from_native(&p.get_transform());
filter::apply(filter, bbox, &ts, &mut sub_img);
mask::apply(&mask_node, mask, opt, bbox, layers, &mut sub_p);
}
}
}
......
e-filter-052.svg
e-filter-053.svg
e-filter-054.svg
e-filter-052.svg
e-filter-053.svg
e-filter-054.svg
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