[Swfdec-commits] 5 commits - swfdec/swfdec_bitmap_data.c swfdec/swfdec_bitmap_data.h swfdec/swfdec_movie.c swfdec/swfdec_net_connection.c swfdec/swfdec_player.c swfdec/swfdec_sprite_movie_as.c swfdec/swfdec_sprite_movie.c

Benjamin Otte company at kemper.freedesktop.org
Fri Sep 19 06:24:20 PDT 2008


 swfdec/swfdec_bitmap_data.c     |   71 ++++++++++++++++++++++++----------------
 swfdec/swfdec_bitmap_data.h     |    7 +++
 swfdec/swfdec_movie.c           |   17 +++++----
 swfdec/swfdec_net_connection.c  |    2 -
 swfdec/swfdec_player.c          |    6 ---
 swfdec/swfdec_sprite_movie.c    |    1 
 swfdec/swfdec_sprite_movie_as.c |    1 
 7 files changed, 60 insertions(+), 45 deletions(-)

New commits:
commit 24f3313a67e5e611e2a14aed4c29aff1b5e87cd2
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Sep 18 18:48:16 2008 +0200

    improve debugging message

diff --git a/swfdec/swfdec_net_connection.c b/swfdec/swfdec_net_connection.c
index 234ca5f..8feb65a 100644
--- a/swfdec/swfdec_net_connection.c
+++ b/swfdec/swfdec_net_connection.c
@@ -87,7 +87,7 @@ swfdec_net_connection_connect (SwfdecNetConnection *conn, const char *url)
   g_free (conn->url);
   conn->url = g_strdup (url);
   if (url) {
-    SWFDEC_ERROR ("FIXME: using NetConnection with non-null URLs is not implemented");
+    SWFDEC_FIXME ("NetConnection with non-null URL %s (aka RTMP) not implemented", url);
   }
   swfdec_net_connection_onstatus (conn, SWFDEC_AS_STR_NetConnection_Connect_Success,
        SWFDEC_AS_STR_status, NULL);
commit 1496ee74db9c1675fb57962d523a5cd2a9cb7fd8
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Sep 18 18:41:54 2008 +0200

    add swfdec_bitmap_data_[gs]et_pixel and use them

diff --git a/swfdec/swfdec_bitmap_data.c b/swfdec/swfdec_bitmap_data.c
index 08e0fa3..4e97ee6 100644
--- a/swfdec/swfdec_bitmap_data.c
+++ b/swfdec/swfdec_bitmap_data.c
@@ -305,17 +305,13 @@ swfdec_bitmap_data_getPixel (SwfdecAsContext *cx, SwfdecAsObject *object,
 {
   SwfdecBitmapData *bitmap;
   guint x, y, color;
-  guint8 *addr;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_BITMAP_DATA, &bitmap, "ii", &x, &y);
 
   if (bitmap->surface == NULL || x >= (guint) bitmap->width || y >= (guint) bitmap->height)
     return;
 
-  addr = cairo_image_surface_get_data (bitmap->surface);
-  addr += cairo_image_surface_get_stride (bitmap->surface) * y;
-  addr += 4 * x;
-  color = *(SwfdecColor *) addr;
+  color = swfdec_bitmap_data_get_pixel (bitmap, x, y);
   color = SWFDEC_COLOR_UNMULTIPLY (color);
   color &= SWFDEC_COLOR_COMBINE (0xFF, 0xFF, 0xFF, 0);
   SWFDEC_AS_VALUE_SET_INT (ret, color);
@@ -329,21 +325,17 @@ swfdec_bitmap_data_setPixel (SwfdecAsContext *cx, SwfdecAsObject *object,
   SwfdecBitmapData *bitmap;
   guint x, y, color;
   SwfdecColor old;
-  guint8 *addr;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_BITMAP_DATA, &bitmap, "iii", &x, &y, &color);
 
   if (bitmap->surface == NULL || x >= bitmap->width || y >= bitmap->height)
     return;
 
-  addr = cairo_image_surface_get_data (bitmap->surface);
-  addr += cairo_image_surface_get_stride (bitmap->surface) * y;
-  addr += 4 * x;
-  old = *(SwfdecColor *) addr;
+  old = swfdec_bitmap_data_get_pixel (bitmap, x, y);
   old |= SWFDEC_COLOR_COMBINE (0xFF, 0xFF, 0xFF, 0);
   color = old & SWFDEC_COLOR_OPAQUE (color);
-  *(SwfdecColor *) addr = SWFDEC_COLOR_MULTIPLY (color);
-  swfdec_bitmap_data_invalidate (bitmap, x, y, 1, 1);
+  color = SWFDEC_COLOR_MULTIPLY (color);
+  swfdec_bitmap_data_set_pixel (bitmap, x, y, color);
 }
 
 SWFDEC_AS_NATIVE (1100, 3, swfdec_bitmap_data_fillRect)
