gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/sprite_instance.cpp serv...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/sprite_instance.cpp serv...
Date: Fri, 19 Jan 2007 14:22:56 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/01/19 14:22:56

Modified files:
        .              : ChangeLog 
        server         : sprite_instance.cpp sprite_instance.h 
        testsuite/misc-ming.all: Makefile.am 
Added files:
        testsuite/misc-ming.all: attachMovieTest.c 
                                 attachMovieTestRunner.cpp 

Log message:
                * server/sprite_instance.{h,cpp}: MovieClip.attachMovie() 
implemented.
                * testsuite/misc-ming.all/: Makefile.am, attachMovieTest.c,
                  attachMovieTestRunner.cpp: testcase and runner for
                  MovieClip.attachMovie().

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2140&r2=1.2141
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.126&r2=1.127
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.56&r2=1.57
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/Makefile.am?cvsroot=gnash&r1=1.51&r2=1.52
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/attachMovieTest.c?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/attachMovieTestRunner.cpp?cvsroot=gnash&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2140
retrieving revision 1.2141
diff -u -b -r1.2140 -r1.2141
--- ChangeLog   19 Jan 2007 13:10:11 -0000      1.2140
+++ ChangeLog   19 Jan 2007 14:22:56 -0000      1.2141
@@ -1,5 +1,12 @@
 2007-01-19 Sandro Santilli <address@hidden>
 
+       * server/sprite_instance.{h,cpp}: MovieClip.attachMovie() implemented.
+       * testsuite/misc-ming.all/: Makefile.am, attachMovieTest.c,
+         attachMovieTestRunner.cpp: testcase and runner for
+         MovieClip.attachMovie().
+
+2007-01-19 Sandro Santilli <address@hidden>
+
        * server/asobj/xmlnode.cpp (xmlnode_new): cast double to int
          before casting to an enum [ fix for gcc-3.3.5 ]
        * server/sprite_instance.cpp: cleanups, including use

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -b -r1.126 -r1.127
--- server/sprite_instance.cpp  19 Jan 2007 10:54:15 -0000      1.126
+++ server/sprite_instance.cpp  19 Jan 2007 14:22:56 -0000      1.127
@@ -177,19 +177,31 @@
        }
 
        std::string newname = fn.arg(1).to_std_string();
-       //int depth_val = int(fn.arg(2).to_number());
 
-       if (fn.nargs > 3 )
-       {
-               //as_object* initObject = fn.arg(3).to_object();
-               //if ( initObject ) newch->copyProperties(*initObject);
+       // should we support negative depths ?
+       uint16_t depth_val = uint16_t(fn.arg(2).to_number());
+
+       boost::intrusive_ptr<character> newch = 
exported_movie->create_character_instance(sprite, depth_val);
+       assert( dynamic_cast<sprite_instance*>(newch.get()) );
+
+       if (fn.nargs > 3 ) {
+               as_object* initObject = fn.arg(3).to_object();
+               newch->copyProperties(*initObject);
        }
 
-       log_error("MovieClip.attachMovie() unimplemented -- "
-               "returning undefined");
+
+       if (sprite->attachCharacter(*newch, depth_val, newname) )
+       {
+               fn.result->set_as_object(newch.get()); 
+       }
+       else
+       {
        fn.result->set_undefined();
-       //fn.result->set_as_object(newch);
-       return;
+       }
+
+       log_warning("MovieClip.attachMovie(%s, %d, %s) TESTING",
+                       id_name.c_str(), depth_val, newname.c_str());
+
 }
 
 // attachAudio(id:Object) : Void
@@ -2327,6 +2339,23 @@
        m_display_list.swap_characters(ch1, ch2);       
 }
 
+bool
+sprite_instance::attachCharacter(character& newch, uint16_t depth, 
std::string& name)
+{
+       newch.set_name(name.c_str());
+
+       // place_character() will set depth on newch
+       m_display_list.place_character(
+               &newch,
+               depth,
+               cxform(),
+               matrix(),
+               1.0,
+               0);
+
+       return true; // FIXME: check return from place_character above ?
+}
+
 character*
 sprite_instance::add_display_object(
                uint16_t character_id,

Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -b -r1.56 -r1.57
--- server/sprite_instance.h    18 Jan 2007 22:53:21 -0000      1.56
+++ server/sprite_instance.h    19 Jan 2007 14:22:56 -0000      1.57
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: sprite_instance.h,v 1.56 2007/01/18 22:53:21 strk Exp $ */
+/* $Id: sprite_instance.h,v 1.57 2007/01/19 14:22:56 strk Exp $ */
 
 // Stateful live Sprite instance
 
@@ -352,6 +352,23 @@
                float ratio,
                uint16_t clip_depth);
 
