[Swfdec-commits] 2 commits - configure.ac swfdec/swfdec_movie.c test/image

Benjamin Otte company at kemper.freedesktop.org
Thu Dec 17 04:06:55 PST 2009


 configure.ac                               |    9 -
 swfdec/swfdec_movie.c                      |   41 +++++++-
 test/image/Makefile.am                     |   61 +++++++++++++
 test/image/blend-mode-0-7.swf              |binary
 test/image/blend-mode-0-7.swf.png          |binary
 test/image/blend-mode-0-8.swf              |binary
 test/image/blend-mode-0-8.swf.png          |binary
 test/image/blend-mode-15-7.swf             |binary
 test/image/blend-mode-15-7.swf.png         |binary
 test/image/blend-mode-15-8.swf             |binary
 test/image/blend-mode-15-8.swf.png         |binary
 test/image/blend-mode-add-7.swf            |binary
 test/image/blend-mode-add-7.swf.png        |binary
 test/image/blend-mode-add-8.swf            |binary
 test/image/blend-mode-add-8.swf.png        |binary
 test/image/blend-mode-alpha-7.swf          |binary
 test/image/blend-mode-alpha-7.swf.png      |binary
 test/image/blend-mode-alpha-8.swf          |binary
 test/image/blend-mode-alpha-8.swf.png      |binary
 test/image/blend-mode-darken-7.swf         |binary
 test/image/blend-mode-darken-7.swf.png     |binary
 test/image/blend-mode-darken-8.swf         |binary
 test/image/blend-mode-darken-8.swf.png     |binary
 test/image/blend-mode-difference-7.swf     |binary
 test/image/blend-mode-difference-7.swf.png |binary
 test/image/blend-mode-difference-8.swf     |binary
 test/image/blend-mode-difference-8.swf.png |binary
 test/image/blend-mode-erase-7.swf          |binary
 test/image/blend-mode-erase-7.swf.png      |binary
 test/image/blend-mode-erase-8.swf          |binary
 test/image/blend-mode-erase-8.swf.png      |binary
 test/image/blend-mode-hardlight-7.swf      |binary
 test/image/blend-mode-hardlight-7.swf.png  |binary
 test/image/blend-mode-hardlight-8.swf      |binary
 test/image/blend-mode-hardlight-8.swf.png  |binary
 test/image/blend-mode-inverse-7.swf        |binary
 test/image/blend-mode-inverse-7.swf.png    |binary
 test/image/blend-mode-inverse-8.swf        |binary
 test/image/blend-mode-inverse-8.swf.png    |binary
 test/image/blend-mode-layer-7.swf          |binary
 test/image/blend-mode-layer-7.swf.png      |binary
 test/image/blend-mode-layer-8.swf          |binary
 test/image/blend-mode-layer-8.swf.png      |binary
 test/image/blend-mode-lighten-7.swf        |binary
 test/image/blend-mode-lighten-7.swf.png    |binary
 test/image/blend-mode-lighten-8.swf        |binary
 test/image/blend-mode-lighten-8.swf.png    |binary
 test/image/blend-mode-multiply-7.swf       |binary
 test/image/blend-mode-multiply-7.swf.png   |binary
 test/image/blend-mode-multiply-8.swf       |binary
 test/image/blend-mode-multiply-8.swf.png   |binary
 test/image/blend-mode-normal-7.swf         |binary
 test/image/blend-mode-normal-7.swf.png     |binary
 test/image/blend-mode-normal-8.swf         |binary
 test/image/blend-mode-normal-8.swf.png     |binary
 test/image/blend-mode-overlay-7.swf        |binary
 test/image/blend-mode-overlay-7.swf.png    |binary
 test/image/blend-mode-overlay-8.swf        |binary
 test/image/blend-mode-overlay-8.swf.png    |binary
 test/image/blend-mode-screen-7.swf         |binary
 test/image/blend-mode-screen-7.swf.png     |binary
 test/image/blend-mode-screen-8.swf         |binary
 test/image/blend-mode-screen-8.swf.png     |binary
 test/image/blend-mode.c                    |  134 +++++++++++++++++++++++++++++
 64 files changed, 231 insertions(+), 14 deletions(-)

