[Swfdec] 2 commits - libswfdec/swfdec_player.c libswfdec/swfdec_player_internal.h libswfdec/swfdec_stage_as.c
Benjamin Otte
company at kemper.freedesktop.org
Thu Aug 2 07:10:06 PDT 2007
libswfdec/swfdec_player.c | 58 ++++++++++++++++++++++---------------
libswfdec/swfdec_player_internal.h | 2 +
libswfdec/swfdec_stage_as.c | 12 +------
3 files changed, 40 insertions(+), 32 deletions(-)
New commits:
diff-tree db20b4472b8409531a3d5f2b09faf5d072f58038 (from 1020868e1da520df7be94e149d2a5d3842c2ea05)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Aug 2 16:10:18 2007 +0200
make external actions happen ASAP
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index a8e648a..ec8e159 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -370,8 +370,9 @@ swfdec_player_add_external_action (Swfde
action->func = action_func;
action->data = action_data;
if (!player->external_timeout.callback) {
- /* trigger execution in 100 ms */
- player->external_timeout.timestamp = player->time + SWFDEC_MSECS_TO_TICKS (100);
+ /* trigger execution immediately, but at least 100ms after the last external timeout */
+ player->external_timeout.timestamp = MAX (player->time + 1,
+ player->external_timeout.timestamp + SWFDEC_MSECS_TO_TICKS (100));
player->external_timeout.callback = swfdec_player_trigger_external_actions;
swfdec_player_add_timeout (player, &player->external_timeout);
}
diff-tree 1020868e1da520df7be94e149d2a5d3842c2ea05 (from 013119a40898e8308caba54d3921d3c477f239c8)
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Aug 2 16:05:57 2007 +0200
make resizing use external events
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 78493bf..a8e648a 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -644,6 +644,9 @@ swfdec_player_dispose (GObject *object)
}
}
#endif
+ swfdec_player_remove_all_external_actions (player, player);
+ g_assert (swfdec_ring_buffer_pop (player->external_actions) == NULL);
+ swfdec_ring_buffer_free (player->external_actions);
g_assert (swfdec_ring_buffer_pop (player->actions) == NULL);
swfdec_ring_buffer_free (player->actions);
g_assert (player->movies == NULL);
@@ -1400,6 +1403,8 @@ swfdec_player_initialize (SwfdecPlayer *
player->rate = rate;
player->width = width;
player->height = height;
+ player->internal_width = player->stage_width >=0 ? (guint) player->stage_width : player->width;
+ player->internal_height = player->stage_height >=0 ? (guint) player->stage_height : player->height;
player->initialized = TRUE;
if (rate) {
player->iterate_timeout.timestamp = player->time + SWFDEC_TICKS_PER_SECOND * 256 / rate;
@@ -1801,24 +1806,21 @@ swfdec_player_get_size (SwfdecPlayer *pl
}
static void
-swfdec_player_set_size_internal (SwfdecPlayer *player, int width, int height)
+swfdec_player_update_size (gpointer playerp, gpointer unused)
{
- gboolean changed = FALSE;
+ SwfdecPlayer *player = playerp;
+ guint width, height;
- if (player->stage_width != width) {
- player->stage_width = width;
- g_object_notify (G_OBJECT (player), "width");
- changed = TRUE;
- }
- if (player->stage_height != height) {
- player->stage_height = height;
- g_object_notify (G_OBJECT (player), "height");
- changed = TRUE;
- }
- swfdec_player_update_scale (player);
- if (changed && player->scale_mode == SWFDEC_SCALE_NONE) {
- swfdec_player_broadcast (player, SWFDEC_AS_STR_Stage, SWFDEC_AS_STR_onResize);
- }
+ /* FIXME: only update if not fullscreen */
+ width = player->stage_width >=0 ? (guint) player->stage_width : player->width;
+ height = player->stage_height >=0 ? (guint) player->stage_height : player->height;
+ /* only broadcast once */
+ if (width == player->internal_width && height == player->internal_height)
+ return;
+
+ player->internal_width = width;
+ player->internal_height = height;
+ swfdec_player_broadcast (player, SWFDEC_AS_STR_Stage, SWFDEC_AS_STR_onResize);
}
/**
@@ -1836,14 +1838,25 @@ swfdec_player_set_size_internal (SwfdecP
void
swfdec_player_set_size (SwfdecPlayer *player, int width, int height)
{
+ gboolean changed = FALSE;
+
g_return_if_fail (SWFDEC_IS_PLAYER (player));
g_return_if_fail (width >= -1);
g_return_if_fail (height >= -1);
- swfdec_player_lock (player);
- swfdec_player_set_size_internal (player, width, height);
- swfdec_player_perform_actions (player);
- swfdec_player_unlock (player);
+ if (player->stage_width != width) {
+ player->stage_width = width;
+ g_object_notify (G_OBJECT (player), "width");
+ changed = TRUE;
+ }
+ if (player->stage_height != height) {
+ player->stage_height = height;
+ g_object_notify (G_OBJECT (player), "height");
+ changed = TRUE;
+ }
+ swfdec_player_update_scale (player);
+ if (changed && player->scale_mode == SWFDEC_SCALE_NONE)
+ swfdec_player_add_external_action (player, player, swfdec_player_update_size, NULL);
}
/**
diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h
index cc9a384..0667e20 100644
--- a/libswfdec/swfdec_player_internal.h
+++ b/libswfdec/swfdec_player_internal.h
@@ -61,6 +61,8 @@ struct _SwfdecPlayer
SwfdecColor bgcolor; /* background color */
SwfdecLoader * loader; /* initial loader */
/* stage properties */
+ guint internal_width; /* width used by the scripting engine */
+ guint internal_height; /* height used by the scripting engine */
gint stage_width; /* width set by the user */
gint stage_height; /* height set by the user */
guint align_flags; /* SwfdecAlignFlag */
diff --git a/libswfdec/swfdec_stage_as.c b/libswfdec/swfdec_stage_as.c
index 85fc9ea..2f27cbb 100644
--- a/libswfdec/swfdec_stage_as.c
+++ b/libswfdec/swfdec_stage_as.c
@@ -134,11 +134,7 @@ get_width (SwfdecAsContext *cx, SwfdecAs
{
SwfdecPlayer *player = SWFDEC_PLAYER (cx);
- if (player->stage_width > -1) {
- SWFDEC_AS_VALUE_SET_INT (ret, player->stage_width);
- } else {
- SWFDEC_AS_VALUE_SET_INT (ret, player->width);
- }
+ SWFDEC_AS_VALUE_SET_INT (ret, player->internal_width);
}
SWFDEC_AS_NATIVE (666, 7, get_height)
@@ -148,11 +144,7 @@ get_height (SwfdecAsContext *cx, SwfdecA
{
SwfdecPlayer *player = SWFDEC_PLAYER (cx);
- if (player->stage_height > -1) {
- SWFDEC_AS_VALUE_SET_INT (ret, player->stage_height);
- } else {
- SWFDEC_AS_VALUE_SET_INT (ret, player->height);
- }
+ SWFDEC_AS_VALUE_SET_INT (ret, player->internal_height);
}
/* FIXME: do this smarter */
More information about the Swfdec
mailing list