[Swfdec] 2 commits - libswfdec/swfdec_movie.c libswfdec/swfdec_player.c

Benjamin Otte company at kemper.freedesktop.org
Fri Jul 27 14:33:04 PDT 2007


 libswfdec/swfdec_movie.c  |   16 +++++++++++++++-
 libswfdec/swfdec_player.c |    4 ++--
 2 files changed, 17 insertions(+), 3 deletions(-)

New commits:
diff-tree b9079d14ce23c4ff652934c1ef222ec2d966fa5c (from 9613d59e95f3801976995550d84eb7560416bb01)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Jul 27 23:33:08 2007 +0200

    fix global <=> local conversions to work with Stage changes

diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index 196a8f3..3a2980d 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -496,16 +496,30 @@ swfdec_movie_mouse_in (SwfdecMovie *movi
 void
 swfdec_movie_local_to_global (SwfdecMovie *movie, double *x, double *y)
 {
+  SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
+
   do {
     cairo_matrix_transform_point (&movie->matrix, x, y);
   } while ((movie = movie->parent));
+
+  *x /= player->scale_x;
+  *y /= player->scale_y;
+  *x += SWFDEC_TWIPS_TO_DOUBLE (player->offset_x);
+  *y += SWFDEC_TWIPS_TO_DOUBLE (player->offset_y);
 }
 
 void
 swfdec_movie_global_to_local (SwfdecMovie *movie, double *x, double *y)
 {
-  if (movie->parent)
+  if (movie->parent) {
     swfdec_movie_global_to_local (movie->parent, x, y);
+  } else {
+    SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
+    *x -= SWFDEC_TWIPS_TO_DOUBLE (player->offset_x);
+    *y -= SWFDEC_TWIPS_TO_DOUBLE (player->offset_y);
+    *x *= player->scale_x;
+    *y *= player->scale_y;
+  }
   if (movie->cache_state >= SWFDEC_MOVIE_INVALID_MATRIX)
     swfdec_movie_update (movie);
   cairo_matrix_transform_point (&movie->inverse_matrix, x, y);
diff-tree 9613d59e95f3801976995550d84eb7560416bb01 (from a3ece6519ae6a1c481845d7a6a383b87aa0cc30d)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Jul 27 19:49:20 2007 +0200

    use the right size when computing offsets

diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 88c14e0..d48ad03 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -481,8 +481,8 @@ swfdec_player_update_scale (SwfdecPlayer
     default:
       g_assert_not_reached ();
   }
-  width = player->stage_width - ceil (player->width * player->scale_x);
-  height = player->stage_height - ceil (player->height * player->scale_y);
+  width = width - ceil (player->width * player->scale_x);
+  height = height - ceil (player->height * player->scale_y);
   if (player->align_flags & SWFDEC_ALIGN_FLAG_LEFT) {
     player->offset_x = 0;
   } else if (player->align_flags & SWFDEC_ALIGN_FLAG_RIGHT) {


More information about the Swfdec mailing list