New commits:
commit b80492d1ea809edf216ffb0245d798c2a039390c
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Aug 29 23:59:49 2007 +0200

    add blend mode tests

diff --git a/test/image/Makefile.am b/test/image/Makefile.am
index 3d0be09..65c9691 100644
--- a/test/image/Makefile.am
+++ b/test/image/Makefile.am
@@ -93,6 +93,67 @@ EXTRA_DIST = \
 	bitmapFill-update-8.swf \
 	bitmapFill-update-8.swf.png \
 	bitmapFill-update.as \
+	blend-mode.c \
+	blend-mode-0-7.swf \
+	blend-mode-0-7.swf.png \
+	blend-mode-0-8.swf \
+	blend-mode-0-8.swf.png \
+	blend-mode-15-7.swf \
+	blend-mode-15-7.swf.png \
+	blend-mode-15-8.swf \
+	blend-mode-15-8.swf.png \
+	blend-mode-add-7.swf \
+	blend-mode-add-7.swf.png \
+	blend-mode-add-8.swf \
+	blend-mode-add-8.swf.png \
+	blend-mode-alpha-7.swf \
+	blend-mode-alpha-7.swf.png \
+	blend-mode-alpha-8.swf \
+	blend-mode-alpha-8.swf.png \
+	blend-mode-darken-7.swf \
+	blend-mode-darken-7.swf.png \
+	blend-mode-darken-8.swf \
+	blend-mode-darken-8.swf.png \
+	blend-mode-difference-7.swf \
+	blend-mode-difference-7.swf.png \
+	blend-mode-difference-8.swf \
+	blend-mode-difference-8.swf.png \
+	blend-mode-erase-7.swf \
+	blend-mode-erase-7.swf.png \
+	blend-mode-erase-8.swf \
+	blend-mode-erase-8.swf.png \
+	blend-mode-hardlight-7.swf \
+	blend-mode-hardlight-7.swf.png \
+	blend-mode-hardlight-8.swf \
+	blend-mode-hardlight-8.swf.png \
+	blend-mode-inverse-7.swf \
+	blend-mode-inverse-7.swf.png \
+	blend-mode-inverse-8.swf \
+	blend-mode-inverse-8.swf.png \
+	blend-mode-layer-7.swf \
+	blend-mode-layer-7.swf.png \
+	blend-mode-layer-8.swf \
+	blend-mode-layer-8.swf.png \
+	blend-mode-lighten-7.swf \
+	blend-mode-lighten-7.swf.png \
+	blend-mode-lighten-8.swf \
+	blend-mode-lighten-8.swf.png \
+	blend-mode-multiply-7.swf \
+	blend-mode-multiply-7.swf.png \
+	blend-mode-multiply-8.swf \
+	blend-mode-multiply-8.swf.png \
+	blend-mode-normal-7.swf \
+	blend-mode-normal-7.swf.png \
+	blend-mode-normal-8.swf \
+	blend-mode-normal-8.swf.png \
+	blend-mode-overlay-7.swf \
+	blend-mode-overlay-7.swf.png \
+	blend-mode-overlay-8.swf \
+	blend-mode-overlay-8.swf.png \
+	blend-mode-screen-7.swf \
+	blend-mode-screen-7.swf.png \
+	blend-mode-screen-8.swf \
+	blend-mode-screen-8.swf.png \
 	BlurFilter-rendering-5.swf \
 	BlurFilter-rendering-5.swf.png \
 	BlurFilter-rendering-6.swf \
