[Swfdec] 4 commits - libswfdec/swfdec_js_movie.c libswfdec/swfdec_script.c player/swfdec_slow_loader.c

Benjamin Otte company at kemper.freedesktop.org
Wed Mar 21 15:50:17 PDT 2007


 libswfdec/swfdec_js_movie.c |   22 ++++++++++++++++++----
 libswfdec/swfdec_script.c   |    6 +++++-
 player/swfdec_slow_loader.c |   20 +++++++++++++++++++-
 3 files changed, 42 insertions(+), 6 deletions(-)

New commits:
diff-tree 13171a49b02675d44bc54c91ec872e173cfcefd6 (from parents)
Merge: dae7f00125145fc3e540c5454942acbbabe800db bbf53a5c2060eadff2632674d2550a09719f41e1
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Mar 21 23:44:29 2007 +0100

    Merge branch 'master' of ssh://company@git.freedesktop.org/git/swfdec

diff-tree dae7f00125145fc3e540c5454942acbbabe800db (from 07efea41adaeeceac6f4ab3ecd9a71c5a9c8791f)
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Mar 21 23:34:07 2007 +0100

    update to new SwfdecLoader stuff

diff --git a/player/swfdec_slow_loader.c b/player/swfdec_slow_loader.c
index 0eb5b61..47b7723 100644
--- a/player/swfdec_slow_loader.c
+++ b/player/swfdec_slow_loader.c
@@ -29,10 +29,19 @@
 G_DEFINE_TYPE (SwfdecSlowLoader, swfdec_slow_loader, SWFDEC_TYPE_LOADER)
 
 static void