+       /// Attach the given character instance to current display list
+       //
+       /// @param newch
+       ///     The character instance to attach.
+       ///
+       /// @param depth
+       ///     The depth to assign to the instance.
+       ///
+       /// @param name
+       ///     The name to assign to the instance.
+       ///
+       /// @return true on success, false on failure
+       ///     FIXME: currently never returns false !
+       ///
+       bool attachCharacter(character& newch, uint16_t depth,
+                       std::string& name);
+
 
        /// Updates the transform properties of the object at
        /// the specified depth.

Index: testsuite/misc-ming.all/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/Makefile.am,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- testsuite/misc-ming.all/Makefile.am 12 Jan 2007 11:34:33 -0000      1.51
+++ testsuite/misc-ming.all/Makefile.am 19 Jan 2007 14:22:56 -0000      1.52
@@ -66,6 +66,8 @@
        place_object_test \
        place_and_remove_object_test \
        place_and_remove_object_insane_test \
+       attachMovieTest \
+       attachMovieTestRunner \
        $(NULL)
 
 check_SCRIPTS = \
@@ -241,6 +243,30 @@
        sh $< -r5 $(top_builddir) place_and_remove_object_insane_test.swf > $@
        chmod 755 $@
 
+attachMovieTest_SOURCES =      \
+       attachMovieTest.c       \
+       ming_utils.h            \
+       ming_utils.c            \
+       $(NULL)
+attachMovieTest_LDADD = $(MING_LIBS)
+
+attachMovieTest.swf: attachMovieTest
+       ./attachMovieTest $(top_srcdir)/testsuite/media
+
+attachMovieTestRunner_SOURCES = \
+       attachMovieTestRunner.cpp \
+       $(NULL)
+attachMovieTestRunner_LDADD = \
+       $(top_builddir)/testsuite/libtestsuite.la \
+       $(NULL)
+attachMovieTestRunner_CXXFLAGS = \
+       -DSRCDIR='"$(srcdir)"' \
+       $(NULL)
+attachMovieTestRunner_DEPENDENCIES = \
+       attachMovieTest.swf \
+       $(top_builddir)/testsuite/libtestsuite.la \
+       $(NULL)
+
 spritehier.swf: spritehier
        ./spritehier
 
@@ -320,6 +346,7 @@
        place_object_testrunner \
        place_and_remove_object_testrunner \
        place_and_remove_object_insane_testrunner \
+       attachMovieTestRunner \
        $(NULL)
 
 

Index: testsuite/misc-ming.all/attachMovieTest.c
===================================================================
RCS file: testsuite/misc-ming.all/attachMovieTest.c
diff -N testsuite/misc-ming.all/attachMovieTest.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-ming.all/attachMovieTest.c   19 Jan 2007 14:22:56 -0000      
1.1
@@ -0,0 +1,145 @@
+/* 
+ *   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program 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 General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ *
+ */ 
+
+/*
+ * Test MovieClip.attachMovie().
+ *
+ * Exports a 'redsquare' symbol and then attach it to main timeline 4 times
+ * at depths 70+[0..3] and with xoffset 70*[0..3]
+ *
+ * run as ./attachMovieTest
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ming.h>
+
+#include "ming_utils.h"
+
+#define OUTPUT_VERSION 6
+#define OUTPUT_FILENAME "attachMovieTest.swf"
+
+void
+addRedSquareExport(SWFMovie mo)
+{
+       SWFShape sh;
+       SWFMovieClip mc;
+
+       sh = make_fill_square (0, 300, 60, 60, 255, 0, 0, 255, 0, 0);
+       mc = newSWFMovieClip();
+
+       SWFMovieClip_add(mc, (SWFBlock)sh);
+       SWFMovieClip_nextFrame(mc);
+
+       SWFMovie_addExport(mo, (SWFBlock)mc, "redsquare");
+
+       SWFMovie_writeExports(mo);
+}
+
+int
+main(int argc, char** argv)
+{
+       SWFMovie mo;
+       SWFMovieClip exportedClip;
+       const char *srcdir=".";
+       SWFFont bfont; 
+
+
+       /*********************************************
+        *
+        * Initialization
+        *
+        *********************************************/
+
+       if ( argc>1 ) srcdir=argv[1];
+       else
+       {
+               fprintf(stderr, "Usage: %s\n", argv[0]);
+               return 1;
+       }
+
+       puts("Setting things up");
+
+       Ming_init();
+        Ming_useSWFVersion (OUTPUT_VERSION);
+       Ming_setScale(20.0); /* let's talk pixels */
+ 
+       mo = newSWFMovie();
+       SWFMovie_setRate(mo, 12);
+       //SWFMovie_setDimension(mo, 6400, 4000);
+       SWFMovie_setDimension(mo, 640, 400);
+
+       /*********************************************
+        *
+        * Body
+        *
+        *********************************************/
+
+       addRedSquareExport(mo);
+       /* it seems we need a SHOWFRAME for this to be effective */
+       /* (maybe it's related to loop-back handling ?) */
+       SWFMovie_nextFrame(mo); 
+
+       add_actions(mo,
+               "attachMovie('redsquare', 'square'+counter, 70+counter);"
+               "this['square'+counter]._x = 70*counter;"
+               "counter++;"
+               );
+
+       SWFMovie_nextFrame(mo); /* showFrame */
+
+       add_actions(mo,
+               "attachMovie('redsquare', 'square'+counter, 70+counter);"
+               "this['square'+counter]._x = 70*counter;"
+               "counter++;"
+               );
+
+       SWFMovie_nextFrame(mo); /* showFrame */
+
+       add_actions(mo,
+               "attachMovie('redsquare', 'square'+counter, 70+counter);"
+               "this['square'+counter]._x = 70*counter;"
+               "counter++;"
+               );
+
+       SWFMovie_nextFrame(mo); /* showFrame */
+
+       add_actions(mo,
+               "attachMovie('redsquare', 'square'+counter, 70+counter);"
+               "this['square'+counter]._x = 70*counter;"
+               "counter++;"
+               );
+
+       add_actions(mo, "stop();");
+
+       SWFMovie_nextFrame(mo); /* showFrame */
+
+
+       /*****************************************************
+        *
+        * Output movie
+        *
+        *****************************************************/
+
+       puts("Saving " OUTPUT_FILENAME );
+
+       SWFMovie_save(mo, OUTPUT_FILENAME);
+
+       return 0;
+}

