[Swfdec] libswfdec/swfdec_tag.c

Benjamin Otte company at kemper.freedesktop.org
Sun Apr 22 04:12:18 PDT 2007


 libswfdec/swfdec_tag.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+)

New commits:
diff-tree ef2514da947a3aeb0d8210cba619fdd350281e94 (from 086e5f3c4da50df4b485792da7ca49a25484aebc)
Author: Benjamin Otte <otte at gnome.org>
Date:   Sun Apr 22 13:07:26 2007 +0200

    make sure the same depth and state aren't taken twice in buttons

diff --git a/libswfdec/swfdec_tag.c b/libswfdec/swfdec_tag.c
index 6000d45..74c5083 100644
--- a/libswfdec/swfdec_tag.c
+++ b/libswfdec/swfdec_tag.c
@@ -272,12 +272,45 @@ tag_func_do_action (SwfdecSwfDecoder * s
   return SWFDEC_STATUS_OK;
 }
 
+#define CONTENT_IN_FRAME(content, frame) \
+  ((content)->sequence->start <= frame && \
+   (content)->sequence->end > frame)
+static guint
+swfdec_button_remove_duplicates (SwfdecButton *button, int depth, guint states)
+{
+  GList *walk;
+  guint taken = 0;
+  guint i;
+
+  /* 1) find out which states are already taken */
+  for (walk = button->records; walk; walk = walk->next) {
+    SwfdecContent *cur = walk->data;
+    if (cur->depth != depth)
+      continue;
+    for (i = 0; i < 4; i++) {
+      if (CONTENT_IN_FRAME (cur, i))
+	taken |= (1 << i);
+    }
+  }
+  /* 2) mark states that overlap */
+  taken &= states;
+  /* 3) remove the overlapping states */
+  if (taken) {
+    SWFDEC_ERROR ("overlapping contents in button, removing for depth %u and states %u",
+	depth, taken);
+    states &= ~taken;
+  }
+  return states;
+}
+
 static void
 swfdec_button_append_content (SwfdecButton *button, guint states, SwfdecContent *content)
 {
   guint i;
   SwfdecContent *cur = NULL;
 
+  states = swfdec_button_remove_duplicates (button, content->depth, states);
+
   for (i = 0; i < 4; i++) {
     if (!cur && (states & 1)) {
       cur = content;


More information about the Swfdec mailing list