+swfdec_slow_loader_notify_cb (SwfdecLoader *child, GParamSpec *pspec, SwfdecLoader *loader)
+{
+  if (g_str_equal (pspec->name, "size")) {
+    swfdec_loader_set_size (loader, swfdec_loader_get_size (child));
+  }
+}
+
+static void
 swfdec_slow_loader_dispose (GObject *object)
 {
   SwfdecSlowLoader *slow = SWFDEC_SLOW_LOADER (object);
 
+  g_signal_handlers_disconnect_by_func (slow->loader, swfdec_slow_loader_notify_cb, slow);
   g_object_unref (slow->loader);
   if (slow->timeout_id) {
     g_source_remove (slow->timeout_id);
@@ -96,7 +105,11 @@ swfdec_slow_loader_tick (gpointer data)
       return TRUE;
   }
 
-  if (slow->loader->eof) {
+  if (slow->loader->error) {
+    swfdec_loader_error (SWFDEC_LOADER (slow), slow->loader->error);
+    slow->timeout_id = 0;
+    return FALSE;
+  } else if (slow->loader->eof) {
     swfdec_loader_eof (SWFDEC_LOADER (slow));
     slow->timeout_id = 0;
     return FALSE;
@@ -109,6 +122,7 @@ SwfdecLoader *
 swfdec_slow_loader_new (SwfdecLoader *loader, guint duration)
 {
   SwfdecSlowLoader *ret;
+  gulong size;
 
   g_return_val_if_fail (SWFDEC_IS_LOADER (loader), NULL);
   g_return_val_if_fail (duration > 0, NULL);
@@ -117,6 +131,10 @@ swfdec_slow_loader_new (SwfdecLoader *lo
   ret->tick_time = 100;
   ret->duration = duration * 1000;
   ret->loader = loader;
+  g_signal_connect (loader, "notify", G_CALLBACK (swfdec_slow_loader_notify_cb), ret);
+  size = swfdec_loader_get_size (loader);
+  if (size)
+    swfdec_loader_set_size (SWFDEC_LOADER (ret), size);
   ret->timeout_id = g_timeout_add (ret->tick_time, swfdec_slow_loader_tick, ret);
 
   return SWFDEC_LOADER (ret);
diff-tree 07efea41adaeeceac6f4ab3ecd9a71c5a9c8791f (from 609e4f1c6bb7aa371146a535ef83cf57e4c30ec3)
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Mar 21 23:33:42 2007 +0100

    compute new width/height relative to original width/height, not current one
    
    also implements MovieClip.getDepth (untested)

diff --git a/libswfdec/swfdec_js_movie.c b/libswfdec/swfdec_js_movie.c
index 5137746..2d9b1a1 100644
--- a/libswfdec/swfdec_js_movie.c
+++ b/libswfdec/swfdec_js_movie.c
@@ -610,12 +610,26 @@ swfdec_js_getURL (JSContext *cx, JSObjec
   return JS_TRUE;
 }
 
+static JSBool
+swfdec_js_getDepth (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+  SwfdecMovie *movie;
+
+  movie = JS_GetPrivate (cx, obj);
+  if (!movie)
+    return JS_TRUE;
+
+  *rval = INT_TO_JSVAL (movie->depth);
+  return JS_TRUE;
+}
+
 static JSFunctionSpec movieclip_methods[] = {
   { "attachMovie",	swfdec_js_movie_attachMovie,	3, 0, 0 },
   { "duplicateMovieClip", swfdec_js_movie_duplicateMovieClip, 2, 0, 0 },
   { "eval",		swfdec_js_global_eval,	      	1, 0, 0 },
   { "getBytesLoaded",	mc_getBytesLoaded,		0, 0, 0 },
   { "getBytesTotal",	mc_getBytesTotal,		0, 0, 0 },
+  { "getDepth",		swfdec_js_getDepth,	      	0, 0, 0 },
   { "getNextHighestDepth", mc_getNextHighestDepth,    	0, 0, 0 },
   { "getProperty",    	swfdec_js_getProperty,		2, 0, 0 },
   { "getURL",    	swfdec_js_getURL,		2, 0, 0 },
@@ -970,9 +984,9 @@ mc_width_set (JSContext *cx, JSObject *o
   }
   swfdec_movie_update (movie);
   movie->modified = TRUE;
-  cur = SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) (rint (movie->extents.x1 - movie->extents.x0)));
+  cur = SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) (rint (movie->original_extents.x1 - movie->original_extents.x0)));
   if (cur != 0) {
-    movie->xscale *= d / cur;
+    movie->xscale = 100 * d / cur;
   } else {
     movie->xscale = 0;
     movie->yscale = 0;
@@ -1016,9 +1030,9 @@ mc_height_set (JSContext *cx, JSObject *
   }
   swfdec_movie_update (movie);
   movie->modified = TRUE;
-  cur = SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) (rint (movie->extents.y1 - movie->extents.y0)));
+  cur = SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) (rint (movie->original_extents.y1 - movie->original_extents.y0)));
   if (cur != 0) {
-    movie->yscale *= d / cur;
+    movie->yscale = 100 * d / cur;
   } else {
     movie->xscale = 0;
     movie->yscale = 0;
diff-tree 609e4f1c6bb7aa371146a535ef83cf57e4c30ec3 (from b12efb820117b62a7150d13359499678e7dcf31d)
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Mar 21 19:25:10 2007 +0100

    add some fixes for number conversion

diff --git a/libswfdec/swfdec_script.c b/libswfdec/swfdec_script.c
index 06915d0..d96ec0f 100644
--- a/libswfdec/swfdec_script.c
+++ b/libswfdec/swfdec_script.c
@@ -265,8 +265,12 @@ swfdec_value_to_number (JSContext *cx, j
     double d;
     if (!JS_ValueToNumber (cx, val, &d))
       return 0;
-    return isnan (d) ? 0 : d;
+    return d;
   } else if (JSVAL_IS_OBJECT(val) && (((SwfdecScript *) cx->fp->swf)->version >= 6)) {
+    /* Checking for version 6 is completely wrong, but a lot of the testsuite 
+     * depends on it (oops).
+     * The code calls the valueOf function and returns 0 if no such function exists.
+     */
     return JSVAL_IS_NULL (val) ? 0 : *cx->runtime->jsNaN;
   } else {
     return 0;


More information about the Swfdec mailing list