diff --git a/test/image/blend-mode-0-7.swf b/test/image/blend-mode-0-7.swf
new file mode 100644
index 0000000..ab4e919
Binary files /dev/null and b/test/image/blend-mode-0-7.swf differ
diff --git a/test/image/blend-mode-0-7.swf.png b/test/image/blend-mode-0-7.swf.png
new file mode 100644
index 0000000..1a8b43d
Binary files /dev/null and b/test/image/blend-mode-0-7.swf.png differ
diff --git a/test/image/blend-mode-0-8.swf b/test/image/blend-mode-0-8.swf
new file mode 100644
index 0000000..4980ad9
Binary files /dev/null and b/test/image/blend-mode-0-8.swf differ
diff --git a/test/image/blend-mode-0-8.swf.png b/test/image/blend-mode-0-8.swf.png
new file mode 100644
index 0000000..d100dd7
Binary files /dev/null and b/test/image/blend-mode-0-8.swf.png differ
diff --git a/test/image/blend-mode-15-7.swf b/test/image/blend-mode-15-7.swf
new file mode 100644
index 0000000..52fcc48
Binary files /dev/null and b/test/image/blend-mode-15-7.swf differ
diff --git a/test/image/blend-mode-15-7.swf.png b/test/image/blend-mode-15-7.swf.png
new file mode 100644
index 0000000..ec5d486
Binary files /dev/null and b/test/image/blend-mode-15-7.swf.png differ
diff --git a/test/image/blend-mode-15-8.swf b/test/image/blend-mode-15-8.swf
new file mode 100644
index 0000000..e4a05e6
Binary files /dev/null and b/test/image/blend-mode-15-8.swf differ
diff --git a/test/image/blend-mode-15-8.swf.png b/test/image/blend-mode-15-8.swf.png
new file mode 100644
index 0000000..49167eb
Binary files /dev/null and b/test/image/blend-mode-15-8.swf.png differ
diff --git a/test/image/blend-mode-add-7.swf b/test/image/blend-mode-add-7.swf
new file mode 100644
index 0000000..ad33ae5
Binary files /dev/null and b/test/image/blend-mode-add-7.swf differ
diff --git a/test/image/blend-mode-add-7.swf.png b/test/image/blend-mode-add-7.swf.png
new file mode 100644
index 0000000..ec6e84b
Binary files /dev/null and b/test/image/blend-mode-add-7.swf.png differ
diff --git a/test/image/blend-mode-add-8.swf b/test/image/blend-mode-add-8.swf
new file mode 100644
index 0000000..9432f60
Binary files /dev/null and b/test/image/blend-mode-add-8.swf differ
diff --git a/test/image/blend-mode-add-8.swf.png b/test/image/blend-mode-add-8.swf.png
new file mode 100644
index 0000000..c9520f0
Binary files /dev/null and b/test/image/blend-mode-add-8.swf.png differ
diff --git a/test/image/blend-mode-alpha-7.swf b/test/image/blend-mode-alpha-7.swf
new file mode 100644
index 0000000..a0c3c3d
Binary files /dev/null and b/test/image/blend-mode-alpha-7.swf differ
diff --git a/test/image/blend-mode-alpha-7.swf.png b/test/image/blend-mode-alpha-7.swf.png
new file mode 100644
index 0000000..55f8abd
Binary files /dev/null and b/test/image/blend-mode-alpha-7.swf.png differ
diff --git a/test/image/blend-mode-alpha-8.swf b/test/image/blend-mode-alpha-8.swf
new file mode 100644
index 0000000..9f7bdfc
Binary files /dev/null and b/test/image/blend-mode-alpha-8.swf differ
diff --git a/test/image/blend-mode-alpha-8.swf.png b/test/image/blend-mode-alpha-8.swf.png
new file mode 100644
index 0000000..d64defd
Binary files /dev/null and b/test/image/blend-mode-alpha-8.swf.png differ
diff --git a/test/image/blend-mode-darken-7.swf b/test/image/blend-mode-darken-7.swf
new file mode 100644
index 0000000..40f8ff0
Binary files /dev/null and b/test/image/blend-mode-darken-7.swf differ
diff --git a/test/image/blend-mode-darken-7.swf.png b/test/image/blend-mode-darken-7.swf.png
new file mode 100644
index 0000000..9fda92e
Binary files /dev/null and b/test/image/blend-mode-darken-7.swf.png differ
diff --git a/test/image/blend-mode-darken-8.swf b/test/image/blend-mode-darken-8.swf
new file mode 100644
index 0000000..abab210
Binary files /dev/null and b/test/image/blend-mode-darken-8.swf differ
diff --git a/test/image/blend-mode-darken-8.swf.png b/test/image/blend-mode-darken-8.swf.png
new file mode 100644
index 0000000..05a7cca
Binary files /dev/null and b/test/image/blend-mode-darken-8.swf.png differ
diff --git a/test/image/blend-mode-difference-7.swf b/test/image/blend-mode-difference-7.swf
new file mode 100644
index 0000000..fdceadb
Binary files /dev/null and b/test/image/blend-mode-difference-7.swf differ
diff --git a/test/image/blend-mode-difference-7.swf.png b/test/image/blend-mode-difference-7.swf.png
new file mode 100644
index 0000000..b5faa9e
Binary files /dev/null and b/test/image/blend-mode-difference-7.swf.png differ
diff --git a/test/image/blend-mode-difference-8.swf b/test/image/blend-mode-difference-8.swf
new file mode 100644
index 0000000..dda194e
Binary files /dev/null and b/test/image/blend-mode-difference-8.swf differ
diff --git a/test/image/blend-mode-difference-8.swf.png b/test/image/blend-mode-difference-8.swf.png
new file mode 100644
index 0000000..be4f9c2
Binary files /dev/null and b/test/image/blend-mode-difference-8.swf.png differ
diff --git a/test/image/blend-mode-erase-7.swf b/test/image/blend-mode-erase-7.swf
new file mode 100644
index 0000000..631ee26
Binary files /dev/null and b/test/image/blend-mode-erase-7.swf differ
diff --git a/test/image/blend-mode-erase-7.swf.png b/test/image/blend-mode-erase-7.swf.png
new file mode 100644
index 0000000..7a47373
Binary files /dev/null and b/test/image/blend-mode-erase-7.swf.png differ
diff --git a/test/image/blend-mode-erase-8.swf b/test/image/blend-mode-erase-8.swf
new file mode 100644
index 0000000..d71bfd8
Binary files /dev/null and b/test/image/blend-mode-erase-8.swf differ
diff --git a/test/image/blend-mode-erase-8.swf.png b/test/image/blend-mode-erase-8.swf.png
new file mode 100644
index 0000000..4e8d0be
Binary files /dev/null and b/test/image/blend-mode-erase-8.swf.png differ
diff --git a/test/image/blend-mode-hardlight-7.swf b/test/image/blend-mode-hardlight-7.swf
new file mode 100644
index 0000000..56ed34a
Binary files /dev/null and b/test/image/blend-mode-hardlight-7.swf differ
diff --git a/test/image/blend-mode-hardlight-7.swf.png b/test/image/blend-mode-hardlight-7.swf.png
new file mode 100644
index 0000000..4f27182
Binary files /dev/null and b/test/image/blend-mode-hardlight-7.swf.png differ
diff --git a/test/image/blend-mode-hardlight-8.swf b/test/image/blend-mode-hardlight-8.swf
new file mode 100644
index 0000000..2d99358
Binary files /dev/null and b/test/image/blend-mode-hardlight-8.swf differ
diff --git a/test/image/blend-mode-hardlight-8.swf.png b/test/image/blend-mode-hardlight-8.swf.png
new file mode 100644
index 0000000..f1d4c98
Binary files /dev/null and b/test/image/blend-mode-hardlight-8.swf.png differ
diff --git a/test/image/blend-mode-inverse-7.swf b/test/image/blend-mode-inverse-7.swf
new file mode 100644
index 0000000..c3383f3
Binary files /dev/null and b/test/image/blend-mode-inverse-7.swf differ
diff --git a/test/image/blend-mode-inverse-7.swf.png b/test/image/blend-mode-inverse-7.swf.png
new file mode 100644
index 0000000..78faaa6
Binary files /dev/null and b/test/image/blend-mode-inverse-7.swf.png differ
diff --git a/test/image/blend-mode-inverse-8.swf b/test/image/blend-mode-inverse-8.swf
new file mode 100644
index 0000000..185daf3
Binary files /dev/null and b/test/image/blend-mode-inverse-8.swf differ
diff --git a/test/image/blend-mode-inverse-8.swf.png b/test/image/blend-mode-inverse-8.swf.png
new file mode 100644
index 0000000..0567aea
Binary files /dev/null and b/test/image/blend-mode-inverse-8.swf.png differ
diff --git a/test/image/blend-mode-layer-7.swf b/test/image/blend-mode-layer-7.swf
new file mode 100644
index 0000000..57fcbcc
Binary files /dev/null and b/test/image/blend-mode-layer-7.swf differ
diff --git a/test/image/blend-mode-layer-7.swf.png b/test/image/blend-mode-layer-7.swf.png
new file mode 100644
index 0000000..1d533e3
Binary files /dev/null and b/test/image/blend-mode-layer-7.swf.png differ
diff --git a/test/image/blend-mode-layer-8.swf b/test/image/blend-mode-layer-8.swf
new file mode 100644
index 0000000..97fe635
Binary files /dev/null and b/test/image/blend-mode-layer-8.swf differ
diff --git a/test/image/blend-mode-layer-8.swf.png b/test/image/blend-mode-layer-8.swf.png
new file mode 100644
index 0000000..1dac444
Binary files /dev/null and b/test/image/blend-mode-layer-8.swf.png differ
diff --git a/test/image/blend-mode-lighten-7.swf b/test/image/blend-mode-lighten-7.swf
new file mode 100644
index 0000000..2eab312
Binary files /dev/null and b/test/image/blend-mode-lighten-7.swf differ
diff --git a/test/image/blend-mode-lighten-7.swf.png b/test/image/blend-mode-lighten-7.swf.png
new file mode 100644
index 0000000..891460c
Binary files /dev/null and b/test/image/blend-mode-lighten-7.swf.png differ
diff --git a/test/image/blend-mode-lighten-8.swf b/test/image/blend-mode-lighten-8.swf
new file mode 100644
index 0000000..542acf2
Binary files /dev/null and b/test/image/blend-mode-lighten-8.swf differ
diff --git a/test/image/blend-mode-lighten-8.swf.png b/test/image/blend-mode-lighten-8.swf.png
new file mode 100644
index 0000000..f9f4400
Binary files /dev/null and b/test/image/blend-mode-lighten-8.swf.png differ
diff --git a/test/image/blend-mode-multiply-7.swf b/test/image/blend-mode-multiply-7.swf
new file mode 100644
index 0000000..3476ad2
Binary files /dev/null and b/test/image/blend-mode-multiply-7.swf differ
diff --git a/test/image/blend-mode-multiply-7.swf.png b/test/image/blend-mode-multiply-7.swf.png
new file mode 100644
index 0000000..4cc2102
Binary files /dev/null and b/test/image/blend-mode-multiply-7.swf.png differ
diff --git a/test/image/blend-mode-multiply-8.swf b/test/image/blend-mode-multiply-8.swf
new file mode 100644
index 0000000..f451ede
Binary files /dev/null and b/test/image/blend-mode-multiply-8.swf differ
diff --git a/test/image/blend-mode-multiply-8.swf.png b/test/image/blend-mode-multiply-8.swf.png
new file mode 100644
index 0000000..69fb02d
Binary files /dev/null and b/test/image/blend-mode-multiply-8.swf.png differ
diff --git a/test/image/blend-mode-normal-7.swf b/test/image/blend-mode-normal-7.swf
new file mode 100644
index 0000000..87202ee
Binary files /dev/null and b/test/image/blend-mode-normal-7.swf differ
diff --git a/test/image/blend-mode-normal-7.swf.png b/test/image/blend-mode-normal-7.swf.png
new file mode 100644
index 0000000..d893ffe
Binary files /dev/null and b/test/image/blend-mode-normal-7.swf.png differ
diff --git a/test/image/blend-mode-normal-8.swf b/test/image/blend-mode-normal-8.swf
new file mode 100644
index 0000000..63666bd
Binary files /dev/null and b/test/image/blend-mode-normal-8.swf differ
diff --git a/test/image/blend-mode-normal-8.swf.png b/test/image/blend-mode-normal-8.swf.png
new file mode 100644
index 0000000..b12cb89
Binary files /dev/null and b/test/image/blend-mode-normal-8.swf.png differ
diff --git a/test/image/blend-mode-overlay-7.swf b/test/image/blend-mode-overlay-7.swf
new file mode 100644
index 0000000..a6cf927
Binary files /dev/null and b/test/image/blend-mode-overlay-7.swf differ
diff --git a/test/image/blend-mode-overlay-7.swf.png b/test/image/blend-mode-overlay-7.swf.png
new file mode 100644
index 0000000..3d39a60
Binary files /dev/null and b/test/image/blend-mode-overlay-7.swf.png differ
diff --git a/test/image/blend-mode-overlay-8.swf b/test/image/blend-mode-overlay-8.swf
new file mode 100644
index 0000000..f86d0b2
Binary files /dev/null and b/test/image/blend-mode-overlay-8.swf differ
diff --git a/test/image/blend-mode-overlay-8.swf.png b/test/image/blend-mode-overlay-8.swf.png
new file mode 100644
index 0000000..f307268
Binary files /dev/null and b/test/image/blend-mode-overlay-8.swf.png differ
diff --git a/test/image/blend-mode-screen-7.swf b/test/image/blend-mode-screen-7.swf
new file mode 100644
index 0000000..c013c30
Binary files /dev/null and b/test/image/blend-mode-screen-7.swf differ
diff --git a/test/image/blend-mode-screen-7.swf.png b/test/image/blend-mode-screen-7.swf.png
new file mode 100644
index 0000000..a05642f
Binary files /dev/null and b/test/image/blend-mode-screen-7.swf.png differ
diff --git a/test/image/blend-mode-screen-8.swf b/test/image/blend-mode-screen-8.swf
new file mode 100644
index 0000000..e57e099
Binary files /dev/null and b/test/image/blend-mode-screen-8.swf differ
diff --git a/test/image/blend-mode-screen-8.swf.png b/test/image/blend-mode-screen-8.swf.png
new file mode 100644
index 0000000..b7169a9
Binary files /dev/null and b/test/image/blend-mode-screen-8.swf.png differ
diff --git a/test/image/blend-mode.c b/test/image/blend-mode.c
new file mode 100644
index 0000000..c302cc4
--- /dev/null
+++ b/test/image/blend-mode.c
@@ -0,0 +1,134 @@
+/* gcc -Wall `pkg-config --libs --cflags libming glib-2.0` blend-mode.c -o blend-mode && ./blend-mode
+ */
+
+#include <ming.h>
+#include <glib.h>
+
+#define SIZE 240
+
+const char *modes[] = {
+  "0",
+  "normal",
+  "layer",
+  "multiply",
+  "screen",
+  "lighten",
+  "darken",
+  "difference",
+  "add",
+  "subtract",
+  "inverse",
+  "alpha",
+  "erase",
+  "overlay",
+  "hardlight",
+  "15"
+};
+
+SWFBitmap
+create_yellow_image (guint w, guint h)
+{
+  guint32 *data;
+  guint x, y;
+  SWFBitmap ret;
+
+  data = g_malloc (w * h * 4);
+  for (y = 0; y < h; y++) {
+    /* get 15 steps of 10 pixel high lines fading in yellow */
+    guint32 pixel = 255 / 15 * (y * 16 / h);
+    pixel *= 0x01010100;
+    for (x = 0; x < w; x++) {
+      data[y * w + x] = pixel;
+    }
+  }
+  ret = newSWFBitmap_fromData ((guint8 *) data, w, h, TRUE);
+  g_free (data);
+  return ret;
+}
+
+SWFBitmap
+create_teal_image (guint w, guint h)
+{
+  guint32 *data;
+  guint x, y;
+  SWFBitmap ret;
+
+  data = g_malloc (w * h * 4);
+  for (y = 0; y < h; y++) {
+    /* get 15 steps of 10 pixel high lines fading in yellow */
+    for (x = 0; x < w; x++) {
+      guint32 pixel = 255 / 15 * (x * 16 / w);
+      pixel *= 0x01000101;
+      data[y * w + x] = pixel;
+    }
+  }
+  ret = newSWFBitmap_fromData ((guint8 *) data, w, h, TRUE);
+  g_free (data);
+  return ret;
+}
+
+static SWFDisplayItem
+add_images (SWFMovie movie, int blend_mode)
+{
+  SWFBitmap bitmap;
+  SWFShape shape;
+  SWFMovieClip clip;
+  SWFDisplayItem item;
+
+  clip = newSWFMovieClip ();
+
+  bitmap = create_yellow_image (SIZE, SIZE);
+  shape = newSWFShapeFromBitmap (bitmap, SWFFILL_CLIPPED_BITMAP);
+  item = SWFMovieClip_add (clip, (SWFBlock) shape);
+  SWFDisplayItem_setDepth (item, 1);
+
+  bitmap = create_teal_image (SIZE, SIZE);
+  shape = newSWFShapeFromBitmap (bitmap, SWFFILL_CLIPPED_BITMAP);
+  item = SWFMovieClip_add (clip, (SWFBlock) shape);
+  SWFDisplayItem_setDepth (item, 2);
+  SWFDisplayItem_setBlendMode (item, blend_mode);
+
+  SWFMovieClip_nextFrame (clip);
+
+  item = SWFMovie_add (movie, (SWFBlock) clip);
+  SWFDisplayItem_setBlendMode (item, SWFBLEND_MODE_LAYER);
+
+  return item;
+}
+
+static void
+do_movie (int version)
+{
+  SWFMovie movie;
+  char *real_name;
+  int mode;
+
+  for (mode = 0; mode < G_N_ELEMENTS (modes); mode++) {
+    movie = newSWFMovieWithVersion (version);
+    movie = newSWFMovie();
+    SWFMovie_setRate (movie, 1);
+    SWFMovie_setDimension (movie, SIZE, SIZE);
+    SWFMovie_setBackground (movie, 0, 0, 0);
+
+    add_images (movie, mode);
+    SWFMovie_nextFrame (movie);
+
+    real_name = g_strdup_printf ("blend-mode-%s-%d.swf", modes[mode], version);
+    SWFMovie_save (movie, real_name);
+    g_free (real_name);
+  }
+}
+
+int
+main (int argc, char **argv)
+{
+  int i;
+
+  if (Ming_init ())
+    return 1;
+
+  for (i = 7; i < 9; i++)
+    do_movie (i);
+
+  return 0;
+}
commit 0fbdc100b58502ff59f4981dc529b7d1573835a2
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Aug 29 23:57:15 2007 +0200

    add blend modes
    
    also up cairo requirement to >= 1.9.4

