[Swfdec] Branch 'vivi' - 24 commits - configure.ac libswfdec/swfdec_sprite_movie.c libswfdec/swfdec_tag.c libswfdec/swfdec_tag.h vivified/core vivified/dock vivified/ui
Benjamin Otte
company at kemper.freedesktop.org
Mon Aug 13 13:34:16 PDT 2007
configure.ac | 1
libswfdec/swfdec_sprite_movie.c | 60 --------------
libswfdec/swfdec_tag.c | 152 ++++++++++++++++++++++++++++--------
libswfdec/swfdec_tag.h | 5 +
vivified/core/Makefile.am | 5 +
vivified/core/vivi_application.c | 97 ++++++++++++++++++----
vivified/core/vivi_application.h | 3
vivified/core/vivi_application_as.c | 27 ++++--
vivified/core/vivi_function.c | 14 +++
vivified/core/vivi_initialize.as | 30 +++++++
vivified/core/vivi_initialize.s | 7 +
vivified/core/vivi_ming.c | 23 ++++-
vivified/dock/vivi_vdock.c | 8 -
vivified/ui/Makefile.am | 4
vivified/ui/main.c | 14 +++
vivified/ui/vivi_commandline.c | 36 ++++++++
vivified/ui/vivi_player.c | 80 ++++++++++++++++++
vivified/ui/vivi_player.h | 57 +++++++++++++
18 files changed, 496 insertions(+), 127 deletions(-)
New commits:
diff-tree e6ae2a00a9b1aadbbc45cea54cefe6bfa60f023b (from 304e2632c4cf90212677d717ad4adbb2e050de7e)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 22:31:36 2007 +0200
make sure the player is inited when stepping
diff --git a/vivified/core/vivi_application_as.c b/vivified/core/vivi_application_as.c
index f5e68f9..24814a7 100644
--- a/vivified/core/vivi_application_as.c
+++ b/vivified/core/vivi_application_as.c
@@ -53,6 +53,7 @@ vivi_application_as_step (SwfdecAsContex
ViviApplication *app = VIVI_APPLICATION (cx);
int steps;
+ vivi_application_init_player (app);
if (argc > 0) {
steps = swfdec_as_value_to_integer (cx, &argv[0]);
if (steps <= 1)
diff-tree 304e2632c4cf90212677d717ad4adbb2e050de7e (from 9f18261bca69f8c630cb5ba3e2b98694c68fd100)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 22:30:53 2007 +0200
actually set the filename, so we can play this thing
diff --git a/vivified/ui/main.c b/vivified/ui/main.c
index 4a2093c..399483f 100644
--- a/vivified/ui/main.c
+++ b/vivified/ui/main.c
@@ -44,6 +44,7 @@ setup (const char *filename)
ViviApplication *app;
app = vivi_application_new ();
+ vivi_application_set_filename (app, filename);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
box = vivi_vdock_new ();
gtk_container_add (GTK_CONTAINER (window), box);
diff-tree 9f18261bca69f8c630cb5ba3e2b98694c68fd100 (from d0cced1cadf66bc1deaeb20b0d9ace5c4f7227c9)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 22:28:32 2007 +0200
make run() and step() actually do something
diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c
index a2b2a95..a87aa55 100644
--- a/vivified/core/vivi_application.c
+++ b/vivified/core/vivi_application.c
@@ -26,6 +26,12 @@
#include "vivi_function.h"
#include "vivi_ming.h"
+typedef enum {
+ VIVI_APPLICATION_STOPPED,
+ VIVI_APPLICATION_PLAYING,
+ VIVI_APPLICATION_STEPPING,
+} ViviApplicationPlayback;
+
enum {
MESSAGE,
LAST_SIGNAL
@@ -130,10 +136,16 @@ vivi_application_init_player (ViviApplic
g_return_if_fail (VIVI_IS_APPLICATION (app));
- if (app->player_inited ||
- app->filename == NULL)
+ g_print ("init\n");
+ if (app->player_inited)
+ return;
+
+ if (app->filename == NULL) {
+ vivi_application_error (app, "no file set to play.");
return;
+ }
+ g_print ("really init\n");
loader = swfdec_file_loader_new (app->filename);
swfdec_player_set_loader (app->player, loader);
app->player_inited = TRUE;
@@ -177,6 +189,51 @@ vivi_application_get_player (ViviApplica
return app->player;
}
+static gboolean
+vivi_application_step_forward (gpointer appp)
+{
+ ViviApplication *app = appp;
+ guint next_event;
+
+ next_event = swfdec_player_get_next_event (app->player);
+ swfdec_player_advance (app->player, next_event);
+
+ return FALSE;
+}
+
+static void
+vivi_application_check (ViviApplication *app)
+{
+ gboolean is_playing = swfdec_gtk_player_get_playing (SWFDEC_GTK_PLAYER (app->player));
+ gboolean is_breakpoint = app->loop != NULL;
+
+ switch (app->playback_state) {
+ case VIVI_APPLICATION_STOPPED:
+ if (is_playing)
+ swfdec_gtk_player_set_playing (SWFDEC_GTK_PLAYER (app->player), FALSE);
+ break;
+ case VIVI_APPLICATION_PLAYING:
+ if (!is_playing)
+ swfdec_gtk_player_set_playing (SWFDEC_GTK_PLAYER (app->player), TRUE);
+ if (is_breakpoint)
+ g_main_loop_quit (app->loop);
+ break;
+ case VIVI_APPLICATION_STEPPING:
+ if (is_playing)
+ swfdec_gtk_player_set_playing (SWFDEC_GTK_PLAYER (app->player), FALSE);
+ if (is_breakpoint) {
+ g_main_loop_quit (app->loop);
+ } else {
+ /* FIXME: sanely handle this */
+ g_idle_add_full (-100, vivi_application_step_forward, app, NULL);
+ }
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
+
void
vivi_applciation_execute (ViviApplication *app, const char *command)
{
@@ -203,6 +260,7 @@ vivi_applciation_execute (ViviApplicatio
object = SWFDEC_AS_VALUE_GET_OBJECT (&val);
swfdec_as_object_run (object, script);
swfdec_script_unref (script);
+ vivi_application_check (app);
}
void
@@ -222,25 +280,13 @@ vivi_application_send_message (ViviAppli
g_free (msg);
}
-typedef enum {
- VIVI_APPLICATION_STOPPED,
- VIVI_APPLICATION_PLAYING,
- VIVI_APPLICATION_STEPPING,
-} ViviApplicationPlayback;
-
-static void
-vivi_application_set_playback (ViviApplication *app, ViviApplicationPlayback playback, guint steps)
-{
- app->playback_state = playback;
- app->playback_count = steps;
-}
-
void
vivi_application_play (ViviApplication *app)
{
g_return_if_fail (VIVI_IS_APPLICATION (app));
- vivi_application_set_playback (app, VIVI_APPLICATION_PLAYING, 1);
+ app->playback_state = VIVI_APPLICATION_PLAYING;
+ app->playback_count = 1;
}
void
@@ -248,5 +294,7 @@ vivi_application_step (ViviApplication *
{
g_return_if_fail (VIVI_IS_APPLICATION (app));
- vivi_application_set_playback (app, VIVI_APPLICATION_STEPPING, n_times);
+ app->playback_state = VIVI_APPLICATION_STEPPING;
+ app->playback_count = n_times;
}
+
diff --git a/vivified/core/vivi_application.h b/vivified/core/vivi_application.h
index f801c50..d250989 100644
--- a/vivified/core/vivi_application.h
+++ b/vivified/core/vivi_application.h
@@ -50,6 +50,7 @@ struct _ViviApplication
gboolean player_inited; /* if the player is inited already */
guint playback_state; /* (running, stepping or stopped) */
guint playback_count; /* how often to just restart this on breakpoints */
+ GMainLoop * loop; /* the breakpoint main loop */
};
struct _ViviApplicationClass
diff-tree d0cced1cadf66bc1deaeb20b0d9ace5c4f7227c9 (from f49bb00b9cf6d91ec6694e47ac1189b7b1c0c433)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 22:25:45 2007 +0200
get rid of functions named after reserved strings
also add restart() and reset()
diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as
index e9480a4..dfae8f3 100644
--- a/vivified/core/vivi_initialize.as
+++ b/vivified/core/vivi_initialize.as
@@ -19,9 +19,12 @@
Commands = new Object ();
Commands.print = Native.print;
-Commands.br = Native["break"];
-Commands["break"] = Native["break"];
-Commands.c = Native.play;
-Commands["continue"] = Native.play;
+Commands.r = Native.run;
+Commands.run = Native.run;
Commands.s = Native.step;
Commands.step = Native.step;
+Commands.reset = Native.reset;
+Commands.restart = function () {
+ Commands.reset ();
+ Commands.run ();
+};
diff-tree f49bb00b9cf6d91ec6694e47ac1189b7b1c0c433 (from de5020c9352f8d7470d707ff5ee9b1f5c64a281a)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 22:25:04 2007 +0200
don't name functions like reserved words
run => reset
continue => run
diff --git a/vivified/core/vivi_application_as.c b/vivified/core/vivi_application_as.c
index e651248..f5e68f9 100644
--- a/vivified/core/vivi_application_as.c
+++ b/vivified/core/vivi_application_as.c
@@ -24,21 +24,19 @@
#include "vivi_application.h"
#include "vivi_function.h"
-VIVI_FUNCTION ("run", vivi_application_as_run)
+VIVI_FUNCTION ("reset", vivi_application_as_reset)
void
-vivi_application_as_run (SwfdecAsContext *cx, SwfdecAsObject *this,
+vivi_application_as_reset (SwfdecAsContext *cx, SwfdecAsObject *this,
guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
ViviApplication *app = VIVI_APPLICATION (cx);
vivi_application_reset (app);
- vivi_application_init_player (app);
- vivi_application_play (app);
}
-VIVI_FUNCTION ("continue", vivi_application_as_continue)
+VIVI_FUNCTION ("run", vivi_application_as_run)
void
-vivi_application_as_continue (SwfdecAsContext *cx, SwfdecAsObject *this,
+vivi_application_as_run (SwfdecAsContext *cx, SwfdecAsObject *this,
guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
ViviApplication *app = VIVI_APPLICATION (cx);
diff-tree de5020c9352f8d7470d707ff5ee9b1f5c64a281a (from eff171fc6e57dcc745125672485ba2e55463d47d)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 19:39:50 2007 +0200
add hack to get focus to the right widget
diff --git a/vivified/ui/main.c b/vivified/ui/main.c
index 590d785..4a2093c 100644
--- a/vivified/ui/main.c
+++ b/vivified/ui/main.c
@@ -29,6 +29,15 @@
#include "vivi_player.h"
static void
+try_grab_focus (GtkWidget *widget, gpointer unused)
+{
+ if (GTK_IS_ENTRY (widget))
+ gtk_widget_grab_focus (widget);
+ else if (GTK_IS_CONTAINER (widget))
+ gtk_container_foreach (GTK_CONTAINER (widget), try_grab_focus, NULL);
+}
+
+static void
setup (const char *filename)
{
GtkWidget *window, *box, *widget;
@@ -42,6 +51,7 @@ setup (const char *filename)
gtk_container_add (GTK_CONTAINER (box), widget);
widget = vivi_command_line_new (app);
gtk_container_add (GTK_CONTAINER (box), widget);
+ gtk_container_foreach (GTK_CONTAINER (widget), try_grab_focus, NULL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show_all (window);
diff-tree eff171fc6e57dcc745125672485ba2e55463d47d (from 746566d83ba51568101d1d71483201cbfbc96e1c)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 19:28:20 2007 +0200
add shortcut mode for calling functions
diff --git a/vivified/ui/vivi_commandline.c b/vivified/ui/vivi_commandline.c
index 3bf90f7..7003065 100644
--- a/vivified/ui/vivi_commandline.c
+++ b/vivified/ui/vivi_commandline.c
@@ -21,6 +21,7 @@
#include "config.h"
#endif
+#include <string.h>
#include "vivi_commandline.h"
G_DEFINE_TYPE (ViviCommandLine, vivi_command_line, VIVI_TYPE_DOCKLET)
@@ -62,6 +63,39 @@ vivi_command_line_class_init (ViviComman
}
static void
+vivi_command_line_execute (ViviCommandLine *cl, const char *command)
+{
+ char *run;
+
+ if (!strpbrk (command, ";\"',()[]{}")) {
+ /* special mode: interpret as space-delimited list:
+ * first argument is function name, following arguemnts are function arguments
+ */
+ char **args = g_strsplit (command, " ", -1);
+ GString *str = g_string_new (args[0]);
+ guint i;
+
+ g_string_append (str, " (");
+ for (i = 1; args[i] != NULL; i++) {
+ if (i > 1)
+ g_string_append (str, ", ");
+ g_string_append_c (str, '"');
+ g_string_append (str, args[i]);
+ g_string_append_c (str, '"');
+ }
+ g_string_append (str, ");");
+ run = g_string_free (str, FALSE);
+ } else {
+ run = (char *) command;
+ }
+
+
+ vivi_applciation_execute (cl->app, run);
+ if (command != run)
+ g_free (run);
+}
+
+static void
command_line_entry_activate_cb (GtkEntry *entry, ViviCommandLine *command_line)
{
const char *text = gtk_entry_get_text (entry);
@@ -69,7 +103,7 @@ command_line_entry_activate_cb (GtkEntry
if (text[0] == '\0')
return;
- vivi_applciation_execute (command_line->app, text);
+ vivi_command_line_execute (command_line, text);
gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
}
diff-tree 746566d83ba51568101d1d71483201cbfbc96e1c (from 56a6d3db4c4effe7befb19f64dabc3af16a7f88b)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 19:27:56 2007 +0200
run scripts with "Commands" object as this object
diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c
index eca0eaf..a2b2a95 100644
--- a/vivified/core/vivi_application.c
+++ b/vivified/core/vivi_application.c
@@ -180,6 +180,8 @@ vivi_application_get_player (ViviApplica
void
vivi_applciation_execute (ViviApplication *app, const char *command)
{
+ SwfdecAsValue val;
+ SwfdecAsObject *object;
SwfdecScript *script;
char *error = NULL;
@@ -193,7 +195,13 @@ vivi_applciation_execute (ViviApplicatio
g_free (error);
return;
}
- swfdec_as_object_run (SWFDEC_AS_CONTEXT (app)->global, script);
+ object = SWFDEC_AS_CONTEXT (app)->global;
+ swfdec_as_object_get_variable (object,
+ swfdec_as_context_get_string (SWFDEC_AS_CONTEXT (app), "Commands"),
+ &val);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ object = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+ swfdec_as_object_run (object, script);
swfdec_script_unref (script);
}
diff-tree 56a6d3db4c4effe7befb19f64dabc3af16a7f88b (from 6fc83760a0d677fb11b348c556d307226b1df053)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 19:27:00 2007 +0200
crash if init script breaks
diff --git a/vivified/core/vivi_function.c b/vivified/core/vivi_function.c
index f518515..6fb5197 100644
--- a/vivified/core/vivi_function.c
+++ b/vivified/core/vivi_function.c
@@ -41,6 +41,13 @@ static const struct {
/* defined in vivi_initialize.s */
extern const char vivi_initialize[];
+static void
+vivi_function_not_reached (ViviApplication *app, guint type, char *message, gpointer unused)
+{
+ if (type == VIVI_MESSAGE_ERROR)
+ g_error ("%s", message);
+}
+
void
vivi_function_init_context (ViviApplication *app)
{
@@ -61,6 +68,8 @@ vivi_function_init_context (ViviApplicat
swfdec_as_context_get_string (cx, functions[i].name),
0, functions[i].fun, 0);
}
+ g_signal_connect (app, "message", G_CALLBACK (vivi_function_not_reached), NULL);
vivi_applciation_execute (app, vivi_initialize);
+ g_signal_handlers_disconnect_by_func (app, G_CALLBACK (vivi_function_not_reached), NULL);
}
diff-tree 6fc83760a0d677fb11b348c556d307226b1df053 (from 882e7bcb4894ab334ff18c1ba3386fde7450b780)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 19:10:04 2007 +0200
lots of fixes
- add copyright header
- the magic object is named "Commands", not "commands"
- only init functions that do exist
diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as
index 7293fd5..e9480a4 100644
--- a/vivified/core/vivi_initialize.as
+++ b/vivified/core/vivi_initialize.as
@@ -1,8 +1,27 @@
-commands = new Object ();
-commands.print = Native.print;
-commands.br = Native.break;
-commands.break = Native.break;
-commands.c = Native.play;
-commands.continue = Native.play;
-commands.s = Native.step;
-commands.step = Native.step;
+/* Vivified
+ * Copyright (C) 2007 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
+ */
+
+Commands = new Object ();
+Commands.print = Native.print;
+Commands.br = Native["break"];
+Commands["break"] = Native["break"];
+Commands.c = Native.play;
+Commands["continue"] = Native.play;
+Commands.s = Native.step;
+Commands.step = Native.step;
diff-tree 882e7bcb4894ab334ff18c1ba3386fde7450b780 (from a4ce7815b625ed24f0350f3e45ce273c7a518a51)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 19:07:10 2007 +0200
make sure swfdec_initialize.lo gets rebuilt when the as file changes
diff --git a/vivified/core/Makefile.am b/vivified/core/Makefile.am
index 8bd684c..6b0e473 100644
--- a/vivified/core/Makefile.am
+++ b/vivified/core/Makefile.am
@@ -11,6 +11,9 @@ libvivified_core_la_SOURCES = \
vivi_initialize.s \
vivi_ming.c
+vivi_initialize.lo: vivi_initialize.s vivi_initialize.as
+ $(LTCCASCOMPILE) -c -o $@ vivi_initialize.s
+
noinst_HEADERS = \
vivi_application.h \
vivi_function.h \
diff-tree a4ce7815b625ed24f0350f3e45ce273c7a518a51 (from 412e1924509cc3190c2437a01e097cf36f4e7038)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 18:02:51 2007 +0200
s/vivi_application_run/vivi_application_execute/
diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c
index 4f1915f..eca0eaf 100644
--- a/vivified/core/vivi_application.c
+++ b/vivified/core/vivi_application.c
@@ -178,7 +178,7 @@ vivi_application_get_player (ViviApplica
}
void
-vivi_application_run (ViviApplication *app, const char *command)
+vivi_applciation_execute (ViviApplication *app, const char *command)
{
SwfdecScript *script;
char *error = NULL;
diff --git a/vivified/core/vivi_application.h b/vivified/core/vivi_application.h
index f45540e..f801c50 100644
--- a/vivified/core/vivi_application.h
+++ b/vivified/core/vivi_application.h
@@ -83,7 +83,7 @@ void vivi_application_play (ViviAppli
void vivi_application_step (ViviApplication * app,
guint n_times);
-void vivi_application_run (ViviApplication * app,
+void vivi_applciation_execute (ViviApplication * app,
const char * command);
G_END_DECLS
diff --git a/vivified/core/vivi_function.c b/vivified/core/vivi_function.c
index 9762f5a..f518515 100644
--- a/vivified/core/vivi_function.c
+++ b/vivified/core/vivi_function.c
@@ -61,6 +61,6 @@ vivi_function_init_context (ViviApplicat
swfdec_as_context_get_string (cx, functions[i].name),
0, functions[i].fun, 0);
}
- vivi_application_run (app, vivi_initialize);
+ vivi_applciation_execute (app, vivi_initialize);
}
diff --git a/vivified/ui/vivi_commandline.c b/vivified/ui/vivi_commandline.c
index 6ae6b03..3bf90f7 100644
--- a/vivified/ui/vivi_commandline.c
+++ b/vivified/ui/vivi_commandline.c
@@ -69,7 +69,7 @@ command_line_entry_activate_cb (GtkEntry
if (text[0] == '\0')
return;
- vivi_application_run (command_line->app, text);
+ vivi_applciation_execute (command_line->app, text);
gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
}
diff-tree 412e1924509cc3190c2437a01e097cf36f4e7038 (from 9cc9d27957f27f1137814ff95a1fb4da8e67669c)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 17:16:33 2007 +0200
really error out on errors
diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c
index 071b1ab..4f1915f 100644
--- a/vivified/core/vivi_application.c
+++ b/vivified/core/vivi_application.c
@@ -191,6 +191,7 @@ vivi_application_run (ViviApplication *a
if (script == NULL) {
vivi_application_error (app, error);
g_free (error);
+ return;
}
swfdec_as_object_run (SWFDEC_AS_CONTEXT (app)->global, script);
swfdec_script_unref (script);
diff-tree 9cc9d27957f27f1137814ff95a1fb4da8e67669c (from 8ea4ca0ffef854446d2ddfdb7c979397a7f3da90)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 17:16:15 2007 +0200
we need an assembler for including the script
diff --git a/configure.ac b/configure.ac
index e9996f4..1303884 100644
--- a/configure.ac
+++ b/configure.ac
@@ -270,6 +270,7 @@ AC_ARG_ENABLE(vivified,
enable_vivi=$enableval,
enable_vivi="no")
if test "$enable_vivi" = "yes"; then
+ AM_PROG_AS
MING_REQUIRED=0.4.0.beta5
PKG_CHECK_MODULES(VIVI, libming >= $MING_REQUIRED, HAVE_VIVI=yes, HAVE_VIVI=no)
if test "x$HAVE_VIVI" = xyes; then
diff-tree 8ea4ca0ffef854446d2ddfdb7c979397a7f3da90 (from 9a26eb30be715cbf23f4dde1bf1ac95b024254c6)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 17:15:16 2007 +0200
add support for a hardcoded init script
diff --git a/vivified/core/Makefile.am b/vivified/core/Makefile.am
index 8639fb4..8bd684c 100644
--- a/vivified/core/Makefile.am
+++ b/vivified/core/Makefile.am
@@ -7,6 +7,8 @@ libvivified_core_la_SOURCES = \
vivi_application.c \
vivi_application_as.c \
vivi_function.c \
+ vivi_initialize.as \
+ vivi_initialize.s \
vivi_ming.c
noinst_HEADERS = \
diff --git a/vivified/core/vivi_function.c b/vivified/core/vivi_function.c
index 5dc64e1..9762f5a 100644
--- a/vivified/core/vivi_function.c
+++ b/vivified/core/vivi_function.c
@@ -38,6 +38,8 @@ static const struct {
};
#undef VIVI_FUNCTION
+/* defined in vivi_initialize.s */
+extern const char vivi_initialize[];
void
vivi_function_init_context (ViviApplication *app)
@@ -57,7 +59,8 @@ vivi_function_init_context (ViviApplicat
for (i = 0; functions[i].name; i++) {
swfdec_as_object_add_function (obj,
swfdec_as_context_get_string (cx, functions[i].name),
- G_TYPE_NONE, functions[i].fun, 0);
+ 0, functions[i].fun, 0);
}
+ vivi_application_run (app, vivi_initialize);
}
diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as
new file mode 100644
index 0000000..7293fd5
--- /dev/null
+++ b/vivified/core/vivi_initialize.as
@@ -0,0 +1,8 @@
+commands = new Object ();
+commands.print = Native.print;
+commands.br = Native.break;
+commands.break = Native.break;
+commands.c = Native.play;
+commands.continue = Native.play;
+commands.s = Native.step;
+commands.step = Native.step;
diff --git a/vivified/core/vivi_initialize.s b/vivified/core/vivi_initialize.s
new file mode 100644
index 0000000..eec00c6
--- /dev/null
+++ b/vivified/core/vivi_initialize.s
@@ -0,0 +1,7 @@
+.section ".rodata"
+.global vivi_initialize
+ .type vivi_initialize, at object
+ .size vivi_initialize, .-vivi_initialize
+vivi_initialize:
+.incbin "vivi_initialize.as"
+.byte 0
diff-tree 9a26eb30be715cbf23f4dde1bf1ac95b024254c6 (from a56f1d2fe63954590ae4f0299af004cc99859131)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 17:12:46 2007 +0200
make the compiler properly detect errors
diff --git a/vivified/core/vivi_ming.c b/vivified/core/vivi_ming.c
index 3ef14b1..7478fac 100644
--- a/vivified/core/vivi_ming.c
+++ b/vivified/core/vivi_ming.c
@@ -57,6 +57,17 @@ vivi_ming_get_error (void)
}
static void
+vivi_ming_clear_error (void)
+{
+ char *ret;
+
+ if (ming_errors != NULL) {
+ ret = vivi_ming_get_error ();
+ g_free (ret);
+ }
+}
+
+static void
vivi_ming_init (void)
{
static gboolean ming_inited = FALSE;
@@ -85,14 +96,16 @@ vivi_ming_compile (const char *code, cha
action = newSWFAction (code);
data = SWFAction_getByteCode (action, &len);
- if (data == NULL || len == 0) {
+ if (data == NULL || len <= 1) {
if (error)
*error = vivi_ming_get_error ();
- return NULL;
+ script = NULL;
+ } else {
+ buffer = swfdec_buffer_new_and_alloc (len);
+ memcpy (buffer->data, data, len);
+ script = swfdec_script_new (buffer, "compiled script", 8);
}
- buffer = swfdec_buffer_new_and_alloc (len);
- memcpy (buffer->data, data, len);
- script = swfdec_script_new (buffer, "compiled script", 8);
+ vivi_ming_clear_error ();
return script;
}
diff-tree a56f1d2fe63954590ae4f0299af004cc99859131 (from fac1e751e6b978fe7f6c69bcc6359af4fb080da7)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 17:00:24 2007 +0200
don't make the printed text a format string
diff --git a/vivified/core/vivi_application_as.c b/vivified/core/vivi_application_as.c
index ac8e0ae..e651248 100644
--- a/vivified/core/vivi_application_as.c
+++ b/vivified/core/vivi_application_as.c
@@ -77,6 +77,6 @@ vivi_application_as_print (SwfdecAsConte
return;
s = swfdec_as_value_to_string (cx, &argv[0]);
- vivi_application_output (app, s);
+ vivi_application_output (app, "%s", s);
}
diff-tree fac1e751e6b978fe7f6c69bcc6359af4fb080da7 (from 89f494a62f58bca42f675acf9656fdb1023c8618)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 16:59:50 2007 +0200
actually execute the native function setup code (oops)
diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c
index f93fb16..071b1ab 100644
--- a/vivified/core/vivi_application.c
+++ b/vivified/core/vivi_application.c
@@ -23,6 +23,7 @@
#include <libswfdec-gtk/swfdec-gtk.h>
#include "vivi_application.h"
+#include "vivi_function.h"
#include "vivi_ming.h"
enum {
@@ -118,6 +119,7 @@ vivi_application_new (void)
app = g_object_new (VIVI_TYPE_APPLICATION, NULL);
swfdec_as_context_startup (SWFDEC_AS_CONTEXT (app), 8);
+ vivi_function_init_context (app);
return app;
}
diff-tree 89f494a62f58bca42f675acf9656fdb1023c8618 (from c8fa0c151546ec27138afd73f3bf2cddd9453aad)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 15:52:52 2007 +0200
add print function
diff --git a/vivified/core/vivi_application_as.c b/vivified/core/vivi_application_as.c
index 988e650..ac8e0ae 100644
--- a/vivified/core/vivi_application_as.c
+++ b/vivified/core/vivi_application_as.c
@@ -64,3 +64,19 @@ vivi_application_as_step (SwfdecAsContex
}
vivi_application_step (app, steps);
}
+
+VIVI_FUNCTION ("print", vivi_application_as_print)
+void
+vivi_application_as_print (SwfdecAsContext *cx, SwfdecAsObject *this,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ ViviApplication *app = VIVI_APPLICATION (cx);
+ const char *s;
+
+ if (argc == 0)
+ return;
+
+ s = swfdec_as_value_to_string (cx, &argv[0]);
+ vivi_application_output (app, s);
+}
+
diff-tree c8fa0c151546ec27138afd73f3bf2cddd9453aad (from 7d3e4b2abaf2803e43a608dd29f2281e6be38df5)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 15:37:59 2007 +0200
have a player widget
diff --git a/vivified/ui/Makefile.am b/vivified/ui/Makefile.am
index 5509035..2a8ed4a 100644
--- a/vivified/ui/Makefile.am
+++ b/vivified/ui/Makefile.am
@@ -8,8 +8,10 @@ vivified_LDADD = \
vivified_SOURCES = \
vivi_commandline.c \
+ vivi_player.c \
main.c
noinst_HEADERS = \
- vivi_commandline.h
+ vivi_commandline.h \
+ vivi_player.h
diff --git a/vivified/ui/main.c b/vivified/ui/main.c
index 1dd43e6..590d785 100644
--- a/vivified/ui/main.c
+++ b/vivified/ui/main.c
@@ -26,6 +26,7 @@
#include "vivified/core/vivified-core.h"
#include "vivified/dock/vivified-dock.h"
#include "vivi_commandline.h"
+#include "vivi_player.h"
static void
setup (const char *filename)
@@ -37,6 +38,8 @@ setup (const char *filename)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
box = vivi_vdock_new ();
gtk_container_add (GTK_CONTAINER (window), box);
+ widget = vivi_player_new (app);
+ gtk_container_add (GTK_CONTAINER (box), widget);
widget = vivi_command_line_new (app);
gtk_container_add (GTK_CONTAINER (box), widget);
diff --git a/vivified/ui/vivi_player.c b/vivified/ui/vivi_player.c
new file mode 100644
index 0000000..657d169
--- /dev/null
+++ b/vivified/ui/vivi_player.c
@@ -0,0 +1,80 @@
+/* Vivified
+ * Copyright (C) 2007 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 "vivi_player.h"
+#include <libswfdec-gtk/swfdec-gtk.h>
+
+G_DEFINE_TYPE (ViviPlayer, vivi_player, VIVI_TYPE_DOCKLET)
+
+static void
+vivi_player_notify_app (ViviApplication *app, GParamSpec *pspec, ViviPlayer *player)
+{
+ if (g_str_equal (pspec->name, "player")) {
+ swfdec_gtk_widget_set_player (SWFDEC_GTK_WIDGET (player->player), vivi_application_get_player (app));
+ }
+}
+
+static void
+vivi_player_dispose (GObject *object)
+{
+ ViviPlayer *player = VIVI_PLAYER (object);
+
+ g_signal_handlers_disconnect_by_func (player->app, vivi_player_notify_app, player);
+
+ G_OBJECT_CLASS (vivi_player_parent_class)->dispose (object);
+}
+
+static void
+vivi_player_class_init (ViviPlayerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = vivi_player_dispose;
+}
+
+static void
+vivi_player_init (ViviPlayer *player)
+{
+ GtkWidget *box;
+
+ box = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
+ gtk_container_add (GTK_CONTAINER (player), box);
+ /* the player */
+ player->player = swfdec_gtk_widget_new (NULL);
+ gtk_container_add (GTK_CONTAINER (box), player->player);
+
+ gtk_widget_show_all (box);
+}
+
+GtkWidget *
+vivi_player_new (ViviApplication *app)
+{
+ ViviPlayer *player;
+
+ player = g_object_new (VIVI_TYPE_PLAYER, "title", "Player", NULL);
+ player->app = app;
+ g_signal_connect (player->app, "notify", G_CALLBACK (vivi_player_notify_app), player);
+ swfdec_gtk_widget_set_player (SWFDEC_GTK_WIDGET (player->player), vivi_application_get_player (app));
+ return GTK_WIDGET (player);
+}
+
diff --git a/vivified/ui/vivi_player.h b/vivified/ui/vivi_player.h
new file mode 100644
index 0000000..9aa9102
--- /dev/null
+++ b/vivified/ui/vivi_player.h
@@ -0,0 +1,57 @@
+/* Vivified
+ * Copyright (C) 2007 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 _VIVI_PLAYER_H_
+#define _VIVI_PLAYER_H_
+
+#include <vivified/core/vivified-core.h>
+#include <vivified/dock/vivified-dock.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _ViviPlayer ViviPlayer;
+typedef struct _ViviPlayerClass ViviPlayerClass;
+
+#define VIVI_TYPE_PLAYER (vivi_player_get_type())
+#define VIVI_IS_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIVI_TYPE_PLAYER))
+#define VIVI_IS_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VIVI_TYPE_PLAYER))
+#define VIVI_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIVI_TYPE_PLAYER, ViviPlayer))
+#define VIVI_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VIVI_TYPE_PLAYER, ViviPlayerClass))
+#define VIVI_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VIVI_TYPE_PLAYER, ViviPlayerClass))
+
+struct _ViviPlayer {
+ ViviDocklet docklet;
+
+ ViviApplication * app; /* the application we connect to */
+ GtkWidget * player; /* SwfdecGtkWidget */
+};
+
+struct _ViviPlayerClass
+{
+ ViviDockletClass docklet_class;
+};
+
+GType vivi_player_get_type (void);
+
+GtkWidget * vivi_player_new (ViviApplication * app);
+
+
+G_END_DECLS
+#endif
diff-tree 7d3e4b2abaf2803e43a608dd29f2281e6be38df5 (from 790d893846fd4ea043d10386a29cb4eab5da6d25)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 15:31:07 2007 +0200
make embedding a second item really work
diff --git a/vivified/dock/vivi_vdock.c b/vivified/dock/vivi_vdock.c
index 1559ec1..d37d563 100644
--- a/vivified/dock/vivi_vdock.c
+++ b/vivified/dock/vivi_vdock.c
@@ -75,20 +75,20 @@ vivi_vdock_add (GtkContainer *container,
if (vdock->docklets == NULL) {
GTK_CONTAINER_CLASS (vivi_vdock_parent_class)->add (container, docker);
} else {
- /* docklet is in docker */
+ /* docklet is in docker, so we need to use parent */
GtkWidget *last = gtk_widget_get_parent (vdock->docklets->data);
GtkWidget *parent = gtk_widget_get_parent (last);
GtkWidget *paned;
- g_object_ref (parent);
+ g_object_ref (last);
if (parent == (GtkWidget *) container) {
GTK_CONTAINER_CLASS (vivi_vdock_parent_class)->remove (container, last);
} else {
gtk_container_remove (GTK_CONTAINER (parent), last);
}
paned = gtk_vpaned_new ();
- gtk_paned_pack1 (GTK_PANED (paned), docker, TRUE, FALSE);
- gtk_paned_pack2 (GTK_PANED (paned), last, TRUE, FALSE);
+ gtk_paned_pack1 (GTK_PANED (paned), last, TRUE, FALSE);
+ gtk_paned_pack2 (GTK_PANED (paned), docker, TRUE, FALSE);
g_object_unref (last);
gtk_widget_show (paned);
if (parent == (GtkWidget *) container) {
diff-tree 790d893846fd4ea043d10386a29cb4eab5da6d25 (from parents)
Merge: aa9c233ed15e37e156d05f1e296126c2a8933132 37ed222d6ea5305df2c238122be4e31a98af3229
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 15:11:04 2007 +0200
Merge branch 'master' into vivi
diff-tree 37ed222d6ea5305df2c238122be4e31a98af3229 (from 9d35a0a007492163043bf609bf2759a05738c8df)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 14:13:01 2007 +0200
implement blend mode and filter parsing (better: ignoring) for buttons
diff --git a/libswfdec/swfdec_tag.c b/libswfdec/swfdec_tag.c
index a556e19..ef1db99 100644
--- a/libswfdec/swfdec_tag.c
+++ b/libswfdec/swfdec_tag.c
@@ -387,43 +387,56 @@ swfdec_button_append_content (SwfdecButt
static int
tag_func_define_button_2 (SwfdecSwfDecoder * s, guint tag)
{
- SwfdecBits *bits = &s->b;
- int id;
- int flags;
- int offset;
+ SwfdecBits bits;
+ int id, reserved;
+ guint length;
SwfdecButton *button;
char *script_name;
- id = swfdec_bits_get_u16 (bits);
+ id = swfdec_bits_get_u16 (&s->b);
button = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_BUTTON);
if (!button)
return SWFDEC_STATUS_OK;
SWFDEC_LOG (" ID: %d", id);
- flags = swfdec_bits_get_u8 (bits);
- if (flags & 0x01)
- button->menubutton = TRUE;
- offset = swfdec_bits_get_u16 (bits);
-
- SWFDEC_LOG (" flags = %d", flags);
- SWFDEC_LOG (" offset = %d", offset);
-
- while (swfdec_bits_peek_u8 (bits)) {
- int reserved;
+ reserved = swfdec_bits_getbits (&s->b, 7);
+ button->menubutton = swfdec_bits_getbit (&s->b) ? TRUE : FALSE;
+ length = swfdec_bits_get_u16 (&s->b);
+
+ SWFDEC_LOG (" reserved = %d", reserved);
+ SWFDEC_LOG (" menu = %d", button->menubutton);
+ SWFDEC_LOG (" length of region = %d", length);
+
+ if (length)
+ swfdec_bits_init_bits (&bits, &s->b, length > 2 ? length - 2 : 0);
+ else
+ swfdec_bits_init_bits (&bits, &s->b, swfdec_bits_left (&s->b) / 8);
+ while (swfdec_bits_peek_u8 (&bits)) {
guint character;
guint depth;
guint states;
+ gboolean blend_mode, has_filters;
SwfdecContent *content;
- swfdec_bits_syncbits (bits);
- reserved = swfdec_bits_getbits (bits, 4);
- states = swfdec_bits_getbits (bits, 4);
- character = swfdec_bits_get_u16 (bits);
- depth = swfdec_bits_get_u16 (bits);
+ if (s->version >= 8) {
+ reserved = swfdec_bits_getbits (&bits, 2);
+ blend_mode = swfdec_bits_getbit (&bits);
+ has_filters = swfdec_bits_getbit (&bits);
+ SWFDEC_LOG (" reserved = %d", reserved);
+ SWFDEC_LOG (" blend_mode = %d", blend_mode);
+ SWFDEC_LOG (" has_filters = %d", has_filters);
+ } else {
+ reserved = swfdec_bits_getbits (&bits, 4);
+ blend_mode = 0;
+ has_filters = 0;
+ SWFDEC_LOG (" reserved = %d", reserved);
+ }
+ states = swfdec_bits_getbits (&bits, 4);
+ character = swfdec_bits_get_u16 (&bits);
+ depth = swfdec_bits_get_u16 (&bits);
- SWFDEC_LOG (" reserved = %d", reserved);
- SWFDEC_LOG ("states: %s%s%s%scharacter=%u layer=%u",
+ SWFDEC_LOG (" states: %s%s%s%scharacter=%u layer=%u",
states & (1 << SWFDEC_BUTTON_HIT) ? "HIT " : "",
states & (1 << SWFDEC_BUTTON_DOWN) ? "DOWN " : "",
states & (1 << SWFDEC_BUTTON_OVER) ? "OVER " : "",
@@ -431,16 +444,22 @@ tag_func_define_button_2 (SwfdecSwfDecod
character, depth);
content = swfdec_content_new (depth);
- swfdec_bits_get_matrix (bits, &content->transform, NULL);
+ swfdec_bits_get_matrix (&bits, &content->transform, NULL);
content->has_transform = TRUE;
SWFDEC_LOG ("matrix: %g %g %g %g %g %g",
content->transform.xx, content->transform.yy,
content->transform.xy, content->transform.yx,
content->transform.x0, content->transform.y0);
- swfdec_bits_get_color_transform (bits, &content->color_transform);
+ swfdec_bits_get_color_transform (&bits, &content->color_transform);
content->has_color_transform = TRUE;
content->graphic = swfdec_swf_decoder_get_character (s, character);
+ if (blend_mode) {
+ guint mode = swfdec_bits_get_u8 (&bits);
+ SWFDEC_WARNING (" blend mode = %u", mode);
+ }
+ if (has_filters)
+ swfdec_filters_parse (&bits);
if (!SWFDEC_IS_GRAPHIC (content->graphic)) {
SWFDEC_ERROR ("id %u does not reference a graphic, ignoring", character);
swfdec_content_free (content);
@@ -448,24 +467,34 @@ tag_func_define_button_2 (SwfdecSwfDecod
swfdec_button_append_content (button, states, content);
}
}
- swfdec_bits_get_u8 (bits);
+ swfdec_bits_get_u8 (&bits);
+ if (swfdec_bits_left (&bits)) {
+ SWFDEC_WARNING ("%u bytes left when parsing button records", swfdec_bits_left (&bits) / 8);
+ }
script_name = g_strdup_printf ("Button%u", SWFDEC_CHARACTER (button)->id);
- while (offset != 0) {
+ while (length != 0) {
guint condition, key;
- offset = swfdec_bits_get_u16 (bits);
- condition = swfdec_bits_get_u16 (bits);
+ length = swfdec_bits_get_u16 (&s->b);
+ if (length)
+ swfdec_bits_init_bits (&bits, &s->b, length > 2 ? length - 2 : 0);
+ else
+ swfdec_bits_init_bits (&bits, &s->b, swfdec_bits_left (&s->b) / 8);
+ condition = swfdec_bits_get_u16 (&bits);
key = condition >> 9;
condition &= 0x1FF;
- SWFDEC_LOG (" offset = %d", offset);
+ SWFDEC_LOG (" length = %d", length);
if (button->events == NULL)
button->events = swfdec_event_list_new (SWFDEC_DECODER (s)->player);
- SWFDEC_LOG ("new event for condition %u (key %u)", condition, key);
- swfdec_event_list_parse (button->events, &s->b, s->version, condition, key,
+ SWFDEC_LOG (" new event for condition %u (key %u)", condition, key);
+ swfdec_event_list_parse (button->events, &bits, s->version, condition, key,
script_name);
+ if (swfdec_bits_left (&bits)) {
+ SWFDEC_WARNING ("%u bytes left after parsing script", swfdec_bits_left (&bits) / 8);
+ }
}
g_free (script_name);
diff-tree 9d35a0a007492163043bf609bf2759a05738c8df (from a52e6ff4dd2e308c031da0434bcdf194b66bbb83)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Aug 13 14:12:25 2007 +0200
split out filter parsing code
diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c
index 4b67ed5..488864c 100644
--- a/libswfdec/swfdec_sprite_movie.c
+++ b/libswfdec/swfdec_sprite_movie.c
@@ -184,64 +184,8 @@ swfdec_sprite_movie_perform_place (Swfde
clip_depth = 0;
}
- if (has_filter) {
- guint i, n_filters, filter_id;
- n_filters = swfdec_bits_get_u8 (bits);
- SWFDEC_LOG (" filters: %u", n_filters);
- for (i = 0; i < n_filters && swfdec_bits_left (bits); i++) {
- filter_id = swfdec_bits_get_u8 (bits);
- switch (filter_id) {
- case 0:
- SWFDEC_WARNING (" drop shadow");
- swfdec_bits_skip_bytes (bits, 16);
- break;
- case 1:
- SWFDEC_WARNING (" blur");
- swfdec_bits_skip_bytes (bits, 9);
- break;
- case 2:
- SWFDEC_WARNING (" glow");
- swfdec_bits_skip_bytes (bits, 15);
- break;
- case 3:
- SWFDEC_WARNING (" bevel");
- swfdec_bits_skip_bytes (bits, 27);
- break;
- case 4:
- {
- guint n;
- n = swfdec_bits_get_u8 (bits);
- SWFDEC_WARNING (" gradient glow");
- swfdec_bits_skip_bytes (bits, n * 5 + 19);
- }
- break;
- case 5:
- {
- guint x, y;
- x = swfdec_bits_get_u8 (bits);
- y = swfdec_bits_get_u8 (bits);
- SWFDEC_WARNING (" %u x %u convolution", x, y);
- swfdec_bits_skip_bytes (bits, (x + y) * 4 + 13);
- }
- break;
- case 6:
- SWFDEC_WARNING (" color matrix");
- swfdec_bits_skip_bytes (bits, 20 * 4);
- break;
- case 7:
- {
- guint n;
- n = swfdec_bits_get_u8 (bits);
- SWFDEC_WARNING (" gradient bevel");
- swfdec_bits_skip_bytes (bits, n * 5 + 19);
- }
- break;
- default:
- SWFDEC_ERROR ("unknown filter id %u", filter_id);
- break;
- }
- }
- }
+ if (has_filter)
+ swfdec_filters_parse (bits);
if (has_blend_mode) {
/* FIXME: implement */
diff --git a/libswfdec/swfdec_tag.c b/libswfdec/swfdec_tag.c
index b6acf1b..a556e19 100644
--- a/libswfdec/swfdec_tag.c
+++ b/libswfdec/swfdec_tag.c
@@ -252,6 +252,67 @@ tag_func_define_sprite (SwfdecSwfDecoder
return SWFDEC_STATUS_OK;
}
+void
+swfdec_filters_parse (SwfdecBits *bits)
+{
+ guint i, n_filters, filter_id;
+ n_filters = swfdec_bits_get_u8 (bits);
+ SWFDEC_WARNING (" filters: %u", n_filters);
+ for (i = 0; i < n_filters && swfdec_bits_left (bits); i++) {
+ filter_id = swfdec_bits_get_u8 (bits);
+ switch (filter_id) {
+ case 0:
+ SWFDEC_WARNING (" drop shadow");
+ swfdec_bits_skip_bytes (bits, 16);
+ break;
+ case 1:
+ SWFDEC_WARNING (" blur");
+ swfdec_bits_skip_bytes (bits, 9);
+ break;
+ case 2:
+ SWFDEC_WARNING (" glow");
+ swfdec_bits_skip_bytes (bits, 15);
+ break;
+ case 3:
+ SWFDEC_WARNING (" bevel");
+ swfdec_bits_skip_bytes (bits, 27);
+ break;
+ case 4:
+ {
+ guint n;
+ n = swfdec_bits_get_u8 (bits);
+ SWFDEC_WARNING (" gradient glow");
+ swfdec_bits_skip_bytes (bits, n * 5 + 19);
+ }
+ break;
+ case 5:
+ {
+ guint x, y;
+ x = swfdec_bits_get_u8 (bits);
+ y = swfdec_bits_get_u8 (bits);
+ SWFDEC_WARNING (" %u x %u convolution", x, y);
+ swfdec_bits_skip_bytes (bits, (x + y) * 4 + 13);
+ }
+ break;
+ case 6:
+ SWFDEC_WARNING (" color matrix");
+ swfdec_bits_skip_bytes (bits, 20 * 4);
+ break;
+ case 7:
+ {
+ guint n;
+ n = swfdec_bits_get_u8 (bits);
+ SWFDEC_WARNING (" gradient bevel");
+ swfdec_bits_skip_bytes (bits, n * 5 + 19);
+ }
+ break;
+ default:
+ SWFDEC_ERROR ("unknown filter id %u", filter_id);
+ break;
+ }
+ }
+}
+
#define CONTENT_IN_FRAME(content, frame) \
((content)->sequence->start <= frame && \
(content)->sequence->end > frame)
diff --git a/libswfdec/swfdec_tag.h b/libswfdec/swfdec_tag.h
index ac7c2fa..91bba34 100644
--- a/libswfdec/swfdec_tag.h
+++ b/libswfdec/swfdec_tag.h
@@ -92,4 +92,9 @@ typedef enum {
SWFDEC_TAG_DEFINEMORPHSHAPE2 = 84
} SwfdecTag;
+/* FIXME: put this somewhere sane */
+#include "swfdec_bits.h"
+void swfdec_filters_parse (SwfdecBits * bits);
+
+
#endif
More information about the Swfdec
mailing list