[Swfdec] Branch 'as' - 4 commits - libswfdec/swfdec_color.c libswfdec/swfdec_movie_asprops.c libswfdec/swfdec_movie.c test/trace

Benjamin Otte company at kemper.freedesktop.org
Wed Jul 11 07:11:31 PDT 2007


 libswfdec/swfdec_color.c         |    1 +
 libswfdec/swfdec_movie.c         |    6 ++++--
 libswfdec/swfdec_movie_asprops.c |    4 ++++
 test/trace/Makefile.am           |    9 +++++++++
 test/trace/rotation2-5.swf       |binary
 test/trace/rotation2-5.swf.trace |   13 +++++++++++++
 test/trace/rotation2-6.swf       |binary
 test/trace/rotation2-6.swf.trace |   13 +++++++++++++
 test/trace/rotation2-7.swf       |binary
 test/trace/rotation2-7.swf.trace |   13 +++++++++++++
 test/trace/rotation2-8.swf       |binary
 test/trace/rotation2-8.swf.trace |   13 +++++++++++++
 test/trace/rotation2.as          |   30 ++++++++++++++++++++++++++++++
 13 files changed, 100 insertions(+), 2 deletions(-)

New commits:
diff-tree 4284f9fa4bd2608ca0abca3fad88dd13e8e5370c (from a636879d4df7c497599474abcac3aa4ec6b860d9)
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Jul 11 15:50:09 2007 +0200

    add a test for various rotations
    
    This test catches a segfault in previous versions

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 8ff2106..c2fc231 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -645,6 +645,15 @@ EXTRA_DIST = \
 	removesprite-depths-7.swf.trace \
 	rotation-5.swf \
 	rotation-5.swf.trace \
+	rotation2.as \
+	rotation2-5.swf \
+	rotation2-5.swf.trace \
+	rotation2-6.swf \
+	rotation2-6.swf.trace \
+	rotation2-7.swf \
+	rotation2-7.swf.trace \
+	rotation2-8.swf \
+	rotation2-8.swf.trace \
 	round-direction.as \
 	round-direction-5.swf \
 	round-direction-5.swf.trace \
diff --git a/test/trace/rotation2-5.swf b/test/trace/rotation2-5.swf
new file mode 100644
index 0000000..e4ecfb8
Binary files /dev/null and b/test/trace/rotation2-5.swf differ
diff --git a/test/trace/rotation2-5.swf.trace b/test/trace/rotation2-5.swf.trace
new file mode 100644
index 0000000..05c4ebf
--- /dev/null
+++ b/test/trace/rotation2-5.swf.trace
@@ -0,0 +1,13 @@
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
+undefined
diff --git a/test/trace/rotation2-6.swf b/test/trace/rotation2-6.swf
new file mode 100644
index 0000000..98e37b6
Binary files /dev/null and b/test/trace/rotation2-6.swf differ
diff --git a/test/trace/rotation2-6.swf.trace b/test/trace/rotation2-6.swf.trace
new file mode 100644
index 0000000..b59d36e
--- /dev/null
+++ b/test/trace/rotation2-6.swf.trace
@@ -0,0 +1,13 @@
+0
+0
+NaN
+NaN
+127
+3.14159265358979
+0
+0
+-179
+179
+180
+-180
+-180
diff --git a/test/trace/rotation2-7.swf b/test/trace/rotation2-7.swf
new file mode 100644
index 0000000..d487d0a
Binary files /dev/null and b/test/trace/rotation2-7.swf differ
diff --git a/test/trace/rotation2-7.swf.trace b/test/trace/rotation2-7.swf.trace
new file mode 100644
index 0000000..b59d36e
--- /dev/null
+++ b/test/trace/rotation2-7.swf.trace
@@ -0,0 +1,13 @@
+0
+0
+NaN
+NaN
+127
+3.14159265358979
+0
+0
+-179
+179
+180
+-180
+-180
diff --git a/test/trace/rotation2-8.swf b/test/trace/rotation2-8.swf
new file mode 100644
index 0000000..75468f4
Binary files /dev/null and b/test/trace/rotation2-8.swf differ
diff --git a/test/trace/rotation2-8.swf.trace b/test/trace/rotation2-8.swf.trace
new file mode 100644
index 0000000..b59d36e
--- /dev/null
+++ b/test/trace/rotation2-8.swf.trace
@@ -0,0 +1,13 @@
+0
+0
+NaN
+NaN
+127
+3.14159265358979
+0
+0
+-179
+179
+180
+-180
+-180
diff --git a/test/trace/rotation2.as b/test/trace/rotation2.as
new file mode 100644
index 0000000..9ac5a5b
--- /dev/null
+++ b/test/trace/rotation2.as
@@ -0,0 +1,30 @@
+// makeswf -v 7 -s 200x150 -r 1 -o rotation2.swf rotation2.as
+
+createEmptyMovieClip ("foo", 0);
+trace (foo._rotation);
+foo._rotation = NaN;
+trace (foo._rotation);
+foo._rotation = Infinity;
+trace (foo._rotation);
+foo._rotation = -Infinity;
+trace (foo._rotation);
+foo._rotation = 12345467890;
+trace (foo._rotation);
+foo._rotation = Math.PI;
+trace (foo._rotation);
+foo._rotation = -360;
+trace (foo._rotation);
+foo._rotation = 360;
+trace (foo._rotation);
+foo._rotation = 181;
+trace (foo._rotation);
+foo._rotation = -181;
+trace (foo._rotation);
+foo._rotation = 180;
+trace (foo._rotation);
+foo._rotation = -180;
+trace (foo._rotation);
+foo._rotation = NaN;
+trace (foo._rotation);
+
+loadMovie ("FSCommand:quit", "");
diff-tree a636879d4df7c497599474abcac3aa4ec6b860d9 (from 772e8f1e4abc0574f7ccf766ccc3c08f33ca8b1d)
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Jul 11 15:33:02 2007 +0200

    don't modify rotation when trying to set it to NaN