@@ -558,17 +550,13 @@ swfdec_bitmap_data_getPixel32 (SwfdecAsContext *cx, SwfdecAsObject *object,
 {
   SwfdecBitmapData *bitmap;
   guint x, y, color;
-  guint8 *addr;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_BITMAP_DATA, &bitmap, "ii", &x, &y);
 
   if (bitmap->surface == NULL || x >= bitmap->width || y >= bitmap->height)
     return;
 
-  addr = cairo_image_surface_get_data (bitmap->surface);
-  addr += cairo_image_surface_get_stride (bitmap->surface) * y;
-  addr += 4 * x;
-  color = *(SwfdecColor *) addr;
+  color = swfdec_bitmap_data_get_pixel (bitmap, x, y);
   color = SWFDEC_COLOR_UNMULTIPLY (color);
   SWFDEC_AS_VALUE_SET_INT (ret, color);
 }
@@ -580,22 +568,18 @@ swfdec_bitmap_data_setPixel32 (SwfdecAsContext *cx, SwfdecAsObject *object,
 {
   SwfdecBitmapData *bitmap;
   guint x, y, color;
-  guint8 *addr;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_BITMAP_DATA, &bitmap, "iii", &x, &y, &color);
 
   if (bitmap->surface == NULL || x >= bitmap->width || y >= bitmap->height)
     return;
 
-  addr = cairo_image_surface_get_data (bitmap->surface);
-  addr += cairo_image_surface_get_stride (bitmap->surface) * y;
-  addr += 4 * x;
   if (swfdec_surface_has_alpha (bitmap->surface)) {
-    *(SwfdecColor *) addr = SWFDEC_COLOR_MULTIPLY ((SwfdecColor) color);
+    color = SWFDEC_COLOR_MULTIPLY ((SwfdecColor) color);
   } else {
-    *(SwfdecColor *) addr = SWFDEC_COLOR_OPAQUE ((SwfdecColor) color);
+    color = SWFDEC_COLOR_OPAQUE ((SwfdecColor) color);
   }
-  swfdec_bitmap_data_invalidate (bitmap, x, y, 1, 1);
+  swfdec_bitmap_data_set_pixel (bitmap, x, y, color);
 }
 
 SWFDEC_AS_NATIVE (1100, 12, swfdec_bitmap_data_floodFill)
@@ -860,3 +844,35 @@ swfdec_bitmap_data_get_pattern (SwfdecBitmapData *bitmap, SwfdecRenderer *render
 
   return pattern;
 }
+
+SwfdecColor
+swfdec_bitmap_data_get_pixel (SwfdecBitmapData *bitmap, guint x, guint y)
+{
+  guint8 *addr;
+
+  g_return_val_if_fail (SWFDEC_IS_BITMAP_DATA (bitmap), 0);
+  g_return_val_if_fail (x < bitmap->width, 0);
+  g_return_val_if_fail (y < bitmap->height, 0);
+
+  addr = cairo_image_surface_get_data (bitmap->surface);
+  addr += cairo_image_surface_get_stride (bitmap->surface) * y;
+  addr += 4 * x;
+  return *(guint32 *) addr;
+}
+
+void
+swfdec_bitmap_data_set_pixel (SwfdecBitmapData *bitmap, guint x, guint y, SwfdecColor color)
+{
+  guint8 *addr;
+
+  g_return_if_fail (SWFDEC_IS_BITMAP_DATA (bitmap));
+  g_return_if_fail (x < bitmap->width);
+  g_return_if_fail (y < bitmap->height);
+
+  addr = cairo_image_surface_get_data (bitmap->surface);
+  addr += cairo_image_surface_get_stride (bitmap->surface) * y;
+  addr += 4 * x;
+  *(guint32 *) addr = color;
+  swfdec_bitmap_data_invalidate (bitmap, x, y, 1, 1);
+}
+
diff --git a/swfdec/swfdec_bitmap_data.h b/swfdec/swfdec_bitmap_data.h
index f8efa6b..b1417c7 100644
--- a/swfdec/swfdec_bitmap_data.h
+++ b/swfdec/swfdec_bitmap_data.h
@@ -60,6 +60,13 @@ guint			swfdec_bitmap_data_get_height		(SwfdecBitmapData *	data);
 cairo_pattern_t *	swfdec_bitmap_data_get_pattern		(SwfdecBitmapData *	data,
 								 SwfdecRenderer *	renderer,
 								 const SwfdecColorTransform *ctrans);
