[Swfdec] libswfdec/Makefile.am libswfdec/swfdec_as_strings.c libswfdec/swfdec_initialize.as libswfdec/swfdec_initialize.h libswfdec/swfdec_stage_as.c

Benjamin Otte company at kemper.freedesktop.org
Thu Jul 26 10:51:20 PDT 2007


 libswfdec/Makefile.am          |    1 
 libswfdec/swfdec_as_strings.c  |    4 ++
 libswfdec/swfdec_initialize.as |    5 ++
 libswfdec/swfdec_initialize.h  |   80 ++++++++++++++++++++++-------------------
 libswfdec/swfdec_stage_as.c    |   79 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 132 insertions(+), 37 deletions(-)

New commits:
diff-tree e9a1e2cf91496460342ffc67cdf965ad1bf73044 (from 570b76928de0ee2374c8b146f61fcf02ffaf7a45)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Jul 26 19:51:13 2007 +0200

    implement Stage and Stage.scaleMode

diff --git a/libswfdec/Makefile.am b/libswfdec/Makefile.am
index 88f4c2f..ed5330e 100644
--- a/libswfdec/Makefile.am
+++ b/libswfdec/Makefile.am
@@ -95,6 +95,7 @@ libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES
 	swfdec_sprite.c \
 	swfdec_sprite_movie.c \
 	swfdec_sprite_movie_as.c \
+	swfdec_stage_as.c \
 	swfdec_swf_decoder.c \
 	swfdec_swf_instance.c \
 	swfdec_tag.c \
diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index f64e15f..a97471d 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -238,6 +238,10 @@ const char swfdec_as_strings[] = 
   SWFDEC_AS_CONSTANT_STRING ("ASnative")
   SWFDEC_AS_CONSTANT_STRING ("_listeners")
   SWFDEC_AS_CONSTANT_STRING ("broadcastMessage")
+  SWFDEC_AS_CONSTANT_STRING ("showAll")
+  SWFDEC_AS_CONSTANT_STRING ("noBorder")
+  SWFDEC_AS_CONSTANT_STRING ("exactFit")
+  SWFDEC_AS_CONSTANT_STRING ("noScale")
   /* add more here */
 ;
 
diff --git a/libswfdec/swfdec_initialize.as b/libswfdec/swfdec_initialize.as
index b153c7a..c922016 100644
--- a/libswfdec/swfdec_initialize.as
+++ b/libswfdec/swfdec_initialize.as
@@ -57,3 +57,8 @@ Mouse = new Object ();
 Mouse.show = ASnative (5, 0);
 Mouse.hide = ASnative (5, 1);
 AsBroadcaster.initialize (Mouse);
