[Swfdec-commits] 7 commits - swfdec/Makefile.am swfdec/swfdec_blur_filter.c swfdec/swfdec_color_matrix_filter_as.c swfdec/swfdec_color_matrix_filter.c swfdec/swfdec_color_matrix_filter.h swfdec/swfdec_filter.h swfdec/swfdec_movie.c swfdec/swfdec_resource.c test/image

Benjamin Otte company at kemper.freedesktop.org
Mon Sep 15 10:23:35 PDT 2008


 swfdec/Makefile.am                        |    2 
 swfdec/swfdec_blur_filter.c               |    7 +
 swfdec/swfdec_color_matrix_filter.c       |  112 ++++++++++++++++++++++++------
 swfdec/swfdec_color_matrix_filter.h       |   53 ++++++++++++++
 swfdec/swfdec_color_matrix_filter_as.c    |  106 ++++++++++++++++++++++++++++
 swfdec/swfdec_filter.h                    |   21 ++---
 swfdec/swfdec_movie.c                     |   12 ++-
 swfdec/swfdec_resource.c                  |    4 -
 test/image/BlurFilter-rendering-5.swf     |binary
 test/image/BlurFilter-rendering-5.swf.png |binary
 test/image/BlurFilter-rendering-6.swf     |binary
 test/image/BlurFilter-rendering-6.swf.png |binary
 test/image/BlurFilter-rendering-7.swf     |binary
 test/image/BlurFilter-rendering-7.swf.png |binary
 test/image/BlurFilter-rendering-8.swf     |binary
 test/image/BlurFilter-rendering-8.swf.png |binary
 test/image/BlurFilter-rendering.as        |   27 +++++++
 test/image/Makefile.am                    |    9 ++
 18 files changed, 313 insertions(+), 40 deletions(-)

New commits:
commit 08ae0ba01e430671b1e3bcc8f5b616753c72e123
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Sep 15 19:13:33 2008 +0200

    implement color matrix filter
    
    Side note: This filter is useful for determining the area a filter affects:
    use the matrix [0, 0, 0, 0, 1] and the filter will make everything red that
    was affected

diff --git a/swfdec/Makefile.am b/swfdec/Makefile.am
index f9d8dfe..2ad2dd5 100644
--- a/swfdec/Makefile.am
+++ b/swfdec/Makefile.am
@@ -65,6 +65,7 @@ libswfdec_source_files = \
 	swfdec_color.c \
 	swfdec_color_as.c \
 	swfdec_color_matrix_filter.c \
+	swfdec_color_matrix_filter_as.c \
 	swfdec_color_transform_as.c \
 	swfdec_constant_pool.c \
 	swfdec_convolution_filter.c \
@@ -269,6 +270,7 @@ noinst_HEADERS = \
 	swfdec_codec_gst.h \
 	swfdec_color.h \
 	swfdec_color_transform_as.h \
+	swfdec_color_matrix_filter.h \
 	swfdec_constant_pool.h \
 	swfdec_convolution_matrix.h \
 	swfdec_debug.h \
