[Swfdec] 12 commits - configure.ac doc/Makefile.am doc/swfdec-sections.txt libswfdec/jpeg libswfdec/swfdec_as_array.c libswfdec/swfdec_as_object.c libswfdec/swfdec_as_strings.c libswfdec/swfdec_player.c libswfdec/swfdec_player.h libswfdec/swfdec_player_internal.h libswfdec/swfdec_tag.c test/trace

Benjamin Otte company at kemper.freedesktop.org
Sat Jul 21 04:41:57 PDT 2007


 configure.ac                       |    2 
 doc/Makefile.am                    |    1 
 doc/swfdec-sections.txt            |    2 
 libswfdec/jpeg/jpeg.c              |   22 ++--
 libswfdec/swfdec_as_array.c        |   70 ++++++-------
 libswfdec/swfdec_as_object.c       |   95 +++++++++++++++--
 libswfdec/swfdec_as_strings.c      |    1 
 libswfdec/swfdec_player.c          |  197 +++++++++++++++++++++++++++++++++----
 libswfdec/swfdec_player.h          |    7 +
 libswfdec/swfdec_player_internal.h |   13 ++
 libswfdec/swfdec_tag.c             |    2 
 test/trace/Makefile.am             |    9 +
 test/trace/addProperty-5.swf       |binary
 test/trace/addProperty-5.swf.trace |   16 +++
 test/trace/addProperty-6.swf       |binary
 test/trace/addProperty-6.swf.trace |   25 ++++
 test/trace/addProperty-7.swf       |binary
 test/trace/addProperty-7.swf.trace |   25 ++++
 test/trace/addProperty-8.swf       |binary
 test/trace/addProperty-8.swf.trace |   25 ++++
 test/trace/addProperty.as          |   35 ++++++
 21 files changed, 469 insertions(+), 78 deletions(-)

New commits:
diff-tree a3c1cdc6959557e10b6c0b2cfd0fdd87967db00c (from 95d8073506dcfe0a6b6d64e4b6ad1834e5920047)
Author: Benjamin Otte <otte at gnome.org>
Date:   Sat Jul 21 12:22:58 2007 +0100

    update scale info when movie gets initialized

diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index f73bd94..bed9c22 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -1326,6 +1326,7 @@ swfdec_player_initialize (SwfdecPlayer *
 	&player->iterate_timeout, player->iterate_timeout.timestamp, player->time);
   }
   g_object_notify (G_OBJECT (player), "initialized");
+  swfdec_player_update_scale (player);
 }
 
 /**
diff-tree 95d8073506dcfe0a6b6d64e4b6ad1834e5920047 (from c393217dbafc5bdf8feac7093ad564a1167547f6)
Author: Benjamin Otte <otte at gnome.org>
Date:   Sat Jul 21 01:00:29 2007 +0100

    redo scaling code
    
    it apparently works now

diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 23083d0..f73bd94 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -438,6 +438,75 @@ swfdec_player_get_property (GObject *obj
 }
 
 static void
+swfdec_player_update_scale (SwfdecPlayer *player)
+{
+  int width, height;
+  double scale_x, scale_y;
+
+  width = player->stage_width >= 0 ? player->stage_width : (int) player->width;
+  height = player->stage_height >= 0 ? player->stage_height : (int) player->height;
+  if (height == 0 || width == 0) {
+    player->scale_x = 1.0;
+    player->scale_y = 1.0;
+    player->offset_x = 0;
+    player->offset_y = 0;
+    return;
+  }
+  if (player->width == 0 || player->height == 0) {
+    scale_x = 1.0;
+    scale_y = 1.0;
+  } else {
+    scale_x = (double) width / player->width;
+    scale_y = (double) height / player->height;
+  }
+  switch (player->scale_mode) {
+    case SWFDEC_SCALE_SHOW_ALL:
+      player->scale_x = MIN (scale_x, scale_y);
+      player->scale_y = player->scale_x;
+      break;
+    case SWFDEC_SCALE_NO_BORDER:
+      player->scale_x = MAX (scale_x, scale_y);
+      player->scale_y = player->scale_x;
+      break;
+    case SWFDEC_SCALE_EXACT_FIT:
+      player->scale_x = scale_x;
+      player->scale_y = scale_y;
+      break;
+    case SWFDEC_SCALE_NONE:
+      player->scale_x = 1.0;
+      player->scale_y = 1.0;
+      break;
+    default:
+      g_assert_not_reached ();
+  }
+  width = player->stage_width - ceil (player->width * player->scale_x);
+  height = player->stage_height - ceil (player->height * player->scale_y);
+  if (player->align_flags & SWFDEC_ALIGN_FLAG_LEFT) {
+    player->offset_x = 0;
+  } else if (player->align_flags & SWFDEC_ALIGN_FLAG_RIGHT) {
+    player->offset_x = width;
+  } else {
+    player->offset_x = width / 2;
+  }
+  if (player->align_flags & SWFDEC_ALIGN_FLAG_TOP) {
+    player->offset_y = 0;
+  } else if (player->align_flags & SWFDEC_ALIGN_FLAG_BOTTOM) {
+    player->offset_y = height;
+  } else {
+    player->offset_y = height / 2;
+  }
+  SWFDEC_LOG ("coordinate translation is %g * x + %d - %g * y + %d", 
+      player->scale_x, player->offset_x, player->scale_y, player->offset_y);
+#if 0
+  /* FIXME: make this emit the signal at the right time */
+  player->invalid.x0 = 0;
+  player->invalid.y0 = 0;
+  player->invalid.x1 = player->stage_width;
+  player->invalid.y1 = player->stage_height;
+#endif
+}
+
+static void
 swfdec_player_set_property (GObject *object, guint param_id, const GValue *value,
     GParamSpec *pspec)
 {
@@ -458,9 +527,11 @@ swfdec_player_set_property (GObject *obj
       break;
     case PROP_ALIGNMENT:
       player->align_flags = swfdec_player_alignment_to_flags (g_value_get_enum (value));
+      swfdec_player_update_scale (player);
       break;
     case PROP_SCALE:
       player->scale_mode = g_value_get_enum (value);
+      swfdec_player_update_scale (player);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -708,14 +779,14 @@ swfdec_player_emit_signals (SwfdecPlayer
     /* FIXME: currently we clamp the rectangle to the visible area, it might
      * be useful to allow out-of-bounds drawing. In that case this needs to be
      * changed */
-    x = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.x0);
+    x = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.x0) * player->scale_x + player->offset_x;
     x = MAX (x, 0.0);
-    y = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.y0);
+    y = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.y0) * player->scale_y + player->offset_y;
     y = MAX (y, 0.0);
