[Swfdec-commits] 2 commits - swfdec/swfdec_as_interpret.c swfdec/swfdec_as_object.c swfdec/swfdec_as_object.h swfdec/swfdec_bitmap_data.c test/image

Benjamin Otte company at kemper.freedesktop.org
Tue Nov 18 03:19:17 PST 2008


 swfdec/swfdec_as_interpret.c              |   27 +---------------
 swfdec/swfdec_as_object.c                 |   50 ++++++++++++++++++++++++++++++
 swfdec/swfdec_as_object.h                 |    1 
 swfdec/swfdec_bitmap_data.c               |    6 ++-
 test/image/bitmap-data-fillRect-5.swf     |binary
 test/image/bitmap-data-fillRect-5.swf.png |binary
 test/image/bitmap-data-fillRect-6.swf     |binary
 test/image/bitmap-data-fillRect-6.swf.png |binary
 test/image/bitmap-data-fillRect-7.swf     |binary
 test/image/bitmap-data-fillRect-7.swf.png |binary
 test/image/bitmap-data-fillRect-8.swf     |binary
 test/image/bitmap-data-fillRect-8.swf.png |binary
 test/image/bitmap-data-fillRect.as        |   16 +++++++++
 13 files changed, 73 insertions(+), 27 deletions(-)

New commits:
commit 2ea5b413acf2637097ec8312f1ae6ea797003ee4
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Nov 18 12:05:19 2008 +0100

    add swfdec_as_object_enumerate()
    
    This functionality seems to be used more often, so make it a nice
    function

diff --git a/swfdec/swfdec_as_interpret.c b/swfdec/swfdec_as_interpret.c
index ca33a9d..525d824 100644
--- a/swfdec/swfdec_as_interpret.c
+++ b/swfdec/swfdec_as_interpret.c
@@ -2384,36 +2384,13 @@ fail:
   swfdec_as_stack_pop_n (cx, 2);
 }
 