+SwfdecColor		swfdec_bitmap_data_get_pixel		(SwfdecBitmapData *	bitmap,
+								 guint			x,
+								 guint			y);
+void			swfdec_bitmap_data_set_pixel		(SwfdecBitmapData *	bitmap,
+								 guint			x,
+								 guint			y,
+								 SwfdecColor		color);
 
 
 G_END_DECLS
commit ce83c94ec8c38ead0146f60d7939bc56504dd42b
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Sep 18 18:03:08 2008 +0200

    make the commented out code for drawing a rectangle around movies work again

diff --git a/swfdec/swfdec_movie.c b/swfdec/swfdec_movie.c
index dc735e7..c491df7 100644
--- a/swfdec/swfdec_movie.c
+++ b/swfdec/swfdec_movie.c
@@ -859,15 +859,16 @@ swfdec_movie_render (SwfdecMovie *movie, cairo_t *cr,
 #if 0
   /* code to draw a red rectangle around the area occupied by this movie clip */
   {
-    double x = 1.0, y = 0.0;
-    cairo_transform (cr, &movie->inverse_transform);
-    cairo_user_to_device_distance (cr, &x, &y);
-    cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
-    cairo_set_line_width (cr, 1 / sqrt (x * x + y * y));
-    cairo_rectangle (cr, object->extents.x0 + 10, object->extents.y0 + 10,
-	object->extents.x1 - object->extents.x0 - 20,
-	object->extents.y1 - object->extents.y0 - 20);
+    cairo_save (cr);
+    cairo_transform (cr, &movie->inverse_matrix);
+    cairo_rectangle (cr, movie->extents.x0, movie->extents.y0,
+	movie->extents.x1 - movie->extents.x0,
+	movie->extents.y1 - movie->extents.y0);
+    swfdec_renderer_reset_matrix (cr);
+    cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
+    cairo_set_line_width (cr, 2.0);
     cairo_stroke (cr);
+    cairo_restore (cr);
   }
 #endif
   if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
commit a6defbf6b8f52698f19490d8565126979b8a018e
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Sep 18 18:01:02 2008 +0200

    properly invalidate in BitmapData.copyPixels
    
    fixes slide test 36

diff --git a/swfdec/swfdec_bitmap_data.c b/swfdec/swfdec_bitmap_data.c
index 381a5f1..08e0fa3 100644
--- a/swfdec/swfdec_bitmap_data.c
+++ b/swfdec/swfdec_bitmap_data.c
@@ -57,6 +57,8 @@ swfdec_bitmap_data_invalidate (SwfdecBitmapData *bitmap, guint x, guint y, guint
   g_return_if_fail (w > 0);
   g_return_if_fail (h > 0);
 
+  if (bitmap->surface)
+    cairo_surface_mark_dirty_rectangle (bitmap->surface, x, y, w, h);
   g_signal_emit (bitmap, signals[INVALIDATE], 0, &rect);
 }
 
@@ -341,7 +343,6 @@ swfdec_bitmap_data_setPixel (SwfdecAsContext *cx, SwfdecAsObject *object,
   old |= SWFDEC_COLOR_COMBINE (0xFF, 0xFF, 0xFF, 0);
   color = old & SWFDEC_COLOR_OPAQUE (color);
   *(SwfdecColor *) addr = SWFDEC_COLOR_MULTIPLY (color);
-  cairo_surface_mark_dirty_rectangle (bitmap->surface, x, y, 1, 1);
   swfdec_bitmap_data_invalidate (bitmap, x, y, 1, 1);
 }
 
@@ -448,8 +449,7 @@ swfdec_bitmap_data_copyPixels (SwfdecAsContext *cx, SwfdecAsObject *object,
   }
   cairo_fill (cr);
   cairo_destroy (cr);
-  cairo_surface_mark_dirty_rectangle (bitmap->surface, rect.x, rect.y, 
-      rect.width, rect.height);
+  swfdec_bitmap_data_invalidate (bitmap, rect.x, rect.y, rect.width, rect.height);
 }
 
 SWFDEC_AS_NATIVE (1100, 5, swfdec_bitmap_data_applyFilter)