diff --git a/swfdec/swfdec_color_matrix_filter.c b/swfdec/swfdec_color_matrix_filter.c
index 95959af..8da4ac7 100644
--- a/swfdec/swfdec_color_matrix_filter.c
+++ b/swfdec/swfdec_color_matrix_filter.c
@@ -1,5 +1,5 @@
 /* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -21,33 +21,103 @@
 #include "config.h"
 #endif
 
-#include "swfdec_as_internal.h"
+#include "swfdec_color_matrix_filter.h"
+
+#include <string.h>
+
 #include "swfdec_debug.h"
 
-SWFDEC_AS_NATIVE (1110, 1, swfdec_color_matrix_filter_get_matrix)
-void
-swfdec_color_matrix_filter_get_matrix (SwfdecAsContext *cx,
-    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
-    SwfdecAsValue *ret)
+G_DEFINE_TYPE (SwfdecColorMatrixFilter, swfdec_color_matrix_filter, SWFDEC_TYPE_FILTER)
+
+static void
+swfdec_color_matrix_filter_clone (SwfdecFilter *dfilter, SwfdecFilter *sfilter)
 {
-  SWFDEC_STUB ("ColorMatrixFilter.matrix (get)");
+  SwfdecColorMatrixFilter *dest = SWFDEC_COLOR_MATRIX_FILTER (dfilter);
+  SwfdecColorMatrixFilter *source = SWFDEC_COLOR_MATRIX_FILTER (sfilter);
+
+  memcpy (dest->matrix, source->matrix, sizeof (double) * 20);
 }
 
-SWFDEC_AS_NATIVE (1110, 2, swfdec_color_matrix_filter_set_matrix)
-void
-swfdec_color_matrix_filter_set_matrix (SwfdecAsContext *cx,
-    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
-    SwfdecAsValue *ret)
+static void
+swfdec_color_matrix_filter_get_rectangle (SwfdecFilter *filter, SwfdecRectangle *dest,
+    const SwfdecRectangle *source)
 {
-  SWFDEC_STUB ("ColorMatrixFilter.matrix (set)");
+  if (dest != source)
+    *dest = *source;
 }
 
-// constructor
-SWFDEC_AS_NATIVE (1110, 0, swfdec_color_matrix_filter_contruct)
-void
-swfdec_color_matrix_filter_contruct (SwfdecAsContext *cx,
-    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
-    SwfdecAsValue *ret)
+static cairo_pattern_t *
+swfdec_color_matrix_filter_apply (SwfdecFilter *filter, cairo_pattern_t *pattern,
+    const SwfdecRectangle *rect)
 {
-  SWFDEC_STUB ("ColorMatrixFilter");
+  SwfdecColorMatrixFilter *cm = SWFDEC_COLOR_MATRIX_FILTER (filter);
+  cairo_surface_t *surface;
+  int x, y;
+  guint8 *data;
+  guint stride;
+  cairo_t *cr;
+  double a, r, g, b, anew, tmp;
+
+  /* FIXME: make this work in a single pass (requires smarter matrix construction) */
+  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, rect->width, rect->height);
+  cairo_surface_set_device_offset (surface, -rect->x, -rect->y);
+
+  cr = cairo_create (surface);
+  cairo_set_source (cr, pattern);
+  cairo_rectangle (cr, rect->x, rect->y, rect->width, rect->height);
+  cairo_fill (cr);
+  cairo_destroy (cr);
+
+  data = cairo_image_surface_get_data (surface);
+  stride = cairo_image_surface_get_stride (surface);
+  for (y = 0; y < rect->height; y++) {
+    for (x = 0; x < rect->height; x++) {
+      a = data[x * 4 + SWFDEC_COLOR_INDEX_ALPHA];
+      r = data[x * 4 + SWFDEC_COLOR_INDEX_RED];
+      g = data[x * 4 + SWFDEC_COLOR_INDEX_GREEN];
+      b = data[x * 4 + SWFDEC_COLOR_INDEX_BLUE];
+      anew = r * cm->matrix[15] + g * cm->matrix[16] + b * cm->matrix[17] +
+	a * cm->matrix[18] + cm->matrix[19];
+      anew = CLAMP (anew, 0, 255);
+      data[x * 4 + SWFDEC_COLOR_INDEX_ALPHA] = anew;
+      tmp = r * cm->matrix[0] + g * cm->matrix[1] + b * cm->matrix[2] +
+	a * cm->matrix[3] + cm->matrix[4];
+      tmp = CLAMP (tmp, 0, anew);
+      data[x * 4 + SWFDEC_COLOR_INDEX_RED] = tmp;
+      tmp = r * cm->matrix[5] + g * cm->matrix[6] + b * cm->matrix[7] +
+	a * cm->matrix[8] + cm->matrix[9];
+      tmp = CLAMP (tmp, 0, anew);
+      data[x * 4 + SWFDEC_COLOR_INDEX_GREEN] = tmp;
+      tmp = r * cm->matrix[10] + g * cm->matrix[11] + b * cm->matrix[12] +
+	a * cm->matrix[13] + cm->matrix[14];
+      tmp = CLAMP (tmp, 0, anew);
+      data[x * 4 + SWFDEC_COLOR_INDEX_BLUE] = tmp;
+    }
+    data += stride;
+  }
+
+  pattern = cairo_pattern_create_for_surface (surface);
+  cairo_surface_destroy (surface);
+
+  return pattern;
 }
