[librsvg] bgo#749415: Don't duplicate logic for deciding when to push discrete layers



commit cb7fd6b635a519e968ea67ec529651fe774abe26
Author: Menner <mik gmx org>
Date:   Sat Jan 2 09:35:52 2016 +0100

    bgo#749415: Don't duplicate logic for deciding when to push discrete layers
    
    rsvg_cairo_render_path() tried to avoid calling
    rsvg_cairo_push/pop_discrete_layer(), but the logic to decide whether
    to actually create an intermediate surface is best left in those
    functions.  With the duplicate/incorrect logic, text had incorrect
    spacing as a result.
    
    Also, remove an extra-old comment from when those functions were first
    implemented.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=749415

 rsvg-cairo-draw.c                           |   23 +++-------------
 tests/fixtures/reftests/bugs/749415-ref.png |  Bin 0 -> 22441 bytes
 tests/fixtures/reftests/bugs/749415.svg     |   38 +++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 19 deletions(-)
---
diff --git a/rsvg-cairo-draw.c b/rsvg-cairo-draw.c
index 37cdb56..4d8fbc2 100644
--- a/rsvg-cairo-draw.c
+++ b/rsvg-cairo-draw.c
@@ -458,16 +458,10 @@ rsvg_cairo_render_path (RsvgDrawingCtx * ctx, const cairo_path_t *path)
     RsvgCairoRender *render = RSVG_CAIRO_RENDER (ctx->render);
     RsvgState *state = rsvg_current_state (ctx);
     cairo_t *cr;
-    int need_tmpbuf = 0;
     RsvgBbox bbox;
     double backup_tolerance;
 
-    need_tmpbuf = ((state->fill != NULL) && (state->stroke != NULL) && state->opacity != 0xff)
-        || state->clip_path || state->mask || state->filter
-        || (state->comp_op != CAIRO_OPERATOR_OVER);
-
-    if (need_tmpbuf)
-        rsvg_cairo_push_discrete_layer (ctx);
+    rsvg_cairo_push_discrete_layer (ctx);
 
     cr = render->cr;
 
@@ -530,10 +524,7 @@ rsvg_cairo_render_path (RsvgDrawingCtx * ctx, const cairo_path_t *path)
 
         cairo_set_fill_rule (cr, state->fill_rule);
 
