[Swfdec-commits] 2 commits - swfdec/swfdec_debug.c swfdec/swfdec_movie_asprops.c swfdec/swfdec_movie.c swfdec/swfdec_player.c swfdec/swfdec_player_internal.h

Benjamin Otte company at kemper.freedesktop.org
Wed Apr 2 03:18:14 PDT 2008


 swfdec/swfdec_debug.c           |   60 +++++++++++++++++++++++++++++++++++++++-
 swfdec/swfdec_movie.c           |    9 +++++-
 swfdec/swfdec_movie_asprops.c   |    6 ++--
 swfdec/swfdec_player.c          |   59 ++++++++++++++++++++++++++++++++-------
 swfdec/swfdec_player_internal.h |    2 +
 5 files changed, 120 insertions(+), 16 deletions(-)

New commits:
commit 4d624cfdf6f5264c241edf5f11bacfa23680ea1c
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Apr 2 12:13:29 2008 +0200

    add documentation to the debug messages

diff --git a/swfdec/swfdec_debug.c b/swfdec/swfdec_debug.c
index 54eee5c..789a459 100644
--- a/swfdec/swfdec_debug.c
+++ b/swfdec/swfdec_debug.c
@@ -1,7 +1,7 @@
 /* Swfdec
  * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
  *		 2005-2006 Eric Anholt <eric at anholt.net>
- *		 2006-2007 Benjamin Otte <otte at gnome.org>
+ *		 2006-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
@@ -26,6 +26,64 @@
 #include <glib.h>
 #include "swfdec_debug.h"
 
+/**
+ * SWFDEC_ERROR:
+ * @...: a printf-style message
+ *
+ * Emits an error debugging message. Error messages are used to indicate 
+ * mal-formed content. Examples are invalid data in the Flash file or results
+ * of broken code. Note that error messages do not indicate that Swfdec stopped
+ * interpretation of the Flash file.
+ */
+
+/**
+ * SWFDEC_FIXME:
+ * @...: a printf-style message
+ *
+ * Emits a fixme debugging message. FIXMEs are used when it is known that a
+ * feature is not yet correctly implemented and could cause wrong behavior while
+ * playing back this Flash file.
+ */
+
+/**
+ * SWFDEC_WARNING:
+ * @...: a printf-style message
+ *
+ * Emits a warning debugging message. Warnings are used to indicate unusual
+ * situations. An example would be a wrong argument type passed to a native 
+ * script function. Warning messages are output by default on development 
+ * builds. So make sure they are important enough to warrant being printed.
+ */
+
+/**
+ * SWFDEC_INFO:
+ * @...: a printf-style message
+ *
+ * Outputs an informational debugging message. This debugging category should 
+ * be used for rare messages that contain useful information. An example is
+ * printing the version and default size of a newly loaded Flash file.
+ */
+
+/**
+ * SWFDEC_DEBUG:
+ * @...: a printf-style message
+ *
+ * Outputs a debugging message. This debugging category should be used whenever
+ * something happens that is worth noting, but not the default behavior. For
+ * default messages, use SWFDEC_LOG(). An example would be if a special argument
+ * was passed by a script to a native function.
+ */
+
+/**
+ * SWFDEC_LOG:
+ * @...: a printf-style message
+ *
+ * Outputs a logging message. This debugging category should be used whenever
+ * there is something that might be interesting to a developer inspecting a run
+ * of Swfdec. It is used for example to dump every parsed token of the Flash 
+ * file.
+ */
+
 static const char *swfdec_debug_level_names[] = {
   "NONE ",
   "ERROR",
commit ade9e423b2718d934071678713ff1f4dddb4b16a
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Apr 1 15:11:51 2008 +0200

    rewrite focusrect handling to make invalidations work

diff --git a/swfdec/swfdec_movie.c b/swfdec/swfdec_movie.c
index cc97939..57704dc 100644
--- a/swfdec/swfdec_movie.c
+++ b/swfdec/swfdec_movie.c
@@ -150,10 +150,15 @@ swfdec_movie_invalidate_last (SwfdecMovie *movie)
 void
 swfdec_movie_invalidate_next (SwfdecMovie *movie)
 {
+  SwfdecPlayer *player;
+
   g_return_if_fail (SWFDEC_IS_MOVIE (movie));
 
   swfdec_movie_invalidate_last (movie);
   movie->invalidate_next = TRUE;
+  player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
+  if (movie == SWFDEC_MOVIE (player->priv->focus))
+    swfdec_player_invalidate_focusrect (player);
 }
 
 /**
@@ -319,8 +324,10 @@ swfdec_movie_unset_actor (SwfdecPlayer *player, SwfdecActor *actor)
 
   if (priv->focus_previous == actor)
     priv->focus_previous = NULL;
-  if (priv->focus == actor)
+  if (priv->focus == actor) {
     priv->focus = NULL;
+    swfdec_player_invalidate_focusrect (player);
+  }
 }
 
 static gboolean
diff --git a/swfdec/swfdec_movie_asprops.c b/swfdec/swfdec_movie_asprops.c
index d004ecf..cc9b891 100644
--- a/swfdec/swfdec_movie_asprops.c
+++ b/swfdec/swfdec_movie_asprops.c
@@ -464,10 +464,10 @@ mc_focusrect_set (SwfdecMovie *movie, const SwfdecAsValue *val)
 
   if (b != actor->focusrect) {
     SwfdecPlayerPrivate *priv = SWFDEC_PLAYER (cx)->priv;
-    gboolean had_focusrect = swfdec_actor_has_focusrect (priv->focus);
+    gboolean had_focusrect = priv->focus ? swfdec_actor_has_focusrect (priv->focus) : FALSE;
     actor->focusrect = b;
-    if (had_focusrect != swfdec_actor_has_focusrect (priv->focus))
-      swfdec_movie_invalidate_last (SWFDEC_MOVIE (priv->focus));
+    if (priv->focus && had_focusrect != swfdec_actor_has_focusrect (priv->focus))
+      swfdec_player_invalidate_focusrect (SWFDEC_PLAYER (cx));
   }
 }
 
diff --git a/swfdec/swfdec_player.c b/swfdec/swfdec_player.c
index 641fc1d..015d6e7 100644
--- a/swfdec/swfdec_player.c
+++ b/swfdec/swfdec_player.c
@@ -1063,6 +1063,22 @@ swfdec_player_broadcast (SwfdecPlayer *player, const char *object_name, const ch
   }
 }
 
+void
+swfdec_player_invalidate_focusrect (SwfdecPlayer *player)
+{
+  SwfdecPlayerPrivate *priv;
+
+  g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+  priv = player->priv;
+
+  if (swfdec_rect_is_empty (&priv->focusrect))
+    return;
+
+  swfdec_player_invalidate (player, &priv->focusrect);
+  swfdec_rect_init_empty (&priv->focusrect);
+}
+
 /**
  * swfdec_player_grab_focus:
  * @player: the player
@@ -1110,11 +1126,10 @@ swfdec_player_grab_focus (SwfdecPlayer *player, SwfdecActor *actor)
     klass = SWFDEC_ACTOR_GET_CLASS (prev);
     if (klass->focus_out)
       klass->focus_out (prev);
-    if (swfdec_actor_has_focusrect (prev))
-      swfdec_movie_invalidate_last (SWFDEC_MOVIE (prev));
   }
   priv->focus_previous = prev;
   priv->focus = actor;
+  swfdec_player_invalidate_focusrect (player);
   if (actor) {
     swfdec_sandbox_use (SWFDEC_MOVIE (actor)->resource->sandbox);
     swfdec_as_object_call (SWFDEC_AS_OBJECT (actor), SWFDEC_AS_STR_onSetFocus,
@@ -1123,8 +1138,6 @@ swfdec_player_grab_focus (SwfdecPlayer *player, SwfdecActor *actor)
     klass = SWFDEC_ACTOR_GET_CLASS (actor);
     if (klass->focus_in)
       klass->focus_in (actor);
-    if (swfdec_actor_has_focusrect (actor))
-      swfdec_movie_invalidate_last (SWFDEC_MOVIE (actor));
   }
   swfdec_player_broadcast (player, SWFDEC_AS_STR_Selection, SWFDEC_AS_STR_onSetFocus, 2, vals);
 }
@@ -1782,6 +1795,27 @@ swfdec_player_update_movies (SwfdecPlayer *player)
   priv->invalid_pending = NULL;
 }
 
+static void
+swfdec_player_update_focusrect (SwfdecPlayer *player)
+{
+  SwfdecPlayerPrivate *priv = player->priv;
+  SwfdecMovie *movie;
+
+  if (!swfdec_rect_is_empty (&priv->focusrect))
+    return;
+
+  if (priv->focus == NULL ||
+      !swfdec_actor_has_focusrect (priv->focus))
+    return;
+
+  movie = SWFDEC_MOVIE (priv->focus);
+  g_assert (movie->state == SWFDEC_MOVIE_UP_TO_DATE);
+  priv->focusrect = movie->extents;
+  if (movie->parent)
+    swfdec_movie_rect_local_to_global (movie->parent, &priv->focusrect);
+  swfdec_player_invalidate (player, &priv->focusrect);
+}
+
 /* used for breakpoints */
 void
 swfdec_player_unlock_soft (SwfdecPlayer *player)
@@ -1792,6 +1826,7 @@ swfdec_player_unlock_soft (SwfdecPlayer *player)
   g_timer_stop (player->priv->runtime);
   swfdec_player_update_movies (player);
   swfdec_player_update_mouse_cursor (player);
+  swfdec_player_update_focusrect (player);
   g_object_thaw_notify (G_OBJECT (player));
   swfdec_player_emit_signals (player);
 }