+
+static void
+swfdec_color_matrix_filter_class_init (SwfdecColorMatrixFilterClass *klass)
+{
+  SwfdecFilterClass *filter_class = SWFDEC_FILTER_CLASS (klass);
+
+  filter_class->clone = swfdec_color_matrix_filter_clone;
+  filter_class->get_rectangle = swfdec_color_matrix_filter_get_rectangle;
+  filter_class->apply = swfdec_color_matrix_filter_apply;
+}
+
+static void
+swfdec_color_matrix_filter_init (SwfdecColorMatrixFilter *filter)
+{
+  filter->matrix[0] = 1.0;
+  filter->matrix[6] = 1.0;
+  filter->matrix[12] = 1.0;
+  filter->matrix[18] = 1.0;
+}
+
diff --git a/swfdec/swfdec_color_matrix_filter.h b/swfdec/swfdec_color_matrix_filter.h
new file mode 100644
index 0000000..b5d0b74
--- /dev/null
+++ b/swfdec/swfdec_color_matrix_filter.h
@@ -0,0 +1,53 @@
+/* Swfdec
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA  02110-1301  USA
+ */
+
+#ifndef _SWFDEC_COLOR_MATRIX_FILTER_H_
+#define _SWFDEC_COLOR_MATRIX_FILTER_H_
+
+#include <swfdec/swfdec_filter.h>
+#include <swfdec/swfdec_convolution_matrix.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _SwfdecColorMatrixFilter SwfdecColorMatrixFilter;
+typedef struct _SwfdecColorMatrixFilterClass SwfdecColorMatrixFilterClass;
+
+#define SWFDEC_TYPE_COLOR_MATRIX_FILTER                    (swfdec_color_matrix_filter_get_type())
+#define SWFDEC_IS_COLOR_MATRIX_FILTER(obj)                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_COLOR_MATRIX_FILTER))
+#define SWFDEC_IS_COLOR_MATRIX_FILTER_CLASS(klass)         (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_COLOR_MATRIX_FILTER))
+#define SWFDEC_COLOR_MATRIX_FILTER(obj)                    (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_COLOR_MATRIX_FILTER, SwfdecColorMatrixFilter))
+#define SWFDEC_COLOR_MATRIX_FILTER_CLASS(klass)            (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_COLOR_MATRIX_FILTER, SwfdecColorMatrixFilterClass))
+#define SWFDEC_COLOR_MATRIX_FILTER_GET_CLASS(obj)          (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_COLOR_MATRIX_FILTER, SwfdecColorMatrixFilterClass))
+
+struct _SwfdecColorMatrixFilter {
+  SwfdecFilter		filter;
+
+  double		matrix[20];	/* color matrix to apply */
+};
+
+struct _SwfdecColorMatrixFilterClass {
+  SwfdecFilterClass	filter_class;
+};
+
+GType			swfdec_color_matrix_filter_get_type	(void);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_color_matrix_filter_as.c b/swfdec/swfdec_color_matrix_filter_as.c
new file mode 100644
index 0000000..f87810e
--- /dev/null
+++ b/swfdec/swfdec_color_matrix_filter_as.c
@@ -0,0 +1,106 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *		 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_color_matrix_filter.h"
+
+#include <string.h>
+
+#include "swfdec_as_array.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (1110, 1, swfdec_color_matrix_filter_get_matrix)
+void
+swfdec_color_matrix_filter_get_matrix (SwfdecAsContext *cx,
+    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+    SwfdecAsValue *ret)
+{
+  SwfdecColorMatrixFilter *cm;
+  SwfdecAsObject *array;
+  SwfdecAsValue val[20];
+  guint i;
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_COLOR_MATRIX_FILTER, &cm, "");
+
+  for (i = 0; i < 20; i++) {
+    SWFDEC_AS_VALUE_SET_NUMBER (&val[i], cm->matrix[i]);
+  }
+  array = swfdec_as_array_new (cx);
+  swfdec_as_array_append (SWFDEC_AS_ARRAY (array), 20, val);
+  SWFDEC_AS_VALUE_SET_OBJECT (ret, array);
+}
+
+static void
+swfdec_color_matrix_filter_do_set_matrix (SwfdecColorMatrixFilter *cm, 
+    SwfdecAsObject *array)
+{
+  SwfdecAsContext *cx = swfdec_gc_object_get_context (cm);
+  SwfdecAsValue val;
+  int i;
+
+  if (!SWFDEC_IS_AS_ARRAY (array)) {
+    memset (cm->matrix, 0, sizeof (double) * 20);
+    return;
+  }
+
+  for (i = 0; i < 20; i++) {
+    if (!swfdec_as_object_get_variable (array, swfdec_as_integer_to_string (cx, i), &val)) {
+      cm->matrix[i] = 0;
+    } else {
+      cm->matrix[i] = swfdec_as_value_to_number (cx, &val);
+    }
+  }
+}
+
+SWFDEC_AS_NATIVE (1110, 2, swfdec_color_matrix_filter_set_matrix)
+void
+swfdec_color_matrix_filter_set_matrix (SwfdecAsContext *cx,
+    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+    SwfdecAsValue *ret)
+{
+  SwfdecColorMatrixFilter *cm;
+  SwfdecAsObject *array;
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_COLOR_MATRIX_FILTER, &cm, "o", &array);
+
+  swfdec_color_matrix_filter_do_set_matrix (cm, array);
+}
+
+SWFDEC_AS_CONSTRUCTOR (1110, 0, swfdec_color_matrix_filter_contruct, swfdec_color_matrix_filter_get_type)
+void
+swfdec_color_matrix_filter_contruct (SwfdecAsContext *cx,
+    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+    SwfdecAsValue *ret)
+{
+  SwfdecColorMatrixFilter *cm;
+  SwfdecAsObject *array;
+
+  if (!swfdec_as_context_is_constructing (cx))
+    return;
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_COLOR_MATRIX_FILTER, &cm, "o", &array);
+
+  swfdec_color_matrix_filter_do_set_matrix (cm, array);
+}
commit 697599be29514e6336adf2bbb8fa014ff2005580
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Sep 15 19:13:03 2008 +0200

    SWF files seem to be loaded without requiring a policy file