-        if (!need_tmpbuf)
-            opacity = (state->fill_opacity * state->opacity) / 255;
-        else
-            opacity = state->fill_opacity;
+        opacity = state->fill_opacity;
 
         _set_source_rsvg_paint_server (ctx,
                                        state->current_color,
@@ -548,10 +539,7 @@ rsvg_cairo_render_path (RsvgDrawingCtx * ctx, const cairo_path_t *path)
 
     if (state->stroke != NULL) {
         int opacity;
-        if (!need_tmpbuf)
-            opacity = (state->stroke_opacity * state->opacity) / 255;
-        else
-            opacity = state->stroke_opacity;
+        opacity = state->stroke_opacity;
 
         _set_source_rsvg_paint_server (ctx,
                                        state->current_color,
@@ -563,8 +551,7 @@ rsvg_cairo_render_path (RsvgDrawingCtx * ctx, const cairo_path_t *path)
 
     cairo_new_path (cr); /* clear the path in case stroke == fill == NULL; otherwise we leave it around from 
computing the bounding box */
 
-    if (need_tmpbuf)
-        rsvg_cairo_pop_discrete_layer (ctx);
+    rsvg_cairo_pop_discrete_layer (ctx);
 }
 
 void
@@ -724,8 +711,6 @@ rsvg_cairo_generate_mask (cairo_t * cr, RsvgMask * self, RsvgDrawingCtx * ctx, R
 static void
 rsvg_cairo_push_render_stack (RsvgDrawingCtx * ctx)
 {
-    /* XXX: Untested, probably needs help wrt filters */
-
     RsvgCairoRender *render = RSVG_CAIRO_RENDER (ctx->render);
     cairo_surface_t *surface;
     cairo_t *child_cr;
diff --git a/tests/fixtures/reftests/bugs/749415-ref.png b/tests/fixtures/reftests/bugs/749415-ref.png
new file mode 100644
index 0000000..91ce21e
Binary files /dev/null and b/tests/fixtures/reftests/bugs/749415-ref.png differ
diff --git a/tests/fixtures/reftests/bugs/749415.svg b/tests/fixtures/reftests/bugs/749415.svg
new file mode 100644
index 0000000..15865a5
--- /dev/null
+++ b/tests/fixtures/reftests/bugs/749415.svg
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg xmlns:svg="http://www.w3.org/2000/svg"; xmlns="http://www.w3.org/2000/svg"; version="1.1" 
width="643.56433" height="257.42575" id="svg2852">
+  <defs id="defs2854"/>
+  <g transform="translate(-58.921894,66.069669)" id="layer1">
+    <text x="69.253036" y="-29.653135" id="text3167" xml:space="preserve" 
style="font-size:32px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu
 Sans;-inkscape-font-specification:DejaVu Sans"><tspan x="69.253036" y="-29.653135" 
id="tspan3169">1</tspan></text>
+    <text x="69.253036" y="179.25775" id="text3167-4" xml:space="preserve" 
style="font-size:32px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu
 Sans;-inkscape-font-specification:DejaVu Sans"><tspan x="69.253036" y="179.25775" 
id="tspan3273">6</tspan></text>
+    <text x="69.253036" y="137.47557" id="text3167-48" xml:space="preserve" 
style="font-size:32px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu
 Sans;-inkscape-font-specification:DejaVu Sans"><tspan x="69.253036" y="137.47557" 
id="tspan3271">5</tspan></text>
+    <text x="69.253036" y="95.693436" id="text3167-45" xml:space="preserve" 
style="font-size:32px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu
 Sans;-inkscape-font-specification:DejaVu Sans"><tspan x="69.253036" y="95.693436" 
id="tspan3269">4</tspan></text>
+    <text x="69.253036" y="53.911259" id="text3167-7" xml:space="preserve" 
style="font-size:32px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu
 Sans;-inkscape-font-specification:DejaVu Sans"><tspan x="69.253036" y="53.911259" 
id="tspan3267">3</tspan></text>
+    <text x="69.253036" y="12.129059" id="text3167-2" xml:space="preserve" 
style="font-size:32px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu
 Sans;-inkscape-font-specification:DejaVu Sans"><tspan x="69.253036" y="12.129059" 
id="tspan3265">2</tspan></text>
+    <g transform="matrix(1.5,0,0,1.5,397.76677,54.817007)" id="g3300">
+      <rect width="4.8888898" height="4.6808534" x="-192.98616" y="-71.900017" id="rect2862-2-1-7-2-61" 
style="fill:#19b2ce;fill-opacity:1;fill-rule:nonzero;stroke:none"/>
+      <rect width="2" height="16" x="-87.267052" y="-182.85747" 
transform="matrix(0.70710678,-0.70710678,0.70710678,0.70710678,0,0)" id="rect2862-2-1-7-2-2-4-42" 
style="fill:#19b2ce;fill-opacity:1;fill-rule:nonzero;stroke:none"/>
+    </g>
+    <text x="164.86249" y="-28.66876" id="text3304" xml:space="preserve" 
style="font-size:32px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu
 Sans;-inkscape-font-specification:DejaVu Sans"><tspan x="164.86249" y="-28.66876" id="tspan3308">Tip mass 
0.5 kg</tspan></text>
+    <rect width="44.000343" height="14.666781" x="97.317757" y="-7.0793319" id="rect2862-2-1-7-4-4-6" 
style="fill:#ce9919;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"/>
+    <text x="161.62811" y="12.691559" id="text3304-7" xml:space="preserve" 
style="font-size:32px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu
 Sans;-inkscape-font-specification:DejaVu Sans"><tspan x="161.62811" y="12.691559" id="tspan3408">Liquid 
crystal device</tspan></text>
+    <rect width="28.712872" height="28.712872" x="104.96149" y="27.906385" id="rect3434" 
style="fill:#cdd9ec;fill-opacity:1;fill-rule:nonzero;stroke:none"/>
+    <text x="161.62811" y="54.473759" id="text3304-4" xml:space="preserve" 
style="font-size:32px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu
 Sans;-inkscape-font-specification:DejaVu Sans"><tspan x="161.62811" y="54.473759" id="tspan3461">Membrane 
7.5 um thick</tspan></text>
+    <rect width="26.400206" height="13.200104" x="106.11783" y="77.429321" id="rect2862-2-1-7-4-44-4-2-33" 
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#808080;stroke-width:0.73499995;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"/>
+    <text x="162.65936" y="96.677811" id="text3304-7-2" xml:space="preserve" 
style="font-size:32px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu
 Sans;-inkscape-font-specification:DejaVu Sans"><tspan x="162.65936" y="96.677811" id="tspan3542">Solar cells 
25 um thick</tspan></text>
+    <g transform="translate(-11.463337,-2.9292343)" id="g3588">
+      <path d="m 82.3125,172.71875 -32.21875,32.21875 2.8125,0 30.8125,-30.8125 -1.40625,-1.40625 z" 
transform="translate(58.921894,-65.07957)" id="rect2862-2-1-7-2-2-3-8-7" 
style="fill:#ceaa19;fill-opacity:1;fill-rule:nonzero;stroke:none"/>
+      <path d="m 92.21875,182.59375 -23.3125,23.34375 2.8125,0 21.90625,-21.90625 -1.40625,-1.4375 z" 
transform="translate(58.921894,-65.07957)" id="rect2862-2-1-7-2-2-3-5-9-9" 
style="fill:#1982ce;fill-opacity:1;fill-rule:nonzero;stroke:none"/>
+    </g>
+    <text x="162.47852" y="138.45995" id="text3304-3" xml:space="preserve" 
style="font-size:32px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu
 Sans;-inkscape-font-specification:DejaVu Sans"><tspan x="162.47852" y="138.45995" 
id="tspan3617">Tethers</tspan></text>
+    <path d="m 187.32394,828.41852 a 83.098595,83.098595 0 1 1 -166.197185,0 83.098595,83.098595 0 1 1 
166.197185,0 z" transform="matrix(0.24067796,0,0,0.24067796,94.233178,-31.78839)" id="path3939-9" 
style="fill:#0000ff;fill-opacity:1;fill-rule:nonzero;stroke:none"/>
+    <path d="m 187.32394,828.41852 a 83.098595,83.098595 0 1 1 -166.197185,0 83.098595,83.098595 0 1 1 
166.197185,0 z" transform="matrix(0.06016949,0,0,0.06016949,438.17176,92.436)" id="path3939-5-1-8" 
style="fill:#f3dd00;fill-opacity:1;fill-rule:nonzero;stroke:none"/>
+    <path d="m 187.32394,828.41852 a 83.098595,83.098595 0 1 1 -166.197185,0 83.098595,83.098595 0 1 1 
166.197185,0 z" transform="matrix(0.06016949,0,0,0.06016949,453.02324,75.60432)" id="path3939-5-6-6" 
style="fill:#f3dd00;fill-opacity:1;fill-rule:nonzero;stroke:none"/>
+    <path d="m 187.32394,828.41852 a 83.098595,83.098595 0 1 1 -166.197185,0 83.098595,83.098595 0 1 1 
166.197185,0 z" transform="matrix(0.06016949,0,0,0.06016949,424.31037,84.5152)" id="path3939-5-5-5" 
style="fill:#f3dd00;fill-opacity:1;fill-rule:nonzero;stroke:none"/>
+    <path d="m 187.32394,828.41852 a 83.098595,83.098595 0 1 1 -166.197185,0 83.098595,83.098595 0 1 1 
166.197185,0 z" transform="matrix(0.06016949,0,0,0.06016949,440.15195,61.74293)" id="path3939-5-0-0" 
style="fill:#f3dd00;fill-opacity:1;fill-rule:nonzero;stroke:none"/>
+    <text x="159.24414" y="179.82025" id="text3304-3-6" xml:space="preserve" 
style="font-size:32px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu
 Sans;-inkscape-font-specification:DejaVu Sans"><tspan x="159.24414" y="179.82025" id="tspan3684">Main 
body</tspan></text>
+    <text x="485.80463" y="138.83588" id="text3304-3-6-2" xml:space="preserve" 
style="font-size:32px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu
 Sans;-inkscape-font-specification:DejaVu Sans"><tspan x="485.80463" y="138.83588" 
id="tspan3711">Instruments</tspan></text>
+    <text x="392.2764" y="138.83588" id="text3167-4-8" xml:space="preserve" 
style="font-size:32px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu
 Sans;-inkscape-font-specification:DejaVu Sans"><tspan x="392.2764" y="138.83588" 
id="tspan3738">7</tspan></text>
+    <rect width="643.56433" height="257.42575" x="0" y="-0.99009901" 
transform="translate(58.921894,-65.07957)" id="rect3740" style="fill:none;stroke:none"/>
+  </g>
+</svg>
\ No newline at end of file


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]