diff --git a/configure.ac b/configure.ac
index 754abb9..835638b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -212,13 +212,8 @@ if test "$HAVE_LIBOIL" = "no"; then
   AC_MSG_ERROR([liboil-0.3 >= $LIBOIL_VER is required to build swfdec])
 fi
 
-CAIRO_VER=1.6.0
-PKG_CHECK_MODULES(CAIRO, cairo >= $CAIRO_VER cairo-png >= $CAIRO_VER, HAVE_CAIRO=yes, HAVE_CAIRO=no)
-AC_SUBST(CAIRO_LIBS)
-AC_SUBST(CAIRO_CFLAGS)
-if test "$HAVE_CAIRO" = "no"; then
-  AC_MSG_ERROR([cairo and cairo-png = $CAIRO_VER is required to build swfdec])
-fi
+CAIRO_VER=1.9.4
+PKG_CHECK_MODULES(CAIRO, cairo >= $CAIRO_VER cairo-png >= $CAIRO_VER)
 
 AC_ARG_ENABLE(gstreamer,
 	AS_HELP_STRING([--enable-gstreamer],
diff --git a/swfdec/swfdec_movie.c b/swfdec/swfdec_movie.c
index 735cf78..7602e17 100644
--- a/swfdec/swfdec_movie.c
+++ b/swfdec/swfdec_movie.c
@@ -691,16 +691,26 @@ swfdec_movie_get_operator_for_blend_mode (guint blend_mode)
     case SWFDEC_BLEND_MODE_ERASE:
       return CAIRO_OPERATOR_DEST_OUT;
     case SWFDEC_BLEND_MODE_MULTIPLY:
+      return CAIRO_OPERATOR_MULTIPLY;
     case SWFDEC_BLEND_MODE_SCREEN:
+      return CAIRO_OPERATOR_SCREEN;
     case SWFDEC_BLEND_MODE_LIGHTEN:
+      return CAIRO_OPERATOR_LIGHTEN;
     case SWFDEC_BLEND_MODE_DARKEN:
+      return CAIRO_OPERATOR_DARKEN;
     case SWFDEC_BLEND_MODE_DIFFERENCE:
-    case SWFDEC_BLEND_MODE_SUBTRACT:
+      return CAIRO_OPERATOR_DIFFERENCE;
     case SWFDEC_BLEND_MODE_INVERT:
+      /* this should be special cased using (white IN src) DIFFERENCE dest */
+      g_assert_not_reached ();
+      return CAIRO_OPERATOR_OVER;
     case SWFDEC_BLEND_MODE_OVERLAY:
+      return CAIRO_OPERATOR_OVERLAY;
     case SWFDEC_BLEND_MODE_HARDLIGHT:
-      SWFDEC_FIXME ("blend mode %u unimplemented in cairo", blend_mode);
-      return CAIRO_OPERATOR_OVER;
+      return CAIRO_OPERATOR_HARD_LIGHT;
+    case SWFDEC_BLEND_MODE_SUBTRACT:
+      SWFDEC_FIXME ("subtract blend mode is not implemented.");
+      return CAIRO_OPERATOR_DIFFERENCE;
     default:
       SWFDEC_WARNING ("invalid blend mode %u", blend_mode);
       return CAIRO_OPERATOR_OVER;
@@ -737,6 +747,25 @@ swfdec_movie_apply_filters (SwfdecMovie *movie, cairo_pattern_t *pattern)
   return pattern;
 }
 
+static void
+swfdec_paint_with_blend_mode (cairo_t *cr, guint blend_mode)
+{
+  if (blend_mode == SWFDEC_BLEND_MODE_INVERT) {
+    cairo_push_group (cr);
+    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+    cairo_paint (cr);
+    cairo_set_source_rgb (cr, 1, 1, 1);
+    cairo_set_operator (cr, CAIRO_OPERATOR_IN);
+    cairo_paint (cr);
+    cairo_pop_group_to_source (cr);
+    cairo_set_operator (cr, CAIRO_OPERATOR_DIFFERENCE);
+    cairo_paint (cr);
+  } else {
+    cairo_set_operator (cr, swfdec_movie_get_operator_for_blend_mode (blend_mode));
+    cairo_paint (cr);
+  }
+}
+
 /**
  * swfdec_movie_mask:
  * @movie: The movie to act as the mask
@@ -872,14 +901,12 @@ swfdec_movie_render (SwfdecMovie *movie, cairo_t *cr,
     }
     pattern = swfdec_movie_apply_filters (movie, pattern);
     cairo_set_source (cr, pattern);
-    cairo_set_operator (cr, swfdec_movie_get_operator_for_blend_mode (movie->blend_mode));
-    cairo_paint (cr);
     cairo_pattern_destroy (pattern);
+    swfdec_paint_with_blend_mode (cr, movie->blend_mode);
     cairo_restore (cr);
   } else if (group != SWFDEC_GROUP_NONE) {
     cairo_pop_group_to_source (cr);
-    cairo_set_operator (cr, swfdec_movie_get_operator_for_blend_mode (movie->blend_mode));
-    cairo_paint (cr);
+    swfdec_paint_with_blend_mode (cr, movie->blend_mode);
   }
 }
 


More information about the Swfdec-commits mailing list