diff --git a/swfdec/swfdec_resource.c b/swfdec/swfdec_resource.c
index 5fb9f01..67a5c9c 100644
--- a/swfdec/swfdec_resource.c
+++ b/swfdec/swfdec_resource.c
@@ -592,8 +592,8 @@ static const SwfdecAccessMatrix swfdec_resource_matrix = {
   { SWFDEC_ACCESS_NO,  SWFDEC_ACCESS_NO,  SWFDEC_ACCESS_NO },
   { SWFDEC_ACCESS_NO,  SWFDEC_ACCESS_YES, SWFDEC_ACCESS_YES },
   { SWFDEC_ACCESS_YES, SWFDEC_ACCESS_NO,  SWFDEC_ACCESS_NO },
-  { SWFDEC_ACCESS_YES, SWFDEC_ACCESS_NO,  SWFDEC_ACCESS_POLICY },
-  { SWFDEC_ACCESS_YES, SWFDEC_ACCESS_NO,  SWFDEC_ACCESS_POLICY }
+  { SWFDEC_ACCESS_YES, SWFDEC_ACCESS_NO,  SWFDEC_ACCESS_YES },
+  { SWFDEC_ACCESS_YES, SWFDEC_ACCESS_NO,  SWFDEC_ACCESS_YES }
 };
 
 static void