@@ -2739,18 +2774,21 @@ static void
 swfdec_player_render_focusrect (SwfdecPlayer *player, cairo_t *cr, SwfdecRect *inval)
 {
 #define LINE_WIDTH (3.0)
-  SwfdecMovie *movie = SWFDEC_MOVIE (player->priv->focus);
-  SwfdecRect rect = movie->extents;
+  SwfdecPlayerPrivate *priv;
   double w, h;
+  SwfdecRect rect;
+
+  priv = player->priv;
+  if (swfdec_rect_is_empty (&priv->focusrect))
+    return;
 
+  rect = priv->focusrect;
   cairo_save (cr);
   /* I wonder why this has to be yellow... */
   cairo_set_source_rgb (cr, 1.0, 1.0, 0.0);
-  if (movie->parent)
-    swfdec_movie_rect_local_to_global (movie->parent, &rect);
+  cairo_set_line_width (cr, LINE_WIDTH);
   swfdec_player_global_to_stage (player, &rect.x0, &rect.y0);
   swfdec_player_global_to_stage (player, &rect.x1, &rect.y1);
-  cairo_set_line_width (cr, LINE_WIDTH);
   w = MAX (rect.x1 - rect.x0 - LINE_WIDTH, 0);
   h = MAX (rect.y1 - rect.y0 - LINE_WIDTH, 0);
   cairo_rectangle (cr, rect.x0 + LINE_WIDTH / 2, rect.y0 + LINE_WIDTH / 2, w, h);
@@ -2817,8 +2855,7 @@ swfdec_player_render (SwfdecPlayer *player, cairo_t *cr,
   }
   cairo_restore (cr);
   /* NB: we render the focusrect after restoring, so the focusrect doesn't scale */
-  if (priv->focus && swfdec_actor_has_focusrect (priv->focus))
-    swfdec_player_render_focusrect (player, cr, &real);
+  swfdec_player_render_focusrect (player, cr, &real);
 
   SWFDEC_INFO ("=== %p: END RENDER ===", player);
 }