@@ -595,7 +595,6 @@ swfdec_bitmap_data_setPixel32 (SwfdecAsContext *cx, SwfdecAsObject *object,
   } else {
     *(SwfdecColor *) addr = SWFDEC_COLOR_OPAQUE ((SwfdecColor) color);
   }
-  cairo_surface_mark_dirty_rectangle (bitmap->surface, x, y, 1, 1);
   swfdec_bitmap_data_invalidate (bitmap, x, y, 1, 1);
 }
 
commit 37a0dde83e494f6fc91dea1906514f3eaf058173
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Sep 18 16:38:51 2008 +0200

    remove all my debugging messages
    
    Now everybody will know my secrets, oh no!

diff --git a/swfdec/swfdec_player.c b/swfdec/swfdec_player.c
index d771b28..4bf3ad3 100644
--- a/swfdec/swfdec_player.c
+++ b/swfdec/swfdec_player.c
@@ -2463,9 +2463,7 @@ swfdec_player_invalidate_movie (SwfdecMovie *movie, double xscale, double yscale
   GSList *walk;
 
   while (movie != NULL) {
-    g_print ("%s\n", movie->name);
     for (walk = movie->filters; walk; walk = walk->next) {
-      g_print ("%g %g\n", xscale, yscale);
       swfdec_filter_get_rectangle (walk->data, rect, xscale, yscale, rect);
     }
     movie = movie->parent;
@@ -2504,14 +2502,10 @@ swfdec_player_invalidate (SwfdecPlayer *player, SwfdecMovie *movie, const Swfdec
 
     swfdec_rect_transform (&tmp, rect, &priv->global_to_stage);
     swfdec_rectangle_init_rect (&r, &tmp);
-    if (movie)
-      g_print ("invalidating %s: %u %u %u %u\n", movie->name, r.x, r.y, r.width, r.height);
     swfdec_player_invalidate_movie (movie, 
 	player->priv->global_to_stage.xx * SWFDEC_TWIPS_SCALE_FACTOR,
 	player->priv->global_to_stage.yy * SWFDEC_TWIPS_SCALE_FACTOR,
 	&r);
-    if (movie)
-      g_print ("invalidating %s: %u %u %u %u\n", movie->name, r.x, r.y, r.width, r.height);
 
     /* 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
diff --git a/swfdec/swfdec_sprite_movie.c b/swfdec/swfdec_sprite_movie.c
index ba85e5d..2e9c34b 100644
--- a/swfdec/swfdec_sprite_movie.c
+++ b/swfdec/swfdec_sprite_movie.c
@@ -350,7 +350,6 @@ out:
       g_slist_free (cur->filters);
     swfdec_movie_invalidate_next (cur);
     cur->filters = filters;
-    g_print ("%s: setting %u filters\n", cur->name, g_slist_length (filters));
   }
 
   if (events)
diff --git a/swfdec/swfdec_sprite_movie_as.c b/swfdec/swfdec_sprite_movie_as.c
index 5bf9b68..ab22c74 100644
--- a/swfdec/swfdec_sprite_movie_as.c
+++ b/swfdec/swfdec_sprite_movie_as.c
@@ -154,7 +154,6 @@ swfdec_sprite_movie_set_filters (SwfdecAsContext *cx, SwfdecAsObject *object,
   SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "o", &array);
 
   swfdec_movie_invalidate_next (movie);
-  g_print ("movie %s gets filters, w00t!\n", movie->name);
 
   swfdec_as_object_get_variable (array, SWFDEC_AS_STR_length, &val);
   length = swfdec_as_value_to_integer (cx, &val);


More information about the Swfdec-commits mailing list