commit 2a9f4cfab2cdb6a1730f0beec126604e3005460b
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Sep 15 18:09:49 2008 +0200

    filters are implemented now

diff --git a/swfdec/swfdec_movie.c b/swfdec/swfdec_movie.c
index 11a5699..b63845c 100644
--- a/swfdec/swfdec_movie.c
+++ b/swfdec/swfdec_movie.c
@@ -829,7 +829,7 @@ swfdec_movie_render (SwfdecMovie *movie, cairo_t *cr,
     SWFDEC_DEBUG ("pushing group for blend mode %u", movie->blend_mode);
     cairo_push_group (cr);
   } else if (group != SWFDEC_GROUP_NONE) {
-    SWFDEC_FIXME ("implement cache-as-bitmap and filters here");
+    SWFDEC_FIXME ("implement cache-as-bitmap here");
     cairo_push_group (cr);
   }
   /* yes, movie with filters, don't get masked */
commit b5051ed8c23eee6242f4dd081b0e3c83eb188c55
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Sep 15 17:54:35 2008 +0200

    use double for computing the device offset (we used negative uints, oops)
    
    Also use proper mark functions when drawing on the surface

diff --git a/swfdec/swfdec_blur_filter.c b/swfdec/swfdec_blur_filter.c
index aab6386..ba4c096 100644
--- a/swfdec/swfdec_blur_filter.c
+++ b/swfdec/swfdec_blur_filter.c
@@ -114,18 +114,20 @@ swfdec_blur_filter_apply (SwfdecFilter *filter, cairo_pattern_t *pattern,
       rect->width + 2 * x * blur->quality,
       rect->height + 2 * y * blur->quality);
   cairo_surface_set_device_offset (a, 
-      - rect->x + x * blur->quality, - rect->y + y * blur->quality);
+      - (double) rect->x + x * blur->quality, - (double) rect->y + y * blur->quality);
   b = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
       rect->width + 2 * x * blur->quality,
       rect->height + 2 * y * blur->quality);
   cairo_surface_set_device_offset (b, 
-      - rect->x + x * blur->quality, - rect->y + y * blur->quality);
+      - (double) rect->x + x * blur->quality, - (double) rect->y + y * blur->quality);
 
   cr = cairo_create (b);
   cairo_set_source (cr, pattern);
   cairo_rectangle (cr, rect->x, rect->y, rect->width, rect->height);
   cairo_fill (cr);
   cairo_destroy (cr);
+  cairo_surface_flush (b);
+
   adata = cairo_image_surface_get_data (a);
   astride = cairo_image_surface_get_stride (a);
   bdata = cairo_image_surface_get_data (b);
