[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11581: Change movie_root initializa
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11581: Change movie_root initialization to enable separation of DisplayObject |
Date: |
Wed, 21 Oct 2009 10:14:18 +0200 |
User-agent: |
Bazaar (1.16.1) |
------------------------------------------------------------
revno: 11581 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Wed 2009-10-21 10:14:18 +0200
message:
Change movie_root initialization to enable separation of DisplayObject
from as_object.
modified:
cygnal/cvm.cpp
gui/gui.cpp
libcore/Button.cpp
libcore/DisplayObject.cpp
libcore/DisplayObject.h
libcore/MovieClip.cpp
libcore/MovieClip.h
libcore/asobj/Selection_as.cpp
libcore/asobj/flash/display/MovieClip_as.cpp
libcore/movie_root.cpp
libcore/movie_root.h
testsuite/MovieTester.cpp
testsuite/MovieTester.h
testsuite/libcore.all/AsValueTest.cpp
testsuite/libcore.all/DisplayListTest.cpp
testsuite/libcore.all/PropertyListTest.cpp
testsuite/movies.all/gravity_embedded-TestRunner.cpp
testsuite/samples/clip_as_button2-TestRunner.cpp
testsuite/samples/gotoFrameOnKeyEvent-TestRunner.cpp
testsuite/samples/subshapes-TestRunner.cpp
utilities/processor.cpp
=== modified file 'cygnal/cvm.cpp'
--- a/cygnal/cvm.cpp 2009-10-02 12:41:25 +0000
+++ b/cygnal/cvm.cpp 2009-10-21 08:14:18 +0000
@@ -445,9 +445,7 @@
md->completeLoad();
- std::auto_ptr<Movie> mi ( md->createMovie() );
-
- m.setRootMovie( mi.release() );
+ m.init(md.get(), MovieClip::MovieVariables());
if ( quitrequested ) { // setRootMovie would execute actions in first frame
quitrequested = false;
return md;
=== modified file 'gui/gui.cpp'
--- a/gui/gui.cpp 2009-10-12 09:42:13 +0000
+++ b/gui/gui.cpp 2009-10-21 07:10:41 +0000
@@ -898,10 +898,8 @@
return;
}
- std::auto_ptr<Movie> mr ( _movieDef->createMovie() );
- mr->setVariables(_flashVars);
-
- _stage->setRootMovie( mr.release() ); // will construct the instance
+ // Initializes the stage with a Movie and the passed flash vars.
+ _stage->init(_movieDef.get(), _flashVars);
bool background = true; // ??
_stage->set_background_alpha(background ? 1.0f : 0.05f);
=== modified file 'libcore/Button.cpp'
--- a/libcore/Button.cpp 2009-10-14 08:47:08 +0000
+++ b/libcore/Button.cpp 2009-10-21 07:10:41 +0000
@@ -212,7 +212,7 @@
void operator() (const action_buffer& ab)
{
- _mr.pushAction(ab, boost::intrusive_ptr<DisplayObject>(_tp));
+ _mr.pushAction(ab, _tp);
called = true;
}
@@ -579,8 +579,7 @@
}
// Call conventional attached method.
- boost::intrusive_ptr<as_function> method =
- getUserDefinedEventHandler(event.functionKey());
+ as_function* method = getUserDefinedEventHandler(event.functionKey());
if (method) {
mr.pushAction(method, this, movie_root::apDOACTION);
}
=== modified file 'libcore/DisplayObject.cpp'
--- a/libcore/DisplayObject.cpp 2009-10-13 08:04:52 +0000
+++ b/libcore/DisplayObject.cpp 2009-10-21 07:10:41 +0000
@@ -317,7 +317,7 @@
// invisible (see Selection.as).
if (_visible && !visible) {
movie_root& mr = getRoot(*this);
- if (mr.getFocus().get() == this) {
+ if (mr.getFocus() == this) {
mr.setFocus(0);
}
}
@@ -464,7 +464,7 @@
if (_maskee) _maskee->setMask(0);
if (_mask) _mask->setMaskee(0);
- bool hasEvent = hasEventHandler(event_id::UNLOAD);
+ const bool hasEvent = hasEventHandler(event_id::UNLOAD);
_unloaded = true;
@@ -487,34 +487,29 @@
Events::const_iterator it = _event_handlers.find(id);
if (it != _event_handlers.end()) return true;
- boost::intrusive_ptr<as_function> method =
- getUserDefinedEventHandler(id.functionKey());
- if (method) return true;
-
- return false;
+ as_function* method = getUserDefinedEventHandler(id.functionKey());
+ return (method);
}
-boost::intrusive_ptr<as_function>
+as_function*
DisplayObject::getUserDefinedEventHandler(const std::string& name) const
{
string_table::key key = getStringTable(*this).find(name);
return getUserDefinedEventHandler(key);
}
-boost::intrusive_ptr<as_function>
+as_function*
DisplayObject::getUserDefinedEventHandler(string_table::key key) const
{
as_value tmp;
- boost::intrusive_ptr<as_function> func;
-
// const cast is needed due to getter/setter members possibly
// modifying this object even when only get !
- if ( const_cast<DisplayObject*>(this)->get_member(key, &tmp) )
+ if (const_cast<DisplayObject*>(this)->get_member(key, &tmp))
{
- func = tmp.to_as_function();
+ return tmp.to_as_function();
}
- return func;
+ return 0;
}
/// Set the real and cached x scale.
@@ -934,7 +929,7 @@
movie_root& mr = getRoot(o);
unsigned int levelno;
if (mr.isLevelTarget(propname, levelno)) {
- Movie* mo = mr.getLevel(levelno).get();
+ Movie* mo = mr.getLevel(levelno);
if (mo) {
val = mo;
return true;
=== modified file 'libcore/DisplayObject.h'
--- a/libcore/DisplayObject.h 2009-10-13 07:32:05 +0000
+++ b/libcore/DisplayObject.h 2009-10-21 07:10:41 +0000
@@ -1012,8 +1012,7 @@
/// A function if a member with the given name exists and
/// casts to an as_function. A NULL pointer otherwise.
///
- boost::intrusive_ptr<as_function> getUserDefinedEventHandler(
- const std::string& name) const;
+ as_function* getUserDefinedEventHandler(const std::string& name) const;
/// Return a user defined event handler, if any
//
@@ -1024,8 +1023,7 @@
/// A function if a member with the given key exists and
/// casts to an as_function. A NULL pointer otherwise.
///
- boost::intrusive_ptr<as_function> getUserDefinedEventHandler(
- string_table::key key) const;
+ as_function* getUserDefinedEventHandler(string_table::key key) const;
void set_event_handlers(const Events& copyfrom);
=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp 2009-10-16 06:56:48 +0000
+++ b/libcore/MovieClip.cpp 2009-10-21 07:10:41 +0000
@@ -653,7 +653,7 @@
MovieClip::queueAction(const action_buffer& action)
{
movie_root& root = getRoot(*this);
- root.pushAction(action, boost::intrusive_ptr<MovieClip>(this));
+ root.pushAction(action, this);
}
void
@@ -2118,7 +2118,7 @@
}
// Parse query string
- VariableMap vars;
+ MovieVariables vars;
url.parse_querystring(url.querystring(), vars);
extern_movie->setVariables(vars);
@@ -2259,15 +2259,15 @@
}
void
-MovieClip::setVariables(VariableMap& vars)
+MovieClip::setVariables(const MovieVariables& vars)
{
string_table& st = getStringTable(*this);
- for (VariableMap::const_iterator it=vars.begin(), itEnd=vars.end();
+ for (MovieVariables::const_iterator it=vars.begin(), itEnd=vars.end();
it != itEnd; ++it)
{
const std::string& name = it->first;
const std::string& val = it->second;
- set_member(st.find(PROPNAME(name)), val);
+ set_member(st.find(name), val);
}
}
=== modified file 'libcore/MovieClip.h'
--- a/libcore/MovieClip.h 2009-10-16 05:29:23 +0000
+++ b/libcore/MovieClip.h 2009-10-21 07:10:41 +0000
@@ -85,6 +85,8 @@
public:
+ typedef std::map<std::string, std::string> MovieVariables;
+
typedef std::list<const action_buffer*> ActionList;
typedef movie_definition::PlayList PlayList;
@@ -740,10 +742,8 @@
/// @} Drawing API
- typedef std::map<std::string, std::string> VariableMap;
-
/// Set all variables in the given map with their corresponding values
- DSOEXPORT void setVariables(VariableMap& vars);
+ DSOEXPORT void setVariables(const MovieVariables& vars);
/// Enumerate child DisplayObjects
//
=== modified file 'libcore/asobj/Selection_as.cpp'
--- a/libcore/asobj/Selection_as.cpp 2009-10-15 09:16:40 +0000
+++ b/libcore/asobj/Selection_as.cpp 2009-10-21 07:10:41 +0000
@@ -108,7 +108,7 @@
boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
movie_root& mr = getRoot(fn);
- DisplayObject* focus = mr.getFocus().get();
+ DisplayObject* focus = mr.getFocus();
TextField* tf = dynamic_cast<TextField*>(focus);
@@ -130,7 +130,7 @@
boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
movie_root& mr = getRoot(fn);
- DisplayObject* focus = mr.getFocus().get();
+ DisplayObject* focus = mr.getFocus();
TextField* tf = dynamic_cast<TextField*>(focus);
@@ -146,7 +146,7 @@
boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
movie_root& mr = getRoot(fn);
- DisplayObject* focus = mr.getFocus().get();
+ DisplayObject* focus = mr.getFocus();
TextField* tf = dynamic_cast<TextField*>(focus);
@@ -164,8 +164,8 @@
movie_root& mr = getRoot(fn);
- boost::intrusive_ptr<DisplayObject> ch = mr.getFocus();
- if (!ch.get()) {
+ DisplayObject* ch = mr.getFocus();
+ if (!ch) {
as_value null;
null.set_null();
return null;
@@ -218,7 +218,7 @@
return as_value(true);
}
- boost::intrusive_ptr<DisplayObject> ch;
+ DisplayObject* ch;
if (focus.is_string()) {
const std::string& target = focus.to_string();
@@ -246,7 +246,7 @@
boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
movie_root& mr = getRoot(fn);
- DisplayObject* focus = mr.getFocus().get();
+ DisplayObject* focus = mr.getFocus();
TextField* tf = dynamic_cast<TextField*>(focus);
=== modified file 'libcore/asobj/flash/display/MovieClip_as.cpp'
--- a/libcore/asobj/flash/display/MovieClip_as.cpp 2009-10-16 06:31:31
+0000
+++ b/libcore/asobj/flash/display/MovieClip_as.cpp 2009-10-21 07:10:41
+0000
@@ -668,8 +668,7 @@
movieclip_swapDepths(const fn_call& fn)
{
- boost::intrusive_ptr<MovieClip> movieclip =
- ensureType<MovieClip>(fn.this_ptr);
+ MovieClip* movieclip = ensureType<MovieClip>(fn.this_ptr);
const int this_depth = movieclip->get_depth();
@@ -785,7 +784,7 @@
}
if (this_parent) {
- this_parent->swapDepths(movieclip.get(), target_depth);
+ this_parent->swapDepths(movieclip, target_depth);
}
else {
movie_root& root = getRoot(fn);
=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp 2009-10-21 06:07:43 +0000
+++ b/libcore/movie_root.cpp 2009-10-21 07:10:41 +0000
@@ -36,6 +36,7 @@
#include "GnashAlgorithm.h"
#include "GnashNumeric.h"
#include "Global_as.h"
+#include "flash/ui/Keyboard_as.h"
#include <boost/algorithm/string/replace.hpp>
#include <utility>
@@ -114,7 +115,7 @@
m_time_remainder(0.0f),
m_drag_state(),
_movies(),
- _rootMovie(),
+ _rootMovie(0),
_invalidated(true),
_disableScripts(false),
_processingActionLevel(movie_root::apSIZE),
@@ -185,6 +186,14 @@
}
void
+movie_root::init(movie_definition* def, const MovieClip::MovieVariables& vars)
+{
+ Movie* mr = def->createMovie();
+ mr->setVariables(vars);
+ setRootMovie(mr);
+}
+
+void
movie_root::setRootMovie(Movie* movie)
{
_rootMovie = movie;
@@ -255,7 +264,7 @@
/* private */
void
-movie_root::setLevel(unsigned int num, boost::intrusive_ptr<Movie> movie)
+movie_root::setLevel(unsigned int num, Movie* movie)
{
assert(movie != NULL);
assert(static_cast<unsigned int>(movie->get_depth()) ==
@@ -272,7 +281,7 @@
// don't leak overloaded levels
LevelMovie lm = it->second;
- if ( lm.get() == _rootMovie.get() )
+ if (lm == _rootMovie)
{
// NOTE: this is not enough to trigger
// an application reset. Was tested
@@ -312,7 +321,7 @@
}
void
-movie_root::swapLevels(boost::intrusive_ptr<MovieClip> movie, int depth)
+movie_root::swapLevels(MovieClip* movie, int depth)
{
assert(movie);
@@ -326,7 +335,7 @@
for (Levels::const_iterator i=_movies.begin(), e=_movies.end(); i!=e;
++i)
{
log_debug(" %d: %p (%s @ depth %d)", i->first,
- (void*)(i->second.get()), i->second->getTarget(),
+ (void*)(i->second), i->second->getTarget(),
i->second->get_depth());
}
#endif
@@ -372,7 +381,7 @@
}
else
{
- boost::intrusive_ptr<MovieClip> otherMovie = targetIt->second;
+ MovieClip* otherMovie = targetIt->second;
otherMovie->set_depth(oldDepth);
oldIt->second = otherMovie;
targetIt->second = movie;
@@ -383,7 +392,7 @@
for (Levels::const_iterator i=_movies.begin(), e=_movies.end(); i!=e;
++i)
{
log_debug(" %d: %p (%s @ depth %d)", i->first,
- (void*)(i->second.get()), i->second->getTarget(),
+ (void*)(i->second), i->second->getTarget(),
i->second->get_depth());
}
#endif
@@ -412,8 +421,8 @@
return;
}
- MovieClip* mo = it->second.get();
- if (mo == _rootMovie.get())
+ MovieClip* mo = it->second;
+ if (mo == _rootMovie)
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Original root movie can't be removed"));
@@ -432,7 +441,7 @@
bool
movie_root::loadLevel(unsigned int num, const URL& url)
{
- boost::intrusive_ptr<movie_definition> md (
+ movie_definition* md (
MovieFactory::makeMovie(url, _runResources));
if (!md)
{
@@ -440,7 +449,7 @@
return false;
}
- boost::intrusive_ptr<Movie> extern_movie = md->createMovie();
+ Movie* extern_movie = md->createMovie();
if (!extern_movie) {
log_error(_("can't create extern Movie for %s"),
@@ -449,7 +458,7 @@
}
// Parse query string
- MovieClip::VariableMap vars;
+ MovieClip::MovieVariables vars;
url.parse_querystring(url.querystring(), vars);
extern_movie->setVariables(vars);
@@ -460,14 +469,16 @@
return true;
}
-boost::intrusive_ptr<Movie>
+Movie*
movie_root::getLevel(unsigned int num) const
{
- Levels::const_iterator i =
_movies.find(num+DisplayObject::staticDepthOffset);
+ Levels::const_iterator i = _movies.find(num +
+ DisplayObject::staticDepthOffset);
if ( i == _movies.end() ) return 0;
- assert(boost::dynamic_pointer_cast<Movie>(i->second));
- return boost::static_pointer_cast<Movie>(i->second);
+ // TODO: if this has to be a Movie, why isn't it stored as one?
+ assert(dynamic_cast<Movie*>(i->second));
+ return dynamic_cast<Movie*>(i->second);
}
void
@@ -782,7 +793,7 @@
// all necessary events and removal of current focus.
// Do not set focus to NULL.
if (ms.activeEntity) {
- setFocus(ms.activeEntity);
+ setFocus(ms.activeEntity.get());
ms.activeEntity->mouseEvent(event_id::PRESS);
need_redisplay=true;
@@ -1107,7 +1118,7 @@
for (Levels::iterator i=_movies.begin(), e=_movies.end(); i!=e; ++i)
{
- boost::intrusive_ptr<MovieClip> movie = i->second;
+ MovieClip* movie = i->second;
movie->clear_invalidated();
@@ -1250,7 +1261,7 @@
}
// Now broadcast message for Mouse listeners
- typedef boost::intrusive_ptr<as_object> ObjPtr;
+ typedef as_object* ObjPtr;
ObjPtr mouseObj = getMouseObject();
if ( mouseObj )
{
@@ -1280,7 +1291,7 @@
}
}
-boost::intrusive_ptr<DisplayObject>
+DisplayObject*
movie_root::getFocus()
{
assert(testInvariant());
@@ -1288,14 +1299,14 @@
}
bool
-movie_root::setFocus(boost::intrusive_ptr<DisplayObject> to)
+movie_root::setFocus(DisplayObject* to)
{
// Nothing to do if current focus is the same as the new focus.
// _level0 also seems unable to receive focus under any circumstances
// TODO: what about _level1 etc ?
if (to == _currentFocus ||
- to == static_cast<DisplayObject*>(_rootMovie.get())) {
+ to == static_cast<DisplayObject*>(_rootMovie)) {
return false;
}
@@ -1310,13 +1321,13 @@
// Store previous focus, as the focus needs to change before onSetFocus
// is called and listeners are notified.
- DisplayObject* from = _currentFocus.get();
+ DisplayObject* from = _currentFocus;
if (from) {
// Perform any actions required on killing focus (only TextField).
from->killFocus();
- from->callMethod(NSV::PROP_ON_KILL_FOCUS, to.get());
+ from->callMethod(NSV::PROP_ON_KILL_FOCUS, to);
}
_currentFocus = to;
@@ -1330,7 +1341,7 @@
/// Notify Selection listeners with previous and new focus as arguments.
if (sel) {
sel->callMethod(NSV::PROP_BROADCAST_MESSAGE, "onSetFocus",
- from, to.get());
+ from, to);
}
assert(testInvariant());
@@ -1702,7 +1713,7 @@
}
void
-movie_root::pushAction(const action_buffer& buf,
boost::intrusive_ptr<DisplayObject> target, int lvl)
+movie_root::pushAction(const action_buffer& buf, DisplayObject* target, int
lvl)
{
assert(lvl >= 0 && lvl < apSIZE);
#ifdef GNASH_DEBUG
@@ -1716,8 +1727,8 @@
}
void
-movie_root::pushAction(boost::intrusive_ptr<as_function> func,
- boost::intrusive_ptr<DisplayObject> target, int lvl)
+movie_root::pushAction(as_function* func,
+ DisplayObject* target, int lvl)
{
assert(lvl >= 0 && lvl < apSIZE);
#ifdef GNASH_DEBUG
@@ -2012,7 +2023,7 @@
}
void
-movie_root::advanceLiveChar(boost::intrusive_ptr<DisplayObject> ch)
+movie_root::advanceLiveChar(DisplayObject* ch)
{
if (!ch->unloaded())
{
@@ -2080,7 +2091,7 @@
// root movie is replaced by a load to _level0...
// (but I guess we'd also drop loadMovie requests in that
// case... just not tested)
- as_object* o = _movies.begin()->second.get();
+ as_object* o = _movies.begin()->second;
std::string::size_type from = 0;
while (std::string::size_type to = tgtstr.find('.', from))
=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h 2009-10-21 06:07:43 +0000
+++ b/libcore/movie_root.h 2009-10-21 07:10:41 +0000
@@ -73,13 +73,13 @@
#include "dsodefs.h" // DSOEXPORT
#include "MouseButtonState.h" // for composition
#include "drag_state.h" // for composition
-#include "flash/ui/Keyboard_as.h"
#include "smart_ptr.h" // for memory management
#include "URL.h" // for loadMovie
#include "GnashKey.h" // key::code
#include "Movie.h"
#include "RunResources.h" // for initialization
#include "gnash.h" // Quality
+#include "MovieClip.h"
#ifdef USE_SWFTREE
# include "tree.hh"
@@ -107,6 +107,7 @@
class Timer;
class MovieClip;
class VirtualClock;
+ class Keyboard_as;
}
namespace gnash
@@ -114,7 +115,7 @@
struct DepthComparator
{
- typedef boost::intrusive_ptr<MovieClip> LevelMovie;
+ typedef MovieClip* LevelMovie;
bool operator() (const LevelMovie& d1, const LevelMovie& d2)
{
@@ -153,38 +154,14 @@
~movie_root();
- /// Set the root movie, replacing the current one if any.
- //
- /// This is needed for the cases in which the top-level movie
- /// is replaced by another movie by effect of a loadMovie call
- /// or similar.
- ///
- /// TODO: inspect what happens about VM version
- /// (should the *new* movie drive VM operations?
- /// -- hope not ! )
- ///
- /// Make sure to call this method before using the movie_root,
- /// as most operations are delegated to the associated/wrapped
- /// Movie.
- ///
- /// Note that the display viewport will be updated to match
- /// the size of given movie.
- ///
- /// A call to this method is equivalent to a call to setLevel(0, movie).
- ///
- /// @param movie
- /// The Movie to wrap.
- /// Will be stored in an intrusive_ptr.
- /// Must have a depth of 0.
- ///
- void setRootMovie(Movie* movie);
+ void init(movie_definition* def, const MovieClip::MovieVariables&
variables);
/// Return the movie at the given level (0 if unloaded level).
//
/// POST CONDITIONS:
/// - The returned DisplayObject has a depth equal to 'num'
///
- boost::intrusive_ptr<Movie> getLevel(unsigned int num) const;
+ Movie* getLevel(unsigned int num) const;
/// Load movie at the specified URL in the given level
//
@@ -216,7 +193,7 @@
/// exists at the target depth the latter is moved in place of
/// the former, with its depth also updated.
///
- void swapLevels(boost::intrusive_ptr<MovieClip> sp, int depth);
+ void swapLevels(MovieClip* sp, int depth);
/// Drop level at given depth.
//
@@ -314,7 +291,7 @@
/// in the same way.
Movie* topLevelMovie() const
{
- return _rootMovie.get();
+ return _rootMovie;
}
/// Return the current nominal frame rate for the Stage.
@@ -457,7 +434,7 @@
///
/// @return the DisplayObject having focus or NULL of none.
///
- boost::intrusive_ptr<DisplayObject> getFocus();
+ DisplayObject* getFocus();
/// Set the DisplayObject having focus
//
@@ -466,7 +443,7 @@
/// @return true if the focus operation succeeded, false if the passed
/// DisplayObject cannot receive focus. setFocus(0) is a valid operation,
so
/// returns true (always succeeds).
- bool setFocus(boost::intrusive_ptr<DisplayObject> to);
+ bool setFocus(DisplayObject* to);
DSOEXPORT void add_invalidated_bounds(InvalidatedRanges& ranges,
bool force);
@@ -595,12 +572,12 @@
void pushAction(std::auto_ptr<ExecutableCode> code, int lvl=apDOACTION);
/// Push an executable code to the ActionQueue
- void pushAction(const action_buffer& buf,
- boost::intrusive_ptr<DisplayObject> target, int lvl=apDOACTION);
+ void pushAction(const action_buffer& buf, DisplayObject* target,
+ int lvl=apDOACTION);
/// Push a function code to the ActionQueue
- void pushAction(boost::intrusive_ptr<as_function> func,
- boost::intrusive_ptr<DisplayObject> target, int lvl=apDOACTION);
+ void pushAction(as_function* func, DisplayObject* target,
+ int lvl=apDOACTION);
#ifdef GNASH_USE_GC
/// Mark all reachable resources (for GC)
@@ -627,14 +604,14 @@
/// its turn comes. Characters are advanced in reverse-placement
/// order (first registered is advanced last)
///
- void addLiveChar(boost::intrusive_ptr<DisplayObject> ch)
+ void addLiveChar(DisplayObject* ch)
{
// Don't register the object in the list twice
#if GNASH_PARANOIA_LEVEL > 1
assert(std::find(_liveChars.begin(), _liveChars.end(), ch) ==
_liveChars.end());
#endif
- _liveChars.push_front(ch.get());
+ _liveChars.push_front(ch);
}
/// Cleanup all resources and run the GC collector
@@ -886,6 +863,31 @@
private:
+ /// Set the root movie, replacing the current one if any.
+ //
+ /// This is needed for the cases in which the top-level movie
+ /// is replaced by another movie by effect of a loadMovie call
+ /// or similar.
+ ///
+ /// TODO: inspect what happens about VM version
+ /// (should the *new* movie drive VM operations?
+ /// -- hope not ! )
+ ///
+ /// Make sure to call this method before using the movie_root,
+ /// as most operations are delegated to the associated/wrapped
+ /// Movie.
+ ///
+ /// Note that the display viewport will be updated to match
+ /// the size of given movie.
+ ///
+ /// A call to this method is equivalent to a call to setLevel(0, movie).
+ ///
+ /// @param movie
+ /// The Movie to wrap.
+ /// Must have a depth of 0.
+ ///
+ void setRootMovie(Movie* movie);
+
const RunResources& _runResources;
/// The URL of the original root movie.
@@ -962,17 +964,6 @@
/// Delete all elements on the timers list
void clearIntervalTimers();
- /// A list of AdvanceableCharacters
- //
- /// This is a list (not a vector) as we want to allow
- /// ::advance of each element to insert new DisplayObjects before
- /// the start w/out invalidating iterators scanning the
- /// list forward for proper movie advancement
- typedef std::list<DisplayObject*> LiveChars;
-
- /// The list of advanceable DisplayObject, in placement order
- LiveChars _liveChars;
-
/// Execute expired timers
void executeAdvanceCallbacks();
@@ -980,7 +971,7 @@
void executeTimers();
/// Notify the global Key ActionScript object about a key status change
- Keyboard_as * notify_global_key(key::code k, bool down);
+ Keyboard_as* notify_global_key(key::code k, bool down);
/// Remove unloaded key and mouselisteners.
void cleanupUnloadedListeners()
@@ -1013,64 +1004,6 @@
/// Can return 0 if it's been deleted.
as_object* getSelectionObject() const;
- typedef std::list<ExecutableCode*> ActionQueue;
-
- ActionQueue _actionQueue[apSIZE];
-
- /// Process all actions in the queue
- void processActionQueue();
-
- int m_viewport_x0, m_viewport_y0;
-
- /// Width and height of viewport, in pixels
- int m_viewport_width, m_viewport_height;
-
- rgba m_background_color;
- bool m_background_color_set;
-
- float m_timer;
- int m_mouse_x, m_mouse_y, m_mouse_buttons;
-
- MouseButtonState m_mouse_button_state;
-
- /// Objects requesting a callback on every movie_root::advance()
- typedef std::set<ActiveRelay*> ObjectCallbacks;
- ObjectCallbacks _objectCallbacks;
-
- typedef std::map<int, Timer*> TimerMap;
-
- TimerMap _intervalTimers;
- unsigned int _lastTimerId;
-
- /// Characters for listening key events
- KeyListeners m_key_listeners;
-
- /// Objects listening for mouse events (down,up,move)
- MouseListeners m_mouse_listeners;
-
- /// The DisplayObject currently holding focus, or 0 if no focus.
- boost::intrusive_ptr<DisplayObject> _currentFocus;
-
- float m_time_remainder;
-
- /// @todo fold this into m_mouse_button_state?
- drag_state m_drag_state;
-
- typedef boost::intrusive_ptr<MovieClip> LevelMovie;
- typedef std::map<int, LevelMovie> Levels;
-
- /// The movie instance wrapped by this movie_root
- //
- /// We keep a pointer to the base MovieClip class
- /// to avoid having to replicate all of the base class
- /// interface to the Movie class definition
- Levels _movies;
-
- /// The root movie. This is initially the same as getLevel(0) but might
- /// change during the run. It will be used to setup and retrive initial
- /// stage size
- boost::intrusive_ptr<Movie> _rootMovie;
-
/// This function should return TRUE iff any action triggered
/// by the event requires redraw, see \ref events_handling for
/// more info.
@@ -1105,7 +1038,7 @@
/// @param ch
/// The DisplayObject to advance, will NOT be advanced if unloaded
///
- static void advanceLiveChar(boost::intrusive_ptr<DisplayObject> ch);
+ static void advanceLiveChar(DisplayObject* ch);
/// Advance all non-unloaded live chars
void advanceLiveChars();
@@ -1114,10 +1047,9 @@
//
/// @param movie
/// The Movie to store at the given level.
- /// Will be stored in an intrusive_ptr.
/// Its depth will be set to <num>+DisplayObject::staticDepthOffset and
/// its name to _level<num>
- void setLevel(unsigned int num, boost::intrusive_ptr<Movie> movie);
+ void setLevel(unsigned int num, Movie* movie);
/// Return the global Key object
Keyboard_as* getKeyObject();
@@ -1146,13 +1078,6 @@
///
bool isInvalidated() { return _invalidated; }
- /// See setInvalidated
- bool _invalidated;
-
- /// This is set to true if execution of scripts
- /// aborted due to action limit set or whatever else
- bool _disableScripts;
-
/// Return the priority level of first action queue containing actions.
//
/// Scanned in proprity order (lower first)
@@ -1164,8 +1089,6 @@
/// return.
int processActionQueue(int lvl);
- int _processingActionLevel;
-
bool processingActions() const
{
return (_processingActionLevel < apSIZE);
@@ -1174,6 +1097,85 @@
const DisplayObject* findDropTarget(boost::int32_t x, boost::int32_t y,
DisplayObject* dragging) const;
+ void handleActionLimitHit(const std::string& ref);
+ /// A list of AdvanceableCharacters
+ //
+ /// This is a list (not a vector) as we want to allow
+ /// ::advance of each element to insert new DisplayObjects before
+ /// the start w/out invalidating iterators scanning the
+ /// list forward for proper movie advancement
+ typedef std::list<DisplayObject*> LiveChars;
+
+ /// The list of advanceable DisplayObject, in placement order
+ LiveChars _liveChars;
+
+ typedef std::list<ExecutableCode*> ActionQueue;
+
+ ActionQueue _actionQueue[apSIZE];
+
+ /// Process all actions in the queue
+ void processActionQueue();
+
+ int m_viewport_x0, m_viewport_y0;
+
+ /// Width and height of viewport, in pixels
+ int m_viewport_width, m_viewport_height;
+
+ rgba m_background_color;
+ bool m_background_color_set;
+
+ float m_timer;
+ int m_mouse_x, m_mouse_y, m_mouse_buttons;
+
+ MouseButtonState m_mouse_button_state;
+
+ /// Objects requesting a callback on every movie_root::advance()
+ typedef std::set<ActiveRelay*> ObjectCallbacks;
+ ObjectCallbacks _objectCallbacks;
+
+ typedef std::map<int, Timer*> TimerMap;
+
+ TimerMap _intervalTimers;
+ unsigned int _lastTimerId;
+
+ /// Characters for listening key events
+ KeyListeners m_key_listeners;
+
+ /// Objects listening for mouse events (down,up,move)
+ MouseListeners m_mouse_listeners;
+
+ /// The DisplayObject currently holding focus, or 0 if no focus.
+ DisplayObject* _currentFocus;
+
+ float m_time_remainder;
+
+ /// @todo fold this into m_mouse_button_state?
+ drag_state m_drag_state;
+
+ typedef MovieClip* LevelMovie;
+ typedef std::map<int, LevelMovie> Levels;
+
+ /// The movie instance wrapped by this movie_root
+ //
+ /// We keep a pointer to the base MovieClip class
+ /// to avoid having to replicate all of the base class
+ /// interface to the Movie class definition
+ Levels _movies;
+
+ /// The root movie. This is initially the same as getLevel(0) but might
+ /// change during the run. It will be used to setup and retrive initial
+ /// stage size
+ Movie* _rootMovie;
+
+ /// See setInvalidated
+ bool _invalidated;
+
+ /// This is set to true if execution of scripts
+ /// aborted due to action limit set or whatever else
+ bool _disableScripts;
+
+ int _processingActionLevel;
+
/// filedescriptor to write to for host application requests
//
/// -1 if none
@@ -1201,8 +1203,6 @@
// ScriptLimits tag.
boost::uint16_t _timeoutLimit;
- void handleActionLimitHit(const std::string& ref);
-
// delay between movie advancement, in milliseconds
unsigned int _movieAdvancementDelay;
=== modified file 'testsuite/MovieTester.cpp'
--- a/testsuite/MovieTester.cpp 2009-07-13 09:04:26 +0000
+++ b/testsuite/MovieTester.cpp 2009-10-21 07:10:41 +0000
@@ -150,13 +150,10 @@
dbglogfile.setVerbosity(1);
- std::auto_ptr<Movie> mi ( _movie_def->createMovie() );
-
- // Set _movie before calling ::render
- _movie = mi.get();
// Finally, place the root movie on the stage ...
- _movie_root->setRootMovie( mi.release() );
+ MovieClip::MovieVariables v;
+ _movie_root->init(_movie_def, v);
// ... and render it
render();
@@ -166,7 +163,6 @@
MovieTester::render(boost::shared_ptr<Renderer> h,
InvalidatedRanges& invalidated_regions)
{
- assert(_movie);
// This is a bit dangerous, as there isn't really support for swapping
// renderers during runtime; though the only problem is likely to be
@@ -209,7 +205,8 @@
_movie_root->add_invalidated_bounds(_invalidatedBounds, false);
#ifdef SHOW_INVALIDATED_BOUNDS_ON_ADVANCE
- std::cout << "frame " << _movie->get_current_frame() << ") Invalidated
bounds " << _invalidatedBounds << std::endl;
+ const MovieClip* r = getRootMovie();
+ std::cout << "frame " << r->get_current_frame() << ") Invalidated
bounds " << _invalidatedBounds << std::endl;
#endif
// Force full redraw by using a WORLD invalidated ranges
@@ -627,8 +624,8 @@
MovieTester::restart()
{
_movie_root->clear(); // restart();
- _movie = _movie_def->createMovie();
- _movie_root->setRootMovie(_movie);
+ MovieClip::MovieVariables v;
+ _movie_root->init(_movie_def, v);
// Set _movie before calling ::render
render();
=== modified file 'testsuite/MovieTester.h'
--- a/testsuite/MovieTester.h 2009-07-13 09:04:26 +0000
+++ b/testsuite/MovieTester.h 2009-10-21 07:34:31 +0000
@@ -32,6 +32,7 @@
#include "Movie.h"
#include "ManualClock.h" // for composition
#include "RunResources.h" // For initialization.
+#include "movie_root.h"
#include <memory> // for auto_ptr
#include <string>
@@ -154,8 +155,10 @@
int depth);
/// Get the topmost sprite instance of this movie
+ //
+ /// We const_cast this because we don't care.
gnash::MovieClip* getRootMovie() {
- return _movie;
+ return const_cast<Movie*>(&_movie_root->getRootMovie());
}
/// Notify mouse pointer movement to the given coordinate
@@ -319,8 +322,6 @@
gnash::movie_definition* _movie_def;
- gnash::Movie* _movie;
-
boost::shared_ptr<sound::sound_handler> _sound_handler;
std::auto_ptr<RunResources> _runResources;
=== modified file 'testsuite/libcore.all/AsValueTest.cpp'
--- a/testsuite/libcore.all/AsValueTest.cpp 2009-07-14 16:15:13 +0000
+++ b/testsuite/libcore.all/AsValueTest.cpp 2009-10-21 07:24:55 +0000
@@ -58,7 +58,7 @@
// Prototypes for test cases
static void test_el();
-static void test_obj(as_object* o);
+static void test_obj(const as_object* o);
static void test_isnan();
static void test_conversion();
@@ -111,20 +111,19 @@
RunResources runResources("");
// Create a bogus movie with swf version 7 support
- boost::intrusive_ptr<movie_definition> md(
- new DummyMovieDefinition(runResources, 7));
+ movie_definition* md = new DummyMovieDefinition(runResources, 7);
ManualClock clock;
movie_root stage(*md, clock, runResources);
- Movie* root = md->createMovie();
- stage.setRootMovie(root);
+ MovieClip::MovieVariables v;
+ stage.init(md, v);
// run the tests
test_isnan();
test_el();
- test_obj(root);
+ test_obj(&stage.getRootMovie());
test_conversion();
}
@@ -245,7 +244,7 @@
}
void
-test_obj(as_object* o)
+test_obj(const as_object* o)
{
// Create an object element with some properties
bool notest = false;
=== modified file 'testsuite/libcore.all/DisplayListTest.cpp'
--- a/testsuite/libcore.all/DisplayListTest.cpp 2009-07-13 08:06:09 +0000
+++ b/testsuite/libcore.all/DisplayListTest.cpp 2009-10-21 07:24:55 +0000
@@ -58,8 +58,8 @@
ManualClock clock;
movie_root stage(*md5, clock, ri);
- Movie* root = md5->createMovie();
- stage.setRootMovie( root );
+ MovieClip::MovieVariables v;
+ stage.init(md5.get(), v);
DisplayList dlist1;
@@ -69,6 +69,8 @@
check_equals(dlist1, dlist2);
+ MovieClip* root = const_cast<Movie*>(&stage.getRootMovie());
+
// just a couple of DisplayObjects
boost::intrusive_ptr<DisplayObject> ch1 ( new DummyCharacter(root) );
boost::intrusive_ptr<DisplayObject> ch2 ( new DummyCharacter(root) );
=== modified file 'testsuite/libcore.all/PropertyListTest.cpp'
--- a/testsuite/libcore.all/PropertyListTest.cpp 2009-10-04 16:01:21
+0000
+++ b/testsuite/libcore.all/PropertyListTest.cpp 2009-10-21 07:24:55
+0000
@@ -70,7 +70,7 @@
movie_root root(*md5, clock, runResources);
- root.setRootMovie( md5->createMovie() );
+ root.init(md5.get(), MovieClip::MovieVariables());
VM& vm = root.getVM();
=== modified file 'testsuite/movies.all/gravity_embedded-TestRunner.cpp'
--- a/testsuite/movies.all/gravity_embedded-TestRunner.cpp 2009-10-04
19:40:33 +0000
+++ b/testsuite/movies.all/gravity_embedded-TestRunner.cpp 2009-10-21
07:10:41 +0000
@@ -48,7 +48,7 @@
gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
dbglogfile.setVerbosity(1);
- MovieClip* root = tester.getRootMovie();
+ const MovieClip* root = tester.getRootMovie();
assert(root);
//const DisplayList& dl = root->getDisplayList();
=== modified file 'testsuite/samples/clip_as_button2-TestRunner.cpp'
--- a/testsuite/samples/clip_as_button2-TestRunner.cpp 2009-08-21 12:40:49
+0000
+++ b/testsuite/samples/clip_as_button2-TestRunner.cpp 2009-10-21 07:10:41
+0000
@@ -60,7 +60,7 @@
// I wouldn't want the first advance to be needed
tester.advance();
- MovieClip* root = tester.getRootMovie();
+ const MovieClip* root = tester.getRootMovie();
assert(root);
check_equals(root->get_frame_count(), 1);
=== modified file 'testsuite/samples/gotoFrameOnKeyEvent-TestRunner.cpp'
--- a/testsuite/samples/gotoFrameOnKeyEvent-TestRunner.cpp 2009-04-03
10:23:04 +0000
+++ b/testsuite/samples/gotoFrameOnKeyEvent-TestRunner.cpp 2009-10-21
07:10:41 +0000
@@ -59,7 +59,7 @@
// I wouldn't want the first advance to be needed
tester.advance();
- MovieClip* root = tester.getRootMovie();
+ const MovieClip* root = tester.getRootMovie();
assert(root);
check_equals(root->get_frame_count(), 7);
=== modified file 'testsuite/samples/subshapes-TestRunner.cpp'
--- a/testsuite/samples/subshapes-TestRunner.cpp 2009-04-03 10:23:04
+0000
+++ b/testsuite/samples/subshapes-TestRunner.cpp 2009-10-21 07:10:41
+0000
@@ -85,7 +85,7 @@
// I wouldn't want the first advance to be needed
//tester.advance();
- MovieClip* root = tester.getRootMovie();
+ const MovieClip* root = tester.getRootMovie();
assert(root);
check_equals(root->get_frame_count(), 1);
=== modified file 'utilities/processor.cpp'
--- a/utilities/processor.cpp 2009-10-02 12:41:25 +0000
+++ b/utilities/processor.cpp 2009-10-21 07:24:55 +0000
@@ -484,11 +484,11 @@
md->completeLoad();
- std::auto_ptr<Movie> mi ( md->createMovie() );
+ MovieClip::MovieVariables v;
+ m.init(md.get(), v);
- m.setRootMovie( mi.release() );
- if ( quitrequested ) // setRootMovie would execute actions in first frame
- {
+ if (quitrequested) {
+ // setRootMovie would execute actions in first frame
quitrequested = false;
return md;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11581: Change movie_root initialization to enable separation of DisplayObject,
Benjamin Wolsey <=