[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10790: Rationalize top-level movie
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10790: Rationalize top-level movie loading. |
Date: |
Wed, 15 Apr 2009 09:26:30 +0200 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10790
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Wed 2009-04-15 09:26:30 +0200
message:
Rationalize top-level movie loading.
Improve documentation.
added:
libcore/Movie.h
renamed:
libcore/BitmapMovieInstance.cpp => libcore/BitmapMovie.cpp
libcore/BitmapMovieInstance.h => libcore/BitmapMovie.h
libcore/movie_instance.cpp => libcore/SWFMovie.cpp
libcore/movie_instance.h => libcore/SWFMovie.h
modified:
cygnal/cvm.cpp
gui/gtk_glue_agg_xv.cpp
gui/gui.cpp
libcore/Bitmap.h
libcore/Button.cpp
libcore/DisplayList.cpp
libcore/DisplayObject.cpp
libcore/DisplayObject.h
libcore/DynamicShape.cpp
libcore/DynamicShape.h
libcore/Makefile.am
libcore/MovieClip.cpp
libcore/MovieClip.h
libcore/Property.h
libcore/TextField.cpp
libcore/TextField.h
libcore/as_object.cpp
libcore/asobj/Object.cpp
libcore/asobj/Sound_as.cpp
libcore/asobj/flash/display/BitmapData_as.cpp
libcore/movie_root.cpp
libcore/movie_root.h
libcore/parser/BitmapMovieDefinition.cpp
libcore/parser/BitmapMovieDefinition.h
libcore/parser/SWFMovieDefinition.cpp
libcore/parser/SWFMovieDefinition.h
libcore/parser/movie_definition.h
libcore/parser/sprite_definition.cpp
libcore/parser/sprite_definition.h
libcore/swf/ControlTag.h
libcore/swf/DoInitActionTag.h
libcore/swf/SetBackgroundColorTag.h
libcore/vm/ASHandlers.cpp
libcore/vm/VM.cpp
plugin/win32/plugin.cpp
pythonmodule/gnashpython.cpp
pythonmodule/gnashpython.h
testsuite/DummyCharacter.h
testsuite/DummyMovieDefinition.h
testsuite/MovieTester.cpp
testsuite/MovieTester.h
testsuite/libcore.all/AsValueTest.cpp
testsuite/libcore.all/ClassSizes.cpp
testsuite/libcore.all/DisplayListTest.cpp
testsuite/libcore.all/PropertyListTest.cpp
testsuite/misc-ming.all/RollOverOutTest-Runner.cpp
testsuite/misc-ming.all/loadMovieTestRunner.cpp
utilities/processor.cpp
libcore/BitmapMovie.cpp
libcore/BitmapMovie.h
libcore/SWFMovie.cpp
libcore/SWFMovie.h
------------------------------------------------------------
revno: 10788.2.1
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Tue 2009-04-14 11:35:01 +0200
message:
Update docs on movie_root.
modified:
libcore/movie_root.h
------------------------------------------------------------
revno: 10788.2.2
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Tue 2009-04-14 13:26:23 +0200
message:
Drop unused and space-wasting dummy style vectors. Put class definition
in conventional order.
modified:
libcore/TextField.cpp
libcore/TextField.h
------------------------------------------------------------
revno: 10788.2.3
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Tue 2009-04-14 14:07:28 +0200
message:
Allow MovieClip to be constructed without a definition, so that it
doesn't have to be faked.
modified:
libcore/MovieClip.cpp
libcore/MovieClip.h
------------------------------------------------------------
revno: 10788.2.4
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Tue 2009-04-14 14:39:03 +0200
message:
Make movie_definition const.
modified:
gui/gtk_glue_agg_xv.cpp
libcore/MovieClip.cpp
libcore/MovieClip.h
libcore/TextField.cpp
libcore/asobj/Object.cpp
libcore/asobj/Sound_as.cpp
libcore/movie_instance.h
libcore/movie_root.cpp
libcore/movie_root.h
libcore/parser/SWFMovieDefinition.cpp
libcore/parser/SWFMovieDefinition.h
libcore/parser/movie_definition.h
libcore/parser/sprite_definition.cpp
libcore/parser/sprite_definition.h
------------------------------------------------------------
revno: 10788.2.5
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Tue 2009-04-14 14:50:30 +0200
message:
Don't expose MovieClip's definition; this is only needed from
movie_instance.
modified:
libcore/MovieClip.cpp
libcore/MovieClip.h
libcore/TextField.cpp
libcore/asobj/Object.cpp
libcore/movie_instance.h
libcore/movie_root.cpp
libcore/movie_root.h
------------------------------------------------------------
revno: 10788.2.6
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Tue 2009-04-14 15:14:27 +0200
message:
Update testsuite.
modified:
libcore/MovieClip.cpp
testsuite/misc-ming.all/loadMovieTestRunner.cpp
------------------------------------------------------------
revno: 10788.2.7
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Tue 2009-04-14 16:07:29 +0200
message:
Document MovieClip; correct old docs.
modified:
libcore/MovieClip.cpp
libcore/MovieClip.h
------------------------------------------------------------
revno: 10788.2.8
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Tue 2009-04-14 17:07:44 +0200
message:
Drop get_background_alpha and do set_background_color in a sensible way.
Clean up various other MovieClip functions, typedefs and member variables.
modified:
libcore/MovieClip.cpp
libcore/MovieClip.h
libcore/asobj/flash/display/BitmapData_as.cpp
libcore/movie_root.cpp
libcore/movie_root.h
libcore/swf/SetBackgroundColorTag.h
------------------------------------------------------------
revno: 10788.2.9
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Tue 2009-04-14 17:35:00 +0200
message:
Minor cleanups.
modified:
libcore/movie_instance.cpp
------------------------------------------------------------
revno: 10788.2.10
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Tue 2009-04-14 18:13:21 +0200
message:
Use movie_instance's definition less.
modified:
gui/gtk_glue_agg_xv.cpp
gui/gui.cpp
libcore/DisplayObject.cpp
libcore/MovieClip.cpp
libcore/asobj/Sound_as.cpp
libcore/movie_instance.h
libcore/movie_root.cpp
libcore/movie_root.h
libcore/vm/ASHandlers.cpp
------------------------------------------------------------
revno: 10788.2.11
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Tue 2009-04-14 19:49:58 +0200
message:
Add common base class (Movie) for top-level movies (SWFMovie, BitmapMovie,
and perhaps in future FLVMovie). This replaces movie_instance and
BitmapMovieInstance.
renamed:
libcore/BitmapMovieInstance.cpp => libcore/BitmapMovie.cpp
libcore/BitmapMovieInstance.h => libcore/BitmapMovie.h
libcore/movie_instance.cpp => libcore/SWFMovie.cpp
libcore/movie_instance.h => libcore/SWFMovie.h
modified:
cygnal/cvm.cpp
gui/gtk_glue_agg_xv.cpp
gui/gui.cpp
libcore/Button.cpp
libcore/DisplayObject.cpp
libcore/DisplayObject.h
libcore/Makefile.am
libcore/MovieClip.cpp
libcore/MovieClip.h
libcore/TextField.cpp
libcore/asobj/Object.cpp
libcore/movie_root.cpp
libcore/movie_root.h
libcore/parser/BitmapMovieDefinition.cpp
libcore/parser/BitmapMovieDefinition.h
libcore/parser/SWFMovieDefinition.cpp
libcore/parser/SWFMovieDefinition.h
libcore/parser/movie_definition.h
libcore/vm/VM.cpp
plugin/win32/plugin.cpp
pythonmodule/gnashpython.cpp
testsuite/DummyCharacter.h
testsuite/DummyMovieDefinition.h
testsuite/MovieTester.cpp
testsuite/MovieTester.h
testsuite/libcore.all/AsValueTest.cpp
testsuite/libcore.all/ClassSizes.cpp
testsuite/libcore.all/DisplayListTest.cpp
testsuite/libcore.all/PropertyListTest.cpp
utilities/processor.cpp
libcore/BitmapMovie.cpp
libcore/BitmapMovie.h
libcore/SWFMovie.cpp
libcore/SWFMovie.h
------------------------------------------------------------
revno: 10788.2.12
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Tue 2009-04-14 19:51:06 +0200
message:
Add Movie.h
added:
libcore/Movie.h
------------------------------------------------------------
revno: 10788.2.13
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Tue 2009-04-14 19:52:33 +0200
message:
Fix testsuite.
modified:
testsuite/DummyMovieDefinition.h
------------------------------------------------------------
revno: 10788.2.14
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Tue 2009-04-14 20:31:04 +0200
message:
Draw BitmapMovie directly, without relying on a fabricated Shape
character.
modified:
libcore/BitmapMovie.cpp
libcore/BitmapMovie.h
libcore/DynamicShape.cpp
libcore/DynamicShape.h
libcore/parser/BitmapMovieDefinition.cpp
libcore/parser/BitmapMovieDefinition.h
------------------------------------------------------------
revno: 10788.2.15
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Tue 2009-04-14 22:13:59 +0200
message:
Fix testsuite, override pointInVisibleShape for mouse entity detection
now BitmapMovie has no DisplayList.
modified:
gui/gui.cpp
libcore/BitmapMovie.cpp
libcore/BitmapMovie.h
libcore/Movie.h
libcore/MovieClip.cpp
libcore/MovieClip.h
libcore/SWFMovie.cpp
libcore/SWFMovie.h
libcore/parser/BitmapMovieDefinition.cpp
libcore/parser/BitmapMovieDefinition.h
testsuite/DummyMovieDefinition.h
testsuite/libcore.all/AsValueTest.cpp
testsuite/libcore.all/DisplayListTest.cpp
testsuite/libcore.all/PropertyListTest.cpp
------------------------------------------------------------
revno: 10788.2.16
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Wed 2009-04-15 07:25:53 +0200
message:
Add more documentation.
modified:
libcore/BitmapMovie.h
libcore/Movie.h
libcore/parser/BitmapMovieDefinition.h
------------------------------------------------------------
revno: 10788.2.17
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Wed 2009-04-15 07:33:51 +0200
message:
Rename create_Movie to createMovie.
modified:
cygnal/cvm.cpp
gui/gui.cpp
libcore/BitmapMovie.h
libcore/Button.cpp
libcore/DisplayList.cpp
libcore/DisplayObject.cpp
libcore/DisplayObject.h
libcore/MovieClip.cpp
libcore/Property.h
libcore/TextField.cpp
libcore/as_object.cpp
libcore/movie_root.cpp
libcore/parser/BitmapMovieDefinition.cpp
libcore/parser/BitmapMovieDefinition.h
libcore/parser/SWFMovieDefinition.cpp
libcore/parser/SWFMovieDefinition.h
libcore/parser/movie_definition.h
plugin/win32/plugin.cpp
pythonmodule/gnashpython.cpp
pythonmodule/gnashpython.h
testsuite/DummyCharacter.h
testsuite/DummyMovieDefinition.h
testsuite/MovieTester.cpp
testsuite/libcore.all/AsValueTest.cpp
testsuite/libcore.all/DisplayListTest.cpp
testsuite/libcore.all/PropertyListTest.cpp
testsuite/misc-ming.all/RollOverOutTest-Runner.cpp
utilities/processor.cpp
------------------------------------------------------------
revno: 10788.2.18
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Wed 2009-04-15 07:54:30 +0200
message:
Drop advance_sprite(), use advance() on its own.
modified:
libcore/MovieClip.cpp
libcore/MovieClip.h
libcore/SWFMovie.cpp
------------------------------------------------------------
revno: 10788.2.19
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Wed 2009-04-15 08:02:24 +0200
message:
Drop empty sprite_definition ctor.
modified:
libcore/parser/sprite_definition.cpp
libcore/parser/sprite_definition.h
------------------------------------------------------------
revno: 10788.2.20
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Wed 2009-04-15 08:22:17 +0200
message:
Change header guards.
modified:
libcore/BitmapMovie.h
libcore/Movie.h
libcore/SWFMovie.h
libcore/parser/SWFMovieDefinition.h
------------------------------------------------------------
revno: 10788.2.21
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Wed 2009-04-15 08:41:11 +0200
message:
Minor cleanups.
modified:
libcore/MovieClip.cpp
libcore/SWFMovie.h
libcore/swf/ControlTag.h
libcore/swf/DoInitActionTag.h
------------------------------------------------------------
revno: 10788.2.22
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Wed 2009-04-15 08:44:13 +0200
message:
More minor formatting changes.
modified:
libcore/MovieClip.cpp
------------------------------------------------------------
revno: 10788.2.23
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Wed 2009-04-15 09:01:39 +0200
message:
Add notes on AVM2 implementation.
modified:
libcore/Bitmap.h
libcore/parser/BitmapMovieDefinition.h
=== modified file 'cygnal/cvm.cpp'
--- a/cygnal/cvm.cpp 2009-04-09 12:45:20 +0000
+++ b/cygnal/cvm.cpp 2009-04-15 05:33:51 +0000
@@ -456,7 +456,7 @@
md->completeLoad();
- std::auto_ptr<movie_instance> mi ( md->create_movie_instance() );
+ std::auto_ptr<Movie> mi ( md->createMovie() );
m.setRootMovie( mi.release() );
if ( quitrequested ) // setRootMovie would execute actions in first frame
=== modified file 'gui/gtk_glue_agg_xv.cpp'
--- a/gui/gtk_glue_agg_xv.cpp 2009-03-19 23:14:43 +0000
+++ b/gui/gtk_glue_agg_xv.cpp 2009-04-14 17:49:58 +0000
@@ -116,11 +116,10 @@
if (first && VM::isInitialized()) {
first = false;
- movie_definition* def = VM::get().getRoot().get_movie_definition();
- assert(def);
+ const Movie& mi = VM::get().getRoot().getRootMovie();
- _movie_width = def->get_width_pixels();
- _movie_height = def->get_height_pixels();
+ _movie_width = mi.widthPixels();
+ _movie_height = mi.heightPixels();
if (!create_xv_shmimage(_movie_width, _movie_height)) {
if (!create_xv_image(_movie_width, _movie_height)) {
=== modified file 'gui/gui.cpp'
--- a/gui/gui.cpp 2009-04-09 11:39:48 +0000
+++ b/gui/gui.cpp 2009-04-15 05:33:51 +0000
@@ -592,7 +592,7 @@
{
if ( _stage )
{
- float fps =
_stage->get_movie_definition()->get_frame_rate();
+ float fps = _stage->frameRate();
// Min interval allowed: 1/100
second (100FPS)
unsigned int ni = 1000.0/fps;
setInterval(ni);
@@ -899,7 +899,7 @@
return;
}
- std::auto_ptr<movie_instance> mr ( _movieDef->create_movie_instance() );
+ std::auto_ptr<Movie> mr ( _movieDef->createMovie() );
mr->setVariables(_flashVars);
_stage->setRootMovie( mr.release() ); // will construct the instance
@@ -948,7 +948,7 @@
size_t cur_frame = m->getRootMovie()->get_current_frame();
size_t tot_frames = m->getRootMovie()->get_frame_count();
bool advanced = m->advance();
- m->get_movie_definition()->ensure_frame_loaded(tot_frames);
+ m->getRootMovie.ensureFrameLoaded(tot_frames);
m->goto_frame(cur_frame+1);
m->set_play_state(gnash::MovieClip::PLAYSTATE_PLAY);
log_debug(_("Frame %d"), m->get_current_frame());
@@ -1004,8 +1004,8 @@
if ( ! loops() )
{
size_t curframe = m->get_current_frame(); // can be 0 on
malformed SWF
- gnash::MovieClip* si = m->getRootMovie();
- if (curframe + 1 >= si->get_frame_count())
+ const gnash::MovieClip& si = m->getRootMovie();
+ if (curframe + 1 >= si.get_frame_count())
{
quit();
}
=== modified file 'libcore/Bitmap.h'
--- a/libcore/Bitmap.h 2009-04-07 17:33:15 +0000
+++ b/libcore/Bitmap.h 2009-04-15 07:01:39 +0000
@@ -30,13 +30,14 @@
namespace gnash {
-/// A Dynamic Bitmap DisplayObject. This is not AS-referencable, but can be
-/// removed and placed using depths like normal DisplayObjects
(DisplayObjects).
+/// A Bitmap DisplayObject. This is not AS-referencable, but can be
+/// removed and placed using depths like normal DisplayObjects.
class Bitmap : public DisplayObject
{
public:
- Bitmap(boost::intrusive_ptr<BitmapData_as> bd, DisplayObject* parent,
int id);
+ Bitmap(boost::intrusive_ptr<BitmapData_as> bd, DisplayObject* parent,
+ int id);
~Bitmap();
=== renamed file 'libcore/BitmapMovieInstance.cpp' => 'libcore/BitmapMovie.cpp'
--- a/libcore/BitmapMovieInstance.cpp 2009-04-07 09:19:54 +0000
+++ b/libcore/BitmapMovie.cpp 2009-04-14 20:13:59 +0000
@@ -15,7 +15,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#include "BitmapMovieInstance.h"
+#include "BitmapMovie.h"
#include "BitmapMovieDefinition.h"
#include "fill_style.h"
#include "Geometry.h" // for class path and class edge
@@ -23,25 +23,24 @@
namespace gnash {
-BitmapMovieInstance::BitmapMovieInstance(BitmapMovieDefinition* def,
+BitmapMovie::BitmapMovie(const BitmapMovieDefinition* const def,
DisplayObject* parent)
:
- movie_instance(def, parent)
-{
- // We need to assign a DisplayObject id to the instance, or an assertion
- // will fail in DisplayObject.cpp (parent==NULL || id != -1)
+ Movie(def, parent),
+ _def(def)
+{
+}
- assert(def);
- boost::intrusive_ptr<DisplayObject> ch = def->createDisplayObject(this,
1);
-
- const int depth = 1 + DisplayObject::staticDepthOffset;
- placeDisplayObject(ch.get(), depth);
+void
+BitmapMovie::display()
+{
+ _def->shape().display(*this);
}
std::auto_ptr<GnashImage>
-BitmapMovieInstance::drawToBitmap(const SWFMatrix& /* mat */, const cxform& /*
cx */,
- DisplayObject::BlendMode /* bm */, const
rect& /* clipRect */,
- bool /* smooth */)
+BitmapMovie::drawToBitmap(const SWFMatrix& /* mat */, const cxform& /* cx */,
+ DisplayObject::BlendMode /* bm */, const rect& /* clipRect */,
+ bool /* smooth */)
{
return std::auto_ptr<GnashImage>();
}
=== renamed file 'libcore/BitmapMovieInstance.h' => 'libcore/BitmapMovie.h'
--- a/libcore/BitmapMovieInstance.h 2009-04-03 09:18:40 +0000
+++ b/libcore/BitmapMovie.h 2009-04-15 06:22:17 +0000
@@ -16,32 +16,92 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#ifndef GNASH_BITMAPMOVIEINSTANCE_H
-#define GNASH_BITMAPMOVIEINSTANCE_H
+#ifndef GNASH_BITMAP_MOVIE_H
+#define GNASH_BITMAP_MOVIE_H
-#include "movie_instance.h" // for inheritance
+#include "BitmapMovieDefinition.h"
+#include "Movie.h" // for inheritance
// Forward declarations
namespace gnash
{
- class BitmapMovieDefinition;
class GnashImage;
+ class DisplayObject;
}
namespace gnash
{
-/// Instance of a BitmapMovieDefinition
-class BitmapMovieInstance : public movie_instance
+/// A top-level movie displaying a still bitmap.
+//
+/// It is uncomfortable that this inherits from MovieClip, as it
+/// has no DisplayList, no actions, and no frames. But its sister class
+/// SWFMovie is a kind of MovieClip (or Sprite), so this arrangement
+/// is necessary for now.
+//
+/// It is a mouse entity, so can receive mouse events, and should also be
+/// draggable.
+//
+/// The class should override all MovieClip methods that rely on the
+/// DisplayList: currently point tests and display().
+class BitmapMovie : public Movie
{
public:
- BitmapMovieInstance(BitmapMovieDefinition* def, DisplayObject*
parent=0);
-
- virtual ~BitmapMovieInstance() {}
-
+ BitmapMovie(const BitmapMovieDefinition* const def, DisplayObject*
parent);
+
+ virtual ~BitmapMovie() {}
+
+ /// Return true if the point is within our bounds
+ //
+ /// MovieClip traverses the DisplayList for this.
+ bool pointInVisibleShape(boost::int32_t x, boost::int32_t y) const {
+ if (!visible()) return false;
+ return pointInBounds(x, y);
+ }
+
+ /// This is a no-op for a BitmapMovie, as it never changes.
+ virtual void advance() { }
+
+ /// Return the bounds of this BitmapMovie.
+ //
+ /// MovieClip uses the DisplayList to calculate this. For us it is
+ /// simpler.
+ virtual rect getBounds() const {
+ return _def->get_frame_size();
+ }
+
+ /// Render the BitmapMovie.
+ //
+ /// This draws the bitmap directly using the BitmapMovie's matrix.
+ virtual void display();
+
+ virtual float frameRate() const {
+ return _def->get_frame_rate();
+ }
+
+ virtual float widthPixels() const {
+ return _def->get_width_pixels();
+ }
+
+ virtual float heightPixels() const {
+ return _def->get_height_pixels();
+ }
+
+ virtual const std::string& url() const {
+ return _def->get_url();
+ }
+
+ virtual int version() const {
+ return _def->get_version();
+ }
+
+ virtual const movie_definition* definition() const {
+ return _def;
+ }
+
/// Render this MovieClip to a GnashImage using the passed transform
//
/// @return The GnashImage with the MovieClip drawn onto it.
@@ -51,16 +111,9 @@
DisplayObject::BlendMode bm = DisplayObject::BLENDMODE_NORMAL,
const rect& clipRect = rect(),
bool smooth = false);
-
- /// Do nothing on restart. Especially don't trash the DisplayList
- //
- /// TODO: this is needed due to the implementation detail of
- /// using the DisplayList to store our bitmap-filled
- /// shape. Using the _drawable instead, or overriding
- /// ::display to simply display our definition is likely
- /// the best way to go instead (we'd also reuse the same
- /// bitmap info rather then creating new instances..)
- void restart() {}
+private:
+
+ const BitmapMovieDefinition* const _def;
};
=== modified file 'libcore/Button.cpp'
--- a/libcore/Button.cpp 2009-04-07 12:34:43 +0000
+++ b/libcore/Button.cpp 2009-04-15 05:33:51 +0000
@@ -386,7 +386,7 @@
InteractiveObject*
Button::topmostMouseEntity(boost::int32_t x, boost::int32_t y)
{
- if (!isVisible() || !isEnabled())
+ if (!visible() || !isEnabled())
{
return 0;
}
@@ -411,7 +411,7 @@
it!=itE; ++it)
{
DisplayObject* ch = *it;
- if ( ! ch->isVisible() ) continue;
+ if ( ! ch->visible() ) continue;
InteractiveObject *hit = ch->topmostMouseEntity(p.x, p.y);
if ( hit ) return hit;
}
@@ -784,7 +784,7 @@
{
// Not visible anyway
- if (!isVisible()) return;
+ if (!visible()) return;
ranges.add(m_old_invalidated_ranges);
@@ -1070,7 +1070,7 @@
movie_root& mr = _vm.getRoot();
unsigned int levelno;
if ( mr.isLevelTarget(name, levelno) ) {
- movie_instance* mo = mr.getLevel(levelno).get();
+ Movie* mo = mr.getLevel(levelno).get();
if ( mo ) {
val->set_as_object(mo);
return true;
=== modified file 'libcore/DisplayList.cpp'
--- a/libcore/DisplayList.cpp 2009-04-03 09:48:13 +0000
+++ b/libcore/DisplayList.cpp 2009-04-15 05:33:51 +0000
@@ -579,7 +579,7 @@
DisplayObject* ch = it->get();
DisplayObject* mask = ch->getMask();
- if (mask && ch->isVisible() && ! mask->isUnloaded())
+ if (mask && ch->visible() && ! mask->isUnloaded())
{
render::begin_submit_mask();
@@ -614,7 +614,7 @@
}
// check for non-mask hiden DisplayObjects
- if (!renderAsMask && (!ch->isVisible())) {
+ if (!renderAsMask && (!ch->visible())) {
ch->omit_display();
// Don't display non-mask hidden DisplayObjects
continue;
=== modified file 'libcore/DisplayObject.cpp'
--- a/libcore/DisplayObject.cpp 2009-04-03 17:25:34 +0000
+++ b/libcore/DisplayObject.cpp 2009-04-15 05:33:51 +0000
@@ -242,7 +242,7 @@
DisplayObject::add_invalidated_bounds(InvalidatedRanges& ranges, bool force)
{
ranges.add(m_old_invalidated_ranges);
- if (isVisible() && (m_invalidated||force))
+ if (visible() && (m_invalidated||force))
{
rect bounds;
bounds.expand_to_transformed_rect(getWorldMatrix(), getBounds());
@@ -733,7 +733,7 @@
as_value rv;
if (!fn.nargs) // getter
{
- rv = as_value(ptr->isVisible());
+ rv = as_value(ptr->visible());
}
else // setter
{
@@ -1210,7 +1210,7 @@
{
// TODO: check what happens when this DisplayObject
- // is a movie_instance loaded into another
+ // is a Movie loaded into another
// running movie.
typedef std::vector<std::string> Path;
@@ -1240,7 +1240,7 @@
if ( path.empty() )
{
- if ( _vm.getRoot().getRootMovie() == this ) return "/";
+ if (&_vm.getRoot().getRootMovie() == this) return "/";
std::stringstream ss;
ss << "_level" << m_depth-DisplayObject::staticDepthOffset;
return ss.str();
@@ -1248,7 +1248,7 @@
// Build the target string from the parents stack
std::string target;
- if ( topLevel != _vm.getRoot().getRootMovie() )
+ if (topLevel != &_vm.getRoot().getRootMovie() )
{
std::stringstream ss;
ss << "_level" <<
topLevel->get_depth()-DisplayObject::staticDepthOffset;
@@ -1282,7 +1282,7 @@
{
// TODO: check what happens when this DisplayObject
- // is a movie_instance loaded into another
+ // is a Movie loaded into another
// running movie.
typedef std::vector<std::string> Path;
@@ -1298,14 +1298,14 @@
if ( ! parent )
{
std::stringstream ss;
- if (!dynamic_cast<const movie_instance*>(ch))
+ if (!dynamic_cast<const Movie*>(ch))
{
// must be an as-referenceable
// DisplayObject created using 'new'
// like, new MovieClip, new Video, new
TextField...
//
log_debug("DisplayObject %p (%s) doesn't have a
parent and "
- "is not a movie_instance", ch, typeName(*ch));
+ "is not a Movie", ch, typeName(*ch));
ss << "<no parent, depth" << ch->get_depth() <<
">";
path.push_back(ss.str());
}
=== modified file 'libcore/DisplayObject.h'
--- a/libcore/DisplayObject.h 2009-04-09 09:58:40 +0000
+++ b/libcore/DisplayObject.h 2009-04-15 05:33:51 +0000
@@ -47,7 +47,7 @@
// Forward declarations
namespace gnash {
class MovieClip;
- class movie_instance;
+ class Movie;
class ExecutableCode;
class action_buffer;
class movie_definition;
@@ -482,21 +482,21 @@
///
virtual bool pointInVisibleShape(boost::int32_t x, boost::int32_t y) const
{
- if ( ! isVisible() ) return false;
+ if ( ! visible() ) return false;
if ( isMask() ) return false;
return pointInShape(x, y);
}
/// Return the relative root of this DisplayObject
//
- /// The "relative" is the movie_instance created by
+ /// The "relative" is the Movie created by
/// the same SWF definition that contained the
/// definition of this DisplayObject.
///
/// The default implementation is to invoke get_root
/// against this DisplayObject's parent.
///
- virtual movie_instance* get_root() const {
+ virtual Movie* get_root() const {
return get_parent()->get_root();
}
@@ -602,7 +602,7 @@
void set_visible(bool visible);
// Return true if this DisplayObject should be rendered
- bool isVisible() const { return _visible; }
+ bool visible() const { return _visible; }
/// ActionScript event handler. Returns true if a handler was called.
//
@@ -646,7 +646,7 @@
virtual const DisplayObject* findDropTarget(boost::int32_t x,
boost::int32_t y, DisplayObject* dragging) const
{
- if (this != dragging && isVisible() && pointInVisibleShape(x, y)) {
+ if (this != dragging && visible() && pointInVisibleShape(x, y)) {
return this;
}
=== modified file 'libcore/DynamicShape.cpp'
--- a/libcore/DynamicShape.cpp 2009-04-07 13:26:18 +0000
+++ b/libcore/DynamicShape.cpp 2009-04-14 18:31:04 +0000
@@ -42,7 +42,7 @@
}
void
-DynamicShape::display(const DisplayObject& inst)
+DynamicShape::display(const DisplayObject& inst) const
{
render::drawShape(_shape, inst.get_world_cxform(), inst.getWorldMatrix());
}
=== modified file 'libcore/DynamicShape.h'
--- a/libcore/DynamicShape.h 2009-04-07 12:34:43 +0000
+++ b/libcore/DynamicShape.h 2009-04-14 18:31:04 +0000
@@ -83,7 +83,7 @@
}
/// Display a DynamicShape object.
- void display(const DisplayObject& inst);
+ void display(const DisplayObject& inst) const;
/// Set current line style and start a new path.
//
=== modified file 'libcore/Makefile.am'
--- a/libcore/Makefile.am 2009-04-07 12:45:25 +0000
+++ b/libcore/Makefile.am 2009-04-14 17:49:58 +0000
@@ -48,7 +48,7 @@
$(NULL)
libgnashcore_la_SOURCES = \
- BitmapMovieInstance.cpp \
+ BitmapMovie.cpp \
Property.cpp \
PropertyList.cpp \
URLAccessManager.cpp \
@@ -79,7 +79,7 @@
parser/filter_factory.cpp \
InteractiveObject.cpp \
SWFMatrix.cpp \
- movie_instance.cpp \
+ SWFMovie.cpp \
movie_root.cpp \
namedStrings.cpp \
rect.cpp \
@@ -142,7 +142,7 @@
asClass.h \
Bitmap.h \
BitmapInfo.h \
- BitmapMovieInstance.h \
+ BitmapMovie.h \
builtin_function.h \
Button.h \
DisplayObject.h \
@@ -177,7 +177,8 @@
LoadVariablesThread.h \
SWFMatrix.h \
MouseButtonState.h \
- movie_instance.h \
+ SWFMovie.h \
+ Movie.h \
movie_root.h \
namedStrings.h \
rect.h \
=== added file 'libcore/Movie.h'
--- a/libcore/Movie.h 1970-01-01 00:00:00 +0000
+++ b/libcore/Movie.h 2009-04-15 06:22:17 +0000
@@ -0,0 +1,88 @@
+//
+// Copyright (C) 2005, 2006, 2007, 2008, 2009 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 3 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
+
+// Stateful live Movie instance
+
+
+#ifndef GNASH_MOVIE_H
+#define GNASH_MOVIE_H
+
+#include <vector>
+#include <set>
+
+#include "MovieClip.h" // for inheritance
+#include "smart_ptr.h" // for composition
+
+// Forward declarations
+namespace gnash {
+ class DisplayObject;
+ class movie_definition;
+}
+
+namespace gnash
+{
+
+/// A top-level, standalone Movie that can be loaded and played.
+//
+/// This is an abstract interface for any Movie that can be loaded directly
+/// into Gnash, including SWFs and Bitmaps.
+//
+/// The interface is not especially clean because SWFs and Bitmaps are
+/// treated the same as top-level movies despite having almost nothing
+/// in common. As this is required by Flash, it seems unavoidable.
+class Movie : public MovieClip
+{
+
+public:
+
+ Movie(const movie_definition* const def, DisplayObject* parent)
+ :
+ MovieClip(def, this, parent, parent ? 0 : -1)
+ {}
+
+ virtual ~Movie() {}
+
+ virtual void advance() = 0;
+
+ virtual float frameRate() const = 0;
+
+ virtual float widthPixels() const = 0;
+
+ virtual float heightPixels() const = 0;
+
+ virtual bool ensureFrameLoaded(size_t /*frameNo*/) const {
+ return true;
+ }
+
+ virtual const std::string& url() const = 0;
+
+ virtual int version() const = 0;
+
+ /// Set a DisplayObject in the dictionary as initialized, returning
+ /// true if not already initialized.
+ virtual bool setCharacterInitialized(int /*cid*/) {
+ return false;
+ }
+
+ virtual const movie_definition* definition() const = 0;
+
+};
+
+
+} // end of namespace gnash
+
+#endif
=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp 2009-04-14 08:51:26 +0000
+++ b/libcore/MovieClip.cpp 2009-04-15 06:44:13 +0000
@@ -33,7 +33,7 @@
#include "fn_call.h"
#include "Key_as.h"
#include "movie_root.h"
-#include "movie_instance.h"
+#include "Movie.h"
#include "swf_event.h"
#include "sprite_definition.h"
#include "ActionExec.h"
@@ -267,7 +267,7 @@
}
return;
}
- if (! ch->isVisible()) return;
+ if (! ch->visible()) return;
_candidates.push_back(ch);
}
@@ -479,28 +479,25 @@
} // anonymous namespace
-MovieClip::MovieClip(movie_definition* def, movie_instance* r,
+MovieClip::MovieClip(const movie_definition* const def, Movie* r,
DisplayObject* parent, int id)
:
InteractiveObject(parent, id),
_def(def),
- m_root(r),
+ _swf(r),
_playState(PLAYSTATE_PLAY),
_currentFrame(0),
_hasLooped(false),
_callingFrameActions(false),
_environment(_vm),
m_sound_stream_id(-1),
- _userCxform(),
_droptarget(),
_lockroot(false)
{
- assert(_def != NULL);
- assert(m_root != NULL);
+ assert(_swf);
set_prototype(getMovieClipInterface());
- //m_root->add_ref(); // @@ circular!
_environment.set_target(this);
// TODO: have the 'MovieClip' constructor take care of this !
@@ -512,15 +509,18 @@
{
stopStreamSound();
- // We might have been deleted by Quit...
- //assert(isDestroyed());
-
_vm.getRoot().remove_key_listener(this);
_vm.getRoot().remove_mouse_listener(this);
deleteAllChecked(_loadVariableRequests);
}
+int
+MovieClip::getSWFVersion() const
+{
+ return _swf->version();
+}
+
// Execute the actions in the action list, in the given
// environment. The list of action will be consumed
// starting from the first element. When the function returns
@@ -586,7 +586,7 @@
unsigned int levelno;
if ( mr.isLevelTarget(name, levelno) )
{
- movie_instance* mo = _vm.getRoot().getLevel(levelno).get();
+ Movie* mo = _vm.getRoot().getLevel(levelno).get();
if ( mo )
{
val->set_as_object(mo);
@@ -637,13 +637,13 @@
}
// Try textfield variables
- TextFieldPtrVect* etc = get_textfield_variable(name);
+ TextFields* etc = get_textfield_variable(name);
if ( etc )
{
- for (TextFieldPtrVect::const_iterator i=etc->begin(), e=etc->end();
+ for (TextFields::const_iterator i=etc->begin(), e=etc->end();
i!=e; ++i)
{
- TextFieldPtr tf = *i;
+ boost::intrusive_ptr<TextField> tf = i->get();
if ( tf->getTextDefined() )
{
val->set_string(tf->get_text_value());
@@ -675,7 +675,10 @@
bool
MovieClip::get_frame_number(const as_value& frame_spec, size_t& frameno) const
{
- //GNASH_REPORT_FUNCTION;
+
+ // If there is no definition, this is a dynamically-created MovieClip
+ // and has no frames.
+ if (!_def) return false;
std::string fspecStr = frame_spec.to_string();
@@ -708,6 +711,10 @@
void
MovieClip::call_frame_actions(const as_value& frame_spec)
{
+ // If there is no definition, this is a dynamically-created MovieClip
+ // and has no frames.
+ if (!_def) return;
+
size_t frame_number;
if ( ! get_frame_number(frame_spec, frame_number) )
{
@@ -719,13 +726,6 @@
return;
}
-#if 0 // why would we want to do this ?
- // Set the current sound_stream_id to -1, meaning that no stream are
- // active. If there are an active stream it will be updated while
- // executing the ControlTags.
- set_sound_stream_id(-1);
-#endif
-
// Execute the ControlTag actions
// We set _callingFrameActions to true so that add_action_buffer
// will execute immediately instead of queuing them.
@@ -751,11 +751,7 @@
DisplayObject*
MovieClip::add_empty_movieclip(const std::string& name, int depth)
{
- // empty_movieclip_def will be deleted during deleting movieclip
- sprite_definition* empty_sprite_def =
- new sprite_definition(*get_movie_definition());
-
- MovieClip* movieclip = new MovieClip(empty_sprite_def, m_root, this, 0);
+ MovieClip* movieclip = new MovieClip(0, _swf, this, 0);
movieclip->set_name(name);
movieclip->setDynamic();
@@ -811,7 +807,7 @@
}
boost::intrusive_ptr<MovieClip> newmovieclip = new MovieClip(_def.get(),
- m_root, parent, get_id());
+ _swf, parent, get_id());
newmovieclip->set_name(newname);
newmovieclip->setDynamic();
@@ -885,32 +881,24 @@
bool called = false;
- // First, check for clip event handler.
+ std::auto_ptr<ExecutableCode> code ( get_event_handler(id) );
+ if ( code.get() )
{
- std::auto_ptr<ExecutableCode> code ( get_event_handler(id) );
- if ( code.get() )
- {
- // Dispatch.
- code->execute();
+ // Dispatch.
+ code->execute();
- called = true;
- }
+ called = true;
}
- // Fall through and call the function also, if it's defined!
-
-
// user-defined onInitialize is never called
- if ( id.id() == event_id::INITIALIZE )
- {
- testInvariant();
- return called;
+ if ( id.id() == event_id::INITIALIZE ) {
+ testInvariant();
+ return called;
}
-
// NOTE: user-defined onLoad is not invoked for static
- // clips on which no clip-events are defined.
- // see
testsuite/misc-ming.all/action_execution_order_extend_test.swf
+ // clips on which no clip-events are defined.
+ // see testsuite/misc-ming.all/action_execution_order_extend_test.swf
//
// Note that this can't be true for movieclips
// not placed by PlaceObject, see
@@ -920,8 +908,8 @@
// a registered class on them, see
// testsuite/misc-ming.all/registerClassTest2.swf
//
- // TODO: test the case in which it's MovieClip.prototype.onLoad
defined !
- //
+ // TODO: test the case in which it's MovieClip.prototype.onLoad
+ // defined !
if ( id.id() == event_id::LOAD )
{
// TODO: we're likely making too much noise for nothing here,
@@ -937,8 +925,8 @@
// nor if it's dynamic
if ( isDynamic() ) break;
- sprite_definition* def =
- dynamic_cast<sprite_definition*>(_def.get());
+ const sprite_definition* def =
+ dynamic_cast<const sprite_definition*>(_def.get());
// must be a loaded movie (loadMovie doesn't mark it as
// "dynamic" - should it? no, or getBytesLoaded will always
@@ -987,12 +975,8 @@
as_object*
MovieClip::get_path_element(string_table::key key)
{
- //log_debug("%s.get_path_element(%s) called", getTarget(),
_vm.getStringTable().value(key));
as_object* obj = getPathElementSeparator(key);
- if ( obj )
- {
- return obj;
- }
+ if (obj) return obj;
std::string name = _vm.getStringTable().value(key);
@@ -1052,16 +1036,15 @@
// property (ie: have a textfield use _x as variable name
and
// be scared)
//
- TextFieldPtrVect* etc =
get_textfield_variable(_vm.getStringTable().value(name));
+ TextFields* etc = get_textfield_variable(_vm.getStringTable().value(name));
if ( etc )
{
#ifdef DEBUG_DYNTEXT_VARIABLES
log_debug(_("it's a Text Variable, associated with %d TextFields"),
etc->size());
#endif
- for (TextFieldPtrVect::iterator i=etc->begin(), e=etc->end(); i!=e;
++i)
+ for (TextFields::iterator i=etc->begin(), e=etc->end(); i!=e; ++i)
{
- TextFieldPtr tf = *i;
- tf->updateText(val.to_string());
+ (*i)->updateText(val.to_string());
}
found = true;
}
@@ -1086,18 +1069,24 @@
LOG_ONCE(log_unimpl("MovieClip.unloadMovie()"));
}
+// child movieclip advance
void
-MovieClip::advance_sprite()
+MovieClip::advance()
{
+#ifdef GNASH_DEBUG
+ log_debug(_("Advance movieclip '%s' at frame %u/%u"),
+ getTargetPath(), _currentFrame,
+ get_frame_count());
+#endif
+
assert(!isUnloaded());
// call_frame should never trigger advance_movieclip
assert(!_callingFrameActions);
// We might have loaded NO frames !
- if ( get_loaded_frames() == 0 )
- {
+ if (get_loaded_frames() == 0) {
IF_VERBOSE_MALFORMED_SWF(
LOG_ONCE( log_swferror(_("advance_movieclip: no frames loaded "
"for movieclip/movie %s"), getTarget()) );
@@ -1105,7 +1094,6 @@
return;
}
-
// Process any pending loadVariables request
processCompletedLoadVariableRequests();
@@ -1138,7 +1126,8 @@
#endif
// Execute the current frame's tags.
- // First time executeFrameTags(0) executed in dlist.cpp(child) or
SWFMovieDefinition(root)
+ // First time executeFrameTags(0) executed in dlist.cpp(child) or
+ // SWFMovieDefinition(root)
if (_currentFrame != (size_t)prev_frame)
{
if ( _currentFrame == 0 && has_looped() )
@@ -1155,7 +1144,8 @@
log_debug(_("Executing frame%d (0-based) tags of movieclip "
"%s"), _currentFrame, getTarget());
#endif
- // Make sure _currentFrame is 0-based during execution of
DLIST tags
+ // Make sure _currentFrame is 0-based during execution of
+ // DLIST tags
executeFrameTags(_currentFrame, _displayList,
SWF::ControlTag::TAG_DLIST |
SWF::ControlTag::TAG_ACTION);
@@ -1166,38 +1156,16 @@
#ifdef GNASH_DEBUG
else
{
- log_debug(_("MovieClip::advance_movieclip we're in PLAYSTATE_STOP
mode"));
- // shouldn't we execute frame tags anyway when in PLAYSTATE_STOP mode ?
- //executeFrameTags(_currentFrame);
+ log_debug(_("MovieClip::advance_movieclip we're in STOP mode"));
}
#endif
-}
-
-// child movieclip advance
-void
-MovieClip::advance()
-{
-// GNASH_REPORT_FUNCTION;
-
-#ifdef GNASH_DEBUG
- log_debug(_("Advance movieclip '%s' at frame %u/%u"),
- getTargetPath(), _currentFrame,
- get_frame_count());
-#endif
-
- // child movieclip frame rate is the same the root movieclip frame rate
- // that's why it is not needed to analyze 'm_time_remainder'
-
- advance_sprite();
}
void
MovieClip::execute_init_action_buffer(const action_buffer& a, int cid)
{
- // WARNING! get_root() would depend on _lockroot !!
- movie_instance* mi = m_root;
- if ( mi->setCharacterInitialized(cid) )
+ if ( _swf->setCharacterInitialized(cid) )
{
#ifdef GNASH_DEBUG
log_debug(_("Queuing init actions in frame %d of movieclip %s"),
@@ -1220,13 +1188,10 @@
void
MovieClip::execute_action(const action_buffer& ab)
{
- as_environment& env = _environment; // just type less
-
- ActionExec exec(ab, env);
+ ActionExec exec(ab, _environment);
exec();
}
-/*private*/
void
MovieClip::restoreDisplayList(size_t tgtFrame)
{
@@ -1259,8 +1224,11 @@
void
MovieClip::executeFrameTags(size_t frame, DisplayList& dlist, int typeflags)
{
+ // If there is no definition, this is a dynamically-created MovieClip
+ // and has no frames.
+ if (!_def) return;
+
testInvariant();
-
assert(typeflags);
const PlayList* playlist = _def->getPlaylist(frame);
@@ -1406,7 +1374,7 @@
// are executed. This means NO actions will be
// pushed on m_action_list.
executeFrameTags(_currentFrame, _displayList,
- SWF::ControlTag::TAG_DLIST);
+ SWF::ControlTag::TAG_DLIST);
}
assert(_currentFrame == target_frame_number);
@@ -1417,16 +1385,21 @@
bool callingFrameActionsBackup = _callingFrameActions;
_callingFrameActions = false;
executeFrameTags(target_frame_number, _displayList,
- SWF::ControlTag::TAG_DLIST |
- SWF::ControlTag::TAG_ACTION);
+ SWF::ControlTag::TAG_DLIST | SWF::ControlTag::TAG_ACTION);
_callingFrameActions = callingFrameActionsBackup;
}
assert(_currentFrame == target_frame_number);
}
-bool MovieClip::goto_labeled_frame(const std::string& label)
+bool
+MovieClip::goto_labeled_frame(const std::string& label)
{
+
+ // If there is no definition, this is a dynamically-created MovieClip
+ // and has no frames. (We are also probably not called in this case).
+ if (!_def) return false;
+
size_t target_frame;
if (_def->get_labeled_frame(label, target_frame))
{
@@ -1464,14 +1437,14 @@
void MovieClip::omit_display()
{
- if (m_child_invalidated)
- _displayList.omit_display();
+ if (m_child_invalidated) _displayList.omit_display();
clear_invalidated();
}
bool
-MovieClip::attachCharacter(DisplayObject& newch, int depth, as_object*
initObject)
+MovieClip::attachCharacter(DisplayObject& newch, int depth,
+ as_object* initObject)
{
_displayList.placeDisplayObject(&newch, depth, initObject);
@@ -1481,8 +1454,8 @@
std::auto_ptr<GnashImage>
MovieClip::drawToBitmap(const SWFMatrix& /* mat */, const cxform& /* cx */,
- DisplayObject::BlendMode /* bm */, const rect& /*
clipRect */,
- bool /* smooth */)
+ DisplayObject::BlendMode /* bm */, const rect& /* clipRect */,
+ bool /* smooth */)
{
return std::auto_ptr<GnashImage>();
}
@@ -1491,15 +1464,16 @@
MovieClip::attachBitmap(boost::intrusive_ptr<BitmapData_as> bd, int depth)
{
DisplayObject* ch = new Bitmap(bd, this, 0);
-
attachCharacter(*ch, depth, 0);
-
}
DisplayObject*
MovieClip::add_display_object(const SWF::PlaceObject2Tag* tag,
DisplayList& dlist)
{
+
+ // If this MovieClip has no definition, it should also have no ControlTags,
+ // and this shouldn't be called.
assert(_def);
assert(tag);
@@ -1563,9 +1537,13 @@
NULL);
}
-void MovieClip::replace_display_object(const SWF::PlaceObject2Tag* tag,
DisplayList& dlist)
+void
+MovieClip::replace_display_object(const SWF::PlaceObject2Tag* tag,
+ DisplayList& dlist)
{
- assert(_def != NULL);
+ // A MovieClip without a definition cannot have any ControlTags, so this
+ // should not be called.
+ assert(_def);
assert(tag != NULL);
SWF::DefinitionTag* cdef = _def->getDefinitionTag(tag->getID());
@@ -1691,7 +1669,7 @@
bool
MovieClip::pointInVisibleShape(boost::int32_t x, boost::int32_t y) const
{
- if ( ! isVisible() ) return false;
+ if ( ! visible() ) return false;
if ( isDynamicMask() && ! mouseEnabled() )
{
// see testsuite/misc-ming.all/masks_test.swf
@@ -1702,7 +1680,7 @@
return false;
}
DisplayObject* mask = getMask(); // dynamic one
- if ( mask && mask->isVisible() && ! mask->pointInShape(x, y) )
+ if ( mask && mask->visible() && ! mask->pointInShape(x, y) )
{
#ifdef GNASH_DEBUG_HITTEST
log_debug(_("%s is dynamically masked by %s, which "
@@ -1748,10 +1726,10 @@
{
//GNASH_REPORT_FUNCTION;
- if (!isVisible()) return 0;
+ if (!visible()) return 0;
// point is in parent's space, we need to convert it in world space
- point wp(x, y);
+ point wp(x, y);
DisplayObject* parent = get_parent();
if ( parent )
{
@@ -1763,9 +1741,9 @@
parent->getWorldMatrix().transform(wp);
}
- if ( mouseEnabled() )
+ if (mouseEnabled())
{
- if ( pointInVisibleShape(wp.x, wp.y) ) return this;
+ if (pointInVisibleShape(wp.x, wp.y)) return this;
else return NULL;
}
@@ -1839,7 +1817,7 @@
if ( ch->isMaskLayer() )
{
- if ( ! ch->isVisible() )
+ if ( ! ch->visible() )
{
log_debug(_("FIXME: invisible mask in MouseEntityFinder."));
}
@@ -1899,7 +1877,7 @@
{
if ( this == dragging ) return 0; // not here...
- if ( ! isVisible() ) return 0; // isn't me !
+ if ( ! visible() ) return 0; // isn't me !
DropTargetFinder finder(x, y, dragging);
_displayList.visitAll(finder);
@@ -1938,7 +1916,7 @@
static const size_t size = sizeof(EH) / sizeof(EH[0]);
- for (size_t i = 0; i < size; i++)
+ for (size_t i = 0; i < size; ++i)
{
const event_id &event = EH[i];
@@ -1958,67 +1936,36 @@
return false;
}
-DisplayObject*
-MovieClip::getDisplayObject(int /* id */)
-{
- //return _def->getDefinitionTag(id);
- // @@ TODO -- look through our dlist for a match
- log_unimpl(_("%s doesn't even check for a char"),
- __PRETTY_FUNCTION__);
- return NULL;
-}
-
-
void
MovieClip::stop_drag()
{
- //assert(m_parent == NULL); // why should we care ?
_vm.getRoot().stop_drag();
}
-float
-MovieClip::get_background_alpha() const
-{
- // @@ this doesn't seem right...
- return _vm.getRoot().get_background_alpha();
-}
-
void
MovieClip::set_background_color(const rgba& color)
{
_vm.getRoot().set_background_color(color);
}
-static bool isTextFieldUnloaded(boost::intrusive_ptr<TextField>& p)
-{
- return p->isUnloaded();
-}
-
-/*private*/
void
MovieClip::cleanup_textfield_variables()
{
// nothing to do
- if ( ! _text_variables.get() ) return;
-
- TextFieldMap& m = *_text_variables;
-
- for (TextFieldMap::iterator i=m.begin(), ie=m.end(); i!=ie; ++i)
+ if (!_text_variables.get()) return;
+
+ TextFieldIndex& m = *_text_variables;
+
+ for (TextFieldIndex::iterator i=m.begin(), ie=m.end(); i!=ie; ++i)
{
- TextFieldPtrVect& v=i->second;
- TextFieldPtrVect::iterator lastValid =
- std::remove_if(v.begin(), v.end(),
- boost::bind(isTextFieldUnloaded, _1));
+ TextFields& v=i->second;
+ TextFields::iterator lastValid = std::remove_if(v.begin(), v.end(),
+ boost::mem_fn(&DisplayObject::isUnloaded));
v.erase(lastValid, v.end());
- // TODO: remove the map element if vector is empty
- //if ( v.empty() )
- //{
- //}
}
}
-/* public */
void
MovieClip::set_textfield_variable(const std::string& name, TextField* ch)
{
@@ -2027,29 +1974,22 @@
// lazy allocation
if ( ! _text_variables.get() )
{
- _text_variables.reset(new TextFieldMap);
+ _text_variables.reset(new TextFieldIndex);
}
(*_text_variables)[name].push_back(ch);
}
-/* private */
-MovieClip::TextFieldPtrVect*
+MovieClip::TextFields*
MovieClip::get_textfield_variable(const std::string& name)
{
// nothing allocated yet...
if ( ! _text_variables.get() ) return NULL;
// TODO: should variable name be considered case-insensitive ?
- TextFieldMap::iterator it = _text_variables->find(name);
- if ( it == _text_variables->end() )
- {
- return 0;
- }
- else
- {
- return &(it->second);
- }
+ TextFieldIndex::iterator it = _text_variables->find(name);
+ if (it == _text_variables->end()) return 0;
+ else return &(it->second);
}
@@ -2059,7 +1999,7 @@
{
// nothing to do if this movieclip is not visible
- if (!isVisible() || get_cxform().is_invisible() )
+ if (!visible() || get_cxform().is_invisible() )
{
ranges.add(m_old_invalidated_ranges); // (in case we just hided)
return;
@@ -2124,7 +2064,6 @@
// It seems it's legal to place 0-framed movieclips on stage.
// See testsuite/misc-swfmill.all/zeroframe_definemovieclip.swf
-
// Now execute frame tags and take care of queuing the LOAD event.
//
// DLIST tags are executed immediately while ACTION tags are queued.
@@ -2139,7 +2078,7 @@
log_debug(_("Executing tags of frame0 in movieclip %s"), getTarget());
#endif
executeFrameTags(0, _displayList, SWF::ControlTag::TAG_DLIST |
- SWF::ControlTag::TAG_ACTION);
+ SWF::ControlTag::TAG_ACTION);
if (_vm.getSWFVersion() > 5)
{
@@ -2160,8 +2099,8 @@
#ifdef GNASH_DEBUG
log_debug(_("Executing tags of frame0 in movieclip %s"), getTarget());
#endif
- executeFrameTags(0, _displayList, SWF::ControlTag::TAG_DLIST |
- SWF::ControlTag::TAG_ACTION);
+ executeFrameTags(0, _displayList, SWF::ControlTag::TAG_DLIST |
+ SWF::ControlTag::TAG_ACTION);
}
// We execute events immediately when the stage-placed DisplayObject
@@ -2207,7 +2146,7 @@
}
-/*private*/
+
void
MovieClip::constructAsScriptObject()
{
@@ -2230,10 +2169,11 @@
break;
}
- sprite_definition* def = dynamic_cast<sprite_definition*>(_def.get());
+ const sprite_definition* def =
+ dynamic_cast<const sprite_definition*>(_def.get());
// We won't "construct" top-level movies
- if ( ! def ) break;
+ if (!def) break;
as_function* ctor = def->getRegisteredClass();
#ifdef GNASH_DEBUG
@@ -2335,7 +2275,7 @@
const movie_root& mr = _vm.getRoot();
- boost::intrusive_ptr<movie_definition> md (
+ boost::intrusive_ptr<movie_definition> md(
create_library_movie(url, mr.runInfo(), NULL, true, postdata));
if (!md)
@@ -2345,11 +2285,11 @@
return false;
}
- boost::intrusive_ptr<movie_instance> extern_movie;
- extern_movie = md->create_movie_instance(parent);
+ boost::intrusive_ptr<Movie> extern_movie;
+ extern_movie = md->createMovie(parent);
if (extern_movie == NULL)
{
- log_error(_("can't create extern movie_instance "
+ log_error(_("can't create extern Movie "
"for %s"), url.str());
return false;
}
@@ -2535,9 +2475,7 @@
// removing _level#
_vm.getRoot().dropLevel(depth);
// I guess this can only happen if someone uses
- // _root.swapDepth([0..1048575])
- //log_error(_("Can't remove movieclip %s as it has no parent"),
- //getTarget());
+ // _swf.swapDepth([0..1048575])
}
}
@@ -2636,43 +2574,23 @@
_environment.markReachableResources();
// Mark our own definition
- if ( _def.get() ) _def->setReachable();
+ if (_def.get()) _def->setReachable();
- // Mark textfields in the TextFieldMap
+ // Mark textfields in the TextFieldIndex
if ( _text_variables.get() )
{
- for(TextFieldMap::const_iterator i=_text_variables->begin(),
+ for (TextFieldIndex::const_iterator i=_text_variables->begin(),
e=_text_variables->end();
i!=e; ++i)
{
- const TextFieldPtrVect& tfs=i->second;
- for (TextFieldPtrVect::const_iterator j=tfs.begin(), je=tfs.end();
j!=je; ++j)
- {
- if ( (*j)->isUnloaded() )
- {
- // NOTE: cleanup_display_list should have cleared
- // these up on ::cleanupDisplayList.
- // I guess if we get more might be due to ::destroy
- // calls happening after our own ::cleanupDisplayList
- // call. Should be ok to postpone cleanup on next
- // ::advance, or we should cleanup here (locally)
- // although we're a 'const' method...
- // Yet another approach would be for TextField::unload
- // to unregister self from our map, but TextField
- // doesn't really store a pointer to the movieclip
- // it's registered against.
- //
- //log_debug("Unloaded TextField in registered textfield "
- //"variables container on ::markReachableResources");
- }
- (*j)->setReachable();
- }
+ const TextFields& tfs=i->second;
+ std::for_each(tfs.begin(), tfs.end(),
+ boost::mem_fn(&DisplayObject::setReachable));
}
}
// Mark our relative root
- assert(m_root != NULL);
- m_root->setReachable();
+ _swf->setReachable();
markDisplayObjectReachable();
@@ -2700,22 +2618,20 @@
return cf;
}
-movie_instance*
+Movie*
MovieClip::get_root() const
{
- return m_root;
+ return _swf;
}
const MovieClip*
MovieClip::getAsRoot() const
{
- //log_debug("getAsRoot called for movieclip %s, with _lockroot "
- //"%d and version %d", getTarget(), getLockRoot(), getSWFVersion());
// TODO1: as an optimization, if swf version < 7
- // we might as well just return m_root,
+ // we might as well just return _swf,
// the whole chain from this movieclip to it's
- // m_root should have the same version...
+ // _swf should have the same version...
//
// TODO2: implement this with iteration rather
// then recursion.
@@ -2727,16 +2643,10 @@
// If we have a parent, we descend to it unless
// our _lockroot is true AND our or the VM's
// SWF version is > 6
- //
- int topSWFVersion =
getVM().getRoot().get_movie_definition()->get_version();
- //int topSWFVersion = getVM().getSWFVersion() > 6;
+ int topSWFVersion = getVM().getRoot().getRootMovie().version();
- if ( getSWFVersion() > 6 || topSWFVersion > 6 )
- {
- if ( getLockRoot() )
- {
- return this; // locked
- }
+ if (getSWFVersion() > 6 || topSWFVersion > 6) {
+ if (getLockRoot()) return this;
}
return parent->getAsRoot();
@@ -2745,8 +2655,7 @@
as_value
MovieClip::lockroot_getset(const fn_call& fn)
{
- boost::intrusive_ptr<MovieClip> ptr =
- ensureType<MovieClip>(fn.this_ptr);
+ boost::intrusive_ptr<MovieClip> ptr = ensureType<MovieClip>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -3129,8 +3038,8 @@
// Get exported resource
const std::string& id_name = fn.arg(0).to_string();
- boost::intrusive_ptr<ExportableResource> exported =
- movieclip->get_movie_definition()->get_exported_resource(id_name);
+ boost::intrusive_ptr<ExportableResource> exported =
+ movieclip->get_root()->definition()->get_exported_resource(id_name);
if (!exported)
{
@@ -5149,18 +5058,16 @@
as_value
movieclip_url_getset(const fn_call& fn)
{
- boost::intrusive_ptr<MovieClip> ptr =
- ensureType<MovieClip>(fn.this_ptr);
+ boost::intrusive_ptr<MovieClip> ptr = ensureType<MovieClip>(fn.this_ptr);
- return as_value(ptr->get_movie_definition()->get_url());
+ return as_value(ptr->get_root()->url());
}
// TODO: move this to DisplayObject class, _focusrect seems a generic property
as_value
movieclip_focusrect_getset(const fn_call& fn)
{
- boost::intrusive_ptr<MovieClip> ptr =
- ensureType<MovieClip>(fn.this_ptr);
+ boost::intrusive_ptr<MovieClip> ptr = ensureType<MovieClip>(fn.this_ptr);
UNUSED(ptr);
if ( fn.nargs == 0 ) // getter
=== modified file 'libcore/MovieClip.h'
--- a/libcore/MovieClip.h 2009-04-09 11:39:48 +0000
+++ b/libcore/MovieClip.h 2009-04-15 05:54:30 +0000
@@ -46,7 +46,7 @@
// Forward declarations
namespace gnash {
- class movie_instance;
+ class Movie;
class swf_event;
class drag_state;
class LoadVariablesThread;
@@ -62,12 +62,27 @@
namespace gnash
{
-/// Stateful Sprite object. Also known as a MovieClip.
-//
-/// Instance of this class are also known as "timelines".
-/// This means that they define a variable scope (see
-/// the as_environment member) and are divided into "frames"
-///
+/// A MovieClip is a container for DisplayObjects.
+//
+/// In AS3 is it distinguished from a Sprite by having a timeline, i.e.
+/// more than one frame. In AS2, there is no Sprite class.
+//
+/// There are basically two types of MovieClip: dynamic and non-dynamic.
+/// Dynamic clips are created using createEmptyMovieClip() or
+/// duplicateMovieClip(). Non-dynamic MovieClips are parsed from a SWF file.
+/// The isDynamic() member function is the only way to tell the difference
+/// (see following paragraph).
+//
+/// The presence of a definition (the _def member) reveals whether the
+/// MovieClip was constructed with an immutable definition or not. MovieClips
+/// created using createEmptyMovieClip() have no definition. MovieClips
+/// constructed using duplicateMovieClip() have the same definition as the
+/// duplicated clip. They are "dynamic", but may have a definition!
+//
+/// A MovieClip always has an _swf member. This is the top-level SWF
+/// (Movie) containing either the definition or the code from
+/// which the MovieClip was created. The _url member and SWF version are
+/// dependent on the _swf. Exports are also sought in this Movie.
class MovieClip : public InteractiveObject
{
@@ -77,20 +92,25 @@
typedef movie_definition::PlayList PlayList;
- typedef std::vector<swf_event*> SWFEventsVector;
+ enum PlayState
+ {
+ PLAYSTATE_PLAY,
+ PLAYSTATE_STOP
+ };
/// Construct a MovieClip instance
//
/// @param def
/// Pointer to the movie_definition this object is an
/// instance of (may be a top-level movie or a sprite).
+ /// This may be 0 if there is no immutable definition.
///
/// @param root
- /// The "relative" _root of this sprite, which is the
+ /// The "relative" _swf of this sprite, which is the
/// instance of top-level sprite defined by the same
/// SWF that also contained *this* sprite definition.
/// Note that this can be *different* from the top-level
- /// movie accessible trought the VM, in case this sprite
+ /// movie accessible through the VM, in case this sprite
/// was defined in an externally loaded movie.
///
/// @param parent
@@ -103,22 +123,15 @@
/// to be deprecated if every instance has a reference to its
/// definition, which should know its id...
///
- MovieClip(movie_definition* def, movie_instance* root,
+ MovieClip(const movie_definition* const def, Movie* root,
DisplayObject* parent, int id);
virtual ~MovieClip();
- enum PlayState
- {
- PLAYSTATE_PLAY,
- PLAYSTATE_STOP
- };
-
-
- // Overridden to use the m_root member
- virtual movie_instance* get_root() const;
-
- /// Return the _root ActionScript property of this sprite.
+ // Return the originating SWF
+ virtual Movie* get_root() const;
+
+ /// Return the _swf ActionScript property of this sprite.
//
/// Relative or absolute is determined by
/// the _lockroot property, see getLockRoot
@@ -126,37 +139,21 @@
///
virtual const MovieClip* getAsRoot() const;
- /// \brief
- /// Return the sprite_definition (or movie_definition)
- /// from which this MovieClip has been created
- movie_definition* get_movie_definition() {
- return _def.get();
- }
-
- /// \brief
- /// Return version of the SWF definition of this instance
- /// as been parsed from.
- //
- int getSWFVersion() const
- {
- return _def->get_version();
- }
-
/// Get the composite bounds of all component drawing elements
virtual rect getBounds() const;
// See dox in DisplayObject.h
- bool pointInShape(boost::int32_t x, boost::int32_t y) const;
+ virtual bool pointInShape(boost::int32_t x, boost::int32_t y) const;
// See dox in DisplayObject.h
- bool pointInVisibleShape(boost::int32_t x, boost::int32_t y) const;
+ virtual bool pointInVisibleShape(boost::int32_t x, boost::int32_t y) const;
/// return true if the given point is located in a(this) hitable sprite.
///
/// all sprites except mouse-insensitive dynamic masks are hitable.
/// _visible property is ignored for hitable DisplayObjects.
///
- bool pointInHitableShape(boost::int32_t x, boost::int32_t y) const;
+ virtual bool pointInHitableShape(boost::int32_t x, boost::int32_t y) const;
/// Return 0-based index to current frame
size_t get_current_frame() const
@@ -166,7 +163,7 @@
size_t get_frame_count() const
{
- return _def->get_frame_count();
+ return _def ? _def->get_frame_count() : 1;
}
/// Return number of completely loaded frames of this sprite/movie
@@ -176,7 +173,7 @@
///
size_t get_loaded_frames() const
{
- return _def->get_loading_frame();
+ return _def ? _def->get_loading_frame() : 1;
}
/// Return total number of bytes in the movie
@@ -195,7 +192,8 @@
const rect& get_frame_size() const
{
- return _def->get_frame_size();
+ static const rect r;
+ return _def ? _def->get_frame_size() : r;
}
/// Stop or play the sprite.
@@ -207,11 +205,6 @@
PlayState getPlayState() const { return _playState; }
- DisplayObject* getDisplayObject(int DisplayObject_id);
-
- // delegates to movie_root (possibly wrong)
- virtual float get_background_alpha() const;
-
// delegates to movie_root (possibly wrong)
void set_background_color(const rgba& color);
@@ -778,13 +771,12 @@
void constructAsScriptObject();
- /// Return true if get_root() should return the *relative* root,
+ /// Return true if getAsRoot() should return the *relative* root,
/// false otherwise.
bool getLockRoot() const { return _lockroot; }
- /// Set whether get_root() should return the *relative* root,
+ /// Set whether getAsRoot() should return the *relative* root,
/// false otherwise. True for relative root.
- ///
void setLockRoot(bool lr) { _lockroot=lr; }
/// Getter-setter for MovieClip._lockroot
@@ -795,14 +787,15 @@
virtual InfoTree::iterator getMovieInfo(InfoTree& tr,
InfoTree::iterator it);
#endif
+
+ /// \brief
+ /// Return version of the SWF definition of this instance
+ /// as been parsed from.
+ //
+ int getSWFVersion() const;
protected:
- /// Used both by this class and movie_instance.
- //
- /// TODO: do this with proper Sprite -> MovieClip inheritance.
- void advance_sprite();
-
#ifdef GNASH_USE_GC
/// Mark sprite-specific reachable resources and invoke
/// the parent's class version (markDisplayObjectReachable)
@@ -813,18 +806,22 @@
/// - sprite environment
/// - definition the sprite has been instantiated from
/// - Textfields having an associated variable registered in this instance.
- /// - Relative root of this instance (m_root)
+ /// - Relative root of this instance (_swf)
///
virtual void markReachableResources() const;
#endif // GNASH_USE_GC
- // Used by BitmapMovieInstance.
+ // Used by BitmapMovie.
void placeDisplayObject(DisplayObject* ch, int depth) {
_displayList.placeDisplayObject(ch, depth);
}
private:
+ typedef std::vector<boost::intrusive_ptr<TextField> > TextFields;
+
+ /// A container for textfields, indexed by their variable name
+ typedef std::map<std::string, TextFields> TextFieldIndex;
/// Process any completed loadVariables request
void processCompletedLoadVariableRequests();
@@ -932,13 +929,32 @@
/// Increment _currentFrame, and take care of looping.
void increment_frame_and_check_for_loop();
+ /// \brief
+ /// Returns a vector of TextField associated with the given variable name,
+ /// or NULL if no such variable name is known.
+ //
+ /// A TextField variable is a variable that acts
+ /// as a setter/getter for a TextField 'text' member.
+ ///
+ /// Search is case-sensitive.
+ ///
+ /// @todo find out wheter we should be case sensitive or not
+ ///
+ /// @return a pointer inside a vector, will be invalidated by modifications
+ /// of the vector (set_textfield_variable)
+ ///
+ TextFields* get_textfield_variable(const std::string& name);
+
+ /// Unregister textfield variables bound to unloaded TextFields
+ void cleanup_textfield_variables();
+
+ /// This is either sprite_definition (for sprites defined by
+ /// DefineSprite tag) or movie_def_impl (for the top-level movie).
+ const boost::intrusive_ptr<const movie_definition> _def;
+
/// List of loadVariables requests
typedef std::list<LoadVariablesThread*> LoadVariablesThreads;
-
- /// This is either sprite_definition (for sprites defined by
- /// DefineSprite tag) or movie_def_impl (for the top-level movie).
- boost::intrusive_ptr<movie_definition> _def;
-
+
/// List of active loadVariable requests
//
/// At ::advance_sprite time, all completed requests will
@@ -947,7 +963,7 @@
LoadVariablesThreads _loadVariableRequests;
/// The SWF that this MovieClip belongs to.
- movie_instance* m_root;
+ Movie* _swf;
/// Current Display List contents.
DisplayList _displayList;
@@ -955,10 +971,6 @@
/// The canvas for dynamic drawing
DynamicShape _drawable;
- // this is deprecated, we'll be pushing gotoframe target
- // actions to the global action queue
- //ActionList m_goto_frame_action_list;
-
PlayState _playState;
// 0-based index to current frame
@@ -973,35 +985,10 @@
/// This timeline's variable scope
as_environment _environment;
- typedef boost::intrusive_ptr<TextField> TextFieldPtr;
- typedef std::vector<TextFieldPtr> TextFieldPtrVect;
-
- /// A container for textfields, indexed by their variable name
- typedef std::map< std::string, TextFieldPtrVect > TextFieldMap;
-
- /// We'll only allocate Textfield variables map if
+ /// We'll only allocate Textfield variables map if
/// we need them (ie: anyone calls set_textfield_variable)
///
- std::auto_ptr<TextFieldMap> _text_variables;
-
- /// \brief
- /// Returns a vector of TextField associated with the given variable name,
- /// or NULL if no such variable name is known.
- //
- /// A TextField variable is a variable that acts
- /// as a setter/getter for a TextField 'text' member.
- ///
- /// Search is case-sensitive.
- ///
- /// @todo find out wheter we should be case sensitive or not
- ///
- /// @return a pointer inside a vector, will be invalidated by modifications
- /// of the vector (set_textfield_variable)
- ///
- TextFieldPtrVect* get_textfield_variable(const std::string& name);
-
- /// Unregister textfield variables bound to unloaded TextFields
- void cleanup_textfield_variables();
+ std::auto_ptr<TextFieldIndex> _text_variables;
/// soundid for current playing stream. If no stream set to -1
int m_sound_stream_id;
=== modified file 'libcore/Property.h'
--- a/libcore/Property.h 2009-02-25 22:33:03 +0000
+++ b/libcore/Property.h 2009-04-15 05:33:51 +0000
@@ -454,7 +454,7 @@
bool isStatic() const { return _flags.get_static(); }
/// Is this member supposed to be visible by a VM of given version ?
- bool isVisible(int swfVersion) const {
+ bool visible(int swfVersion) const {
return _flags.get_visible(swfVersion);
}
=== renamed file 'libcore/movie_instance.cpp' => 'libcore/SWFMovie.cpp'
--- a/libcore/movie_instance.cpp 2009-04-03 09:18:40 +0000
+++ b/libcore/SWFMovie.cpp 2009-04-15 05:54:30 +0000
@@ -15,7 +15,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#include "movie_instance.h"
+#include "SWFMovie.h"
#include "movie_definition.h"
#include "movie_root.h"
#include "log.h"
@@ -29,25 +29,21 @@
namespace gnash {
-movie_instance::movie_instance(movie_definition* def, DisplayObject* parent)
+SWFMovie::SWFMovie(const SWFMovieDefinition* const def, DisplayObject* parent)
:
- MovieClip(def, this, parent, parent ? 0 : -1),
+ Movie(def, parent),
_def(def)
{
}
void
-movie_instance::stagePlacementCallback(as_object* initObj)
+SWFMovie::stagePlacementCallback(as_object* initObj)
{
assert (!initObj);
saveOriginalTarget();
- //GNASH_REPORT_FUNCTION;
-
- //_def->stopLoader();
-
// Load first frame (1-based index)
size_t nextframe = 1;
if ( !_def->ensure_frame_loaded(nextframe) )
@@ -64,18 +60,15 @@
// Advance of an SWF-defined movie instance
void
-movie_instance::advance()
+SWFMovie::advance()
{
- //GNASH_REPORT_FUNCTION;
-
- //_def->stopLoader();
-
// Load next frame if available (+2 as m_current_frame is 0-based)
//
// We do this inside advance_root to make sure
// it's only for a root sprite (not a sprite defined
// by DefineSprite!)
- size_t nextframe = std::min<size_t>(get_current_frame()+2,
get_frame_count());
+ size_t nextframe = std::min<size_t>(get_current_frame() + 2,
+ get_frame_count());
if ( !_def->ensure_frame_loaded(nextframe) )
{
IF_VERBOSE_MALFORMED_SWF(
@@ -84,9 +77,7 @@
);
}
- advance_sprite();
-
- //_def->resumeLoader();
+ MovieClip::advance();
}
} // namespace gnash
=== renamed file 'libcore/movie_instance.h' => 'libcore/SWFMovie.h'
--- a/libcore/movie_instance.h 2009-04-03 09:18:40 +0000
+++ b/libcore/SWFMovie.h 2009-04-15 06:41:11 +0000
@@ -18,19 +18,17 @@
// Stateful live Movie instance
-#ifndef GNASH_MOVIE_INSTANCE_H
-#define GNASH_MOVIE_INSTANCE_H
-
-#include <vector>
+#ifndef GNASH_SWF_MOVIE_H
+#define GNASH_SWF_MOVIE_H
+
+#include "Movie.h" // for inheritance
+#include "smart_ptr.h" // for composition
+#include "SWFMovieDefinition.h" // for dtor visibility by smart ptr
+
#include <set>
-#include "MovieClip.h" // for inheritance
-#include "smart_ptr.h" // for composition
-#include "movie_definition.h" // for dtor visibility by smart ptr
-
// Forward declarations
namespace gnash {
- class movie_root;
class DisplayObject;
}
@@ -38,19 +36,33 @@
{
/// Stateful Movie object (a special kind of sprite)
-class movie_instance : public MovieClip
+class SWFMovie : public Movie
{
public:
- // We take a generic movie_definition to allow
- // for subclasses for other then SWF movies
- movie_instance(movie_definition* def, DisplayObject* parent);
+ SWFMovie(const SWFMovieDefinition* const def, DisplayObject* parent);
- virtual ~movie_instance() {}
+ virtual ~SWFMovie() {}
virtual void advance();
+ virtual float frameRate() const {
+ return _def->get_frame_rate();
+ }
+
+ virtual float widthPixels() const {
+ return _def->get_width_pixels();
+ }
+
+ virtual float heightPixels() const {
+ return _def->get_height_pixels();
+ }
+
+ virtual bool ensureFrameLoaded(size_t frameNo) const {
+ return _def->ensure_frame_loaded(frameNo);
+ }
+
/// Handle a top-level movie on stage placement.
//
/// This method will just ensure first frame is loaded
@@ -60,6 +72,14 @@
///
void stagePlacementCallback(as_object* initObj = 0);
+ const std::string& url() const {
+ return _def->get_url();
+ }
+
+ int version() const {
+ return _def->get_version();
+ }
+
/// Set a DisplayObject in the dictionary as initialized, returning
/// true if not already initialized.
bool setCharacterInitialized(int cid)
@@ -67,6 +87,10 @@
return _initializedCharacters.insert(cid).second;
}
+ const movie_definition* definition() const {
+ return _def.get();
+ }
+
private:
/// A map to track execution of init actions
@@ -76,7 +100,8 @@
///
std::set<int> _initializedCharacters;
- boost::intrusive_ptr<movie_definition> _def;
+ /// This should only be a top-level movie, not a sprite_definition.
+ const boost::intrusive_ptr<const SWFMovieDefinition> _def;
};
=== modified file 'libcore/TextField.cpp'
--- a/libcore/TextField.cpp 2009-04-14 07:33:24 +0000
+++ b/libcore/TextField.cpp 2009-04-15 05:33:51 +0000
@@ -232,8 +232,6 @@
registerTextVariable();
- m_dummy_style.push_back(fill_style());
-
reset_bounding_box(0, 0);
}
@@ -505,7 +503,7 @@
TextField::topmostMouseEntity(boost::int32_t x, boost::int32_t y)
{
- if (!isVisible()) return 0;
+ if (!visible()) return 0;
// shouldn't this be !can_handle_mouse_event() instead ?
// not selectable, so don't catch mouse events!
@@ -773,7 +771,7 @@
break;
case NSV::PROP_uVISIBLE:
{
- val->set_bool(isVisible());
+ val->set_bool(visible());
return true;
}
case NSV::PROP_uALPHA:
@@ -1815,16 +1813,10 @@
TextField::TypeValue
TextField::parseTypeValue(const std::string& val)
{
- StringNoCaseLessThan cmp;
+ StringNoCaseEqual cmp;
- if ( ! cmp(val, "input") )
- {
- return typeInput;
- }
- if ( ! cmp(val, "dynamic") )
- {
- return typeDynamic;
- }
+ if (cmp(val, "input")) return typeInput;
+ if (cmp(val, "dynamic")) return typeDynamic;
return typeInvalid;
}
@@ -2442,9 +2434,9 @@
bool italic = tf->italiced();
// NOTE: should query movie-private font lib, not global-shared one
- movie_instance* mi = text->get_root();
+ Movie* mi = text->get_root();
assert(mi);
- movie_definition* md = mi->get_movie_definition();
+ const movie_definition* md = mi->definition();
assert(md);
Font* f = md->get_font(fontName, bold, italic);
if ( ! f ) f = fontlib::get_font(fontName, bold, italic);
=== modified file 'libcore/TextField.h'
--- a/libcore/TextField.h 2009-04-04 15:35:18 +0000
+++ b/libcore/TextField.h 2009-04-14 11:26:23 +0000
@@ -96,7 +96,10 @@
InteractiveObject* topmostMouseEntity(boost::int32_t x,
boost::int32_t y);
- bool wantsInstanceName() const
+ // Text fields need to handle cxform specially
+ virtual cxform get_world_cxform() const;
+
+ bool wantsInstanceName() const
{
return true; // text fields can be referenced
}
@@ -460,16 +463,21 @@
///
void setTextValue(const std::wstring& wstr);
+protected:
+
+ /// Mark reachable reosurces (for GC)
+ //
+ /// Reachable resources are:
+ /// - The font being used (m_font)
+ /// - Our definition
+ /// - Common DisplayObject resources
+ ///
+ void markReachableResources() const;
private:
void init();
- /// The immutable definition of our TextField
- //
- /// This is NULL for dynamic TextFields.
- boost::intrusive_ptr<const SWF::DefineEditTextTag> _tag;
-
/// \brief Set our text to the given string by effect of an update of a
/// registered variable name
//
@@ -492,37 +500,12 @@
/// Call this function when willing to invoke the onChanged event
handler
void onChanged();
- /// The actual text.
- //
- /// Because we have to deal with non-ascii DisplayObjects (129-255), this
- /// is a wide string; the cursor position and the position within the
- /// string are then the same, which makes manipulating the string much
- /// easier.
- std::wstring _text;
-
- /// This flag will be true as soon as the TextField
- /// is assigned a text value. Only way to be false is
- /// when definition has the hasText flag set to false
- /// and no actionscript added text.
- bool _textDefined;
-
- /// bounds of dynamic text, as laid out
- rect m_text_bounding_box;
-
/// Reset our text bounding box to the given point.
void reset_bounding_box(boost::int32_t x, boost::int32_t y)
{
m_text_bounding_box.set_to_point(x, y);
}
- typedef std::vector<SWF::TextRecord> TextRecords;
- TextRecords _textRecords;
-
- /// used to pass a color on to Shape::display()
- std::vector<fill_style> m_dummy_style;
-
- std::vector<line_style> m_dummy_line_style;
-
/// Convert the DisplayObjects in _text into a series of
/// text_glyph_records to be rendered.
void format_text();
@@ -545,6 +528,57 @@
/// m_text_glyph_records.
float align_line(TextAlignment align, int last_line_start_record, float
x);
+ /// Associate a variable to the text of this DisplayObject
+ //
+ /// Setting the associated variable actually changes the
+ /// displayed text. Getting the variable would return the
+ /// displayed text.
+ ///
+ /// If the given variable already exist use it to set
+ /// current text before overriding it.
+ ///
+ /// Since the variable target may be undefined at time
+ /// of instantiation of this EditText DisplayObject, the
+ /// class keeps track of wheter it succeeded registering
+ /// the variable and this function will do nothing in this
+ /// case. Thus it is safe to call it multiple time, using
+ /// an as-needed policy (will be called from get_text_value and
+ /// display)
+ ///
+ void registerTextVariable();
+
+ typedef std::pair<as_object*, string_table::key> VariableRef;
+
+ /// \brief
+ /// Parse the given variable name
+ /// into sprite and a string_table::key components
+ ///
+ VariableRef parseTextVariableRef(const std::string& variableName) const;
+
+ /// The immutable definition of our TextField
+ //
+ /// This is NULL for dynamic TextFields.
+ boost::intrusive_ptr<const SWF::DefineEditTextTag> _tag;
+
+ /// The actual text.
+ //
+ /// Because we have to deal with non-ascii DisplayObjects (129-255), this
+ /// is a wide string; the cursor position and the position within the
+ /// string are then the same, which makes manipulating the string much
+ /// easier.
+ std::wstring _text;
+
+ /// This flag will be true as soon as the TextField
+ /// is assigned a text value. Only way to be false is
+ /// when definition has the hasText flag set to false
+ /// and no actionscript added text.
+ bool _textDefined;
+
+ /// bounds of dynamic text, as laid out
+ rect m_text_bounding_box;
+
+ typedef std::vector<SWF::TextRecord> TextRecords;
+ TextRecords _textRecords;
bool _underlined;
boost::uint16_t _leading;
@@ -579,37 +613,6 @@
/// Corresponds to the maxChars property.
boost::int32_t _maxChars;
-
- /// Associate a variable to the text of this DisplayObject
- //
- /// Setting the associated variable actually changes the
- /// displayed text. Getting the variable would return the
- /// displayed text.
- ///
- /// If the given variable already exist use it to set
- /// current text before overriding it.
- ///
- /// Since the variable target may be undefined at time
- /// of instantiation of this EditText DisplayObject, the
- /// class keeps track of wheter it succeeded registering
- /// the variable and this function will do nothing in this
- /// case. Thus it is safe to call it multiple time, using
- /// an as-needed policy (will be called from get_text_value and
- /// display)
- ///
- void registerTextVariable();
-
- typedef std::pair<as_object*, string_table::key> VariableRef;
-
- /// \brief
- /// Parse the given variable name
- /// into sprite and a string_table::key components
- ///
- VariableRef parseTextVariableRef(const std::string& variableName) const;
-
- // Text fields need to handle cxform specially
- virtual cxform get_world_cxform() const;
-
/// The flag keeping status of TextVariable registration
//
/// It will be set to true if there's no need to register
@@ -657,17 +660,6 @@
/// Represents the selected part of the text. The second element must
/// never be less than the first.
std::pair<size_t, size_t> _selection;
-
-protected:
-
- /// Mark reachable reosurces (for GC)
- //
- /// Reachable resources are:
- /// - The font being used (m_font)
- /// - Our definition
- /// - Common DisplayObject resources
- ///
- void markReachableResources() const;
};
/// Initialize the global TextField class
=== modified file 'libcore/as_object.cpp'
--- a/libcore/as_object.cpp 2009-04-01 07:00:32 +0000
+++ b/libcore/as_object.cpp 2009-04-15 05:33:51 +0000
@@ -459,7 +459,7 @@
Property* prop = _members.getProperty(key, nsname);
// TODO: add ignoreVisibility parameter to allow using
// __proto__ even when not visible ?
- if (prop && prop->isVisible(swfVersion))
+ if (prop && prop->visible(swfVersion))
{
if (owner != NULL)
*owner = this;
@@ -485,7 +485,7 @@
throw ActionLimitException("Lookup depth exceeded.");
Property* prop = obj->_members.getProperty(key);
- if (prop && prop->isVisible(swfVersion) )
+ if (prop && prop->visible(swfVersion) )
{
if (owner != NULL)
*owner = obj.get();
@@ -509,7 +509,7 @@
// We won't scan the inheritance chain if we find a member,
// even if invisible.
//
- if ( prop ) return prop; // TODO: what about isVisible ?
+ if ( prop ) return prop; // TODO: what about visible ?
// don't enter an infinite loop looking for __proto__ ...
if (key == NSV::PROP_uuPROTOuu) return NULL;
@@ -529,7 +529,7 @@
throw ActionLimitException("Property lookup depth
exceeded.");
Property* p = obj->_members.getProperty(key, nsname);
- if (p && (p->isGetterSetter() | p->isStatic()) &&
p->isVisible(swfVersion))
+ if (p && (p->isGetterSetter() | p->isStatic()) &&
p->visible(swfVersion))
{
return p; // What should we do if this is not a
getter/setter ?
}
@@ -1140,7 +1140,7 @@
Property* prop = _members.getProperty(NSV::PROP_uuPROTOuu);
if ( ! prop ) return 0;
- if ( ! prop->isVisible(swfVersion) ) return 0;
+ if ( ! prop->visible(swfVersion) ) return 0;
as_value tmp = prop->getValue(*this);
=== modified file 'libcore/asobj/Object.cpp'
--- a/libcore/asobj/Object.cpp 2009-04-03 09:18:40 +0000
+++ b/libcore/asobj/Object.cpp 2009-04-14 17:49:58 +0000
@@ -288,11 +288,6 @@
// Find the exported resource
- // TODO: check to *which* definition should we ask the export
- // this code uses the *relative* root of current environment's
target
-#if 0
- movie_definition* def = _vm.getRoot().get_movie_definition();
-#else
// Using definition of current target fixes the youtube beta case
// https://savannah.gnu.org/bugs/index.php?23130
DisplayObject* tgt = fn.env().get_target();
@@ -300,11 +295,11 @@
log_error("current environment has no target, wouldn't know
where to look for symbol required for registerClass");
return as_value(false);
}
- movie_instance* relRoot = tgt->get_root();
+ Movie* relRoot = tgt->get_root();
assert(relRoot);
- movie_definition* def = relRoot->get_movie_definition();
-#endif
- boost::intrusive_ptr<ExportableResource> exp_res =
+ const movie_definition* def = relRoot->definition();
+
+ boost::intrusive_ptr<ExportableResource> exp_res =
def->get_exported_resource(symbolid);
if ( ! exp_res )
{
=== modified file 'libcore/asobj/Sound_as.cpp'
--- a/libcore/asobj/Sound_as.cpp 2009-04-03 09:48:13 +0000
+++ b/libcore/asobj/Sound_as.cpp 2009-04-14 16:13:21 +0000
@@ -640,7 +640,7 @@
const std::string& name = fn.arg(0).to_string();
// check the import.
- movie_definition* def = so->getVM().getRoot().get_movie_definition();
+ const movie_definition* def = fn.callerDef;
assert(def);
boost::intrusive_ptr<ExportableResource> res =
def->get_exported_resource(name);
@@ -698,15 +698,7 @@
// check the import.
// NOTE: we should be checking in the SWF containing the calling code
// (see 'winter bell' from orisinal morning sunshine for a testcase)
- const movie_definition* def;
- if ( ! fn.callerDef ) {
- log_error("Function call to Sound.attachSound have no callerDef");
- def = so->getVM().getRoot().get_movie_definition();
- }
- else {
- def = fn.callerDef;
- }
-
+ const movie_definition* def = fn.callerDef;
assert(def);
boost::intrusive_ptr<ExportableResource> res =
def->get_exported_resource(name);
=== modified file 'libcore/asobj/flash/display/BitmapData_as.cpp'
--- a/libcore/asobj/flash/display/BitmapData_as.cpp 2009-04-03 09:18:40
+0000
+++ b/libcore/asobj/flash/display/BitmapData_as.cpp 2009-04-14 15:07:44
+0000
@@ -34,8 +34,6 @@
#include "Object.h" // for AS inheritance
#include "VM.h" // for addStatics
-#include "BitmapMovieInstance.h"
-
#include <vector>
#include <sstream>
#include <algorithm>
=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp 2009-04-06 08:16:33 +0000
+++ b/libcore/movie_root.cpp 2009-04-15 05:33:51 +0000
@@ -23,7 +23,7 @@
#include "movie_root.h"
#include "log.h"
#include "MovieClip.h"
-#include "movie_instance.h" // for implicit upcast to MovieClip
+#include "Movie.h" // for implicit upcast to MovieClip
#include "render.h"
#include "VM.h"
#include "ExecutableCode.h"
@@ -178,13 +178,13 @@
}
void
-movie_root::setRootMovie(movie_instance* movie)
+movie_root::setRootMovie(Movie* movie)
{
_rootMovie = movie;
m_viewport_x0 = 0;
m_viewport_y0 = 0;
- movie_definition* md = movie->get_movie_definition();
+ const movie_definition* md = movie->definition();
float fps = md->get_frame_rate();
_movieAdvancementDelay = static_cast<int>(1000/fps);
@@ -248,7 +248,7 @@
/* private */
void
-movie_root::setLevel(unsigned int num, boost::intrusive_ptr<movie_instance>
movie)
+movie_root::setLevel(unsigned int num, boost::intrusive_ptr<Movie> movie)
{
assert(movie != NULL);
assert(static_cast<unsigned int>(movie->get_depth()) ==
@@ -406,7 +406,7 @@
}
MovieClip* mo = it->second.get();
- if ( mo == getRootMovie() )
+ if (mo == _rootMovie)
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Original root movie can't be removed"));
@@ -433,11 +433,11 @@
return false;
}
- boost::intrusive_ptr<movie_instance> extern_movie;
- extern_movie = md->create_movie_instance();
+ boost::intrusive_ptr<Movie> extern_movie;
+ extern_movie = md->createMovie();
if (extern_movie == NULL)
{
- log_error(_("can't create extern movie_instance for %s"),
+ log_error(_("can't create extern Movie for %s"),
url.str());
return false;
}
@@ -455,14 +455,14 @@
return true;
}
-boost::intrusive_ptr<movie_instance>
+boost::intrusive_ptr<Movie>
movie_root::getLevel(unsigned int num) const
{
Levels::const_iterator i =
_movies.find(num+DisplayObject::staticDepthOffset);
if ( i == _movies.end() ) return 0;
- assert(boost::dynamic_pointer_cast<movie_instance>(i->second));
- return boost::static_pointer_cast<movie_instance>(i->second);
+ assert(boost::dynamic_pointer_cast<Movie>(i->second));
+ return boost::static_pointer_cast<Movie>(i->second);
}
void
@@ -1092,7 +1092,7 @@
clearInvalidated();
// TODO: should we consider the union of all levels bounds ?
- const rect& frame_size = getRootMovie()->get_frame_size();
+ const rect& frame_size = _rootMovie->get_frame_size();
if ( frame_size.is_null() )
{
// TODO: check what we should do if other levels
@@ -1115,7 +1115,7 @@
movie->clear_invalidated();
- if (movie->isVisible() == false) continue;
+ if (movie->visible() == false) continue;
// null frame size ? don't display !
const rect& sub_frame_size = movie->get_frame_size();
@@ -1136,7 +1136,7 @@
ch->clear_invalidated();
- if (ch->isVisible() == false) continue;
+ if (ch->visible() == false) continue;
ch->display();
@@ -1311,7 +1311,7 @@
// _level0 also seems unable to receive focus under any circumstances
// TODO: what about _level1 etc ?
if (to == _currentFocus ||
- to == static_cast<DisplayObject*>(getRootMovie())) {
+ to == static_cast<DisplayObject*>(_rootMovie.get())) {
return false;
}
@@ -1426,7 +1426,7 @@
}
// If scaling is allowed, always return the original movie size.
- return static_cast<unsigned
int>(get_movie_definition()->get_width_pixels());
+ return static_cast<unsigned int>(_rootMovie->widthPixels());
}
/// Get actionscript height of stage, in pixels. The height
@@ -1440,7 +1440,7 @@
}
// If scaling is allowed, always return the original movie size.
- return static_cast<unsigned
int>(get_movie_definition()->get_height_pixels());
+ return static_cast<unsigned int>(_rootMovie->heightPixels());
}
/// Takes a short int bitfield: the four bits correspond
@@ -1496,11 +1496,11 @@
// If we go from or to noScale, we notify a resize
// if and only if display viewport is != then actual
// movie size
- movie_definition* md = _rootMovie->get_movie_definition();
+ const movie_definition* md = _rootMovie->definition();
- log_debug("Going to or from scaleMode=noScale. Viewport:%dx%d
Def:%dx%d",
- m_viewport_width, m_viewport_height,
- md->get_width_pixels(), md->get_height_pixels());
+ log_debug("Going to or from scaleMode=noScale. Viewport:%dx%d "
+ "Def:%dx%d", m_viewport_width, m_viewport_height,
+ md->get_width_pixels(), md->get_height_pixels());
if ( m_viewport_width != md->get_width_pixels()
|| m_viewport_height != md->get_height_pixels() )
@@ -2068,11 +2068,13 @@
void
movie_root::set_background_color(const rgba& color)
{
-
- if ( m_background_color_set ) return;
+ if (m_background_color_set) return;
m_background_color_set = true;
+
+ rgba newcolor = color;
+ newcolor.m_a = m_background_color.m_a;
- if ( m_background_color != color ) {
+ if (m_background_color != color) {
setInvalidated();
m_background_color = color;
}
@@ -2081,7 +2083,6 @@
void
movie_root::set_background_alpha(float alpha)
{
- //GNASH_REPORT_FUNCTION;
boost::uint8_t newAlpha = clamp<int>(frnd(alpha * 255.0f), 0, 255);
@@ -2364,7 +2365,7 @@
//
/// Stage
//
- movie_definition* def = get_movie_definition();
+ const movie_definition* def = _rootMovie->definition();
assert(def);
it = tr.insert(it, StringPair("Stage Properties", ""));
=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h 2009-04-09 11:39:48 +0000
+++ b/libcore/movie_root.h 2009-04-14 17:49:58 +0000
@@ -77,7 +77,7 @@
#include "smart_ptr.h" // for memory management
#include "URL.h" // for loadMovie
#include "GnashKey.h" // key::code
-#include "movie_instance.h"
+#include "Movie.h"
#include "RunInfo.h" // for initialization
#include "gnash.h" // Quality
@@ -123,13 +123,22 @@
}
};
-/// The movie stage (absolute top level node in the DisplayObjects hierarchy)
-//
-/// This is a wrapper around the set of loaded levels being played.
-///
-/// There is a *single* instance of this class for each run;
-/// loading external movies will *not* create a new instance of it.
-///
+/// This class represents the 'Stage' and top-level movie.
+//
+/// It is a wrapper around the set of loaded levels being played. Each
+/// 'run' of a SWF movie, including all further movies loaded during the
+/// run, has exactly one movie_root, which is kept for the entire run.
+/// Loading a new top-level movie does not create a new movie_root.
+//
+/// The 'Stage' part of movie_root is accessible through the ActionScript
+/// Stage object, implemented in Stage_as.
+//
+/// The movie_root class is responsible for accepting and passing on
+/// user events (mouse or key events), for maintaining the heart-beat
+/// mechanism, and for advancing all MovieClips on request from the
+/// hosting application.
+//
+/// The _root object is provided by getAsRoot().
class DSOEXPORT movie_root : boost::noncopyable
{
@@ -157,7 +166,7 @@
///
/// Make sure to call this method before using the movie_root,
/// as most operations are delegated to the associated/wrapped
- /// movie_instance.
+ /// Movie.
///
/// Note that the display viewport will be updated to match
/// the size of given movie.
@@ -165,18 +174,18 @@
/// A call to this method is equivalent to a call to setLevel(0, movie).
///
/// @param movie
- /// The movie_instance to wrap.
+ /// The Movie to wrap.
/// Will be stored in an intrusive_ptr.
/// Must have a depth of 0.
///
- void setRootMovie(movie_instance* movie);
+ void setRootMovie(Movie* movie);
/// 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_instance> getLevel(unsigned int num) const;
+ boost::intrusive_ptr<Movie> getLevel(unsigned int num) const;
/// Load movie at the specified URL in the given level
//
@@ -199,14 +208,14 @@
/// Character's depths are updated.
///
/// @param sp
- /// The level to change depth/level of. A pointer to it is expected
- /// to be found in the _level# container, or an error will be
printed
- /// and the call would result in a no-op.
+ /// The level to change depth/level of. A pointer to it is expected
+ /// to be found in the _level# container, or an error will be printed
+ /// and the call would result in a no-op.
///
/// @param depth
- /// New depth to assign to the DisplayObject. If another level
exists at
- /// the target depth the latter is moved in place of the former,
with
- /// its depth also updated.
+ /// New depth to assign to the DisplayObject. If another level
+ /// 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);
@@ -294,9 +303,16 @@
void set_drag_state(const drag_state& st);
/// @return the originating root movie (not necessarely _level0)
- movie_instance* getRootMovie() const
+ const Movie& getRootMovie() const
{
- return _rootMovie.get();
+ return *_rootMovie;
+ }
+
+ /// Return the current nominal frame rate for the Stage.
+ //
+ /// This is dependent on the Movie set as root movie.
+ float frameRate() const {
+ return _rootMovie->frameRate();
}
void stop_drag()
@@ -304,15 +320,6 @@
m_drag_state.reset();
}
- /// Return definition of originating root movie
- //
- /// TODO: rename to getOriginatingDefinition ?
- ///
- movie_definition* get_movie_definition() const
- {
- return getRootMovie()->get_movie_definition();
- }
-
/// Add an interval timer
//
/// @param timer
@@ -344,18 +351,13 @@
///
size_t get_current_frame() const
{
- return getRootMovie()->get_current_frame();
+ return _rootMovie->get_current_frame();
}
void set_background_color(const rgba& color);
void set_background_alpha(float alpha);
- float get_background_alpha() const
- {
- return m_background_color.m_a / 255.0f;
- }
-
/// Return the VM used by this movie_root
VM& getVM() { return _vm; }
@@ -370,13 +372,14 @@
/// Entry point for movie advancement
//
/// This function does:
- /// - Execute all timers
- /// - Reset the next Random number
- /// - Advance all advanceable DisplayObjects in reverse-placement order
- /// - Cleanup key listeners
- /// - Process all queued actions
- /// - Remove unloaded DisplayObjects from the advanceable
DisplayObjects list.
- /// - Run the GC collector
+ /// - Execute all timers
+ /// - Reset the next Random number
+ /// - Advance all advanceable DisplayObjects in reverse-placement order
+ /// - Cleanup key listeners
+ /// - Process all queued actions
+ /// - Remove unloaded DisplayObjects from the advanceable
+ /// DisplayObjects list.
+ /// - Run the GC collector
void advanceMovie();
/// 0-based!! delegates to originating root movie
@@ -384,7 +387,7 @@
/// TODO: drop this method. currently used by gprocessor.
void goto_frame(size_t target_frame_number)
{
- getRootMovie()->goto_frame(target_frame_number);
+ _rootMovie->goto_frame(target_frame_number);
}
void display();
@@ -394,7 +397,7 @@
/// TODO: drop ?
void set_play_state(MovieClip::PlayState s)
{
- getRootMovie()->setPlayState(s);
+ _rootMovie->setPlayState(s);
}
/// Notify still loaded DisplayObject listeners for key events
@@ -1028,7 +1031,7 @@
//
/// We keep a pointer to the base MovieClip class
/// to avoid having to replicate all of the base class
- /// interface to the movie_instance class definition
+ /// interface to the Movie class definition
Levels _movies;
typedef std::map<int, DisplayObject*> Childs;
@@ -1039,7 +1042,7 @@
/// 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_instance> _rootMovie;
+ boost::intrusive_ptr<Movie> _rootMovie;
/// This function should return TRUE iff any action triggered
/// by the event requires redraw, see \ref events_handling for
@@ -1083,11 +1086,11 @@
/// Put the given movie at the given level
//
/// @param movie
- /// The movie_instance to store at the given level.
+ /// 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_instance>
movie);
+ void setLevel(unsigned int num, boost::intrusive_ptr<Movie> movie);
/// Return the global Key object
//
=== modified file 'libcore/parser/BitmapMovieDefinition.cpp'
--- a/libcore/parser/BitmapMovieDefinition.cpp 2009-04-07 12:34:43 +0000
+++ b/libcore/parser/BitmapMovieDefinition.cpp 2009-04-15 05:33:51 +0000
@@ -18,7 +18,7 @@
//
#include "smart_ptr.h" // GNASH_USE_GC
-#include "BitmapMovieInstance.h"
+#include "BitmapMovie.h"
#include "BitmapMovieDefinition.h"
#include "fill_style.h"
#include "Geometry.h" // for class path and class edge
@@ -29,35 +29,33 @@
namespace gnash {
-DisplayObject*
-BitmapMovieDefinition::createDisplayObject(DisplayObject* parent, int id)
+Movie*
+BitmapMovieDefinition::createMovie(DisplayObject* parent)
{
-
// It's possible for this to fail.
if (!_bitmap.get()) return 0;
- if (!_shape.get()) _shape.reset(new DynamicShape);
-
// Set its boundaries
- _shape->setBounds(_framesize);
+ _shape.setBounds(_framesize);
// Add the bitmap fill style (fill style 0)
SWFMatrix mat;
mat.set_scale(1.0/20, 1.0/20); // bitmap fills get SWFMatrix reversed
fill_style bmFill(_bitmap.get(), mat);
- const size_t fillLeft = _shape->add_fill_style(bmFill);
+ const size_t fillLeft = _shape.add_fill_style(bmFill);
// Define a rectangle filled with the bitmap style
// We use one twip for each pixel in the image
// The DisplayObject will be scaled * 20
- // when placed in BitmapMovieInstance's DisplayList
+ // when placed in BitmapMovie's DisplayList
boost::int32_t w = _framesize.width();
boost::int32_t h = _framesize.height();
IF_VERBOSE_PARSE(
- log_parse(_("Creating a shape_definition wrapping a %g x %g
bitmap"), w, h);
+ log_parse(_("Creating a shape_definition wrapping a %g x %g
bitmap"),
+ w, h);
);
Path bmPath(w, h, fillLeft, 0, 0, false);
@@ -68,17 +66,15 @@
// Add the path
- _shape->add_path(bmPath);
+ _shape.add_path(bmPath);
- return new Shape(_shape, parent, id);
+ return new BitmapMovie(this, parent);
}
-BitmapMovieDefinition::BitmapMovieDefinition(
- std::auto_ptr<GnashImage> image,
+BitmapMovieDefinition::BitmapMovieDefinition(std::auto_ptr<GnashImage> image,
const std::string& url)
:
_version(6),
- // GnashImage size is in pixels
_framesize(0, 0, image->width()*20, image->height()*20),
_framecount(1),
_framerate(12),
@@ -86,7 +82,6 @@
_bytesTotal(image->size()),
_bitmap(render::createBitmapInfo(image))
{
- // Do not create DefineShapeTag now (why?)
}
#ifdef GNASH_USE_GC
=== modified file 'libcore/parser/BitmapMovieDefinition.h'
--- a/libcore/parser/BitmapMovieDefinition.h 2009-04-14 07:23:05 +0000
+++ b/libcore/parser/BitmapMovieDefinition.h 2009-04-15 07:01:39 +0000
@@ -21,7 +21,6 @@
#include "smart_ptr.h" // GNASH_USE_GC
#include "movie_definition.h" // for inheritance
#include "rect.h" // for composition
-#include "BitmapMovieInstance.h" // for create_movie_instance
#include "BitmapInfo.h" // for destructor visibility by intrusive_ptr
#include "DynamicShape.h" // for destructor visibility by intrusive_ptr
#include "GnashImage.h"
@@ -37,7 +36,7 @@
/// A "movie" definition for a bitmap file
//
-/// The create_movie_instance function will return a BitmapMovieInstance
+/// The createMovie function will return a BitmapMovie
///
class BitmapMovieDefinition : public movie_definition
{
@@ -58,7 +57,13 @@
BitmapMovieDefinition(std::auto_ptr<GnashImage> image,
const std::string& url);
- virtual DisplayObject* createDisplayObject(DisplayObject*, int);
+ /// This is currently useless
+ //
+ /// TODO: For AVM2, it may be used to create a Bitmap DisplayObject
+ /// instead of a Movie when used from the Loader class.
+ virtual DisplayObject* createDisplayObject(DisplayObject*, int) {
+ return 0;
+ }
virtual int get_version() const {
return _version;
@@ -72,11 +77,11 @@
return std::ceil(twipsToPixels(_framesize.height()));
}
- virtual size_t get_frame_count() const {
+ virtual size_t get_frame_count() const {
return _framecount;
}
- virtual float get_frame_rate() const {
+ virtual float get_frame_rate() const {
return _framerate;
}
@@ -101,11 +106,8 @@
return _bytesTotal;
}
- /// Create a playable movie_instance from this def.
- virtual movie_instance* create_movie_instance(DisplayObject* parent=0)
- {
- return new BitmapMovieInstance(this, parent);
- }
+ /// Create a playable Movie from this def.
+ virtual Movie* createMovie(DisplayObject* parent=0);
virtual const std::string& get_url() const {
return _url;
@@ -120,8 +122,8 @@
return 1;
}
- BitmapInfo* getBitmap() const {
- return _bitmap.get();
+ const DynamicShape& shape() const {
+ return _shape;
}
protected:
@@ -134,7 +136,7 @@
/// - bitmap (_bitmap)
///
void markReachableResources() const;
-#endif // GNASH_USE_GC
+#endif
private:
@@ -148,7 +150,7 @@
boost::intrusive_ptr<BitmapInfo> _bitmap;
- boost::shared_ptr<DynamicShape> _shape;
+ DynamicShape _shape;
};
=== modified file 'libcore/parser/SWFMovieDefinition.cpp'
--- a/libcore/parser/SWFMovieDefinition.cpp 2009-04-09 08:59:49 +0000
+++ b/libcore/parser/SWFMovieDefinition.cpp 2009-04-15 05:33:51 +0000
@@ -25,19 +25,16 @@
#include "smart_ptr.h" // GNASH_USE_GC
#include "SWFMovieDefinition.h"
#include "movie_definition.h" // for inheritance
-#include "MovieClip.h" // for ??
#include "zlib_adapter.h"
#include "IOChannel.h" // for use
#include "SWFStream.h"
#include "GnashImageJpeg.h"
#include "RunInfo.h"
#include "Font.h"
+#include "VM.h"
#include "log.h"
-#include "MovieClip.h"
-#include "movie_instance.h"
+#include "SWFMovie.h"
#include "swf/TagLoadersTable.h"
-#include "movie_root.h"
-#include "VM.h" // for assertions
#include "GnashException.h" // for parser exception
#include "ControlTag.h"
#include "sound_definition.h" // for sound_sample
@@ -187,16 +184,11 @@
SWFMovieDefinition::SWFMovieDefinition(const RunInfo& runInfo)
:
// FIXME: use a class-static TagLoadersTable for SWFMovieDefinition
-#ifdef USE_SWFTREE
- _metadata(),
-#endif
_tag_loaders(SWF::TagLoadersTable::getInstance()),
m_frame_rate(30.0f),
m_frame_count(0u),
m_version(0),
_frames_loaded(0u),
- _frames_loaded_mutex(),
- _frame_reached_condition(),
_waiting_for_frame(0),
m_loading_sound_stream(-1),
m_file_length(0),
@@ -226,7 +218,8 @@
//assert(m_jpeg_in->get() == NULL);
}
-void SWFMovieDefinition::addDisplayObject(int id, SWF::DefinitionTag* c)
+void
+SWFMovieDefinition::addDisplayObject(int id, SWF::DefinitionTag* c)
{
assert(c);
boost::mutex::scoped_lock lock(_dictionaryMutex);
@@ -247,13 +240,15 @@
return ch.get(); // mm... why don't we return the boost::intrusive_ptr?
}
-void SWFMovieDefinition::add_font(int font_id, Font* f)
+void
+SWFMovieDefinition::add_font(int font_id, Font* f)
{
assert(f);
m_fonts.insert(std::make_pair(font_id, boost::intrusive_ptr<Font>(f)));
}
-Font* SWFMovieDefinition::get_font(int font_id) const
+Font*
+SWFMovieDefinition::get_font(int font_id) const
{
FontMap::const_iterator it = m_fonts.find(font_id);
@@ -432,10 +427,6 @@
// should call this only once
assert( ! _loader.started() );
- // The VM is needed by the parser
- // to allocate swf_function objects !
- assert ( VM::isInitialized() );
-
// should call readHeader before this
assert(_str.get());
@@ -467,7 +458,7 @@
// 1-based frame number
bool
-SWFMovieDefinition::ensure_frame_loaded(size_t framenum)
+SWFMovieDefinition::ensure_frame_loaded(size_t framenum) const
{
boost::mutex::scoped_lock lock(_frames_loaded_mutex);
@@ -485,10 +476,10 @@
return ( framenum <= _frames_loaded );
}
-movie_instance*
-SWFMovieDefinition::create_movie_instance(DisplayObject* parent)
+Movie*
+SWFMovieDefinition::createMovie(DisplayObject* parent)
{
- return new movie_instance(this, parent);
+ return new SWFMovie(this, parent);
}
@@ -852,7 +843,7 @@
bool
SWFMovieDefinition::get_labeled_frame(const std::string& label,
- size_t& frame_number)
+ size_t& frame_number) const
{
boost::mutex::scoped_lock lock(_namedFramesMutex);
NamedFrameMap::const_iterator it = _namedFrames.find(label);
=== modified file 'libcore/parser/SWFMovieDefinition.h'
--- a/libcore/parser/SWFMovieDefinition.h 2009-04-14 07:00:59 +0000
+++ b/libcore/parser/SWFMovieDefinition.h 2009-04-15 06:22:17 +0000
@@ -51,7 +51,7 @@
class SWFStream;
class movie_root;
class MovieClip;
- class movie_instance;
+ class SWFMovie;
namespace SWF {
class TagLoadersTable;
}
@@ -172,7 +172,7 @@
/// Immutable definition of a SWF movie's contents.
//
/// It cannot be played directly, and does not hold
-/// current state; for that you need to call create_movie_instance()
+/// current state; for that you need to call createMovie()
/// to get a movie instance
///
class SWFMovieDefinition : public movie_definition
@@ -255,7 +255,8 @@
//
// locks _namedFramesMutex
//
- bool get_labeled_frame(const std::string& label, size_t& frame_number);
+ bool get_labeled_frame(const std::string& label, size_t& frame_number)
+ const;
void add_font(int font_id, Font* f);
@@ -358,7 +359,7 @@
/// Ensure that frame number 'framenum' (1-based offset)
/// has been loaded (load on demand).
///
- bool ensure_frame_loaded(size_t framenum);
+ bool ensure_frame_loaded(size_t framenum) const;
/// Read and parse all the SWF stream (blocking until load is finished)
//
@@ -377,9 +378,9 @@
///
/// TOCHECK:
/// The _root reference of the newly created movie_root
- /// will be set to a newly created movie_instance.
+ /// will be set to a newly created Movie.
///
- movie_instance* create_movie_instance(DisplayObject* parent=0);
+ Movie* createMovie(DisplayObject* parent=0);
virtual DisplayObject* createDisplayObject(DisplayObject*, int) {
return 0;
@@ -469,14 +470,14 @@
mutable boost::mutex _frames_loaded_mutex;
/// A semaphore to signal load of a specific frame
- boost::condition _frame_reached_condition;
+ mutable boost::condition _frame_reached_condition;
/// Set this to trigger signaling of loaded frame
//
/// Make sure you _frames_loaded_mutex is locked
/// when accessing this member !
///
- size_t _waiting_for_frame;
+ mutable size_t _waiting_for_frame;
/// Number bytes loaded / parsed
unsigned long _bytes_loaded;
@@ -568,4 +569,4 @@
} // namespace gnash
-#endif // GNASH_MOVIE_DEF_IMPL_H
+#endif
=== modified file 'libcore/parser/movie_definition.h'
--- a/libcore/parser/movie_definition.h 2009-04-09 08:59:49 +0000
+++ b/libcore/parser/movie_definition.h 2009-04-15 05:33:51 +0000
@@ -23,7 +23,7 @@
/// multiple instances.
///
/// A Movie definition is defined by the gnash::movie_definition class.
-/// A Movie instance is defined by the gnash::movie_instance class.
+/// A Movie instance is defined by the gnash::Movie class.
///
/// A Movie instance exposes the ActionScript
/// Object base interface (gnash::as_object),
@@ -38,7 +38,7 @@
/// SWFMovieDefinition class, being the top-level definition of
/// a movie (the one with a CharacterDictionary in it).
///
-/// Also note that gnash::movie_instance is a subclass of gnash::MovieClip,
+/// Also note that gnash::Movie is a subclass of gnash::MovieClip,
/// being the instance of a gnash::sprite_definition.
///
///
@@ -62,7 +62,7 @@
// Forward declarations
namespace gnash {
class BitmapInfo;
- class movie_instance;
+ class Movie;
class MovieClip;
namespace SWF {
class ControlTag;
@@ -123,18 +123,18 @@
/// Create a movie instance from a def.
//
/// Not all movie definitions allow creation of
- /// movie_instance. In particular, sprite_definition
+ /// Movie. In particular, sprite_definition
/// can only create MovieClip, so will return NULL
/// from this method.
///
/// The default implementation returns NULL.
///
/// Override this method for any definition that is
- /// able to be instanciated as a movie_instance.
+ /// able to be instanciated as a Movie.
/// SWFMovieDefinition is one such example, future examples
/// should include jpeg_movie_def and similar..
///
- virtual movie_instance* create_movie_instance(DisplayObject*
/*parent*/=0)
+ virtual Movie* createMovie(DisplayObject* /*parent*/=0)
{
return NULL;
}
@@ -217,7 +217,8 @@
///
/// @return true if a frame with that label was found, false otherwise
///
- virtual bool get_labeled_frame(const std::string& /*label*/, size_t&
/*frame_number*/)
+ virtual bool get_labeled_frame(const std::string& /*label*/,
+ size_t& /*frame_number*/) const
{
return false;
}
@@ -430,7 +431,7 @@
///
/// The default implementation is to always return true.
///
- virtual bool ensure_frame_loaded(size_t /*framenum*/) {
+ virtual bool ensure_frame_loaded(size_t /*framenum*/) const {
return true;
}
=== modified file 'libcore/parser/sprite_definition.cpp'
--- a/libcore/parser/sprite_definition.cpp 2009-04-06 11:16:20 +0000
+++ b/libcore/parser/sprite_definition.cpp 2009-04-15 06:02:24 +0000
@@ -167,7 +167,7 @@
bool
sprite_definition::get_labeled_frame(const std::string& label,
- size_t& frame_number)
+ size_t& frame_number) const
{
NamedFrameMap::const_iterator it = _namedFrames.find(label);
if ( it == _namedFrames.end() ) return false;
@@ -189,19 +189,6 @@
read(in, runInfo);
}
-sprite_definition::sprite_definition(movie_definition& m)
- :
- // FIXME: use a class-static TagLoadersTable for sprite_definition
- _tag_loaders(SWF::TagLoadersTable::getInstance()),
- m_movie_def(m),
- m_frame_count(1),
- m_loading_frame(1),
- registeredClass(0),
- _loadingSoundStream(-1)
-{
-}
-
-
/*
* This function is not inlined to avoid having to include as_function.h
* from sprite_definition.h. We need as_function.h for visibility of
=== modified file 'libcore/parser/sprite_definition.h'
--- a/libcore/parser/sprite_definition.h 2009-04-14 07:00:59 +0000
+++ b/libcore/parser/sprite_definition.h 2009-04-15 06:02:24 +0000
@@ -66,17 +66,6 @@
sprite_definition(movie_definition& m, SWFStream& in,
const RunInfo& runInfo);
- /// \brief
- /// Create an empty sprite
- //
- /// A sprite definition consists of a series control tags.
- ///
- /// @param m
- /// the Top-Level movie_definition this sprite is read
- /// from (not a sprite_definition!)
- sprite_definition(movie_definition& m);
-
-
/// Destructor, releases playlist data
~sprite_definition();
@@ -93,7 +82,7 @@
void registerClass(as_function* the_class);
/// Get the Class registered to this definition.
- as_function* getRegisteredClass()
+ as_function* getRegisteredClass() const
{
return registeredClass.get();
}
@@ -284,7 +273,8 @@
virtual void add_frame_name(const std::string& name);
// See dox in movie_definition
- bool get_labeled_frame(const std::string& label, size_t& frame_number);
+ bool get_labeled_frame(const std::string& label, size_t& frame_number)
+ const;
/// frame_number is 0-based
const PlayList* getPlaylist(size_t frame_number) const
@@ -307,7 +297,7 @@
/// Ensure framenum frames of this sprite
/// have been loaded.
///
- virtual bool ensure_frame_loaded(size_t framenum)
+ virtual bool ensure_frame_loaded(size_t framenum) const
{
// TODO: return false on timeout
while ( m_loading_frame < framenum )
=== modified file 'libcore/swf/ControlTag.h'
--- a/libcore/swf/ControlTag.h 2009-04-09 11:39:48 +0000
+++ b/libcore/swf/ControlTag.h 2009-04-15 06:41:11 +0000
@@ -15,8 +15,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#ifndef GNASH_EXECUTE_TAG_H
-#define GNASH_EXECUTE_TAG_H
+#ifndef GNASH_CONTROL_TAG_H
+#define GNASH_CONTROL_TAG_H
#include <cassert>
=== modified file 'libcore/swf/DoInitActionTag.h'
--- a/libcore/swf/DoInitActionTag.h 2009-04-03 09:18:40 +0000
+++ b/libcore/swf/DoInitActionTag.h 2009-04-15 06:41:11 +0000
@@ -41,9 +41,9 @@
public:
DoInitActionTag(SWFStream& in, movie_definition& md, int cid)
- :
- _buf(md),
- _cid(cid)
+ :
+ _buf(md),
+ _cid(cid)
{
read(in);
}
=== modified file 'libcore/swf/SetBackgroundColorTag.h'
--- a/libcore/swf/SetBackgroundColorTag.h 2009-03-17 11:39:48 +0000
+++ b/libcore/swf/SetBackgroundColorTag.h 2009-04-14 15:07:44 +0000
@@ -84,10 +84,7 @@
void execute(MovieClip* m, DisplayList& /*dlist*/) const
{
- float current_alpha = m->get_background_alpha();
- rgba newcolor = m_color; // to avoid making m_color mutable
- newcolor.m_a = frnd(current_alpha * 255.0f);
- m->set_background_color(newcolor);
+ m->set_background_color(m_color);
}
void execute_state(MovieClip* m, DisplayList& dlist) const
=== modified file 'libcore/vm/ASHandlers.cpp'
--- a/libcore/vm/ASHandlers.cpp 2009-04-09 11:39:48 +0000
+++ b/libcore/vm/ASHandlers.cpp 2009-04-14 16:13:21 +0000
@@ -75,13 +75,6 @@
#endif
}
-// Define this to have WaitForFrame actions really
-// wait for target frame (and never skip actions)
-// See:
-// http://sswf.sourceforge.net/SWFalexref.html#action_wait_for_frame
-//
-#undef REALLY_WAIT_ON_WAIT_FOR_FRAME
-
namespace gnash {
namespace SWF { // gnash::SWF
@@ -662,10 +655,6 @@
}
// Actually *wait* for target frame, and never skip any action
-#ifdef REALLY_WAIT_ON_WAIT_FOR_FRAME
- target_sprite->get_movie_definition()->ensure_frame_loaded(framenum);
- assert(target_sprite->get_loaded_frames() >= framenum);
-#endif
size_t lastloaded = target_sprite->get_loaded_frames();
if ( lastloaded < framenum )
@@ -1985,11 +1974,6 @@
return;
}
-#ifdef REALLY_WAIT_ON_WAIT_FOR_FRAME
- target_sprite->get_movie_definition()->ensure_frame_loaded(framenum);
- assert(target_sprite->get_loaded_frames() >= framenum);
-#endif
-
size_t lastloaded = target_sprite->get_loaded_frames();
if ( lastloaded < framenum )
{
=== modified file 'libcore/vm/VM.cpp'
--- a/libcore/vm/VM.cpp 2009-02-26 18:48:57 +0000
+++ b/libcore/vm/VM.cpp 2009-04-14 17:49:58 +0000
@@ -26,7 +26,7 @@
#include "smart_ptr.h" // GNASH_USE_GC
#include "builtin_function.h"
#include "movie_definition.h"
-#include "movie_instance.h"
+#include "Movie.h"
#include "movie_root.h"
#include "Global.h"
#include "rc.h" //for overriding default version string with rcfile
=== modified file 'plugin/win32/plugin.cpp'
--- a/plugin/win32/plugin.cpp 2009-02-25 22:33:03 +0000
+++ b/plugin/win32/plugin.cpp 2009-04-15 05:33:51 +0000
@@ -480,12 +480,12 @@
md->completeLoad();
DBG("Movie loaded.\n");
- std::auto_ptr<gnash::movie_instance> mr(md->create_movie_instance());
+ std::auto_ptr<gnash::Movie> mr(md->createMovie());
mr->setVariables(_flashVars);
root.setRootMovie(mr.release());
root.set_display_viewport(0, 0, _width, _height);
root.set_background_alpha(1.0f);
- gnash::movie_instance* mi = root.getRootMovie();
+ gnash::Movie* mi = root.getRootMovie();
DBG("Movie instance created.\n");
ShowWindow(_window, SW_SHOW);
=== modified file 'pythonmodule/gnashpython.cpp'
--- a/pythonmodule/gnashpython.cpp 2009-04-06 10:16:59 +0000
+++ b/pythonmodule/gnashpython.cpp 2009-04-15 05:33:51 +0000
@@ -21,7 +21,7 @@
#include "URL.h"
#include "noseek_fd_adapter.h"
#include "movie_definition.h"
-#include "movie_instance.h"
+#include "Movie.h"
#include "movie_root.h"
#include "MovieClip.h"
#include "gnash.h"
@@ -186,7 +186,7 @@
_movieDef->completeLoad();
_movieDef->ensure_frame_loaded(_movieDef->get_frame_count());
- std::auto_ptr<movie_instance> mi ( _movieDef->create_movie_instance() );
+ std::auto_ptr<Movie> mi ( _movieDef->createMovie() );
// Finally, place the root movie on the stage ...
_movieRoot->setRootMovie( mi.release() );
=== modified file 'pythonmodule/gnashpython.h'
--- a/pythonmodule/gnashpython.h 2009-04-06 10:16:59 +0000
+++ b/pythonmodule/gnashpython.h 2009-04-15 05:33:51 +0000
@@ -183,7 +183,7 @@
boost::uint32_t width() { return _character->get_width(); }
- bool visible() { return _character->isVisible(); }
+ bool visible() { return _character->visible(); }
void advance() { _character->advance(); }
=== modified file 'testsuite/DummyCharacter.h'
--- a/testsuite/DummyCharacter.h 2009-04-04 15:35:18 +0000
+++ b/testsuite/DummyCharacter.h 2009-04-15 05:33:51 +0000
@@ -20,7 +20,7 @@
#include "InteractiveObject.h" // for inheritance
#include "rect.h" // for composition
-#include "movie_instance.h" // for create_movie_instance
+#include "Movie.h" // for createMovie
#include "snappingrange.h" // for InvalidatedRanges typedef (don't like it)
#include <string>
=== modified file 'testsuite/DummyMovieDefinition.h'
--- a/testsuite/DummyMovieDefinition.h 2009-04-14 07:24:33 +0000
+++ b/testsuite/DummyMovieDefinition.h 2009-04-15 05:33:51 +0000
@@ -18,9 +18,9 @@
#ifndef GNASH_DUMMYMOVIEDEFINITION_H
#define GNASH_DUMMYMOVIEDEFINITION_H
-#include "movie_definition.h" // for inheritance
+#include "SWFMovieDefinition.h" // for inheritance
#include "rect.h" // for composition
-#include "movie_instance.h" // for create_movie_instance
+#include "SWFMovie.h" // for createMovie
#include <string>
#include <memory> // for auto_ptr
@@ -35,11 +35,11 @@
/// methods of movie_definition by returning user-defined
/// values for version/size/frame rate etc..
///
-/// The create_movie_instance function will return the same
+/// The createMovie function will return the same
/// object created by createEmptyMovieClip() calls
/// (an empty movieclip... still to be designed)
///
-class DummyMovieDefinition : public movie_definition
+class DummyMovieDefinition : public SWFMovieDefinition
{
int _version;
rect _framesize;
@@ -50,7 +50,7 @@
public:
- virtual DisplayObject* createDisplayObject(DisplayObject*, int /* id
*/) { return 0; }
+ virtual DisplayObject* createDisplayObject(DisplayObject*, int /* id */) {
return 0; }
/// Default constructor
@@ -64,8 +64,9 @@
/// - 0 bytes (for get_bytes_loaded()/get_bytes_total())
/// - empty url
///
- DummyMovieDefinition()
+ DummyMovieDefinition(const RunInfo& ri)
:
+ SWFMovieDefinition(ri),
_version(6),
_framesize(0, 0, 640*20, 480*20),
_framecount(1),
@@ -81,8 +82,9 @@
/// All but the target version will be initialized
/// exactly as with the default constructor.
///
- DummyMovieDefinition(int version)
+ DummyMovieDefinition(const RunInfo& ri, int version)
:
+ SWFMovieDefinition(ri),
_version(version),
_framesize(0, 0, 640*20, 480*20),
_framecount(1),
@@ -92,6 +94,10 @@
{
}
+ virtual bool ensure_frame_loaded(size_t) const {
+ return true;
+ }
+
virtual int get_version() const {
return _version;
}
@@ -125,9 +131,9 @@
}
/// Create a playable movie instance from a def.
- virtual movie_instance* create_movie_instance(DisplayObject*
parent=NULL)
+ virtual Movie* createMovie(DisplayObject* parent=NULL)
{
- return new movie_instance(this, parent);
+ return new SWFMovie(this, parent);
}
virtual const PlayList& get_playlist(size_t frame_number) const
=== modified file 'testsuite/MovieTester.cpp'
--- a/testsuite/MovieTester.cpp 2009-04-04 10:37:03 +0000
+++ b/testsuite/MovieTester.cpp 2009-04-15 05:33:51 +0000
@@ -23,7 +23,7 @@
#include "URL.h"
#include "noseek_fd_adapter.h"
#include "movie_definition.h"
-#include "movie_instance.h"
+#include "Movie.h"
#include "movie_root.h"
#include "MovieClip.h"
#include "gnash.h" // for create_movie and create_library_movie and for
gnash::key namespace
@@ -143,7 +143,7 @@
dbglogfile.setVerbosity(1);
- std::auto_ptr<movie_instance> mi ( _movie_def->create_movie_instance()
);
+ std::auto_ptr<Movie> mi ( _movie_def->createMovie() );
// Set _movie before calling ::render
_movie = mi.get();
@@ -613,7 +613,7 @@
MovieTester::restart()
{
_movie_root->clear(); // restart();
- _movie = _movie_def->create_movie_instance();
+ _movie = _movie_def->createMovie();
_movie_root->setRootMovie(_movie);
// Set _movie before calling ::render
=== modified file 'testsuite/MovieTester.h'
--- a/testsuite/MovieTester.h 2009-04-03 09:18:40 +0000
+++ b/testsuite/MovieTester.h 2009-04-14 17:49:58 +0000
@@ -29,7 +29,7 @@
#include "GnashKey.h"
#include "sound_handler.h" // for creating the "test" sound handlers
#include "render_handler.h" // for dtor visibility by auto_ptr
-#include "movie_instance.h"
+#include "Movie.h"
#include "ManualClock.h" // for composition
#include "RunInfo.h" // For initialization.
@@ -317,7 +317,7 @@
gnash::movie_definition* _movie_def;
- gnash::movie_instance* _movie;
+ gnash::Movie* _movie;
boost::shared_ptr<sound::sound_handler> _sound_handler;
=== modified file 'testsuite/libcore.all/AsValueTest.cpp'
--- a/testsuite/libcore.all/AsValueTest.cpp 2009-03-17 12:32:36 +0000
+++ b/testsuite/libcore.all/AsValueTest.cpp 2009-04-15 05:33:51 +0000
@@ -105,15 +105,18 @@
// Initialize gnash lib
gnashInit();
+
+ RunInfo runInfo("");
// Create a bogus movie with swf version 7 support
- boost::intrusive_ptr<movie_definition> md ( new DummyMovieDefinition(7) );
+ boost::intrusive_ptr<movie_definition> md(
+ new DummyMovieDefinition(runInfo, 7));
+
ManualClock clock;
- RunInfo runInfo("");
movie_root stage(*md, clock, runInfo);
- movie_instance* root = md->create_movie_instance();
+ Movie* root = md->createMovie();
stage.setRootMovie(root);
// run the tests
=== modified file 'testsuite/libcore.all/ClassSizes.cpp'
--- a/testsuite/libcore.all/ClassSizes.cpp 2009-04-09 12:45:20 +0000
+++ b/testsuite/libcore.all/ClassSizes.cpp 2009-04-14 17:49:58 +0000
@@ -79,7 +79,7 @@
(DefinitionTag) (DefineTextTag) (DefineFontTag) (DefineMorphShapeTag) \
(as_object) \
(DisplayObject) (StaticText) (MorphShape) (Shape) \
-(InteractiveObject) (MovieClip) (TextField) (Button) (movie_instance) \
+(InteractiveObject) (MovieClip) (TextField) (Button) (Movie) \
(movie_root)
int
=== modified file 'testsuite/libcore.all/DisplayListTest.cpp'
--- a/testsuite/libcore.all/DisplayListTest.cpp 2009-04-03 09:48:13 +0000
+++ b/testsuite/libcore.all/DisplayListTest.cpp 2009-04-15 05:33:51 +0000
@@ -47,16 +47,17 @@
// Initialize gnash lib
gnashInit();
+
+ RunInfo ri("");
// Initialize a VM
- boost::intrusive_ptr<movie_definition> md5 ( new
DummyMovieDefinition(5) );
- boost::intrusive_ptr<movie_definition> md6 ( new
DummyMovieDefinition(6) );
+ boost::intrusive_ptr<movie_definition> md5(new DummyMovieDefinition(ri,
5));
+ boost::intrusive_ptr<movie_definition> md6(new DummyMovieDefinition(ri,
6));
ManualClock clock;
- RunInfo ri("");
movie_root stage(*md5, clock, ri);
- movie_instance* root = md5->create_movie_instance();
+ Movie* root = md5->createMovie();
stage.setRootMovie( root );
DisplayList dlist1;
=== modified file 'testsuite/libcore.all/PropertyListTest.cpp'
--- a/testsuite/libcore.all/PropertyListTest.cpp 2009-02-25 22:33:03
+0000
+++ b/testsuite/libcore.all/PropertyListTest.cpp 2009-04-15 05:33:51
+0000
@@ -53,18 +53,21 @@
// Initialize gnash lib
gnashInit();
- boost::intrusive_ptr<movie_definition> md5 ( new
DummyMovieDefinition(5) );
- boost::intrusive_ptr<movie_definition> md7 ( new
DummyMovieDefinition(7) );
+ // We don't care about the base URL.
+ RunInfo runInfo("");
+
+ boost::intrusive_ptr<movie_definition> md5(
+ new DummyMovieDefinition(runInfo, 5));
+ boost::intrusive_ptr<movie_definition> md7(
+ new DummyMovieDefinition(runInfo, 7));
// TODO: test both SWF5 and SWF7 as they are different !!
ManualClock clock;
- // We don't care about the base URL.
- RunInfo runInfo("");
movie_root root(*md5, clock, runInfo);
- root.setRootMovie( md5->create_movie_instance() );
+ root.setRootMovie( md5->createMovie() );
VM& vm = root.getVM();
=== modified file 'testsuite/misc-ming.all/RollOverOutTest-Runner.cpp'
--- a/testsuite/misc-ming.all/RollOverOutTest-Runner.cpp 2009-04-09
11:41:59 +0000
+++ b/testsuite/misc-ming.all/RollOverOutTest-Runner.cpp 2009-04-15
05:33:51 +0000
@@ -56,8 +56,8 @@
const DisplayObject* mc2 = tester.findDisplayItemByName(*root,
"square2");
check(mc2);
- check_equals(mc1->isVisible(), true);
- check_equals(mc2->isVisible(), false);
+ check_equals(mc1->visible(), true);
+ check_equals(mc2->visible(), false);
check_equals(root->getPlayState(), MovieClip::PLAYSTATE_STOP);
check_equals(root->get_current_frame(), 1);
=== modified file 'testsuite/misc-ming.all/loadMovieTestRunner.cpp'
--- a/testsuite/misc-ming.all/loadMovieTestRunner.cpp 2009-04-03 09:29:19
+0000
+++ b/testsuite/misc-ming.all/loadMovieTestRunner.cpp 2009-04-14 13:14:27
+0000
@@ -106,8 +106,8 @@
DisplayObject* coverartch =
const_cast<DisplayObject*>(tester->findDisplayItemByName(*root, "coverart"));
MovieClip* coverart = coverartch->to_movie();
check(coverart);
- url = coverart->get_movie_definition()->get_url();
- check_equals(coverart->get_movie_definition()->get_url(),
baseURL.str());
+ url = coverart->get_root()->url();
+ check_equals(coverart->get_root()->url(), baseURL.str());
// Check scribbling on the empty canvas
checkScribbling();
@@ -121,7 +121,7 @@
coverartch =
const_cast<DisplayObject*>(tester->findDisplayItemByName(*root, "coverart"));
check(coverart != coverartch->to_movie());
coverart = coverartch->to_movie();
- check_equals(coverart->get_movie_definition()->get_url(),
lynchURL.str());
+ check_equals(coverart->get_root()->url(), lynchURL.str());
tester->depressMouseButton();
// Check scribbling on the lynch
@@ -139,7 +139,7 @@
usleep(500); // give it some time... TODO: drop this test and use a
self-containment instead
coverartch =
const_cast<DisplayObject*>(tester->findDisplayItemByName(*root, "coverart"));
coverart = coverartch->to_movie();
- check_equals(coverart->get_movie_definition()->get_url(),
greenURL.str());
+ check_equals(coverart->get_root()->url(), greenURL.str());
// TODO: find a way to test if the jpeg is really displayed
// (like turn it into a mouse-event-handling char and use
isMouseOverActiveEntity ?)
@@ -158,7 +158,7 @@
usleep(500); // give it some time... TODO: drop this test and use a
self-containment instead
coverartch =
const_cast<DisplayObject*>(tester->findDisplayItemByName(*root, "coverart"));
coverart = coverartch->to_movie();
- check_equals(coverart->get_movie_definition()->get_url(),
offspringURL.str());
+ check_equals(coverart->get_root()->url(), offspringURL.str());
// Check scribbling on the offspring
checkScribbling();
=== modified file 'utilities/processor.cpp'
--- a/utilities/processor.cpp 2009-04-09 11:39:48 +0000
+++ b/utilities/processor.cpp 2009-04-15 05:33:51 +0000
@@ -464,7 +464,7 @@
md->completeLoad();
- std::auto_ptr<movie_instance> mi ( md->create_movie_instance() );
+ std::auto_ptr<Movie> mi ( md->createMovie() );
m.setRootMovie( mi.release() );
if ( quitrequested ) // setRootMovie would execute actions in first frame
- [Gnash-commit] /srv/bzr/gnash/trunk r10790: Rationalize top-level movie loading.,
Benjamin Wolsey <=