@@ -150,6 +152,7 @@ swfdec_blur_filter_apply (SwfdecFilter *filter, cairo_pattern_t *pattern,
   cairo_surface_destroy (a);
   a = b;
 out:
+  cairo_surface_mark_dirty (a);
   pattern = cairo_pattern_create_for_surface (a);
   cairo_surface_destroy (a);
 
commit d23af3ac08a4a8b256045169d91c84ff149fd8fb
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Sep 15 16:37:02 2008 +0200

    indentation fix

diff --git a/swfdec/swfdec_filter.h b/swfdec/swfdec_filter.h
index 6431dac..1dea930 100644
--- a/swfdec/swfdec_filter.h
+++ b/swfdec/swfdec_filter.h
@@ -55,18 +55,17 @@ struct _SwfdecFilterClass {
 
 GType			swfdec_filter_get_type	(void);
 
-SwfdecFilter *		swfdec_filter_clone	(SwfdecFilter *		filter);
-cairo_pattern_t *	swfdec_filter_apply	(SwfdecFilter *		filter,
-						 cairo_pattern_t *	pattern,
-						 const SwfdecRectangle *source);
-void			swfdec_filter_get_rectangle
-						(SwfdecFilter *		filter,
-						 SwfdecRectangle *	dest,
-						 const SwfdecRectangle *source);
+SwfdecFilter *		swfdec_filter_clone		(SwfdecFilter *		filter);
+cairo_pattern_t *	swfdec_filter_apply		(SwfdecFilter *		filter,
+							 cairo_pattern_t *	pattern,
+							 const SwfdecRectangle *source);
+void			swfdec_filter_get_rectangle	(SwfdecFilter *		filter,
+							 SwfdecRectangle *	dest,
+							 const SwfdecRectangle *source);
 
-GSList *		swfdec_filter_parse	(SwfdecPlayer *		player,
-						 SwfdecBits *		bits);
-void			swfdec_filter_skip	(SwfdecBits *		bits);
+GSList *		swfdec_filter_parse		(SwfdecPlayer *		player,
+							 SwfdecBits *		bits);
+void			swfdec_filter_skip		(SwfdecBits *		bits);
 						
 
 G_END_DECLS
commit 6ffc679406b1556c7c208e6aa8b0c4d203461ce3
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Sep 15 13:25:32 2008 +0200

    add a test for BlurFilter rendering

diff --git a/test/image/BlurFilter-rendering-5.swf b/test/image/BlurFilter-rendering-5.swf
new file mode 100644
index 0000000..1039ba2
Binary files /dev/null and b/test/image/BlurFilter-rendering-5.swf differ
diff --git a/test/image/BlurFilter-rendering-5.swf.png b/test/image/BlurFilter-rendering-5.swf.png
new file mode 100644
index 0000000..1c191a2
Binary files /dev/null and b/test/image/BlurFilter-rendering-5.swf.png differ
diff --git a/test/image/BlurFilter-rendering-6.swf b/test/image/BlurFilter-rendering-6.swf
new file mode 100644
index 0000000..884c512
Binary files /dev/null and b/test/image/BlurFilter-rendering-6.swf differ
diff --git a/test/image/BlurFilter-rendering-6.swf.png b/test/image/BlurFilter-rendering-6.swf.png
new file mode 100644
index 0000000..1c191a2
Binary files /dev/null and b/test/image/BlurFilter-rendering-6.swf.png differ
diff --git a/test/image/BlurFilter-rendering-7.swf b/test/image/BlurFilter-rendering-7.swf
new file mode 100644
index 0000000..1fd2aa1
Binary files /dev/null and b/test/image/BlurFilter-rendering-7.swf differ
diff --git a/test/image/BlurFilter-rendering-7.swf.png b/test/image/BlurFilter-rendering-7.swf.png
new file mode 100644
index 0000000..02b8b77
Binary files /dev/null and b/test/image/BlurFilter-rendering-7.swf.png differ
diff --git a/test/image/BlurFilter-rendering-8.swf b/test/image/BlurFilter-rendering-8.swf
new file mode 100644
index 0000000..119ad0e
Binary files /dev/null and b/test/image/BlurFilter-rendering-8.swf differ
diff --git a/test/image/BlurFilter-rendering-8.swf.png b/test/image/BlurFilter-rendering-8.swf.png
new file mode 100644
index 0000000..ef39f1f
Binary files /dev/null and b/test/image/BlurFilter-rendering-8.swf.png differ
diff --git a/test/image/BlurFilter-rendering.as b/test/image/BlurFilter-rendering.as
new file mode 100644
index 0000000..bf8dfe5
--- /dev/null
+++ b/test/image/BlurFilter-rendering.as
@@ -0,0 +1,27 @@
+// makeswf -v 7 -s 200x150 -r 1 -o BlurFilter-rendering.swf BlurFilter-rendering.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 ();
+};
+
+
+for (x = 0; x < 4; x++) {
+  for (y = 0; y < 3; y++) {
+    a = createEmptyMovieClip ("a" + getNextHighestDepth (), getNextHighestDepth ());
+    rectangle (a, 0xFF, 10, 10, 30, 30);
+    a._x = 50 * x;
+    a._y = 50 * y;
+    a.filters = [ new flash.filters.BlurFilter (2 * y, 2 * y, x) ];
+  };
+};
+
+createEmptyMovieClip ("mask", 1000);
+rectangle (mask, 0xFF00, 5, 5, 30, 30);
+a.setMask (mask);
diff --git a/test/image/Makefile.am b/test/image/Makefile.am
index c063b0d..00c6276 100644
--- a/test/image/Makefile.am
+++ b/test/image/Makefile.am
@@ -93,6 +93,15 @@ EXTRA_DIST = \
 	bitmapFill-update-8.swf \
 	bitmapFill-update-8.swf.png \
 	bitmapFill-update.as \
+	BlurFilter-rendering-5.swf \
+	BlurFilter-rendering-5.swf.png \
+	BlurFilter-rendering-6.swf \
+	BlurFilter-rendering-6.swf.png \
+	BlurFilter-rendering-7.swf \
+	BlurFilter-rendering-7.swf.png \
+	BlurFilter-rendering-8.swf \
+	BlurFilter-rendering-8.swf.png \
+	BlurFilter-rendering.as \
 	bw.jpg \
 	clip-change.c \
 	clip-change-backward-5.swf \
commit 590f2495060d289b912e219a2c2bf2cbe7e08d82
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Sep 15 13:24:35 2008 +0200

    movies that are masked _and_ have filters, get neither of those applied
    
    Who'da thunk?

diff --git a/swfdec/swfdec_movie.c b/swfdec/swfdec_movie.c
index a9c7feb..11a5699 100644
--- a/swfdec/swfdec_movie.c
+++ b/swfdec/swfdec_movie.c
@@ -702,7 +702,8 @@ typedef enum {
 static SwfdecGroup
 swfdec_movie_needs_group (SwfdecMovie *movie)
 {
-  if (movie->filters)
+  /* yes, masked movies don't get filters applied */
+  if (movie->filters && movie->masked_by == NULL)
     return SWFDEC_GROUP_FILTERS;
   if (movie->cache_as_bitmap)
     return SWFDEC_GROUP_CACHED;
@@ -808,6 +809,7 @@ swfdec_movie_render (SwfdecMovie *movie, cairo_t *cr,
   SwfdecMovieClass *klass;
   SwfdecColorTransform trans;
   SwfdecGroup group;
+  gboolean needs_mask;
 
   g_return_if_fail (SWFDEC_IS_MOVIE (movie));
   g_return_if_fail (cr != NULL);
@@ -830,7 +832,9 @@ swfdec_movie_render (SwfdecMovie *movie, cairo_t *cr,
     SWFDEC_FIXME ("implement cache-as-bitmap and filters here");
     cairo_push_group (cr);
   }
-  if (movie->masked_by != NULL) {
+  /* yes, movie with filters, don't get masked */
+  needs_mask = movie->masked_by != NULL && movie->filters == NULL;
+  if (needs_mask) {
     cairo_push_group (cr);
   } else {
     cairo_save (cr);
@@ -863,7 +867,7 @@ swfdec_movie_render (SwfdecMovie *movie, cairo_t *cr,
   if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
     g_warning ("error rendering with cairo: %s", cairo_status_to_string (cairo_status (cr)));
   }
-  if (movie->masked_by) {
+  if (needs_mask) {
     cairo_pattern_t *mask;
     cairo_matrix_t mat;
     if (movie->parent)


More information about the Swfdec-commits mailing list