-static gboolean
-swfdec_action_enumerate_foreach (SwfdecAsObject *object, const char *variable,
-    SwfdecAsValue *value, guint flags, gpointer listp)
-{
-  GSList **list = listp;
-
-  if (flags & SWFDEC_AS_VARIABLE_HIDDEN)
-    return TRUE;
-
-  *list = g_slist_remove (*list, variable);
-  *list = g_slist_prepend (*list, (gpointer) variable);
-  return TRUE;
-}
-
 static void
 swfdec_action_do_enumerate (SwfdecAsContext *cx, SwfdecAsObject *object)
 {
   guint i;
-  GSList *walk, *list = NULL;
+  GSList *walk, *list;
   
-  for (i = 0; i < 256 && object; i++) {
-    swfdec_as_object_foreach (object, swfdec_action_enumerate_foreach, &list);
-    object = swfdec_as_object_get_prototype (object);
-  }
-  if (i == 256) {
-    swfdec_as_context_abort (cx, "Prototype recursion limit exceeded");
-    g_slist_free (list);
-    return;
-  }
-  list = g_slist_reverse (list);
+  list = swfdec_as_object_enumerate (object);
   i = 0;
   for (walk = list; walk; walk = walk->next) {
     /* 8 is an arbitrary value */
diff --git a/swfdec/swfdec_as_object.c b/swfdec/swfdec_as_object.c
index 6e9ab92..8ea79fc 100644
--- a/swfdec/swfdec_as_object.c
+++ b/swfdec/swfdec_as_object.c
@@ -1149,6 +1149,56 @@ swfdec_as_object_foreach (SwfdecAsObject *object, SwfdecAsVariableForeach func,
 
 /*** SIMPLIFICATIONS ***/
 
+static gboolean
+swfdec_as_object_enumerate_foreach (SwfdecAsObject *object, const char *variable,
+    SwfdecAsValue *value, guint flags, gpointer listp)
+{
+  GSList **list = listp;
+
+  if (flags & SWFDEC_AS_VARIABLE_HIDDEN)
+    return TRUE;
+
+  *list = g_slist_remove (*list, variable);
+  *list = g_slist_prepend (*list, (gpointer) variable);
+  return TRUE;
+}
+
+/**
+ * swfdec_as_object_enumerate:
+ * @object: the object to enumerate
+ *
+ * Enumerates all non-hidden properties of a given object and its prototypes
+ * and returns their names as garbage-collected strings in a list. This 
+ * function is a special case of swfdec_as_object_foreach().
+ *
+ * Returns: a GSList of all properties of the object. You need to 
+ *          g_slist_free() the list after use.
+ **/
+GSList *
+swfdec_as_object_enumerate (SwfdecAsObject *object)
+{
+  guint i;
+  GSList *list = NULL;
+  
+  for (i = 0; i < SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT && object; i++) {
+    swfdec_as_object_foreach (object, swfdec_as_object_enumerate_foreach, &list);
+    object = swfdec_as_object_get_prototype (object);
+  }
+  if (i == 256) {
+    swfdec_as_context_abort (object->context, "Prototype recursion limit exceeded");
+    g_slist_free (list);
+    return NULL;
+  }
+#if 0
+  list = g_slist_reverse (list);
+#else 
+  /* we force an alphabetical order into the list for now. This is wrong, 
+   * but at least ensures reproducability */
+  list = g_slist_sort (list, (GCompareFunc) strcmp);
+#endif
+  return list;
+}
+
 static void
 swfdec_as_object_do_nothing (SwfdecAsContext *cx, SwfdecAsObject *object,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
diff --git a/swfdec/swfdec_as_object.h b/swfdec/swfdec_as_object.h
index f1acba9..95f42ac 100644
--- a/swfdec/swfdec_as_object.h
+++ b/swfdec/swfdec_as_object.h
@@ -126,6 +126,7 @@ void		swfdec_as_object_unset_variable_flags
 gboolean	swfdec_as_object_foreach	(SwfdecAsObject *       object,
 						 SwfdecAsVariableForeach func,
 						 gpointer		data);
+GSList *	swfdec_as_object_enumerate	(SwfdecAsObject *	object);
 
 SwfdecAsFunction *swfdec_as_object_add_function	(SwfdecAsObject *	object,
 						 const char *		name,
commit bb5ece1032c5bb6db72e76e7b8f9e9040c7f1885
Author: MenTaLguY <mental at bede.(none)>
Date:   Mon Nov 17 17:46:15 2008 -0500

    fix BitmapData.fillRect and add test for it

diff --git a/swfdec/swfdec_bitmap_data.c b/swfdec/swfdec_bitmap_data.c
index ba0439f..041b448 100644
--- a/swfdec/swfdec_bitmap_data.c
+++ b/swfdec/swfdec_bitmap_data.c
@@ -399,14 +399,16 @@ swfdec_bitmap_data_fillRect (SwfdecAsContext *cx, SwfdecAsObject *object,
   if (!swfdec_rectangle_from_as_object (&rect, recto) || bitmap->surface == NULL)
     return;
 
-  /* We can treat a guint as a SwfdecColor */
-  if (SWFDEC_COLOR_ALPHA (color) == 0)
+  if (!swfdec_surface_has_alpha(bitmap->surface))
+    /* We can treat a guint as a SwfdecColor */
     color = SWFDEC_COLOR_OPAQUE (color);
 
   cr = cairo_create (bitmap->surface);
   swfdec_color_set_source (cr, color);
   cairo_rectangle (cr, rect.x, rect.y, rect.width, rect.height);
+  cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
   cairo_fill (cr);
+  cairo_destroy(cr);
   swfdec_bitmap_data_invalidate (bitmap, rect.x, rect.y, rect.width, rect.height);
 }
 
diff --git a/test/image/bitmap-data-fillRect-5.swf b/test/image/bitmap-data-fillRect-5.swf
new file mode 100644
index 0000000..bafe54b
Binary files /dev/null and b/test/image/bitmap-data-fillRect-5.swf differ
diff --git a/test/image/bitmap-data-fillRect-5.swf.png b/test/image/bitmap-data-fillRect-5.swf.png
new file mode 100644
index 0000000..9859129
Binary files /dev/null and b/test/image/bitmap-data-fillRect-5.swf.png differ
diff --git a/test/image/bitmap-data-fillRect-6.swf b/test/image/bitmap-data-fillRect-6.swf
new file mode 100644
index 0000000..73f3103
Binary files /dev/null and b/test/image/bitmap-data-fillRect-6.swf differ
diff --git a/test/image/bitmap-data-fillRect-6.swf.png b/test/image/bitmap-data-fillRect-6.swf.png
new file mode 100644
index 0000000..9859129
Binary files /dev/null and b/test/image/bitmap-data-fillRect-6.swf.png differ
diff --git a/test/image/bitmap-data-fillRect-7.swf b/test/image/bitmap-data-fillRect-7.swf
new file mode 100644
index 0000000..1121689
Binary files /dev/null and b/test/image/bitmap-data-fillRect-7.swf differ
diff --git a/test/image/bitmap-data-fillRect-7.swf.png b/test/image/bitmap-data-fillRect-7.swf.png
new file mode 100644
index 0000000..9859129
Binary files /dev/null and b/test/image/bitmap-data-fillRect-7.swf.png differ
diff --git a/test/image/bitmap-data-fillRect-8.swf b/test/image/bitmap-data-fillRect-8.swf
new file mode 100644
index 0000000..3f60b68
Binary files /dev/null and b/test/image/bitmap-data-fillRect-8.swf differ
diff --git a/test/image/bitmap-data-fillRect-8.swf.png b/test/image/bitmap-data-fillRect-8.swf.png
new file mode 100644
index 0000000..130d530
Binary files /dev/null and b/test/image/bitmap-data-fillRect-8.swf.png differ
diff --git a/test/image/bitmap-data-fillRect.as b/test/image/bitmap-data-fillRect.as
new file mode 100644
index 0000000..a2ef5a8
--- /dev/null
+++ b/test/image/bitmap-data-fillRect.as
@@ -0,0 +1,16 @@
+// makeswf -v 7 -s 200x150 -r 1 -o bitmap-data-fillRect.swf bitmap-data-fillRect.as
+
+var RECT_SIZE = 25;
+
+var mc1 = createEmptyMovieClip("mc1", getNextHighestDepth());
+var b1 = new flash.display.BitmapData(RECT_SIZE, RECT_SIZE, false, 0xffff0000);
+var mc2 = createEmptyMovieClip("mc2", getNextHighestDepth());
+var b2 = new flash.display.BitmapData(RECT_SIZE, RECT_SIZE, true, 0xffff0000);
+b1.fillRect(b1.rectangle, 0x80000000);
+b2.fillRect(b2.rectangle, 0x80000000);
+mc1.attachBitmap(b1, mc1.getNextHighestDepth());
+mc2.attachBitmap(b2, mc2.getNextHighestDepth());
+mc1._x = 0;
+mc1._y = 0;
+mc2._x = RECT_SIZE;
+mc2._y = RECT_SIZE;


More information about the Swfdec-commits mailing list