diff --git a/libswfdec/swfdec_movie_asprops.c b/libswfdec/swfdec_movie_asprops.c
index 8a1518f..80a5638 100644
--- a/libswfdec/swfdec_movie_asprops.c
+++ b/libswfdec/swfdec_movie_asprops.c
@@ -294,6 +294,10 @@ mc_rotation_set (SwfdecMovie *movie, con
 
   /* FIXME: Flash 4 handles this differently */
   d = swfdec_as_value_to_number (SWFDEC_AS_OBJECT (movie)->context, val);
+  if (isnan (d)) {
+    SWFDEC_WARNING ("setting rotation to NaN - not allowed");
+    return;
+  }
   d = fmod (d, 360.0);
   if (d > 180.0)
     d -= 360.0;
diff-tree 772e8f1e4abc0574f7ccf766ccc3c08f33ca8b1d (from 2a8fa0ba21a086ca7d1b73adaca2920ff9c6a4e5)
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Jul 11 15:30:36 2007 +0200

    assert a valid matrix when inverting

diff --git a/libswfdec/swfdec_color.c b/libswfdec/swfdec_color.c
index 83be167..e609e53 100644
--- a/libswfdec/swfdec_color.c
+++ b/libswfdec/swfdec_color.c
@@ -196,6 +196,7 @@ swfdec_matrix_ensure_invertible (cairo_m
   if (inverse == NULL)
     inverse = &tmp;
   
+  g_assert (isfinite (matrix->xx) && isfinite (matrix->yx) && isfinite (matrix->xy) && isfinite (matrix->yy));
   *inverse = *matrix;
   while (cairo_matrix_invert (inverse)) {
     SWFDEC_INFO ("matrix not invertible, adding epsilon to smallest member");
diff-tree 2a8fa0ba21a086ca7d1b73adaca2920ff9c6a4e5 (from 882b9ce2a53d333556ae7855b92f8bb5060c438d)
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Jul 11 15:30:21 2007 +0200

    only rotate if the rotation is finite
    
    NaN is a valid rotation value, d'oh

diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index 98cb397..3c2462f 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -152,8 +152,10 @@ swfdec_movie_update_matrix (SwfdecMovie 
   d = movie->xscale / swfdec_matrix_get_xscale (&movie->original_transform);
   e = movie->yscale / swfdec_matrix_get_yscale (&movie->original_transform);
   cairo_matrix_scale (&movie->matrix, d, e);
-  d = movie->rotation - swfdec_matrix_get_rotation (&movie->original_transform);
-  cairo_matrix_rotate (&movie->matrix, d * G_PI / 180);
+  if (isfinite (movie->rotation)) {
+    d = movie->rotation - swfdec_matrix_get_rotation (&movie->original_transform);
+    cairo_matrix_rotate (&movie->matrix, d * G_PI / 180);
+  }
   swfdec_matrix_ensure_invertible (&movie->matrix, &movie->inverse_matrix);
 
   swfdec_movie_update_extents (movie);


More information about the Swfdec mailing list