-    width = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.x1 - player->invalid.x0);
-    width = MIN (width, player->width - x);
-    height = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.y1 - player->invalid.y0);
-    height = MIN (height, player->height - y);
+    width = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.x1 - player->invalid.x0) * player->scale_x;
+    width = MIN (width, player->stage_width - x);
+    height = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.y1 - player->invalid.y0) * player->scale_y;
+    height = MIN (height, player->stage_height - y);
     g_signal_emit (player, signals[INVALIDATE], 0, x, y, width, height);
     swfdec_rect_init_empty (&player->invalid);
   }
@@ -736,8 +807,10 @@ swfdec_player_do_handle_mouse (SwfdecPla
     double x, double y, int button)
 {
   swfdec_player_lock (player);
-  x *= SWFDEC_TWIPS_SCALE_FACTOR;
-  y *= SWFDEC_TWIPS_SCALE_FACTOR;
+  x -= player->offset_x;
+  y -= player->offset_y;
+  x = x * SWFDEC_TWIPS_SCALE_FACTOR / player->scale_x;
+  y = y * SWFDEC_TWIPS_SCALE_FACTOR / player->scale_y;
   SWFDEC_LOG ("handling mouse at %g %g %d", x, y, button);
   if (player->mouse_x != x || player->mouse_y != y) {
     player->mouse_x = x;
@@ -1486,19 +1559,25 @@ swfdec_player_render (SwfdecPlayer *play
     return;
 
   if (width == 0.0)
-    width = player->width;
+    width = player->stage_width;
   if (height == 0.0)
-    height = player->height;
-  real.x0 = floor (x * SWFDEC_TWIPS_SCALE_FACTOR);
-  real.y0 = floor (y * SWFDEC_TWIPS_SCALE_FACTOR);
-  real.x1 = ceil ((x + width) * SWFDEC_TWIPS_SCALE_FACTOR);
-  real.y1 = ceil ((y + height) * SWFDEC_TWIPS_SCALE_FACTOR);
-  SWFDEC_INFO ("=== %p: START RENDER, area %g %g  %g %g ===", player, 
-      real.x0, real.y0, real.x1, real.y1);
+    height = player->stage_height;
+  /* clip the area */
   cairo_save (cr);
   cairo_rectangle (cr, x, y, width, height);
   cairo_clip (cr);
-  cairo_scale (cr, 1.0 / SWFDEC_TWIPS_SCALE_FACTOR, 1.0 / SWFDEC_TWIPS_SCALE_FACTOR);
+  /* compute the rectangle */
+  x -= player->offset_x;
+  y -= player->offset_y;
+  real.x0 = floor (x * SWFDEC_TWIPS_SCALE_FACTOR) / player->scale_x;
+  real.y0 = floor (y * SWFDEC_TWIPS_SCALE_FACTOR) / player->scale_y;
+  real.x1 = ceil ((x + width) * SWFDEC_TWIPS_SCALE_FACTOR) / player->scale_x;
+  real.y1 = ceil ((y + height) * SWFDEC_TWIPS_SCALE_FACTOR) / player->scale_y;
+  SWFDEC_INFO ("=== %p: START RENDER, area %g %g  %g %g ===", player, 
+      real.x0, real.y0, real.x1, real.y1);
+  /* convert the cairo matrix */
+  cairo_translate (cr, player->offset_x, player->offset_y);
+  cairo_scale (cr, player->scale_x / SWFDEC_TWIPS_SCALE_FACTOR, player->scale_y / SWFDEC_TWIPS_SCALE_FACTOR);
   swfdec_color_set_source (cr, player->bgcolor);
   cairo_paint (cr);
 
@@ -1664,6 +1743,7 @@ swfdec_player_set_size (SwfdecPlayer *pl
     g_object_notify (G_OBJECT (player), "height");
   }
   g_object_thaw_notify (G_OBJECT (player));
+  swfdec_player_update_scale (player);
 }
 
 /**
diff --git a/libswfdec/swfdec_player.h b/libswfdec/swfdec_player.h
index b5f4c4b..578427e 100644
--- a/libswfdec/swfdec_player.h
+++ b/libswfdec/swfdec_player.h
@@ -49,7 +49,7 @@ typedef enum {
   SWFDEC_SCALE_SHOW_ALL,
   SWFDEC_SCALE_NO_BORDER,
   SWFDEC_SCALE_EXACT_FIT,
-  SWFDEC_SCALE_NO_SCALE
+  SWFDEC_SCALE_NONE
 } SwfdecScaleMode;
 
 typedef struct _SwfdecPlayer SwfdecPlayer;
diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h
index cd8000b..3010bf0 100644
--- a/libswfdec/swfdec_player_internal.h
+++ b/libswfdec/swfdec_player_internal.h
@@ -62,6 +62,10 @@ struct _SwfdecPlayer
   gint			stage_height;		/* height set by the user */
   guint			align_flags;		/* SwfdecAlignFlag */
   SwfdecScaleMode	scale_mode;		/* scale mode */
+  double		scale_x;		/* cached x scale value */
+  double		scale_y;		/* cached y scale value */
+  int			offset_x;		/* x offset from top left edge after scaling */
+  int			offset_y;		/* y offset from top left edge after scaling */
 
   guint			unnamed_count;		/* variable used for naming unnamed movies */
   /* ActionScript */
diff-tree c393217dbafc5bdf8feac7093ad564a1167547f6 (from 14010d91f34a35ff74b3ac6f04f06647450b5eb9)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Jul 20 23:14:19 2007 +0100

    add missing function

diff --git a/doc/swfdec-sections.txt b/doc/swfdec-sections.txt
index 930fbeb..5ad6dec 100644
--- a/doc/swfdec-sections.txt
+++ b/doc/swfdec-sections.txt
@@ -338,6 +338,7 @@ SwfdecAsFrame
 swfdec_as_frame_get_next
 SwfdecAsStackIterator
 swfdec_as_stack_iterator_init
+swfdec_as_stack_iterator_init_arguments
 swfdec_as_stack_iterator_next
 <SUBSECTION Standard>
 swfdec_as_frame_get_type
diff-tree 14010d91f34a35ff74b3ac6f04f06647450b5eb9 (from 93f5c8e89e875ae20e8ce882f82e6228a6bf9d0e)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Jul 20 23:14:02 2007 +0100

    add swfdec_internal.h

diff --git a/doc/Makefile.am b/doc/Makefile.am
index f88b306..494217a 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -94,6 +94,7 @@ IGNORE_HFILES= \
 	swfdec_graphic.h \
 	swfdec_graphic_movie.h \
 	swfdec_image.h \
+	swfdec_internal.h \
 	swfdec_interval.h \
 	swfdec_js.h \
 	swfdec_listener.h \
diff-tree 93f5c8e89e875ae20e8ce882f82e6228a6bf9d0e (from 308978ae953a1be7ca1fd0558daf07fe3088a16a)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Jul 20 15:00:26 2007 +0100

    add SwfdecScaleMode and docs

diff --git a/doc/swfdec-sections.txt b/doc/swfdec-sections.txt
index 793d347..930fbeb 100644
--- a/doc/swfdec-sections.txt
+++ b/doc/swfdec-sections.txt
@@ -110,6 +110,7 @@ SwfdecLoaderRequest
 swfdec_loader_data_type_get_extension
 SwfdecAlignment
 SwfdecMouseCursor
+SwfdecScaleMode
 </SECTION>
 
 
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 231068b..23083d0 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -110,11 +110,22 @@
  * @SWFDEC_ALIGNMENT_RIGHT: right
  * @SWFDEC_ALIGNMENT_BOTTOM_LEFT: left
  * @SWFDEC_ALIGNMENT_BOTTOM: bottom
- * @SWFDEC_ALIGNMENT_BOTTOM_RIGHT bottom right
+ * @SWFDEC_ALIGNMENT_BOTTOM_RIGHT: bottom right
  *
  * These are the possible values for the alignment of an unscaled movie.
  */
 
+/**
+ * SwfdecScaleMode:
+ * @SWFDEC_SCALE_SHOW_ALL: Show the whole content as large as possible
+ * @SWFDEC_SCALE_NO_BORDER: Fill the whole area, possibly cropping parts
+ * @SWFDEC_SCALE_EXACT_FIT: Fill the whole area, don't keep aspect ratio
+ * @SWFDEC_SCALE_NO_SCALE: Do not scale the movie at all
+ *
+ * Describes how the movie should be scaled if the given size doesn't equal the
+ * movie's size.
+ */
+
 /*** Timeouts ***/
 
 static SwfdecTick
@@ -326,7 +337,8 @@ enum {
   PROP_BACKGROUND_COLOR,
   PROP_WIDTH,
   PROP_HEIGHT,
-  PROP_ALIGNMENT
+  PROP_ALIGNMENT,
+  PROP_SCALE
 };
 
 G_DEFINE_TYPE (SwfdecPlayer, swfdec_player, SWFDEC_TYPE_AS_CONTEXT)
@@ -416,6 +428,9 @@ swfdec_player_get_property (GObject *obj
     case PROP_ALIGNMENT:
       g_value_set_enum (value, swfdec_player_alignment_from_flags (player->align_flags));
       break;
+    case PROP_SCALE:
+      g_value_set_enum (value, player->scale_mode);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
       break;
@@ -444,6 +459,9 @@ swfdec_player_set_property (GObject *obj
     case PROP_ALIGNMENT:
       player->align_flags = swfdec_player_alignment_to_flags (g_value_get_enum (value));
       break;
+    case PROP_SCALE:
+      player->scale_mode = g_value_get_enum (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
       break;
@@ -947,6 +965,9 @@ swfdec_player_class_init (SwfdecPlayerCl
   g_object_class_install_property (object_class, PROP_ALIGNMENT,
       g_param_spec_enum ("alignment", "alignment", "point of the screen to align the output to",
 	  SWFDEC_TYPE_ALIGNMENT, SWFDEC_ALIGNMENT_CENTER, G_PARAM_READWRITE));
+  g_object_class_install_property (object_class, PROP_SCALE,
+      g_param_spec_enum ("scale-mode", "scale mode", "method used to scale the movie",
+	  SWFDEC_TYPE_SCALE_MODE, SWFDEC_SCALE_SHOW_ALL, G_PARAM_READWRITE));
 
   /**
    * SwfdecPlayer::invalidate:
diff --git a/libswfdec/swfdec_player.h b/libswfdec/swfdec_player.h
index b4ce558..b5f4c4b 100644
--- a/libswfdec/swfdec_player.h
+++ b/libswfdec/swfdec_player.h
@@ -45,6 +45,13 @@ typedef enum {
   SWFDEC_ALIGNMENT_BOTTOM_RIGHT
 } SwfdecAlignment;
 
+typedef enum {
+  SWFDEC_SCALE_SHOW_ALL,
+  SWFDEC_SCALE_NO_BORDER,
+  SWFDEC_SCALE_EXACT_FIT,
+  SWFDEC_SCALE_NO_SCALE
+} SwfdecScaleMode;
+
 typedef struct _SwfdecPlayer SwfdecPlayer;
 typedef struct _SwfdecPlayerClass SwfdecPlayerClass;
 
diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h
index 8ba3b8c..cd8000b 100644
--- a/libswfdec/swfdec_player_internal.h
+++ b/libswfdec/swfdec_player_internal.h
@@ -61,6 +61,7 @@ struct _SwfdecPlayer
   gint			stage_width;		/* width set by the user */
   gint			stage_height;		/* height set by the user */
   guint			align_flags;		/* SwfdecAlignFlag */
+  SwfdecScaleMode	scale_mode;		/* scale mode */
 
   guint			unnamed_count;		/* variable used for naming unnamed movies */
   /* ActionScript */
diff-tree 308978ae953a1be7ca1fd0558daf07fe3088a16a (from eacb7dc28e3c8c0b4312cb2c2e6e93668e0d6721)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Jul 20 13:09:31 2007 +0100

    add a simple test for Object.addProeprty()

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 94713c4..2828f72 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -28,6 +28,15 @@ EXTRA_DIST = \
 	add2-6.swf.trace \
 	add2-7.swf \
 	add2-7.swf.trace \
+	addProperty.as \
+	addProperty-5.swf \
+	addProperty-5.swf.trace \
+	addProperty-6.swf \
+	addProperty-6.swf.trace \
+	addProperty-7.swf \
+	addProperty-7.swf.trace \
+	addProperty-8.swf \
+	addProperty-8.swf.trace \
 	and-or-5.swf \
 	and-or-5.swf.trace \
 	and-or-6.swf \
diff --git a/test/trace/addProperty-5.swf b/test/trace/addProperty-5.swf
new file mode 100644
index 0000000..5997928
Binary files /dev/null and b/test/trace/addProperty-5.swf differ
diff --git a/test/trace/addProperty-5.swf.trace b/test/trace/addProperty-5.swf.trace
new file mode 100644
index 0000000..642c8f2
--- /dev/null
+++ b/test/trace/addProperty-5.swf.trace
@@ -0,0 +1,16 @@
+undefined
+42
+undefined
+42
+undefined
+42
+undefined
+42
+undefined
+42
+undefined
+42
+undefined
+42
+42
+undefined
diff --git a/test/trace/addProperty-6.swf b/test/trace/addProperty-6.swf
new file mode 100644
index 0000000..35ab5b6
Binary files /dev/null and b/test/trace/addProperty-6.swf differ
diff --git a/test/trace/addProperty-6.swf.trace b/test/trace/addProperty-6.swf.trace
new file mode 100644
index 0000000..68dc97a
--- /dev/null
+++ b/test/trace/addProperty-6.swf.trace
@@ -0,0 +1,25 @@
+true
+get
+1
+true
+get2
+2
+false
+get2
+2
+false
+get2
+2
+true
+get
+1
+false
+get
+1
+true
+get
+1
+set
+get
+1
+42
diff --git a/test/trace/addProperty-7.swf b/test/trace/addProperty-7.swf
new file mode 100644
index 0000000..eb727a6
Binary files /dev/null and b/test/trace/addProperty-7.swf differ
diff --git a/test/trace/addProperty-7.swf.trace b/test/trace/addProperty-7.swf.trace
new file mode 100644
index 0000000..68dc97a
--- /dev/null
+++ b/test/trace/addProperty-7.swf.trace
@@ -0,0 +1,25 @@
+true
+get
+1
+true
+get2
+2
+false
+get2
+2
+false
+get2
+2
+true
+get
+1
+false
+get
+1
+true
+get
+1
+set
+get
+1
+42
diff --git a/test/trace/addProperty-8.swf b/test/trace/addProperty-8.swf
new file mode 100644
index 0000000..aeedf6b
Binary files /dev/null and b/test/trace/addProperty-8.swf differ
diff --git a/test/trace/addProperty-8.swf.trace b/test/trace/addProperty-8.swf.trace
new file mode 100644
index 0000000..68dc97a
--- /dev/null
+++ b/test/trace/addProperty-8.swf.trace
@@ -0,0 +1,25 @@
+true
+get
+1
+true
+get2
+2
+false
+get2
+2
+false
+get2
+2
+true
+get
+1
+false
+get
+1
+true
+get
+1
+set
+get
+1
+42
diff --git a/test/trace/addProperty.as b/test/trace/addProperty.as
new file mode 100644
index 0000000..9608696
--- /dev/null
+++ b/test/trace/addProperty.as
@@ -0,0 +1,35 @@
+// makeswf -v 7 -s 200x150 -r 1 -o addProperty.swf addProperty.as
+
+function get () {
+  trace ("get");
+  return 1;
+};
+function get2 () {
+  trace ("get2");
+  return 2;
+};
+function set (x) {
+  trace ("set");
+  this.bla = x;
+};
+o = new Object ();
+o.foo = 42;
+trace (o.addProperty ("foo", get, null));
+trace (o.foo);
+trace (o.addProperty ("foo", get2, null));
+trace (o.foo);
+trace (o.addProperty ("foo", get));
+trace (o.foo);
+trace (o.addProperty ("foo", get, 10));
+trace (o.foo);
+trace (o.addProperty ("foo", get, get));
+trace (o.foo);
+trace (o.addProperty ("foo", get2, undefined));
+trace (o.foo);
+trace (o.addProperty ("foo", get, set));
+trace (o.foo);
+o.foo = 42;
+trace (o.foo);
+trace (o.bla);
+
+loadMovie ("FSCommand:quit", "");
diff-tree eacb7dc28e3c8c0b4312cb2c2e6e93668e0d6721 (from 54fb8238661bbcd2928f5b1d6b10781aa2dcb36c)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Jul 20 13:05:57 2007 +0100

    implement Object.addProperty()

diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index c89654d..ae37d96 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -162,6 +162,7 @@ swfdec_as_object_do_get (SwfdecAsObject 
   if (var) {
     if (var->get) {
       swfdec_as_function_call (var->get, object, 0, NULL, val);
+      swfdec_as_context_run (object->context);
       *flags = var->flags;
     } else {
       *val = var->value;
@@ -172,6 +173,21 @@ swfdec_as_object_do_get (SwfdecAsObject 
   return FALSE;
 }
 
+static SwfdecAsVariable *
+swfdec_as_object_lookup_variable (SwfdecAsObject *object, const char *variable)
+{
+  SwfdecAsVariable *var;
+
+  var = swfdec_as_object_hash_lookup (object, variable);
+  if (var == NULL) {
+    if (!swfdec_as_context_use_mem (object->context, sizeof (SwfdecAsVariable)))
+      return NULL;
+    var = g_slice_new0 (SwfdecAsVariable);
+    g_hash_table_insert (object->properties, (gpointer) variable, var);
+  }
+  return var;
+}
+
 static void
 swfdec_as_object_do_set (SwfdecAsObject *object, const char *variable, 
     const SwfdecAsValue *val)
@@ -186,19 +202,16 @@ swfdec_as_object_do_set (SwfdecAsObject 
     }
   }
 
-  var = swfdec_as_object_hash_lookup (object, variable);
-  if (var == NULL) {
-    if (!swfdec_as_context_use_mem (object->context, sizeof (SwfdecAsVariable)))
-      return;
-    var = g_slice_new0 (SwfdecAsVariable);
-    g_hash_table_insert (object->properties, (gpointer) variable, var);
-  }
+  var = swfdec_as_object_lookup_variable (object, variable);
+  if (var == NULL)
+    return;
   if (var->flags & SWFDEC_AS_VARIABLE_READONLY)
     return;
   if (var->get) {
     if (var->set) {
       SwfdecAsValue tmp;
       swfdec_as_function_call (var->set, object, 1, val, &tmp);
+      swfdec_as_context_run (object->context);
     }
   } else { 
     var->value = *val;
@@ -912,6 +925,43 @@ swfdec_as_object_set_constructor (Swfdec
 /*** AS CODE ***/
 
 static void
+swfdec_as_object_addProperty (SwfdecAsContext *cx, SwfdecAsObject *object,
+    guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+  SwfdecAsFunction *get, *set;
+  SwfdecAsVariable *var;
+  const char *name;
+
+  SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
+  if (argc < 3)
+    return;
+  name = swfdec_as_value_to_string (cx, &argv[0]);
+  if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[1]) ||
+      !SWFDEC_IS_AS_FUNCTION ((get = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[1]))))
+    return;
+  if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[2])) {
+    set = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[2]);
+    if (!SWFDEC_IS_AS_FUNCTION (set))
+      return;
+  } else if (SWFDEC_AS_VALUE_IS_NULL (&argv[2])) {
+    set = NULL;
+  } else {
+    return;
+  }
+
+  var = swfdec_as_object_lookup_variable (object, name);
+  if (var == NULL)
+    return;
+  var->get = get;
+  var->set = set;
+  var->flags = SWFDEC_AS_VARIABLE_PERMANENT;
+  if (set == NULL)
+    var->flags |= SWFDEC_AS_VARIABLE_READONLY;
+
+  SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE);
+}
+
+static void
 swfdec_as_object_hasOwnProperty (SwfdecAsContext *cx, SwfdecAsObject *object,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
 {
@@ -972,6 +1022,8 @@ swfdec_as_object_init_context (SwfdecAsC
   swfdec_as_object_set_variable (object, SWFDEC_AS_STR_prototype, &val);
 
   if (version > 5) {
+    swfdec_as_object_add_function (proto, SWFDEC_AS_STR_addProperty, 
+	SWFDEC_TYPE_AS_OBJECT, swfdec_as_object_addProperty, 0);
     swfdec_as_object_add_function (proto, SWFDEC_AS_STR_hasOwnProperty, 
 	SWFDEC_TYPE_AS_OBJECT, swfdec_as_object_hasOwnProperty, 1);
   }
diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index 92da9ba..5ec2d1f 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -234,6 +234,7 @@ const char swfdec_as_strings[] = 
   SWFDEC_AS_CONSTANT_STRING ("indexOf")
   SWFDEC_AS_CONSTANT_STRING ("call")
   SWFDEC_AS_CONSTANT_STRING ("Boolean")
+  SWFDEC_AS_CONSTANT_STRING ("addProperty")
   /* add more here */
 ;
 
diff-tree 54fb8238661bbcd2928f5b1d6b10781aa2dcb36c (from 39cffed289c62a06e51ad44672f8b458da1d4cea)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Jul 20 12:41:13 2007 +0100

    add support for function getters and setters

diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index 3bb325f..c89654d 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -92,6 +92,8 @@ typedef struct _SwfdecAsVariable SwfdecA
 struct _SwfdecAsVariable {
   guint			flags;		/* SwfdecAsVariableFlag values */
   SwfdecAsValue     	value;		/* value of property */
+  SwfdecAsFunction *	get;		/* getter set with swfdec_as_object_add_property */
+  SwfdecAsFunction *	set;		/* setter or %NULL */
 };
 
 G_DEFINE_TYPE (SwfdecAsObject, swfdec_as_object, G_TYPE_OBJECT)
@@ -112,7 +114,13 @@ swfdec_as_object_mark_property (gpointer
   SwfdecAsVariable *var = value;
 
   swfdec_as_string_mark (key);
-  swfdec_as_value_mark (&var->value);
+  if (var->get) {
+    swfdec_as_object_mark (SWFDEC_AS_OBJECT (var->get));
+    if (var->set)
+      swfdec_as_object_mark (SWFDEC_AS_OBJECT (var->set));
+  } else {
+    swfdec_as_value_mark (&var->value);
+  }
 }
 
 static void
@@ -152,8 +160,13 @@ swfdec_as_object_do_get (SwfdecAsObject 
   SwfdecAsVariable *var = swfdec_as_object_hash_lookup (object, variable);
 
   if (var) {
-    *val = var->value;
-    *flags = var->flags;
+    if (var->get) {
+      swfdec_as_function_call (var->get, object, 0, NULL, val);
+      *flags = var->flags;
+    } else {
+      *val = var->value;
+      *flags = var->flags;
+    }
     return TRUE;
   }
   return FALSE;
@@ -180,8 +193,16 @@ swfdec_as_object_do_set (SwfdecAsObject 
     var = g_slice_new0 (SwfdecAsVariable);
     g_hash_table_insert (object->properties, (gpointer) variable, var);
   }
-  if (!(var->flags & SWFDEC_AS_VARIABLE_READONLY))
+  if (var->flags & SWFDEC_AS_VARIABLE_READONLY)
+    return;
+  if (var->get) {
+    if (var->set) {
+      SwfdecAsValue tmp;
+      swfdec_as_function_call (var->set, object, 1, val, &tmp);
+    }
+  } else { 
     var->value = *val;
+  }
 }
 
 static void
diff-tree 39cffed289c62a06e51ad44672f8b458da1d4cea (from aaca1deef82d3d2545b77919455d044c79b2ca11)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Jul 20 12:41:01 2007 +0100

    s/index/idx/
    
    naming a variable index shadows a global function

diff --git a/libswfdec/jpeg/jpeg.c b/libswfdec/jpeg/jpeg.c
index e9a98ef..52143dc 100644
--- a/libswfdec/jpeg/jpeg.c
+++ b/libswfdec/jpeg/jpeg.c
@@ -735,9 +735,9 @@ jpeg_decoder_define_huffman_tables (Jpeg
     tc = x >> 4;
     th = x & 0xf;
 
-    COG_DEBUG ("huff table type %d (%s) index %d", tc, tc ? "ac" : "dc", th);
+    COG_DEBUG ("huff table type %d (%s) idx %d", tc, tc ? "ac" : "dc", th);
     if (tc > 1 || th > 3) {
-      jpeg_decoder_error(dec, "huffman table type or index out of range");
+      jpeg_decoder_error(dec, "huffman table type or idx out of range");
       return;
     }
 
@@ -911,7 +911,7 @@ jpeg_decoder_start_of_scan (JpegDecoder 
     int ac_table;
     int x;
     int y;
-    int index;
+    int idx;
     int h_subsample;
     int v_subsample;
     int quant_index;
@@ -920,22 +920,22 @@ jpeg_decoder_start_of_scan (JpegDecoder 
     tmp = jpeg_bits_get_u8 (bits);
     dc_table = tmp >> 4;
     ac_table = tmp & 0xf;
-    index = jpeg_decoder_find_component_by_id (dec, component_id);
+    idx = jpeg_decoder_find_component_by_id (dec, component_id);
 
-    h_subsample = dec->components[index].h_sample;
-    v_subsample = dec->components[index].v_sample;
-    quant_index = dec->components[index].quant_table;
+    h_subsample = dec->components[idx].h_sample;
+    v_subsample = dec->components[idx].v_sample;
+    quant_index = dec->components[idx].quant_table;
 
     for (y = 0; y < v_subsample; y++) {
       for (x = 0; x < h_subsample; x++) {
-        dec->scan_list[n].component_index = index;
+        dec->scan_list[n].component_index = idx;
         dec->scan_list[n].dc_table = dc_table;
         dec->scan_list[n].ac_table = ac_table;
         dec->scan_list[n].quant_table = quant_index;
         dec->scan_list[n].x = x;
         dec->scan_list[n].y = y;
         dec->scan_list[n].offset =
-            y * 8 * dec->components[index].rowstride + x * 8;
+            y * 8 * dec->components[idx].rowstride + x * 8;
         n++;
         if (n > JPEG_LIMIT_SCAN_LIST_LENGTH) {
           jpeg_decoder_error(dec, "scan list too long");
@@ -947,8 +947,8 @@ jpeg_decoder_start_of_scan (JpegDecoder 
     dec->scan_h_subsample = MAX (dec->scan_h_subsample, h_subsample);
     dec->scan_v_subsample = MAX (dec->scan_v_subsample, v_subsample);
 
-    COG_DEBUG ("component %d: index=%d dc_table=%d ac_table=%d n=%d",
-        component_id, index, dc_table, ac_table, n);
+    COG_DEBUG ("component %d: idx=%d dc_table=%d ac_table=%d n=%d",
+        component_id, idx, dc_table, ac_table, n);
   }
   dec->scan_list_length = n;
 
diff-tree aaca1deef82d3d2545b77919455d044c79b2ca11 (from f01c9464494628c60a9b4bd49dde7b612a340489)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Jul 20 01:12:54 2007 +0100

    use -std=gnu99
    
    gnu99 will be the default gcc std flag, when c99 support is complete.
    See http://www.delorie.com/gnu/docs/gcc/gcc_2.html for details.

diff --git a/configure.ac b/configure.ac
index 6d46ee8..79461a2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,7 +38,7 @@ AC_SUBST(SWFDEC_LIBVERSION)
 AM_PROG_LIBTOOL
 
 dnl C99 is only required to get definitions for NAN and INFINITY.
-GLOBAL_CFLAGS="$GLOBAL_CFLAGS -std=c99"
+AS_COMPILER_FLAG(-std=gnu99, GLOBAL_CFLAGS="$GLOBAL_CFLAGS -std=gnu99")
 
 dnl ensures the library is linked against the internal Mozilla
 dnl if this doesn't work on your platform, I'll take patches :)
diff --git a/libswfdec/swfdec_as_array.c b/libswfdec/swfdec_as_array.c
index cc03b03..f6314a7 100644
--- a/libswfdec/swfdec_as_array.c
+++ b/libswfdec/swfdec_as_array.c
@@ -109,13 +109,13 @@ static gboolean swfdec_as_array_foreach_
     const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
 {
   ForeachRemoveRangeData *fdata = data;
-  gint32 index;
+  gint32 idx;
 
-  index = swfdec_as_array_to_index (variable);
-  if (index == -1)
+  idx = swfdec_as_array_to_index (variable);
+  if (idx == -1)
     return FALSE;
 
-  if (index >= fdata->start_index && index < fdata->start_index + fdata->num)
+  if (idx >= fdata->start_index && idx < fdata->start_index + fdata->num)
     return TRUE;
 
   return FALSE;
@@ -155,16 +155,16 @@ swfdec_as_array_foreach_move_range (Swfd
     SwfdecAsValue *value, guint flags, gpointer data)
 {
   ForeachMoveRangeData *fdata = data;
-  gint32 index;
+  gint32 idx;
 
-  index = swfdec_as_array_to_index (variable);
-  if (index == -1)
+  idx = swfdec_as_array_to_index (variable);
+  if (idx == -1)
     return variable;
 
-  if (index >= fdata->start_index && index < fdata->start_index + fdata->num) {
+  if (idx >= fdata->start_index && idx < fdata->start_index + fdata->num) {
     return swfdec_as_double_to_string (object->context,
-	fdata->to_index + index - fdata->start_index);
-  } else if (index >= fdata->to_index && index < fdata->to_index + fdata->num) {
+	fdata->to_index + idx - fdata->start_index);
+  } else if (idx >= fdata->to_index && idx < fdata->to_index + fdata->num) {
     return NULL;
   } else {
     return variable;
@@ -248,13 +248,13 @@ swfdec_as_array_foreach_append_array_ran
     SwfdecAsValue *value, guint flags, gpointer data)
 {
   ForeachAppendArrayRangeData *fdata = data;
-  gint32 index;
+  gint32 idx;
   const char *var;
 
-  index = swfdec_as_array_to_index (variable);
-  if (index >= fdata->start_index && index < fdata->start_index + fdata->num) {
+  idx = swfdec_as_array_to_index (variable);
+  if (idx >= fdata->start_index && idx < fdata->start_index + fdata->num) {
     var = swfdec_as_double_to_string (fdata->object_to->context,
-	fdata->offset + (index - fdata->start_index));
+	fdata->offset + (idx - fdata->start_index));
     swfdec_as_object_set_variable (fdata->object_to, var, value);
   }
 
@@ -498,13 +498,13 @@ swfdec_as_array_foreach_reverse (SwfdecA
     SwfdecAsValue *value, guint flags, gpointer data)
 {
   gint32 *length = data;
-  gint32 index;
+  gint32 idx;
 
-  index = swfdec_as_array_to_index (variable);
-  if (index == -1)
+  idx = swfdec_as_array_to_index (variable);
+  if (idx == -1)
     return variable;
 
-  return swfdec_as_double_to_string (object->context, *length - 1 - index);
+  return swfdec_as_double_to_string (object->context, *length - 1 - idx);
 }
 
 static void
@@ -700,11 +700,11 @@ swfdec_as_array_foreach_sort_rename (Swf
     SwfdecAsValue *value, guint flags, gpointer data)
 {
   ForeachSortData *fdata = data;
-  gint32 index, i;
+  gint32 idx, i;
   gboolean after_undefined = FALSE;
 
-  index = swfdec_as_array_to_index (variable);
-  if (index == -1)
+  idx = swfdec_as_array_to_index (variable);
+  if (idx == -1)
     return variable;
 
   if (SWFDEC_AS_VALUE_IS_UNDEFINED (value))
@@ -734,11 +734,11 @@ static gboolean swfdec_as_array_foreach_
   ForeachSortData *fdata = data;
   SwfdecAsValue val;
   const char *var;
-  gint32 index, i;
+  gint32 idx, i;
   gboolean after_undefined = FALSE;
 
-  index = swfdec_as_array_to_index (variable);
-  if (index == -1)
+  idx = swfdec_as_array_to_index (variable);
+  if (idx == -1)
     return TRUE;
 
   if (SWFDEC_AS_VALUE_IS_UNDEFINED (value))
@@ -751,7 +751,7 @@ static gboolean swfdec_as_array_foreach_
       if (after_undefined)
 	i += fdata->length - fdata->defined_values - 1;
       var = swfdec_as_double_to_string (object->context, i);
-      SWFDEC_AS_VALUE_SET_INT (&val, index);
+      SWFDEC_AS_VALUE_SET_INT (&val, idx);
       swfdec_as_object_set_variable (fdata->object_new, var, &val);
       return TRUE;
     }
@@ -771,10 +771,10 @@ swfdec_as_array_sort_set_undefined_index
 {
   SwfdecAsValue val;
   const char *var;
-  gint32 index, i, length, num;
+  gint32 idx, i, length, num;
 
-  for (index = 0; index < fdata->order_size; index++) {
-    if (fdata->order[index] == &fdata->undefined)
+  for (idx = 0; idx < fdata->order_size; idx++) {
+    if (fdata->order[idx] == &fdata->undefined)
       break;
   }
 
@@ -785,7 +785,7 @@ swfdec_as_array_sort_set_undefined_index
       var = swfdec_as_double_to_string (object->context, num);
       num++;
     } while (swfdec_as_object_get_variable (object, var, &val));
-    var = swfdec_as_double_to_string (fdata->object_new->context, index + i);
+    var = swfdec_as_double_to_string (fdata->object_new->context, idx + i);
     SWFDEC_AS_VALUE_SET_INT (&val, num - 1);
     swfdec_as_object_set_variable (fdata->object_new, var, &val);
   }
@@ -799,10 +799,10 @@ swfdec_as_array_foreach_sort_compare_und
     SwfdecAsValue *value, guint flags, gpointer data)
 {
   ForeachSortData *fdata = data;
-  gint32 index;
+  gint32 idx;
 
-  index = swfdec_as_array_to_index (variable);
-  if (index == -1)
+  idx = swfdec_as_array_to_index (variable);
+  if (idx == -1)
     return TRUE;
 
   if (SWFDEC_AS_VALUE_IS_UNDEFINED (value))
@@ -822,11 +822,11 @@ swfdec_as_array_foreach_sort_populate (S
     SwfdecAsValue *value, guint flags, gpointer data)
 {
   ForeachSortData *fdata = data;
-  gint32 index, i;
+  gint32 idx, i;
   gint cval = -1;
 
-  index = swfdec_as_array_to_index (variable);
-  if (index == -1)
+  idx = swfdec_as_array_to_index (variable);
+  if (idx == -1)
     return TRUE;
 
   if (SWFDEC_AS_VALUE_IS_UNDEFINED (value))
diff-tree f01c9464494628c60a9b4bd49dde7b612a340489 (from cec4657acdddf91c39a4ecf53e6a0102aa20d7eb)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Jul 19 10:39:51 2007 +0100

    VideFrame tags can happen inside DefineSprite

diff --git a/libswfdec/swfdec_tag.c b/libswfdec/swfdec_tag.c
index fb8dfc7..b6acf1b 100644
--- a/libswfdec/swfdec_tag.c
+++ b/libswfdec/swfdec_tag.c
@@ -668,7 +668,7 @@ static struct tag_func_struct tag_funcs[
   [SWFDEC_TAG_ENABLEDEBUGGER] = {"EnableDebugger", NULL, 0},
   [SWFDEC_TAG_DOINITACTION] = {"DoInitAction", tag_func_do_init_action, SPRITE},
   [SWFDEC_TAG_DEFINEVIDEOSTREAM] = {"DefineVideoStream", tag_func_define_video, 0},
-  [SWFDEC_TAG_VIDEOFRAME] = {"VideoFrame", tag_func_video_frame, 0},
+  [SWFDEC_TAG_VIDEOFRAME] = {"VideoFrame", tag_func_video_frame, SPRITE},
   [SWFDEC_TAG_DEFINEFONTINFO2] = {"DefineFontInfo2", tag_func_define_font_info, 0},
   [SWFDEC_TAG_MX4] = {"MX4", NULL, 0},
   [SWFDEC_TAG_ENABLEDEBUGGER2] = {"EnableDebugger2", NULL, 0},
diff-tree cec4657acdddf91c39a4ecf53e6a0102aa20d7eb (from 7fea1baed62362bc04093cdc509488bb11658c49)
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Jul 18 14:30:08 2007 +0100

    add n alignment property

diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index be041a2..231068b 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -325,7 +325,8 @@ enum {
   PROP_NEXT_EVENT,
   PROP_BACKGROUND_COLOR,
   PROP_WIDTH,
-  PROP_HEIGHT
+  PROP_HEIGHT,
+  PROP_ALIGNMENT
 };
 
 G_DEFINE_TYPE (SwfdecPlayer, swfdec_player, SWFDEC_TYPE_AS_CONTEXT)
@@ -337,6 +338,53 @@ swfdec_player_remove_movie (SwfdecPlayer
   player->movies = g_list_remove (player->movies, movie);
 }
 
+static guint
+swfdec_player_alignment_to_flags (SwfdecAlignment alignment)
+{
+  static const guint align_flags[9] = { 
+    SWFDEC_ALIGN_FLAG_TOP | SWFDEC_ALIGN_FLAG_LEFT,
+    SWFDEC_ALIGN_FLAG_TOP,
+    SWFDEC_ALIGN_FLAG_TOP | SWFDEC_ALIGN_FLAG_RIGHT,
+    SWFDEC_ALIGN_FLAG_LEFT,
+    0,
+    SWFDEC_ALIGN_FLAG_RIGHT,
+    SWFDEC_ALIGN_FLAG_BOTTOM | SWFDEC_ALIGN_FLAG_LEFT,
+    SWFDEC_ALIGN_FLAG_BOTTOM,
+    SWFDEC_ALIGN_FLAG_BOTTOM | SWFDEC_ALIGN_FLAG_RIGHT
+  };
+  return align_flags[alignment];
+}
+
+static SwfdecAlignment
+swfdec_player_alignment_from_flags (guint flags)
+{
+  if (flags & SWFDEC_ALIGN_FLAG_TOP) {
+    if (flags & SWFDEC_ALIGN_FLAG_LEFT) {
+      return SWFDEC_ALIGNMENT_TOP_LEFT;
+    } else if (flags & SWFDEC_ALIGN_FLAG_RIGHT) {
+      return SWFDEC_ALIGNMENT_TOP_RIGHT;
+    } else {
+      return SWFDEC_ALIGNMENT_TOP;
+    }
+  } else if (flags & SWFDEC_ALIGN_FLAG_BOTTOM) {
+    if (flags & SWFDEC_ALIGN_FLAG_LEFT) {
+      return SWFDEC_ALIGNMENT_BOTTOM_LEFT;
+    } else if (flags & SWFDEC_ALIGN_FLAG_RIGHT) {
+      return SWFDEC_ALIGNMENT_BOTTOM_RIGHT;
+    } else {
+      return SWFDEC_ALIGNMENT_BOTTOM;
+    }
+  } else {
+    if (flags & SWFDEC_ALIGN_FLAG_LEFT) {
+      return SWFDEC_ALIGNMENT_LEFT;
+    } else if (flags & SWFDEC_ALIGN_FLAG_RIGHT) {
+      return SWFDEC_ALIGNMENT_RIGHT;
+    } else {
+      return SWFDEC_ALIGNMENT_CENTER;
+    }
+  }
+}
+
 static void
 swfdec_player_get_property (GObject *object, guint param_id, GValue *value, 
     GParamSpec * pspec)
@@ -365,6 +413,9 @@ swfdec_player_get_property (GObject *obj
     case PROP_HEIGHT:
       g_value_set_int (value, player->stage_height);
       break;
+    case PROP_ALIGNMENT:
+      g_value_set_enum (value, swfdec_player_alignment_from_flags (player->align_flags));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
       break;
@@ -390,6 +441,9 @@ swfdec_player_set_property (GObject *obj
     case PROP_HEIGHT:
       swfdec_player_set_size (player, player->stage_width, g_value_get_int (value));
       break;
+    case PROP_ALIGNMENT:
+      player->align_flags = swfdec_player_alignment_to_flags (g_value_get_enum (value));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
       break;
@@ -890,6 +944,9 @@ swfdec_player_class_init (SwfdecPlayerCl
   g_object_class_install_property (object_class, PROP_HEIGHT,
       g_param_spec_int ("height", "height", "current height of the movie",
 	  -1, G_MAXINT, -1, G_PARAM_READWRITE));
+  g_object_class_install_property (object_class, PROP_ALIGNMENT,
+      g_param_spec_enum ("alignment", "alignment", "point of the screen to align the output to",
+	  SWFDEC_TYPE_ALIGNMENT, SWFDEC_ALIGNMENT_CENTER, G_PARAM_READWRITE));
 
   /**
    * SwfdecPlayer::invalidate:
diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h
index b5e0a39..8ba3b8c 100644
--- a/libswfdec/swfdec_player_internal.h
+++ b/libswfdec/swfdec_player_internal.h
@@ -27,6 +27,13 @@
 
 G_BEGIN_DECLS
 
+typedef enum {
+  SWFDEC_ALIGN_FLAG_TOP		= (1 << 0),
+  SWFDEC_ALIGN_FLAG_BOTTOM	= (1 << 1),
+  SWFDEC_ALIGN_FLAG_LEFT	= (1 << 2),
+  SWFDEC_ALIGN_FLAG_RIGHT	= (1 << 3)
+} SwfdecAlignFlag;
+
 typedef void (* SwfdecActionFunc) (gpointer object, gpointer data);
 
 typedef struct _SwfdecTimeout SwfdecTimeout;
@@ -53,6 +60,7 @@ struct _SwfdecPlayer
   /* stage properties */
   gint			stage_width;		/* width set by the user */
   gint			stage_height;		/* height set by the user */
+  guint			align_flags;		/* SwfdecAlignFlag */
 
   guint			unnamed_count;		/* variable used for naming unnamed movies */
   /* ActionScript */


More information about the Swfdec mailing list