+
+/*** STAGE ***/
+
+Stage = new Object ();
+Stage.addProperty ("scaleMode", ASnative (666, 1), ASnative (666, 2));
diff --git a/libswfdec/swfdec_initialize.h b/libswfdec/swfdec_initialize.h
index 2b6c78c..2660c64 100644
--- a/libswfdec/swfdec_initialize.h
+++ b/libswfdec/swfdec_initialize.h
@@ -2,7 +2,7 @@
 
 /* compiled from swfdec_initialize.as */
 const unsigned char swfdec_initialize[] = {
-  0x88, 0xDE, 0x00, 0x16,  0x00, 0x41, 0x73, 0x42,  0x72, 0x6F, 0x61, 0x64,  0x63, 0x61, 0x73, 0x74,
+  0x88, 0xFA, 0x00, 0x19,  0x00, 0x41, 0x73, 0x42,  0x72, 0x6F, 0x61, 0x64,  0x63, 0x61, 0x73, 0x74,
   0x65, 0x72, 0x00, 0x62,  0x72, 0x6F, 0x61, 0x64,  0x63, 0x61, 0x73, 0x74,  0x4D, 0x65, 0x73, 0x73,
   0x61, 0x67, 0x65, 0x00,  0x41, 0x53, 0x6E, 0x61,  0x74, 0x69, 0x76, 0x65,  0x00, 0x61, 0x64, 0x64,
   0x4C, 0x69, 0x73, 0x74,  0x65, 0x6E, 0x65, 0x72,  0x00, 0x74, 0x68, 0x69,  0x73, 0x00, 0x78, 0x00,
@@ -16,41 +16,47 @@ const unsigned char swfdec_initialize[] 
   0x5F, 0x6C, 0x69, 0x73,  0x74, 0x65, 0x6E, 0x65,  0x72, 0x73, 0x00, 0x41,  0x53, 0x53, 0x65, 0x74,
   0x50, 0x72, 0x6F, 0x70,  0x46, 0x6C, 0x61, 0x67,  0x73, 0x00, 0x4D, 0x6F,  0x75, 0x73, 0x65, 0x00,
   0x4F, 0x62, 0x6A, 0x65,  0x63, 0x74, 0x00, 0x73,  0x68, 0x6F, 0x77, 0x00,  0x68, 0x69, 0x64, 0x65,
-  0x00, 0x9B, 0x12, 0x00,  0x41, 0x73, 0x42, 0x72,  0x6F, 0x61, 0x64, 0x63,  0x61, 0x73, 0x74, 0x65,
-  0x72, 0x00, 0x00, 0x00,  0x00, 0x00, 0x96, 0x02,  0x00, 0x08, 0x00, 0x1C,  0x96, 0x13, 0x00, 0x08,
-  0x01, 0x07, 0x0C, 0x00,  0x00, 0x00, 0x07, 0x65,  0x00, 0x00, 0x00, 0x07,  0x02, 0x00, 0x00, 0x00,
-  0x08, 0x02, 0x3D, 0x4F,  0x96, 0x02, 0x00, 0x08,  0x00, 0x1C, 0x96, 0x02,  0x00, 0x08, 0x03, 0x9B,
-  0x07, 0x00, 0x00, 0x01,  0x00, 0x78, 0x00, 0x3C,  0x00, 0x96, 0x02, 0x00,  0x08, 0x05, 0x1C, 0x96,
-  0x07, 0x00, 0x07, 0x01,  0x00, 0x00, 0x00, 0x08,  0x04, 0x1C, 0x96, 0x02,  0x00, 0x08, 0x06, 0x52,
-  0x17, 0x96, 0x02, 0x00,  0x08, 0x05, 0x1C, 0x96,  0x07, 0x00, 0x07, 0x01,  0x00, 0x00, 0x00, 0x08,
-  0x04, 0x1C, 0x96, 0x02,  0x00, 0x08, 0x07, 0x4E,  0x96, 0x02, 0x00, 0x08,  0x08, 0x52, 0x17, 0x96,
-  0x02, 0x00, 0x05, 0x01,  0x3E, 0x4F, 0x96, 0x02,  0x00, 0x08, 0x00, 0x1C,  0x96, 0x02, 0x00, 0x08,
-  0x06, 0x9B, 0x07, 0x00,  0x00, 0x01, 0x00, 0x78,  0x00, 0x8F, 0x00, 0x96,  0x04, 0x00, 0x08, 0x09,
-  0x08, 0x04, 0x1C, 0x96,  0x02, 0x00, 0x08, 0x07,  0x4E, 0x3C, 0x96, 0x02,  0x00, 0x08, 0x0A, 0x41,
-  0x96, 0x07, 0x00, 0x08,  0x0A, 0x07, 0x00, 0x00,  0x00, 0x00, 0x3C, 0x99,  0x02, 0x00, 0x09, 0x00,
-  0x96, 0x02, 0x00, 0x08,  0x0A, 0x4C, 0x1C, 0x50,  0x1D, 0x96, 0x02, 0x00,  0x08, 0x0A, 0x1C, 0x96,
-  0x02, 0x00, 0x08, 0x09,  0x1C, 0x96, 0x02, 0x00,  0x08, 0x0B, 0x4E, 0x48,  0x12, 0x9D, 0x02, 0x00,
-  0x42, 0x00, 0x96, 0x02,  0x00, 0x08, 0x09, 0x1C,  0x96, 0x02, 0x00, 0x08,  0x0A, 0x1C, 0x4E, 0x96,
-  0x02, 0x00, 0x08, 0x05,  0x1C, 0x49, 0x12, 0x9D,  0x02, 0x00, 0x23, 0x00,  0x96, 0x07, 0x00, 0x07,
-  0x01, 0x00, 0x00, 0x00,  0x08, 0x0A, 0x1C, 0x96,  0x07, 0x00, 0x07, 0x02,  0x00, 0x00, 0x00, 0x08,
-  0x09, 0x1C, 0x96, 0x02,  0x00, 0x08, 0x0C, 0x52,  0x17, 0x96, 0x02, 0x00,  0x05, 0x01, 0x3E, 0x99,
-  0x02, 0x00, 0x9C, 0xFF,  0x96, 0x02, 0x00, 0x05,  0x00, 0x3E, 0x4F, 0x96,  0x02, 0x00, 0x08, 0x00,
-  0x1C, 0x96, 0x02, 0x00,  0x08, 0x0D, 0x9B, 0x07,  0x00, 0x00, 0x01, 0x00,  0x6F, 0x00, 0x75, 0x00,
-  0x96, 0x02, 0x00, 0x08,  0x0E, 0x1C, 0x96, 0x13,  0x00, 0x08, 0x01, 0x07,  0x0C, 0x00, 0x00, 0x00,
-  0x07, 0x65, 0x00, 0x00,  0x00, 0x07, 0x02, 0x00,  0x00, 0x00, 0x08, 0x02,  0x3D, 0x4F, 0x96, 0x02,
-  0x00, 0x08, 0x0E, 0x1C,  0x96, 0x04, 0x00, 0x08,  0x03, 0x08, 0x00, 0x1C,  0x96, 0x02, 0x00, 0x08,
-  0x03, 0x4E, 0x4F, 0x96,  0x02, 0x00, 0x08, 0x0E,  0x1C, 0x96, 0x04, 0x00,  0x08, 0x06, 0x08, 0x00,
-  0x1C, 0x96, 0x02, 0x00,  0x08, 0x06, 0x4E, 0x4F,  0x96, 0x02, 0x00, 0x08,  0x0E, 0x1C, 0x96, 0x09,
-  0x00, 0x08, 0x07, 0x07,  0x00, 0x00, 0x00, 0x00,  0x08, 0x0F, 0x40, 0x4F,  0x96, 0x09, 0x00, 0x07,
-  0x83, 0x00, 0x00, 0x00,  0x08, 0x10, 0x08, 0x0E,  0x1C, 0x96, 0x07, 0x00,  0x07, 0x03, 0x00, 0x00,
-  0x00, 0x08, 0x11, 0x3D,  0x17, 0x4F, 0x96, 0x08,  0x00, 0x07, 0x83, 0x00,  0x00, 0x00, 0x02, 0x08,
-  0x00, 0x1C, 0x96, 0x07,  0x00, 0x07, 0x03, 0x00,  0x00, 0x00, 0x08, 0x11,  0x3D, 0x17, 0x96, 0x09,
-  0x00, 0x08, 0x12, 0x07,  0x00, 0x00, 0x00, 0x00,  0x08, 0x13, 0x40, 0x1D,  0x96, 0x02, 0x00, 0x08,
-  0x12, 0x1C, 0x96, 0x13,  0x00, 0x08, 0x14, 0x07,  0x00, 0x00, 0x00, 0x00,  0x07, 0x05, 0x00, 0x00,
-  0x00, 0x07, 0x02, 0x00,  0x00, 0x00, 0x08, 0x02,  0x3D, 0x4F, 0x96, 0x02,  0x00, 0x08, 0x12, 0x1C,
-  0x96, 0x13, 0x00, 0x08,  0x15, 0x07, 0x01, 0x00,  0x00, 0x00, 0x07, 0x05,  0x00, 0x00, 0x00, 0x07,
-  0x02, 0x00, 0x00, 0x00,  0x08, 0x02, 0x3D, 0x4F,  0x96, 0x02, 0x00, 0x08,  0x12, 0x1C, 0x96, 0x07,
-  0x00, 0x07, 0x01, 0x00,  0x00, 0x00, 0x08, 0x00,  0x1C, 0x96, 0x02, 0x00,  0x08, 0x0D, 0x52, 0x17,
-  0x00
+  0x00, 0x53, 0x74, 0x61,  0x67, 0x65, 0x00, 0x73,  0x63, 0x61, 0x6C, 0x65,  0x4D, 0x6F, 0x64, 0x65,
+  0x00, 0x61, 0x64, 0x64,  0x50, 0x72, 0x6F, 0x70,  0x65, 0x72, 0x74, 0x79,  0x00, 0x9B, 0x12, 0x00,
+  0x41, 0x73, 0x42, 0x72,  0x6F, 0x61, 0x64, 0x63,  0x61, 0x73, 0x74, 0x65,  0x72, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x96, 0x02,  0x00, 0x08, 0x00, 0x1C,  0x96, 0x13, 0x00, 0x08,  0x01, 0x07, 0x0C, 0x00,
+  0x00, 0x00, 0x07, 0x65,  0x00, 0x00, 0x00, 0x07,  0x02, 0x00, 0x00, 0x00,  0x08, 0x02, 0x3D, 0x4F,
+  0x96, 0x02, 0x00, 0x08,  0x00, 0x1C, 0x96, 0x02,  0x00, 0x08, 0x03, 0x9B,  0x07, 0x00, 0x00, 0x01,
+  0x00, 0x78, 0x00, 0x3C,  0x00, 0x96, 0x02, 0x00,  0x08, 0x05, 0x1C, 0x96,  0x07, 0x00, 0x07, 0x01,
+  0x00, 0x00, 0x00, 0x08,  0x04, 0x1C, 0x96, 0x02,  0x00, 0x08, 0x06, 0x52,  0x17, 0x96, 0x02, 0x00,
+  0x08, 0x05, 0x1C, 0x96,  0x07, 0x00, 0x07, 0x01,  0x00, 0x00, 0x00, 0x08,  0x04, 0x1C, 0x96, 0x02,
+  0x00, 0x08, 0x07, 0x4E,  0x96, 0x02, 0x00, 0x08,  0x08, 0x52, 0x17, 0x96,  0x02, 0x00, 0x05, 0x01,
+  0x3E, 0x4F, 0x96, 0x02,  0x00, 0x08, 0x00, 0x1C,  0x96, 0x02, 0x00, 0x08,  0x06, 0x9B, 0x07, 0x00,
+  0x00, 0x01, 0x00, 0x78,  0x00, 0x8F, 0x00, 0x96,  0x04, 0x00, 0x08, 0x09,  0x08, 0x04, 0x1C, 0x96,
+  0x02, 0x00, 0x08, 0x07,  0x4E, 0x3C, 0x96, 0x02,  0x00, 0x08, 0x0A, 0x41,  0x96, 0x07, 0x00, 0x08,
+  0x0A, 0x07, 0x00, 0x00,  0x00, 0x00, 0x3C, 0x99,  0x02, 0x00, 0x09, 0x00,  0x96, 0x02, 0x00, 0x08,
+  0x0A, 0x4C, 0x1C, 0x50,  0x1D, 0x96, 0x02, 0x00,  0x08, 0x0A, 0x1C, 0x96,  0x02, 0x00, 0x08, 0x09,
+  0x1C, 0x96, 0x02, 0x00,  0x08, 0x0B, 0x4E, 0x48,  0x12, 0x9D, 0x02, 0x00,  0x42, 0x00, 0x96, 0x02,
+  0x00, 0x08, 0x09, 0x1C,  0x96, 0x02, 0x00, 0x08,  0x0A, 0x1C, 0x4E, 0x96,  0x02, 0x00, 0x08, 0x05,
+  0x1C, 0x49, 0x12, 0x9D,  0x02, 0x00, 0x23, 0x00,  0x96, 0x07, 0x00, 0x07,  0x01, 0x00, 0x00, 0x00,
+  0x08, 0x0A, 0x1C, 0x96,  0x07, 0x00, 0x07, 0x02,  0x00, 0x00, 0x00, 0x08,  0x09, 0x1C, 0x96, 0x02,
+  0x00, 0x08, 0x0C, 0x52,  0x17, 0x96, 0x02, 0x00,  0x05, 0x01, 0x3E, 0x99,  0x02, 0x00, 0x9C, 0xFF,
+  0x96, 0x02, 0x00, 0x05,  0x00, 0x3E, 0x4F, 0x96,  0x02, 0x00, 0x08, 0x00,  0x1C, 0x96, 0x02, 0x00,
+  0x08, 0x0D, 0x9B, 0x07,  0x00, 0x00, 0x01, 0x00,  0x6F, 0x00, 0x75, 0x00,  0x96, 0x02, 0x00, 0x08,
+  0x0E, 0x1C, 0x96, 0x13,  0x00, 0x08, 0x01, 0x07,  0x0C, 0x00, 0x00, 0x00,  0x07, 0x65, 0x00, 0x00,
+  0x00, 0x07, 0x02, 0x00,  0x00, 0x00, 0x08, 0x02,  0x3D, 0x4F, 0x96, 0x02,  0x00, 0x08, 0x0E, 0x1C,
+  0x96, 0x04, 0x00, 0x08,  0x03, 0x08, 0x00, 0x1C,  0x96, 0x02, 0x00, 0x08,  0x03, 0x4E, 0x4F, 0x96,
+  0x02, 0x00, 0x08, 0x0E,  0x1C, 0x96, 0x04, 0x00,  0x08, 0x06, 0x08, 0x00,  0x1C, 0x96, 0x02, 0x00,
+  0x08, 0x06, 0x4E, 0x4F,  0x96, 0x02, 0x00, 0x08,  0x0E, 0x1C, 0x96, 0x09,  0x00, 0x08, 0x07, 0x07,
+  0x00, 0x00, 0x00, 0x00,  0x08, 0x0F, 0x40, 0x4F,  0x96, 0x09, 0x00, 0x07,  0x83, 0x00, 0x00, 0x00,
+  0x08, 0x10, 0x08, 0x0E,  0x1C, 0x96, 0x07, 0x00,  0x07, 0x03, 0x00, 0x00,  0x00, 0x08, 0x11, 0x3D,
+  0x17, 0x4F, 0x96, 0x08,  0x00, 0x07, 0x83, 0x00,  0x00, 0x00, 0x02, 0x08,  0x00, 0x1C, 0x96, 0x07,
+  0x00, 0x07, 0x03, 0x00,  0x00, 0x00, 0x08, 0x11,  0x3D, 0x17, 0x96, 0x09,  0x00, 0x08, 0x12, 0x07,
+  0x00, 0x00, 0x00, 0x00,  0x08, 0x13, 0x40, 0x1D,  0x96, 0x02, 0x00, 0x08,  0x12, 0x1C, 0x96, 0x13,
+  0x00, 0x08, 0x14, 0x07,  0x00, 0x00, 0x00, 0x00,  0x07, 0x05, 0x00, 0x00,  0x00, 0x07, 0x02, 0x00,
+  0x00, 0x00, 0x08, 0x02,  0x3D, 0x4F, 0x96, 0x02,  0x00, 0x08, 0x12, 0x1C,  0x96, 0x13, 0x00, 0x08,
+  0x15, 0x07, 0x01, 0x00,  0x00, 0x00, 0x07, 0x05,  0x00, 0x00, 0x00, 0x07,  0x02, 0x00, 0x00, 0x00,
+  0x08, 0x02, 0x3D, 0x4F,  0x96, 0x02, 0x00, 0x08,  0x12, 0x1C, 0x96, 0x07,  0x00, 0x07, 0x01, 0x00,
+  0x00, 0x00, 0x08, 0x00,  0x1C, 0x96, 0x02, 0x00,  0x08, 0x0D, 0x52, 0x17,  0x96, 0x09, 0x00, 0x08,
+  0x16, 0x07, 0x00, 0x00,  0x00, 0x00, 0x08, 0x13,  0x40, 0x1D, 0x96, 0x11,  0x00, 0x07, 0x02, 0x00,
+  0x00, 0x00, 0x07, 0x9A,  0x02, 0x00, 0x00, 0x07,  0x02, 0x00, 0x00, 0x00,  0x08, 0x02, 0x3D, 0x96,
+  0x11, 0x00, 0x07, 0x01,  0x00, 0x00, 0x00, 0x07,  0x9A, 0x02, 0x00, 0x00,  0x07, 0x02, 0x00, 0x00,
+  0x00, 0x08, 0x02, 0x3D,  0x96, 0x09, 0x00, 0x08,  0x17, 0x07, 0x03, 0x00,  0x00, 0x00, 0x08, 0x16,
+  0x1C, 0x96, 0x02, 0x00,  0x08, 0x18, 0x52, 0x17,  0x00
 };
 
