CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/05/21 11:11:40
Modified files:
. : ChangeLog
server/parser : Makefile.am movie_def_impl.cpp movie_def_impl.h
movie_definition.h sprite_definition.cpp
sprite_definition.h
server/swf : tag_loaders.cpp
Added files:
server/parser : Timeline.h
Log message:
* server/parser/: Makefile.am, Timeline.h: new class for
timeline control.
* server/parser/: movie_definition.h, movie_def_impl.{cpp,h},
sprite_definition.{cpp,h}: new addTimelineDepth() and
removeTimelineDepth() interfaces in base class, implementation
in subclasses.
* server/swf/tag_loaders.cpp (remove_object2_tag): add getDepth()
method; call movie_definition::addTimelineDepth when a
PlaceObject
tag is parsed and movie_definition::removeTimelineDepth when
a RemoveObject is parsed.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3293&r2=1.3294
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/Makefile.am?cvsroot=gnash&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.cpp?cvsroot=gnash&r1=1.70&r2=1.71
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.h?cvsroot=gnash&r1=1.39&r2=1.40
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_definition.h?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/sprite_definition.cpp?cvsroot=gnash&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/sprite_definition.h?cvsroot=gnash&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/Timeline.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/tag_loaders.cpp?cvsroot=gnash&r1=1.103&r2=1.104
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3293
retrieving revision 1.3294
diff -u -b -r1.3293 -r1.3294
--- ChangeLog 21 May 2007 11:05:11 -0000 1.3293
+++ ChangeLog 21 May 2007 11:11:38 -0000 1.3294
@@ -1,5 +1,15 @@
2007-05-21 Sandro Santilli <address@hidden>
+ * server/parser/: Makefile.am, Timeline.h: new class for
+ timeline control.
+ * server/parser/: movie_definition.h, movie_def_impl.{cpp,h},
+ sprite_definition.{cpp,h}: new addTimelineDepth() and
+ removeTimelineDepth() interfaces in base class, implementation
+ in subclasses.
+ * server/swf/tag_loaders.cpp (remove_object2_tag): add getDepth()
+ method; call movie_definition::addTimelineDepth when a PlaceObject
+ tag is parsed and movie_definition::removeTimelineDepth when
+ a RemoveObject is parsed.
* server/swf/PlaceObject2Tag.h: add getDepth() method, more dox
and 3 new inspectors to know wheter it's a place, replace or move
tag.
Index: server/parser/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/server/parser/Makefile.am,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- server/parser/Makefile.am 4 May 2007 09:40:25 -0000 1.32
+++ server/parser/Makefile.am 21 May 2007 11:11:39 -0000 1.33
@@ -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
-# $Id: Makefile.am,v 1.32 2007/05/04 09:40:25 strk Exp $
+# $Id: Makefile.am,v 1.33 2007/05/21 11:11:39 strk Exp $
AUTOMAKE_OPTIONS =
@@ -60,6 +60,7 @@
video_stream_def.cpp
noinst_HEADERS = \
+ Timeline.h \
action_buffer.h \
button_character_def.h \
character_def.h \
Index: server/parser/movie_def_impl.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.cpp,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -b -r1.70 -r1.71
--- server/parser/movie_def_impl.cpp 14 May 2007 21:57:52 -0000 1.70
+++ server/parser/movie_def_impl.cpp 21 May 2007 11:11:39 -0000 1.71
@@ -949,6 +949,10 @@
boost::mutex::scoped_lock lock(_frames_loaded_mutex);
++_frames_loaded;
+
+ // Close current frame definition in Timeline object
+ _timeline.closeFrame();
+
if ( _frames_loaded > m_frame_count )
{
IF_VERBOSE_MALFORMED_SWF(
Index: server/parser/movie_def_impl.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- server/parser/movie_def_impl.h 14 Apr 2007 15:53:18 -0000 1.39
+++ server/parser/movie_def_impl.h 21 May 2007 11:11:39 -0000 1.40
@@ -31,6 +31,7 @@
#include "bitmap_character_def.h" // for boost::intrusive_ptr visibility of
dtor
#include "resource.h" // for boost::intrusive_ptr visibility of dtor
#include "stream.h" // for get_bytes_loaded
+#include "Timeline.h" // for composition
#include <map> // for CharacterDictionary
#include <string>
@@ -296,6 +297,12 @@
_bytes_loaded=bytes;
}
+ /// Timeline depth info
+ //
+ /// TODO: move to base class ?
+ ///
+ Timeline _timeline;
+
public:
movie_def_impl(create_bitmaps_flag cbf, create_font_shapes_flag cfs);
@@ -590,6 +597,24 @@
return unused;
}
+ // See dox in base class
+ //
+ // TODO: implement in base class ?
+ //
+ void addTimelineDepth(int depth)
+ {
+ _timeline.addDepth(depth);
+ }
+
+ // See dox in base class
+ //
+ // TODO: implement in base class ?
+ //
+ void removeTimelineDepth(int depth)
+ {
+ _timeline.removeDepth(depth);
+ }
+
};
} // namespace gnash
Index: server/parser/movie_definition.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_definition.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- server/parser/movie_definition.h 10 Apr 2007 15:48:39 -0000 1.20
+++ server/parser/movie_definition.h 21 May 2007 11:11:39 -0000 1.21
@@ -555,6 +555,35 @@
virtual void load_next_frame_chunk()
{
}
+
+ /// Add a depth to the timeline depth set in current frame
+ //
+ /// The default implementations is a no-op
+ ///
+ /// It is overridden by timeline-equipped definitions:
+ /// - sprite_definition
+ /// - movie_def_impl
+ ///
+ /// @param depth
+ /// Depth of an instance placed by PlaceObject* tag.
+ /// Assumed to be in the static zone (an assertion would fail
otherwise).
+ ///
+ virtual void addTimelineDepth(int /*depth*/) {}
+
+ /// Remove a depth from the timeline depth set in current frame
+ //
+ /// The default implementations is a no-op
+ ///
+ /// It is overridden by timeline-equipped definitions:
+ /// - sprite_definition
+ /// - movie_def_impl
+ ///
+ /// @param depth
+ /// Depth of an instance placed by PlaceObject* tag.
+ /// Assumed to be in the static zone (an assertion would fail
otherwise).
+ ///
+ virtual void removeTimelineDepth(int /*depth*/) {}
+
};
} // namespace gnash
Index: server/parser/sprite_definition.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/sprite_definition.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- server/parser/sprite_definition.cpp 28 Apr 2007 00:04:26 -0000 1.14
+++ server/parser/sprite_definition.cpp 21 May 2007 11:11:39 -0000 1.15
@@ -101,6 +101,10 @@
// show frame tag -- advance to the next frame.
++m_loading_frame;
+ // Close current frame definition in Timeline object
+ _timeline.closeFrame();
+
+
IF_VERBOSE_PARSE (
log_parse(_(" show_frame "
SIZET_FMT "/" SIZET_FMT
Index: server/parser/sprite_definition.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/sprite_definition.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- server/parser/sprite_definition.h 18 Apr 2007 14:07:32 -0000 1.17
+++ server/parser/sprite_definition.h 21 May 2007 11:11:39 -0000 1.18
@@ -30,6 +30,7 @@
#include "stream.h"
#include "log.h"
#include "rect.h"
+#include "Timeline.h" // for composition
namespace gnash
{
@@ -81,6 +82,24 @@
return registeredClass.get();
}
+ // See dox in base class
+ //
+ // TODO: implement in base class ?
+ //
+ void addTimelineDepth(int depth)
+ {
+ _timeline.addDepth(depth);
+ }
+
+ // See dox in base class
+ //
+ // TODO: implement in base class ?
+ //
+ void removeTimelineDepth(int depth)
+ {
+ _timeline.removeDepth(depth);
+ }
+
private:
void read(stream* in);
@@ -351,6 +370,12 @@
///
boost::intrusive_ptr<as_function> registeredClass;
+ /// Timeline depth info
+ //
+ /// TODO: move to base class ?
+ ///
+ Timeline _timeline;
+
};
Index: server/swf/tag_loaders.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/tag_loaders.cpp,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -b -r1.103 -r1.104
--- server/swf/tag_loaders.cpp 18 May 2007 15:39:51 -0000 1.103
+++ server/swf/tag_loaders.cpp 21 May 2007 11:11:39 -0000 1.104
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: tag_loaders.cpp,v 1.103 2007/05/18 15:39:51 martinwguy Exp $ */
+/* $Id: tag_loaders.cpp,v 1.104 2007/05/21 11:11:39 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -787,6 +787,7 @@
ch->read(in, tag, m->get_version());
m->add_execute_tag(ch);
+ m->addTimelineDepth(ch->getDepth());
}
// Create and initialize a sprite, and add it to the movie.
@@ -834,6 +835,10 @@
/// SWF Tag RemoveObject2 (28)
+//
+/// TODO: move in a separate file, like it was done
+/// for PlaceObject2Tag.
+///
class remove_object_2 : public execute_tag
{
public:
@@ -854,17 +859,27 @@
m_depth = in->read_u16()+character::staticDepthOffset;
}
+ // TODO: be non-virtual if no allowing sublcassing this class
virtual void execute(sprite_instance* m)
{
m->remove_display_object(m_depth, m_id);
}
+ // TODO: be non-virtual if no allowing sublcassing this class
virtual void execute_state(sprite_instance* m)
{
execute(m);
}
+ // TODO: be non-virtual if no allowing sublcassing this class
virtual bool is_remove_tag() const { return true; }
+
+ /// Return the depth affected by this RemoveObject tag
+ //
+ /// NOTE: the returned depth is always in the
+ /// static depth zone (character::staticDepthOffset .. -1)
+ ///
+ int getDepth() const { return m_depth; }
};
@@ -881,6 +896,7 @@
);
m->add_execute_tag(t);
+ m->removeTimelineDepth(t->getDepth());
}
Index: server/parser/Timeline.h
===================================================================
RCS file: server/parser/Timeline.h
diff -N server/parser/Timeline.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ server/parser/Timeline.h 21 May 2007 11:11:39 -0000 1.1
@@ -0,0 +1,210 @@
+// Timeline.h: Holds immutable data for a sprite/movie timeline, for Gnash.
+//
+// Copyright (C) 2007 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#ifndef GNASH_TIMELINE_H
+#define GNASH_TIMELINE_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <vector>
+#include <set>
+#include <boost/thread/mutex.hpp>
+
+namespace gnash
+{
+
+
+/// \brief
+/// Holds the immutable data for a sprite/move timeline, as read from
+/// as SWF stream.
+//
+/// Timeline data consists in a set of depths supposed to contain an instance
+/// for each frame in the sprite/movie.
+///
+/// This information is extracted while parsing the SWF so it might be
+/// incomplete for a frame until parsing of that frame completes.
+///
+/// Multiple threads can use instances of this class.
+/// In particular, the loader/parser thread will use the mutators and the movie
+/// advancement/actions executors thread will use the inspectors.
+/// For this reason access to the data is mutex-protected. Locking info are
+/// specified for each locking function.
+///
+class Timeline
+{
+
+public:
+
+ /// Construct a Timeline instance
+ Timeline()
+ {
+ _frameDepths.push_back(DepthSet());
+ }
+
+ /// Destroy a Timeline instance
+ ~Timeline() {}
+
+ /// \brief
+ /// Reserve memory for up to the given number
+ /// of frames.
+ //
+ /// You don't need to call this function except
+ /// for improving performance when number of frames
+ /// is known in advance. This is expected in well-formed
+ /// SWF streams.
+ ///
+ /// Locks the mutex
+ /// (likely superfluos, as tipically called right after creation)
+ ///
+ void reserve(size_t nframes)
+ {
+ boost::mutex::scoped_lock lock(_frameDepthsMutex);
+
+ // reserve one more element for the end sentinel
+ _frameDepths.reserve(nframes+1);
+ }
+
+ /// \brief
+ /// Close data for current frame and move cursor to next one,
+ /// allocating it if needed
+ //
+ /// Locks the mutex to avoid race conditions in which the parser
+ /// is closing a frame and the VM is inspecting a frame (either the
+ /// same or a different one). See getDepths().
+ ///
+ void closeFrame()
+ {
+ boost::mutex::scoped_lock lock(_frameDepthsMutex);
+
+ // Copy depth set from previous frame
+ _frameDepths.push_back(_frameDepths.back());
+ }
+
+ /// Add a timeline depth to the current frame
+ //
+ /// Does NOT lock the mutex as this function is intended to be
+ /// called by a single thread (the loader/parser).
+ ///
+ /// @param depth
+ /// Depth of an instance placed by PlaceObject* tag.
+ /// Assumed to be in the static zone (an assertion would fail
otherwise).
+ ///
+ void addDepth(int depth)
+ {
+ assert(depth < 0 && depth >= -16384); // or should be > -16384
(not ==?)
+
+ _frameDepths.back().insert(depth);
+ }
+
+ /// Remove a timeline depth from the current frame
+ //
+ /// Does NOT lock the mutex as this function is intended to be
+ /// called by a single thread (the loader/parser).
+ ///
+ /// @param depth
+ /// Depth of an instance removed by RemoveObject* tag, or by
PlaceObject* tag
+ /// with replace/move semantic.
+ /// Assumed to be in the static zone (an assertion would fail
otherwise).
+ ///
+ void removeDepth(int depth)
+ {
+ assert(depth < 0 && depth >= -16384); // or should be > -16384
(not ==?)
+
+ _frameDepths.back().erase(depth);
+ }
+
+ /// \brief
+ /// Get the set of timeline depths supposed to contain
+ /// an instance in the given frame (0-based)
+ //
+ /// PRECONDITIONS:
+ /// - Definition for target frame was completed.
+ /// See closeFrame().
+ ///
+ /// Locks the mutex to avoid race conditions in which the parser
+ /// is closing a frame and the VM is inspecting a frame (either the
+ /// same or a different one). See closeFrame().
+ ///
+ /// @param frameno
+ /// 0-based frame number we want to inspect.
+ /// Assumed to be in the static zone (an assertion would fail
otherwise).
+ ///
+ /// @param depths
+ /// A vector to copy all frame depths to.
+ /// The depths are copied to both provide thread-safety
+ /// and to allow future optimization of memory.
+ /// In particular we might construct frame depths on demand, by
+ /// scanning a list of insertion/deletion events, rather then
+ /// keeping a set of depths for *each* frame.
+ ///
+ ///
+ ///
+ void getFrameDepths(size_t frameno, std::vector<int> depths)
+ {
+ assert(frameno < _frameDepths.size());
+
+ depths.assign(_frameDepths[frameno].begin(),
_frameDepths[frameno].end());
+ }
+
+private:
+
+ /// A set of depths in the static zone
+ typedef std::set<int> DepthSet;
+
+ /// A vector of depth sets (one for each frame)
+ typedef std::vector<DepthSet> FrameDepths;
+
+ /// Return the number of frames completely defined
+ //
+ /// Doesn't lock the mutex.
+ ///
+ size_t closedFrames() const
+ {
+ assert(!_frameDepths.empty());
+ return _frameDepths.size()-1;
+ }
+
+ /// Return the 0-based index of the frame currently being defined
+ //
+ /// Doesn't lock the mutex.
+ ///
+ size_t currentFrame() const
+ {
+ return _frameDepths.size()-1;
+ }
+
+
+ /// A set of depth for each frame
+ //
+ /// Access to this container is mutex-protected
+ /// for thread safety. See _frameDepthsMutex.
+ ///
+ FrameDepths _frameDepths;
+
+ /// Mutex protecting access to the _frameDepths member
+ boost::mutex _frameDepthsMutex;
+
+};
+
+
+} // end of namespace gnash
+
+#endif // GNASH_SPRITE_H
_______________________________________________
Gnash-commit mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/gnash-commit