diff --git a/echosvg-svg-dom/src/main/java/io/sf/carte/echosvg/dom/svg/AbstractSVGTransformList.java b/echosvg-svg-dom/src/main/java/io/sf/carte/echosvg/dom/svg/AbstractSVGTransformList.java index 947951713..5129e83fd 100644 --- a/echosvg-svg-dom/src/main/java/io/sf/carte/echosvg/dom/svg/AbstractSVGTransformList.java +++ b/echosvg-svg-dom/src/main/java/io/sf/carte/echosvg/dom/svg/AbstractSVGTransformList.java @@ -287,7 +287,7 @@ public void assign(SVGTransform transform) { setScale(matrix.getA(), matrix.getD()); break; case SVGTransform.SVG_TRANSFORM_ROTATE: - if (matrix.getE() == 0.0f) { + if (matrix.getE() == 0f && matrix.getF() == 0f) { rotate(transform.getAngle()); } else { angleOnly = false; diff --git a/echosvg-test/src/test/java/io/sf/carte/echosvg/test/svg/SVGAnimationRenderingAccuracyTest.java b/echosvg-test/src/test/java/io/sf/carte/echosvg/test/svg/SVGAnimationRenderingAccuracyTest.java new file mode 100644 index 000000000..c6a0f37c6 --- /dev/null +++ b/echosvg-test/src/test/java/io/sf/carte/echosvg/test/svg/SVGAnimationRenderingAccuracyTest.java @@ -0,0 +1,54 @@ +/* + + See the NOTICE file distributed with this work for additional + information regarding copyright ownership. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + */ +package io.sf.carte.echosvg.test.svg; + +import io.sf.carte.echosvg.transcoder.SVGAbstractTranscoder; +import io.sf.carte.echosvg.transcoder.image.ImageTranscoder; + +/** + * Checks for regressions in rendering of a document with animations. + * + * @author For later modifications, see Git history. + * @version $Id$ + */ +public class SVGAnimationRenderingAccuracyTest extends RenderingTest { + + private float time; + + public SVGAnimationRenderingAccuracyTest(float time) { + super(); + this.time = time; + } + + @Override + protected String getImageSuffix() { + return (time == 0f) ? "" : "-t" + Float.toString(time); + } + + /** + * Returns the ImageTranscoder the Test should use + */ + @Override + ImageTranscoder getTestImageTranscoder() { + ImageTranscoder t = super.getTestImageTranscoder(); + t.addTranscodingHint(SVGAbstractTranscoder.KEY_SNAPSHOT_TIME, time); + return t; + } + +} diff --git a/echosvg-test/src/test/java/io/sf/carte/echosvg/test/svg/SamplesRenderingTest.java b/echosvg-test/src/test/java/io/sf/carte/echosvg/test/svg/SamplesRenderingTest.java index 1184d54d2..7e1995428 100644 --- a/echosvg-test/src/test/java/io/sf/carte/echosvg/test/svg/SamplesRenderingTest.java +++ b/echosvg-test/src/test/java/io/sf/carte/echosvg/test/svg/SamplesRenderingTest.java @@ -320,6 +320,12 @@ public void testSystemColors() throws TranscoderException, IOException { /* * Coordinates */ + @Test + public void testAnimRotateOrigin() throws TranscoderException, IOException { + float[] times = {0.5f, 1.5f, 1.52f, 3.5f}; + testAnim("samples/tests/spec/coordinates/animRotateOrigin.svg", times); + } + @Test public void testPercentagesAndUnits() throws TranscoderException, IOException { test("samples/tests/spec/coordinates/percentagesAndUnits.svg"); @@ -1710,6 +1716,14 @@ private void testResolutionPxMM(String file, float pxToMM) runner.runTest(0.000001f, 0.000001f); } + private void testAnim(String file, float[] times) throws TranscoderException, IOException { + for (float time : times) { + RenderingTest runner = new SVGAnimationRenderingAccuracyTest(time); + runner.setFile(file); + runner.runTest(0.000001f, 0.000001f); + } + } + /** * Dynamic test of the rendering of a SVG file. * diff --git a/samples/tests/spec/coordinates/animRotateOrigin.svg b/samples/tests/spec/coordinates/animRotateOrigin.svg new file mode 100644 index 000000000..7253f8080 --- /dev/null +++ b/samples/tests/spec/coordinates/animRotateOrigin.svg @@ -0,0 +1,49 @@ + + + + + + + + + + + Check animated transforms + + + + + + + + + + + + + + + + diff --git a/test-references/samples/tests/spec/coordinates/animRotateOrigin-t0.5.png b/test-references/samples/tests/spec/coordinates/animRotateOrigin-t0.5.png new file mode 100644 index 000000000..4b93c5e16 Binary files /dev/null and b/test-references/samples/tests/spec/coordinates/animRotateOrigin-t0.5.png differ diff --git a/test-references/samples/tests/spec/coordinates/animRotateOrigin-t1.5.png b/test-references/samples/tests/spec/coordinates/animRotateOrigin-t1.5.png new file mode 100644 index 000000000..4b93c5e16 Binary files /dev/null and b/test-references/samples/tests/spec/coordinates/animRotateOrigin-t1.5.png differ diff --git a/test-references/samples/tests/spec/coordinates/animRotateOrigin-t1.52.png b/test-references/samples/tests/spec/coordinates/animRotateOrigin-t1.52.png new file mode 100644 index 000000000..bf38825e5 Binary files /dev/null and b/test-references/samples/tests/spec/coordinates/animRotateOrigin-t1.52.png differ diff --git a/test-references/samples/tests/spec/coordinates/animRotateOrigin-t3.5.png b/test-references/samples/tests/spec/coordinates/animRotateOrigin-t3.5.png new file mode 100644 index 000000000..4b93c5e16 Binary files /dev/null and b/test-references/samples/tests/spec/coordinates/animRotateOrigin-t3.5.png differ