Index: testsuite/misc-ming.all/attachMovieTestRunner.cpp
===================================================================
RCS file: testsuite/misc-ming.all/attachMovieTestRunner.cpp
diff -N testsuite/misc-ming.all/attachMovieTestRunner.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-ming.all/attachMovieTestRunner.cpp   19 Jan 2007 14:22:56 
-0000      1.1
@@ -0,0 +1,85 @@
+/* 
+ *   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program 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 General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ *
+ */ 
+
+#define INPUT_FILENAME "attachMovieTest.swf"
+
+#include "MovieTester.h"
+#include "sprite_instance.h"
+#include "character.h"
+#include "dlist.h"
+#include "container.h"
+#include "log.h"
+
+#include "check.h"
+#include <string>
+#include <cassert>
+
+using namespace gnash;
+using namespace std;
+
+int
+main(int /*argc*/, char** /*argv*/)
+{
+       string filename = INPUT_FILENAME;
+       MovieTester tester(filename);
+
+       gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
+       dbglogfile.setVerbosity(1);
+
+       sprite_instance* root = tester.getRootMovie();
+       assert(root);
+
+       check_equals(root->get_frame_count(), 5);
+       check_equals(root->get_play_state(), sprite_instance::PLAY);
+       check_equals(root->get_current_frame(), 0);
+
+       check(! tester.findDisplayItemByDepth(*root, 70) );
+       check(! tester.findDisplayItemByDepth(*root, 71) );
+       check(! tester.findDisplayItemByDepth(*root, 72) );
+       check(! tester.findDisplayItemByDepth(*root, 73) );
+
+       tester.advance();
+
+       check( tester.findDisplayItemByDepth(*root, 70) );
+       check(! tester.findDisplayItemByDepth(*root, 71) );
+       check(! tester.findDisplayItemByDepth(*root, 72) );
+       check(! tester.findDisplayItemByDepth(*root, 73) );
+
+       tester.advance();
+
+       check( tester.findDisplayItemByDepth(*root, 70) );
+       check( tester.findDisplayItemByDepth(*root, 71) );
+       check(! tester.findDisplayItemByDepth(*root, 72) );
+       check(! tester.findDisplayItemByDepth(*root, 73) );
+
+       tester.advance();
+
+       check( tester.findDisplayItemByDepth(*root, 70) );
+       check( tester.findDisplayItemByDepth(*root, 71) );
+       check( tester.findDisplayItemByDepth(*root, 72) );
+       check(! tester.findDisplayItemByDepth(*root, 73) );
+
+       tester.advance();
+
+       check( tester.findDisplayItemByDepth(*root, 70) );
+       check( tester.findDisplayItemByDepth(*root, 71) );
+       check( tester.findDisplayItemByDepth(*root, 72) );
+       check( tester.findDisplayItemByDepth(*root, 73) );
+}
+




reply via email to

[Prev in Thread] Current Thread [Next in Thread]