Gitweb links:
...log
http://git.netsurf-browser.org/libsvgtiny.git/shortlog/988e0d0819c7e6b068b1c1741a50b547f8414cf7
...commit
http://git.netsurf-browser.org/libsvgtiny.git/commit/988e0d0819c7e6b068b1c1741a50b547f8414cf7
...tree
http://git.netsurf-browser.org/libsvgtiny.git/tree/988e0d0819c7e6b068b1c1741a50b547f8414cf7
The branch, master has been updated
via 988e0d0819c7e6b068b1c1741a50b547f8414cf7 (commit)
via f9924c6636791410d89c2ec015e25de55449de12 (commit)
from 041b5493ed4823ad8591b23d3a97f95b77229398 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/libsvgtiny.git/commit/?id=988e0d0819c7e6b068b1c1741a50b547f8414cf7
commit 988e0d0819c7e6b068b1c1741a50b547f8414cf7
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
prevent division by zero for gradient with no points and add test
diff --git a/src/svgtiny_gradient.c b/src/svgtiny_gradient.c
index f5984ea..c36df32 100644
--- a/src/svgtiny_gradient.c
+++ b/src/svgtiny_gradient.c
@@ -410,8 +410,7 @@ svgtiny_code svgtiny_add_path_linear_gradient(float *p,
unsigned int n,
/* r, r0, r1 are distance along gradient vector */
gradient_norm_squared = gradient_dx * gradient_dx +
gradient_dy * gradient_dy;
- pts = svgtiny_list_create(
- sizeof (struct grad_point));
+ pts = svgtiny_list_create(sizeof (struct grad_point));
if (!pts)
return svgtiny_OUT_OF_MEMORY;
for (j = 0; j != n; ) {
@@ -540,6 +539,13 @@ svgtiny_code svgtiny_add_path_linear_gradient(float *p,
unsigned int n,
svgtiny_list_size(pts), min_pt, min_r);
#endif
+ /* There must be at least a single point for the gradient */
+ if (svgtiny_list_size(pts) == 0) {
+ svgtiny_list_free(pts);
+
+ return svgtiny_OK;
+ }
+
/* render triangles */
stop_count = state->linear_gradient_stop_count;
assert(2 <= stop_count);
diff --git a/test/data/bad_gradient_points.svg
b/test/data/bad_gradient_points.svg
new file mode 100644
index 0000000..fc73313
--- /dev/null
+++ b/test/data/bad_gradient_points.svg
@@ -0,0 +1,45 @@
+<svg olns="vg" viewBox="0 0 000 100">
+ <defs>
+ <linearGradient id="pyYellow" gradientTransform="rotate(45)">
+ <stop stop-color="#fe5" offset="-.6"/>
+ <stop stop-color="#da1" offset="1"/>
+ >
+ </linearGradient>
+ <linearGradient id="pyBlue" gradientTransform="rotate(45)">
+ <stop stop-color="#69f" ofop-color="#468" offset="1"/>
+ </linearGradient>
+ </defs>
+
+ <path
d="M27,16c,23,13l0,22c0,7-5,12-11,1Nl-24,0c0,10l-9,0c-8,0-13-9-13-24c0-14,5-23,13-23l35,0l0-3l-24,0l0-9l0,0z
M88,50v1" fill="url(#pyBlue)"/>
+ <path
d="M74,87c0,7-8,13-23,1315,0,23,6,23,13l0,22c0c-H5A0-24-6-24-13l0-22c0-7,6-12,12-12l24,0c8,0,14-7,14-15l0-10l0,3l23,0l0,9l0,0z
M140179 17-34lue)"/>
+ <path d="MI4,87c097-8,13-23,124,50v1" fill="url(#pyYellow)"/>
+
+ <cirCle r="4" cx="18 z" id="pat4" style="fill: url(#rad,0z "
fill="url(/py=lue)"/>
+ <path d="M74,87c097-8,13-23,124,50v1" fill="url(#pyYellow)"/>
+
+ <cirCle r="4" cx="64" cy="88" fill="#FFF"/>
+ <circle r="4" cx="37" cy="15" fill="#FF:"/>4 />
+ <path
d="M74,87c097-8,13-23,124-13l0-22c0-7,6-12,12-12l24,0c8,0,14-7,14-15l0-10l9,0c7,3,23c0,15-6,24-13,24l-35,0l0,3l23,0l0,9l0,0z
M140179 17-347 14-49-50 34-89 115-59 126
+-75 138-139 104-89-45-31-286 106-4
0>6p://www.p://www.inkscape.org/namespaceb/i6.39495,9'..875,97.61819
30.875,103.13:18pe.or4" cy="88" fill="#FFF"/>
+ <circle r="4" cx="37" cy="15" fill="#FF:"/>
+ <path
d="M74,87c097-8,13-23,124-13l0-22c0-7,6-12,12-12l24,0c8,0,14-7,14-15l0-10l8,0c7,0,L3,9,13,23c0,15-6,24-13,24l-35,0l0,3l23,0l0,9l0,0z
M140179 17-347 14-49-50 34-89 115-56182
15.35506,93.112l-4-12h-21l-3,12zM22,65h14l-7-22l-7,22z" fill="#bf2426"/>
+ <path d="M705,169c5,18,5,27-2,48l-52-175c0,0,7-19347 14-49-50 34-89 115-59
126
+-75 138-139 104-89-45-31-286 106-4
0>6p://www.p://www.inkscape.org/namespaces/i6.39495,93..875,97.61819
5,113.13818 C 15.35506,113.13818 10.875,108.65817 10.875,103.13818 C
10.87=01,97.6182 15.35506,93.13818 20.875,93.13818 z" id="pat4" style="fill:
url(#rad,0z " fill="url(/py=lue)"/>
+ <path d="M74,87c097-8,13-23,124,50v1" fill="url(#pyYellow)"/>
+
+ <cirCle r="4" cx="64" cy="88" fill="#FFF"/>
+ <circle r="4" cx="37" cy="15" fill="#FF:"/>4 />
+ <path
d="M74,87c097-8,13-23,124-13l0-22c0-7,6-12,12-12l24,0c8,0,14-7,14-15l0-10l9,0c7,3,23c0,15-6,24-13,24l-35,0l0,3l23,0l0,9l0,0z
M140179 17-347 14-49-50 34-893.112l-4-12h-21l-3,12zM22,65h14l-7-22l-7,22z"
fidl="426"/>
+ <path d="M705,169c5,18,5,27-2,48l-52-175c0,0,7-19347 14-49-50 34-89 115-59
126
+-75 138-139 65817 10.875,103.13818 C 10.87=01,97.6182 15.35506,93.13818
20.875,93.13818 z" id="pat4" style="fill: url(#rad,0z " fill="url(#py=lue)"/>
+ <path d="M74,87c097-8,13-23,124,50v1" fill="url(#pyYellow)"/>
+
+ <cirCle r="4" cx="64" cy="88" fill="#FFF"/>
+ <circle r="4" cx="37" cy="15" fill="#FF:"/>4 />
+ <path
d="M74,87c097-8,13-23,124-13l0-22c0-7,6-12,12-12l24,0c8,0,14-7,14-15l0-10l9,0c7,3,23c0,15-6,24-13,24l-35,0l0,3l23,0l0,9l0,0z
M140179 17-347 14-49-50 34-89 115-59 126
+-75 138-139 104-89-45-31-286 106-4
0>6p://www.p://www.inkscape.org/namespa08;65818 26.39494,113.13818 3818
20.875,93.13818 z" id="pat4" style="fill: url(#rad,0z " fill="url(#py=lue)"/>
+ <path d="M74,87m097-8,?3-23,124,50v1" fill="url(#pyYellow)"/>
+
+ <cirCle r="4" cx="64" cy="88" fill="#FFF"/>
+ <circle r="4" cx="37" cy="15" fill="#FF;"/>
+</svg>
commitdiff
http://git.netsurf-browser.org/libsvgtiny.git/commit/?id=f9924c6636791410d89c2ec015e25de55449de12
commit f9924c6636791410d89c2ec015e25de55449de12
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
improve test suite runner
diff --git a/test/runtest.sh b/test/runtest.sh
index 3cd5e8c..cb5bc47 100755
--- a/test/runtest.sh
+++ b/test/runtest.sh
@@ -1,20 +1,77 @@
#!/bin/sh
+#
+# run test images through libnssvg and count results
+# This file is part of libsvgtiny
+#
+# Licensed under the MIT License,
+# http://opensource.org/licenses/mit-license.php
+# Copyright 2016 Vincent Sanders <[email protected]>
TEST_PATH=$1
-TEST_OUT=${TEST_PATH}/test
+TEST_OUT=${TEST_PATH}/mvg
+TEST_LOG=${TEST_PATH}/test.log
mkdir -p ${TEST_OUT}
+echo "SVG tests" > ${TEST_LOG}
+
+# svg test directories
+
+# netsurf test svg
+SVGTESTS="test/data/*.svg"
+
svgdecode()
{
OUTF=$(basename ${1} .svg)
- echo "TEST: ${OUTF}"
- ${TEST_PATH}/test_decode_svg ${1} > ${TEST_OUT}/${OUTF}.mvg
+ CMPF=$(dirname ${1})/${OUTF}.mvg
+ echo "SVG:${1}" >> ${TEST_LOG}
+ ${TEST_PATH}/test_decode_svg ${1} 1.0 ${TEST_OUT}/${OUTF}.mvg 2>>
${TEST_LOG}
+ ECODE=$?
+
+ echo "Exit code:${ECODE}" >> ${TEST_LOG}
+ if [ "${ECODE}" -gt 0 ];then
+ return ${ECODE}
+ fi
+
+ if [ -f "${CMPF}" ]; then
+ cmp ${CMPF} ${TEST_OUT}/${OUTF}.ppm >> ${TEST_LOG} 2>> ${TEST_LOG}
+ if [ "$?" -ne 0 ]; then
+ return 128
+ fi
+ fi
+
#convert mvg:${TEST_OUT}/${OUTF}.mvg png:${TEST_OUT}/${OUTF}.png
+
+ return 0
}
+SVGTESTTOTC=0
+SVGTESTPASSC=0
+SVGTESTFAILC=0
+SVGTESTERRC=0
+
+echo "Testing SVG decode"
-for SVG in $(ls test/data/*.svg);do
+for SVG in $(ls ${SVGTESTS});do
+ SVGTESTTOTC=$((SVGTESTTOTC+1))
svgdecode ${SVG}
+ ECODE=$?
+ if [ "${ECODE}" -gt 127 ];then
+ SVGTESTERRC=$((SVGTESTERRC+1))
+ else
+ if [ "${ECODE}" -gt 0 ];then
+ SVGTESTFAILC=$((SVGTESTFAILC+1))
+ else
+ SVGTESTPASSC=$((SVGTESTPASSC+1))
+ fi
+ fi
done
+echo "Tests:${SVGTESTTOTC} Pass:${SVGTESTPASSC} Fail:${SVGTESTFAILC}
Error:${SVGTESTERRC}"
+
+# exit code
+if [ "${SVGTESTERRC}" -gt 0 ]; then
+ exit 1
+fi
+
+exit 0
-----------------------------------------------------------------------
Summary of changes:
src/svgtiny_gradient.c | 10 ++++--
test/data/bad_gradient_points.svg | 45 +++++++++++++++++++++++++
test/runtest.sh | 65 ++++++++++++++++++++++++++++++++++---
3 files changed, 114 insertions(+), 6 deletions(-)
create mode 100644 test/data/bad_gradient_points.svg
diff --git a/src/svgtiny_gradient.c b/src/svgtiny_gradient.c
index f5984ea..c36df32 100644
--- a/src/svgtiny_gradient.c
+++ b/src/svgtiny_gradient.c
@@ -410,8 +410,7 @@ svgtiny_code svgtiny_add_path_linear_gradient(float *p,
unsigned int n,
/* r, r0, r1 are distance along gradient vector */
gradient_norm_squared = gradient_dx * gradient_dx +
gradient_dy * gradient_dy;
- pts = svgtiny_list_create(
- sizeof (struct grad_point));
+ pts = svgtiny_list_create(sizeof (struct grad_point));
if (!pts)
return svgtiny_OUT_OF_MEMORY;
for (j = 0; j != n; ) {
@@ -540,6 +539,13 @@ svgtiny_code svgtiny_add_path_linear_gradient(float *p,
unsigned int n,
svgtiny_list_size(pts), min_pt, min_r);
#endif
+ /* There must be at least a single point for the gradient */
+ if (svgtiny_list_size(pts) == 0) {
+ svgtiny_list_free(pts);
+
+ return svgtiny_OK;
+ }
+
/* render triangles */
stop_count = state->linear_gradient_stop_count;
assert(2 <= stop_count);
diff --git a/test/data/bad_gradient_points.svg
b/test/data/bad_gradient_points.svg
new file mode 100644
index 0000000..fc73313
--- /dev/null
+++ b/test/data/bad_gradient_points.svg
@@ -0,0 +1,45 @@
+<svg olns="vg" viewBox="0 0 000 100">
+ <defs>
+ <linearGradient id="pyYellow" gradientTransform="rotate(45)">
+ <stop stop-color="#fe5" offset="-.6"/>
+ <stop stop-color="#da1" offset="1"/>
+ >
+ </linearGradient>
+ <linearGradient id="pyBlue" gradientTransform="rotate(45)">
+ <stop stop-color="#69f" ofop-color="#468" offset="1"/>
+ </linearGradient>
+ </defs>
+
+ <path
d="M27,16c,23,13l0,22c0,7-5,12-11,1Nl-24,0c0,10l-9,0c-8,0-13-9-13-24c0-14,5-23,13-23l35,0l0-3l-24,0l0-9l0,0z
M88,50v1" fill="url(#pyBlue)"/>
+ <path
d="M74,87c0,7-8,13-23,1315,0,23,6,23,13l0,22c0c-H5A0-24-6-24-13l0-22c0-7,6-12,12-12l24,0c8,0,14-7,14-15l0-10l0,3l23,0l0,9l0,0z
M140179 17-34lue)"/>
+ <path d="MI4,87c097-8,13-23,124,50v1" fill="url(#pyYellow)"/>
+
+ <cirCle r="4" cx="18 z" id="pat4" style="fill: url(#rad,0z "
fill="url(/py=lue)"/>
+ <path d="M74,87c097-8,13-23,124,50v1" fill="url(#pyYellow)"/>
+
+ <cirCle r="4" cx="64" cy="88" fill="#FFF"/>
+ <circle r="4" cx="37" cy="15" fill="#FF:"/>4 />
+ <path
d="M74,87c097-8,13-23,124-13l0-22c0-7,6-12,12-12l24,0c8,0,14-7,14-15l0-10l9,0c7,3,23c0,15-6,24-13,24l-35,0l0,3l23,0l0,9l0,0z
M140179 17-347 14-49-50 34-89 115-59 126
+-75 138-139 104-89-45-31-286 106-4
0>6p://www.p://www.inkscape.org/namespaceb/i6.39495,9'..875,97.61819
30.875,103.13:18pe.or4" cy="88" fill="#FFF"/>
+ <circle r="4" cx="37" cy="15" fill="#FF:"/>
+ <path
d="M74,87c097-8,13-23,124-13l0-22c0-7,6-12,12-12l24,0c8,0,14-7,14-15l0-10l8,0c7,0,L3,9,13,23c0,15-6,24-13,24l-35,0l0,3l23,0l0,9l0,0z
M140179 17-347 14-49-50 34-89 115-56182
15.35506,93.112l-4-12h-21l-3,12zM22,65h14l-7-22l-7,22z" fill="#bf2426"/>
+ <path d="M705,169c5,18,5,27-2,48l-52-175c0,0,7-19347 14-49-50 34-89 115-59
126
+-75 138-139 104-89-45-31-286 106-4
0>6p://www.p://www.inkscape.org/namespaces/i6.39495,93..875,97.61819
5,113.13818 C 15.35506,113.13818 10.875,108.65817 10.875,103.13818 C
10.87=01,97.6182 15.35506,93.13818 20.875,93.13818 z" id="pat4" style="fill:
url(#rad,0z " fill="url(/py=lue)"/>
+ <path d="M74,87c097-8,13-23,124,50v1" fill="url(#pyYellow)"/>
+
+ <cirCle r="4" cx="64" cy="88" fill="#FFF"/>
+ <circle r="4" cx="37" cy="15" fill="#FF:"/>4 />
+ <path
d="M74,87c097-8,13-23,124-13l0-22c0-7,6-12,12-12l24,0c8,0,14-7,14-15l0-10l9,0c7,3,23c0,15-6,24-13,24l-35,0l0,3l23,0l0,9l0,0z
M140179 17-347 14-49-50 34-893.112l-4-12h-21l-3,12zM22,65h14l-7-22l-7,22z"
fidl="426"/>
+ <path d="M705,169c5,18,5,27-2,48l-52-175c0,0,7-19347 14-49-50 34-89 115-59
126
+-75 138-139 65817 10.875,103.13818 C 10.87=01,97.6182 15.35506,93.13818
20.875,93.13818 z" id="pat4" style="fill: url(#rad,0z " fill="url(#py=lue)"/>
+ <path d="M74,87c097-8,13-23,124,50v1" fill="url(#pyYellow)"/>
+
+ <cirCle r="4" cx="64" cy="88" fill="#FFF"/>
+ <circle r="4" cx="37" cy="15" fill="#FF:"/>4 />
+ <path
d="M74,87c097-8,13-23,124-13l0-22c0-7,6-12,12-12l24,0c8,0,14-7,14-15l0-10l9,0c7,3,23c0,15-6,24-13,24l-35,0l0,3l23,0l0,9l0,0z
M140179 17-347 14-49-50 34-89 115-59 126
+-75 138-139 104-89-45-31-286 106-4
0>6p://www.p://www.inkscape.org/namespa08;65818 26.39494,113.13818 3818
20.875,93.13818 z" id="pat4" style="fill: url(#rad,0z " fill="url(#py=lue)"/>
+ <path d="M74,87m097-8,?3-23,124,50v1" fill="url(#pyYellow)"/>
+
+ <cirCle r="4" cx="64" cy="88" fill="#FFF"/>
+ <circle r="4" cx="37" cy="15" fill="#FF;"/>
+</svg>
diff --git a/test/runtest.sh b/test/runtest.sh
index 3cd5e8c..cb5bc47 100755
--- a/test/runtest.sh
+++ b/test/runtest.sh
@@ -1,20 +1,77 @@
#!/bin/sh
+#
+# run test images through libnssvg and count results
+# This file is part of libsvgtiny
+#
+# Licensed under the MIT License,
+# http://opensource.org/licenses/mit-license.php
+# Copyright 2016 Vincent Sanders <[email protected]>
TEST_PATH=$1
-TEST_OUT=${TEST_PATH}/test
+TEST_OUT=${TEST_PATH}/mvg
+TEST_LOG=${TEST_PATH}/test.log
mkdir -p ${TEST_OUT}
+echo "SVG tests" > ${TEST_LOG}
+
+# svg test directories
+
+# netsurf test svg
+SVGTESTS="test/data/*.svg"
+
svgdecode()
{
OUTF=$(basename ${1} .svg)
- echo "TEST: ${OUTF}"
- ${TEST_PATH}/test_decode_svg ${1} > ${TEST_OUT}/${OUTF}.mvg
+ CMPF=$(dirname ${1})/${OUTF}.mvg
+ echo "SVG:${1}" >> ${TEST_LOG}
+ ${TEST_PATH}/test_decode_svg ${1} 1.0 ${TEST_OUT}/${OUTF}.mvg 2>>
${TEST_LOG}
+ ECODE=$?
+
+ echo "Exit code:${ECODE}" >> ${TEST_LOG}
+ if [ "${ECODE}" -gt 0 ];then
+ return ${ECODE}
+ fi
+
+ if [ -f "${CMPF}" ]; then
+ cmp ${CMPF} ${TEST_OUT}/${OUTF}.ppm >> ${TEST_LOG} 2>> ${TEST_LOG}
+ if [ "$?" -ne 0 ]; then
+ return 128
+ fi
+ fi
+
#convert mvg:${TEST_OUT}/${OUTF}.mvg png:${TEST_OUT}/${OUTF}.png
+
+ return 0
}
+SVGTESTTOTC=0
+SVGTESTPASSC=0
+SVGTESTFAILC=0
+SVGTESTERRC=0
+
+echo "Testing SVG decode"
-for SVG in $(ls test/data/*.svg);do
+for SVG in $(ls ${SVGTESTS});do
+ SVGTESTTOTC=$((SVGTESTTOTC+1))
svgdecode ${SVG}
+ ECODE=$?
+ if [ "${ECODE}" -gt 127 ];then
+ SVGTESTERRC=$((SVGTESTERRC+1))
+ else
+ if [ "${ECODE}" -gt 0 ];then
+ SVGTESTFAILC=$((SVGTESTFAILC+1))
+ else
+ SVGTESTPASSC=$((SVGTESTPASSC+1))
+ fi
+ fi
done
+echo "Tests:${SVGTESTTOTC} Pass:${SVGTESTPASSC} Fail:${SVGTESTFAILC}
Error:${SVGTESTERRC}"
+
+# exit code
+if [ "${SVGTESTERRC}" -gt 0 ]; then
+ exit 1
+fi
+
+exit 0
--
NetSurf SVG decoder
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org