diff --git a/swfdec/swfdec_player_internal.h b/swfdec/swfdec_player_internal.h
index d1b78fd..c0c63a2 100644
--- a/swfdec/swfdec_player_internal.h
+++ b/swfdec/swfdec_player_internal.h
@@ -126,6 +126,7 @@ struct _SwfdecPlayerPrivate
   SwfdecActor *		focus;			/* actor that currently has keyboard focus (or NULL if none) */
   SwfdecActor *		focus_previous;		/* the previues actor that had focus */
   GList *		focus_list;	      	/* list of movies with a tabIndex set or NULL for no tabIndex usage */
+  SwfdecRect		focusrect;		/* current focus rectangle in global coordinates or empty */
 
   /* audio */
   GList *		audio;		 	/* list of playing SwfdecAudio */
@@ -186,6 +187,7 @@ SwfdecSocket *	swfdec_player_create_socket	(SwfdecPlayer *		player,
 						 const char *		hostname,
 						 guint			port);
 
+void		swfdec_player_invalidate_focusrect (SwfdecPlayer *	player);
 void		swfdec_player_grab_focus	(SwfdecPlayer *		player,
 						 SwfdecActor *		actor);
 #define swfdec_player_is_key_pressed(player,key) ((player)->priv->key_pressed[(key) / 8] & (1 << ((key) % 8)))


More information about the Swfdec-commits mailing list