[Swfdec] 4 commits - libswfdec/swfdec_movie.c libswfdec/swfdec_movie.h libswfdec/swfdec_resource.c test/image test/trace
Benjamin Otte
company at kemper.freedesktop.org
Tue Nov 20 03:40:45 PST 2007
libswfdec/swfdec_movie.c | 32 +++++++++++++++-
libswfdec/swfdec_movie.h | 6 +++
libswfdec/swfdec_resource.c | 4 +-
test/image/Makefile.am | 9 ++++
test/image/mask-different-parent-5.swf |binary
test/image/mask-different-parent-5.swf.png |binary
test/image/mask-different-parent-6.swf |binary
test/image/mask-different-parent-6.swf.png |binary
test/image/mask-different-parent-7.swf |binary
test/image/mask-different-parent-7.swf.png |binary
test/image/mask-different-parent-8.swf |binary
test/image/mask-different-parent-8.swf.png |binary
test/image/mask-different-parent.as | 30 +++++++++++++++
test/trace/Makefile.am | 6 +++
test/trace/moviecliploader-known-image-size-7.swf |binary
test/trace/moviecliploader-known-image-size-7.swf.trace | 2 +
test/trace/moviecliploader-known-image-size-8.swf |binary
test/trace/moviecliploader-known-image-size-8.swf.trace | 2 +
test/trace/moviecliploader-known-image-size.as | 10 +++++
test/trace/swfdec.jpg |binary
20 files changed, 98 insertions(+), 3 deletions(-)
New commits:
commit 169db248bb4b38d1a58bf2400ce5260212362de2
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Nov 20 12:40:19 2007 +0100
add a testcase for masking with a movie that has a completely different parent
diff --git a/test/image/Makefile.am b/test/image/Makefile.am
index ada45e9..bf4e192 100644
--- a/test/image/Makefile.am
+++ b/test/image/Makefile.am
@@ -84,6 +84,15 @@ EXTRA_DIST = \
mask-and-clip-8-8.swf.png \
mask-and-clip-9-8.swf \
mask-and-clip-9-8.swf.png \
+ mask-different-parent.as \
+ mask-different-parent-5.swf \
+ mask-different-parent-5.swf.png \
+ mask-different-parent-6.swf \
+ mask-different-parent-6.swf.png \
+ mask-different-parent-7.swf \
+ mask-different-parent-7.swf.png \
+ mask-different-parent-8.swf \
+ mask-different-parent-8.swf.png \
mask-remove-clip.as \
mask-remove-clip-5.swf \
mask-remove-clip-5.swf.png \
diff --git a/test/image/mask-different-parent-5.swf b/test/image/mask-different-parent-5.swf
new file mode 100644
index 0000000..415a0fe
Binary files /dev/null and b/test/image/mask-different-parent-5.swf differ
diff --git a/test/image/mask-different-parent-5.swf.png b/test/image/mask-different-parent-5.swf.png
new file mode 100644
index 0000000..96f62a7
Binary files /dev/null and b/test/image/mask-different-parent-5.swf.png differ
diff --git a/test/image/mask-different-parent-6.swf b/test/image/mask-different-parent-6.swf
new file mode 100644
index 0000000..328f71f
Binary files /dev/null and b/test/image/mask-different-parent-6.swf differ
diff --git a/test/image/mask-different-parent-6.swf.png b/test/image/mask-different-parent-6.swf.png
new file mode 100644
index 0000000..35887f6
Binary files /dev/null and b/test/image/mask-different-parent-6.swf.png differ
diff --git a/test/image/mask-different-parent-7.swf b/test/image/mask-different-parent-7.swf
new file mode 100644
index 0000000..d1e53a5
Binary files /dev/null and b/test/image/mask-different-parent-7.swf differ
diff --git a/test/image/mask-different-parent-7.swf.png b/test/image/mask-different-parent-7.swf.png
new file mode 100644
index 0000000..fd2c78d
Binary files /dev/null and b/test/image/mask-different-parent-7.swf.png differ
diff --git a/test/image/mask-different-parent-8.swf b/test/image/mask-different-parent-8.swf
new file mode 100644
index 0000000..dfa9ac1
Binary files /dev/null and b/test/image/mask-different-parent-8.swf differ
diff --git a/test/image/mask-different-parent-8.swf.png b/test/image/mask-different-parent-8.swf.png
new file mode 100644
index 0000000..ded8bd5
Binary files /dev/null and b/test/image/mask-different-parent-8.swf.png differ
diff --git a/test/image/mask-different-parent.as b/test/image/mask-different-parent.as
new file mode 100644
index 0000000..51f35dc
--- /dev/null
+++ b/test/image/mask-different-parent.as
@@ -0,0 +1,30 @@
+// makeswf -v 7 -s 200x150 -r 1 -o mask-different-parent.swf mask-different-parent.as
+
+rectangle = function (mc, color, x, y, w, h)
+{
+ mc.beginFill (color);
+ mc.moveTo (x, y);
+ mc.lineTo (x, y + h);
+ mc.lineTo (x + w, y + h);
+ mc.lineTo (x + w, y);
+ mc.lineTo (x, y);
+ mc.endFill ();
+};
+
+createEmptyMovieClip ("a", 0);
+a.createEmptyMovieClip ("a", 0);
+a.a.createEmptyMovieClip ("a", 0);
+a.a.a.createEmptyMovieClip ("a", 0);
+a._xscale = 50;
+a._yscale = 50;
+a.a._x = 50;
+a.a._y = 50;
+a.a.a._xscale = 200;
+a.a.a._yscale = 200;
+rectangle (a.a.a.a, 0xFF0000, 0, 0, 100, 100);
+
+createEmptyMovieClip ("b", 1);
+rectangle (b, 0xFF, 0, 0, 100, 100);
+
+b.setMask (a.a.a.a);
+
commit 65a41812cc3db14b5e41a2a62dee9361fc0707ec
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Nov 20 12:28:16 2007 +0100
add test that tests image size is known in onLoadInit
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 22c2c3f..715e7bf 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -1358,6 +1358,11 @@ EXTRA_DIST = \
moviecliploader-getprogress-7.swf.trace \
moviecliploader-getprogress-8.swf \
moviecliploader-getprogress-8.swf.trace \
+ moviecliploader-known-image-size.as \
+ moviecliploader-known-image-size-7.swf \
+ moviecliploader-known-image-size-7.swf.trace \
+ moviecliploader-known-image-size-8.swf \
+ moviecliploader-known-image-size-8.swf.trace \
moviecliploader-properties.as \
moviecliploader-properties-5.swf \
moviecliploader-properties-5.swf.trace \
@@ -2431,6 +2436,7 @@ EXTRA_DIST = \
super-this-7.swf.trace \
super-this-8.swf \
super-this-8.swf.trace \
+ swfdec.jpg \
system-capabilities-query.as \
system-capabilities-query-5.swf \
system-capabilities-query-5.swf.trace \
diff --git a/test/trace/moviecliploader-known-image-size-7.swf b/test/trace/moviecliploader-known-image-size-7.swf
new file mode 100644
index 0000000..e9dcdb6
Binary files /dev/null and b/test/trace/moviecliploader-known-image-size-7.swf differ
diff --git a/test/trace/moviecliploader-known-image-size-7.swf.trace b/test/trace/moviecliploader-known-image-size-7.swf.trace
new file mode 100644
index 0000000..6461e6b
--- /dev/null
+++ b/test/trace/moviecliploader-known-image-size-7.swf.trace
@@ -0,0 +1,2 @@
+Check that image size is known in onLoadInit
+150 / 150
diff --git a/test/trace/moviecliploader-known-image-size-8.swf b/test/trace/moviecliploader-known-image-size-8.swf
new file mode 100644
index 0000000..7122d18
Binary files /dev/null and b/test/trace/moviecliploader-known-image-size-8.swf differ
diff --git a/test/trace/moviecliploader-known-image-size-8.swf.trace b/test/trace/moviecliploader-known-image-size-8.swf.trace
new file mode 100644
index 0000000..6461e6b
--- /dev/null
+++ b/test/trace/moviecliploader-known-image-size-8.swf.trace
@@ -0,0 +1,2 @@
+Check that image size is known in onLoadInit
+150 / 150
diff --git a/test/trace/moviecliploader-known-image-size.as b/test/trace/moviecliploader-known-image-size.as
new file mode 100644
index 0000000..6faba44
--- /dev/null
+++ b/test/trace/moviecliploader-known-image-size.as
@@ -0,0 +1,10 @@
+// makeswf -v 7 -s 200x150 -r 1 -o moviecliploader-known-image-size.swf moviecliploader-known-image-size.as
+
+trace ("Check that image size is known in onLoadInit");
+createEmptyMovieClip ("a", 1);
+l = new MovieClipLoader ();
+l.onLoadInit = function (m) {
+ trace (m._width + " / " + m._height);
+ loadMovie ("fscommand:quit", "");
+};
+l.loadClip ("swfdec.jpg", "a");
diff --git a/test/trace/swfdec.jpg b/test/trace/swfdec.jpg
new file mode 100644
index 0000000..a3cc6e4
Binary files /dev/null and b/test/trace/swfdec.jpg differ
commit 101fd4fa1ce5141adc410b49123da90bf4cec459
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Nov 20 11:56:56 2007 +0100
initialize movieclip before calling onLoadInit
This is required so that _width and _height properties work correctly
diff --git a/libswfdec/swfdec_resource.c b/libswfdec/swfdec_resource.c
index 8a17d9e..02a63b3 100644
--- a/libswfdec/swfdec_resource.c
+++ b/libswfdec/swfdec_resource.c
@@ -556,8 +556,6 @@ swfdec_resource_emit_on_load_init (SwfdecResource *resource)
if (resource->state != SWFDEC_RESOURCE_COMPLETE)
return FALSE;
- swfdec_resource_emit_signal (resource, SWFDEC_AS_STR_onLoadInit, FALSE, NULL, 0);
- resource->state = SWFDEC_RESOURCE_DONE;
if (resource->movie && SWFDEC_IS_IMAGE_DECODER (resource->decoder)) {
SwfdecImage *image = SWFDEC_IMAGE_DECODER (resource->decoder)->image;
if (image) {
@@ -565,6 +563,8 @@ swfdec_resource_emit_on_load_init (SwfdecResource *resource)
swfdec_movie_queue_update (SWFDEC_MOVIE (resource->movie), SWFDEC_MOVIE_INVALID_CONTENTS);
}
}
+ swfdec_resource_emit_signal (resource, SWFDEC_AS_STR_onLoadInit, FALSE, NULL, 0);
+ resource->state = SWFDEC_RESOURCE_DONE;
/* free now unneeded resources */
if (resource->clip_loader) {
g_object_unref (resource->clip_loader);
commit 8cc556946e6aaa5e1af846e5308744d53f27d5de
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Nov 20 11:56:22 2007 +0100
make masks work when the parents of mask and masked movie don't match
diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index 2325138..a3772c8 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -564,6 +564,32 @@ swfdec_movie_rect_local_to_global (SwfdecMovie *movie, SwfdecRect *rect)
}
void
+swfdec_movie_global_to_local_matrix (SwfdecMovie *movie, cairo_matrix_t *matrix)
+{
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+ g_return_if_fail (matrix != NULL);
+
+ cairo_matrix_init_identity (matrix);
+ while (movie) {
+ cairo_matrix_multiply (matrix, &movie->inverse_matrix, matrix);
+ movie = movie->parent;
+ }
+}
+
+void
+swfdec_movie_local_to_global_matrix (SwfdecMovie *movie, cairo_matrix_t *matrix)
+{
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+ g_return_if_fail (matrix != NULL);
+
+ cairo_matrix_init_identity (matrix);
+ while (movie) {
+ cairo_matrix_multiply (matrix, matrix, &movie->matrix);
+ movie = movie->parent;
+ }
+}
+
+void
swfdec_movie_global_to_local (SwfdecMovie *movie, double *x, double *y)
{
g_return_if_fail (SWFDEC_IS_MOVIE (movie));
@@ -876,7 +902,11 @@ swfdec_movie_render (SwfdecMovie *movie, cairo_t *cr,
if (movie->parent == movie->masked_by->parent) {
cairo_transform (cr, &movie->inverse_matrix);
} else {
- SWFDEC_FIXME ("implement different parents when masking");
+ cairo_matrix_t mat;
+ swfdec_movie_local_to_global_matrix (movie, &mat);
+ cairo_transform (cr, &mat);
+ swfdec_movie_global_to_local_matrix (movie->masked_by, &mat);
+ cairo_transform (cr, &mat);
}
mask = swfdec_movie_mask (cr, movie->masked_by, &rect);
cairo_pop_group_to_source (cr);
diff --git a/libswfdec/swfdec_movie.h b/libswfdec/swfdec_movie.h
index 2827d06..8149e33 100644
--- a/libswfdec/swfdec_movie.h
+++ b/libswfdec/swfdec_movie.h
@@ -221,6 +221,12 @@ void swfdec_movie_local_to_global (SwfdecMovie * movie,
void swfdec_movie_global_to_local (SwfdecMovie * movie,
double * x,
double * y);
+void swfdec_movie_global_to_local_matrix
+ (SwfdecMovie * movie,
+ cairo_matrix_t * matrix);
+void swfdec_movie_local_to_global_matrix
+ (SwfdecMovie * movie,
+ cairo_matrix_t * matrix);
void swfdec_movie_rect_local_to_global (SwfdecMovie * movie,
SwfdecRect * rect);
void swfdec_movie_rect_global_to_local (SwfdecMovie * movie,
More information about the Swfdec
mailing list