diff --git a/libswfdec/swfdec_stage_as.c b/libswfdec/swfdec_stage_as.c
new file mode 100644
index 0000000..119d69c
--- /dev/null
+++ b/libswfdec/swfdec_stage_as.c
@@ -0,0 +1,79 @@
+/* Swfdec
+ * 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 "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_player_internal.h"
+
+/*** AS CODE ***/
+
+SWFDEC_AS_NATIVE (666, 1, get_scaleMode)
+void
+get_scaleMode (SwfdecAsContext *cx, SwfdecAsObject *object,
+    guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+  SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+
+  switch (player->scale_mode) {
+    case SWFDEC_SCALE_SHOW_ALL:
+      SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_showAll);
+      break;
+    case SWFDEC_SCALE_NO_BORDER:
+      SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_noBorder);
+      break;
+    case SWFDEC_SCALE_EXACT_FIT:
+      SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_exactFit);
+      break;
+    case SWFDEC_SCALE_NONE:
+      SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_noScale);
+      break;
+    default:
+      g_assert_not_reached ();
+      break;
+  }
+}
+
+SWFDEC_AS_NATIVE (666, 2, set_scaleMode)
+void
+set_scaleMode (SwfdecAsContext *cx, SwfdecAsObject *object,
+    guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+  SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+  const char *s;
+  SwfdecScaleMode mode;
+
+  if (argc == 0)
+    return;
+  s = swfdec_as_value_to_string (cx, &argv[0]);
+  if (g_ascii_strcasecmp (s, SWFDEC_AS_STR_noBorder) == 0) {
+    mode = SWFDEC_SCALE_NO_BORDER;
+  } else if (g_ascii_strcasecmp (s, SWFDEC_AS_STR_exactFit) == 0) {
+    mode = SWFDEC_SCALE_EXACT_FIT;
+  } else if (g_ascii_strcasecmp (s, SWFDEC_AS_STR_noScale) == 0) {
+    mode = SWFDEC_SCALE_NONE;
+  } else {
+    mode = SWFDEC_SCALE_SHOW_ALL;
+  }
+  swfdec_player_set_scale_mode (player, mode);
+}
+


More information about the Swfdec mailing list