[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r12292: Cleanups, simplification and
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r12292: Cleanups, simplification and rationalization of DisplayObjects and movie_root. |
Date: |
Sat, 10 Jul 2010 18:48:34 +0200 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 12292 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Sat 2010-07-10 18:48:34 +0200
message:
Cleanups, simplification and rationalization of DisplayObjects and movie_root.
modified:
libcore/DisplayObject.cpp
libcore/DisplayObject.h
libcore/MovieClip.cpp
libcore/MovieClip.h
libcore/TextField.cpp
libcore/Video.cpp
libcore/Video.h
libcore/movie_root.cpp
libcore/movie_root.h
libcore/vm/ActionExec.cpp
libcore/vm/with_stack_entry.h
=== modified file 'libcore/DisplayObject.cpp'
--- a/libcore/DisplayObject.cpp 2010-07-10 09:22:06 +0000
+++ b/libcore/DisplayObject.cpp 2010-07-10 14:03:14 +0000
@@ -760,7 +760,7 @@
//
/// This depends on the useHandCursor AS property, but:
/// 1. Only AS-referenceable objects may use a hand cursor (TODO: check
-/// Video).
+/// Video).
/// 2. Only objects with a release event may use a hand cursor.
/// 3. The default value (if the property is not defined) is true.
bool
@@ -771,10 +771,7 @@
if (!hasEventHandler(event_id::RELEASE)) return false;
as_value val;
- // const_cast needed due to get_member being non-const due to the
- // possibility that a getter-setter would actually modify us ...
- if (!getObject(const_cast<DisplayObject*>(this))->get_member(
- NSV::PROP_USEHANDCURSOR, &val)) {
+ if (!getObject(this)->get_member(NSV::PROP_USEHANDCURSOR, &val)) {
return true;
}
return val.to_bool();
=== modified file 'libcore/DisplayObject.h'
--- a/libcore/DisplayObject.h 2010-07-05 08:32:15 +0000
+++ b/libcore/DisplayObject.h 2010-07-10 13:40:04 +0000
@@ -249,13 +249,13 @@
int get_depth() const { return _depth; }
- void set_depth(int d) { _depth = d; }
+ void set_depth(int d) { _depth = d; }
/// Get sound volume for this DisplayObject
int getVolume() const { return _volume; }
/// Set sound volume for this DisplayObject
- void setVolume(int vol) { _volume=vol; }
+ void setVolume(int vol) { _volume = vol; }
/// Get concatenated sound volume for this DisplayObject
//
@@ -281,7 +281,7 @@
/// @param updateCache if true, updates the cache values
/// from the SWFMatrix (only if SWFMatrix != current SWFMatrix)
///
- void setMatrix(const SWFMatrix& m, bool updateCache=false);
+ void setMatrix(const SWFMatrix& m, bool updateCache = false);
/// Set the xscale value of current SWFMatrix
//
@@ -339,12 +339,6 @@
}
}
- void concatenate_cxform(const cxform& cx) {
- m_color_transform.concatenate(cx);
- }
-
- void concatenateMatrix(const SWFMatrix& m) { m_matrix.concatenate(m); }
-
int get_ratio() const { return m_ratio; }
void set_ratio(int r)
@@ -413,13 +407,6 @@
///
void setMask(DisplayObject* mask);
- /// Returns true if this DisplayObject is a mask (either layer or
- /// dynamic mask)
- bool isMask() const
- {
- return isDynamicMask() || isMaskLayer();
- }
-
/// Set DisplayObject name, initializing the original target member
void set_name(string_table::key name) {
_name = name;
@@ -529,8 +516,8 @@
///
virtual bool pointInVisibleShape(boost::int32_t x, boost::int32_t y) const
{
- if ( ! visible() ) return false;
- if ( isMask() ) return false;
+ if (!visible()) return false;
+ if (isDynamicMask() || isMaskLayer()) return false;
return pointInShape(x, y);
}
@@ -575,18 +562,6 @@
///
virtual as_object* pathElement(string_table::key key);
- /// Advance this DisplayObject to next frame.
- //
- /// Character advancement is only meaningful for sprites
- /// and sprite containers (button DisplayObjects) because
- /// sprites are the only DisplayObjects that have frames.
- ///
- /// Frame advancement include execution of all control tags.
- ///
- virtual void advance()
- {
- }
-
/// \brief
/// Return true if PlaceObjects tag are allowed to move
/// this DisplayObject.
=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp 2010-07-09 07:24:43 +0000
+++ b/libcore/MovieClip.cpp 2010-07-10 15:29:18 +0000
@@ -381,7 +381,6 @@
stopStreamSound();
stage().remove_key_listener(this);
- stage().remove_mouse_listener(this);
deleteChecked(_loadVariableRequests.begin(), _loadVariableRequests.end());
}
@@ -1720,7 +1719,6 @@
MovieClip::registerAsListener()
{
stage().add_key_listener(this);
- stage().add_mouse_listener(this);
}
void
=== modified file 'libcore/MovieClip.h'
--- a/libcore/MovieClip.h 2010-06-29 14:41:42 +0000
+++ b/libcore/MovieClip.h 2010-07-10 13:11:41 +0000
@@ -229,6 +229,9 @@
return _droptarget;
}
+ /// Advance to the next frame of the MovieClip.
+ //
+ /// Actions will be executed or pushed to the queue as necessary.
virtual void advance();
/// Set the sprite state at the specified frame number.
=== modified file 'libcore/TextField.cpp'
--- a/libcore/TextField.cpp 2010-07-10 09:22:06 +0000
+++ b/libcore/TextField.cpp 2010-07-10 11:20:23 +0000
@@ -2603,11 +2603,6 @@
TextField::handleFocus()
{
- // despite the swfdec suggestions, the simpleguess.swf
- // testcase (real case, SWF4) only works with TextField
- // accepting focus
- //if (getSWFVersion(*getObject(this)) < 6) return false;
-
set_invalidated();
/// Select the entire text on focus.
=== modified file 'libcore/Video.cpp'
--- a/libcore/Video.cpp 2010-07-09 06:58:02 +0000
+++ b/libcore/Video.cpp 2010-07-10 13:01:35 +0000
@@ -243,20 +243,8 @@
{
// For soft references.
saveOriginalTarget();
-
- // Register this video instance as a live DisplayObject
- stage().addLiveChar(this);
-}
-
-
-void
-Video::advance()
-{
- if (_ns) {
- // NOTE: only needed for gstreamer:
- if (_ns->newFrameReady()) set_invalidated();
- }
-}
+}
+
void
Video::add_invalidated_bounds(InvalidatedRanges& ranges, bool force)
=== modified file 'libcore/Video.h'
--- a/libcore/Video.h 2010-06-06 10:17:39 +0000
+++ b/libcore/Video.h 2010-07-10 13:01:35 +0000
@@ -63,9 +63,6 @@
virtual SWFRect getBounds() const;
- /// We use the call to ::advance to properly set invalidated status
- virtual void advance();
-
/// Register this video instance as a live DisplayObject
virtual void construct(as_object* init = 0);
=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp 2010-07-10 09:50:05 +0000
+++ b/libcore/movie_root.cpp 2010-07-10 15:29:18 +0000
@@ -91,6 +91,7 @@
bool generate_mouse_button_events(movie_root& mr, MouseButtonState& ms);
const DisplayObject* getNearestObject(const DisplayObject* o);
as_object* getBuiltinObject(movie_root& mr, string_table::key cl);
+ void advanceLiveChar(MovieClip* ch);
}
// Utility classes
@@ -127,7 +128,6 @@
m_timer(0.0f),
_mouseX(0),
_mouseY(0),
- _mouseDown(0),
_lastTimerId(0),
_lastKeyEvent(key::INVALID),
_currentFocus(0),
@@ -531,7 +531,6 @@
// remove key/mouse listeners
_keyListeners.clear();
- _mouseListeners.clear();
// Cleanup the stack.
_vm.getStack().clear();
@@ -645,13 +644,12 @@
{
assert(testInvariant());
- //log_debug("Mouse click notification");
+ _mouseButtonState.isDown = mouse_pressed;
+
if (mouse_pressed) {
- _mouseDown = true;
notify_mouse_listeners(event_id(event_id::MOUSE_DOWN));
}
else {
- _mouseDown = false;
notify_mouse_listeners(event_id(event_id::MOUSE_UP));
}
@@ -671,7 +669,6 @@
// Generate a mouse event
_mouseButtonState.topmostEntity = getTopmostMouseEntity(x, y);
- _mouseButtonState.isDown = _mouseDown;
// Set _droptarget if dragging a sprite
MovieClip* dragging = 0;
@@ -979,7 +976,8 @@
-void movie_root::cleanupUnloadedListeners(Listeners& ll)
+void
+movie_root::cleanupUnloadedListeners(Listeners& ll)
{
bool needScan;
@@ -1000,7 +998,7 @@
// remove unloaded DisplayObject listeners from movie_root
for (Listeners::iterator iter = ll.begin(); iter != ll.end(); )
{
- DisplayObject* const ch = *iter;
+ InteractiveObject* const ch = *iter;
if ( ch->unloaded() )
{
if ( ! ch->isDestroyed() )
@@ -1036,7 +1034,7 @@
iter != itEnd; ++iter)
{
// sprite, button & input_edit_text DisplayObjects
- DisplayObject* const ch = *iter;
+ InteractiveObject* const ch = *iter;
if (!ch->unloaded()) {
if (down) {
// KEY_UP and KEY_DOWN events are unrelated to any key!
@@ -1059,7 +1057,7 @@
}
void
-movie_root::add_listener(Listeners& ll, DisplayObject* listener)
+movie_root::add_listener(Listeners& ll, InteractiveObject* listener)
{
assert(listener);
@@ -1071,24 +1069,23 @@
void
-movie_root::remove_listener(Listeners& ll, DisplayObject* listener)
+movie_root::remove_listener(Listeners& ll, InteractiveObject* listener)
{
assert(listener);
- ll.remove_if(std::bind2nd(std::equal_to<DisplayObject*>(), listener));
+ ll.remove_if(std::bind2nd(std::equal_to<InteractiveObject*>(), listener));
}
void
movie_root::notify_mouse_listeners(const event_id& event)
{
- Listeners copy = _mouseListeners;
- for (Listeners::iterator iter = copy.begin(), itEnd=copy.end();
+ LiveChars copy = _liveChars;
+ for (LiveChars::iterator iter = copy.begin(), itEnd=copy.end();
iter != itEnd; ++iter)
{
- DisplayObject* const ch = *iter;
- if (!ch->unloaded())
- {
- ch->notifyEvent(event);
+ MovieClip* const ch = *iter;
+ if (!ch->unloaded()) {
+ ch->mouseEvent(event);
}
}
@@ -1816,7 +1813,7 @@
// NOTE: cleanupUnloadedListeners() should have cleaned up all unloaded
// key listeners. The remaining ones should be marked by their parents
#if ( GNASH_PARANOIA_LEVEL > 1 ) ||
defined(ALLOW_GC_RUN_DURING_ACTIONS_EXECUTION)
- for (LiveChars::const_iterator i=_keyListeners.begin(),
+ for (Listeners::const_iterator i=_keyListeners.begin(),
e=_keyListeners.end(); i!=e; ++i) {
#ifdef ALLOW_GC_RUN_DURING_ACTIONS_EXECUTION
(*i)->setReachable();
@@ -1826,20 +1823,6 @@
}
#endif
- // NOTE: cleanupUnloadedListeners() should have cleaned up all
- // unloaded mouse listeners. The remaining ones should be marked by
- // their parents
-#if ( GNASH_PARANOIA_LEVEL > 1 ) ||
defined(ALLOW_GC_RUN_DURING_ACTIONS_EXECUTION)
- for (LiveChars::const_iterator i = _mouseListeners.begin(),
- e = _mouseListeners.end(); i!=e; ++i) {
-#ifdef ALLOW_GC_RUN_DURING_ACTIONS_EXECUTION
- (*i)->setReachable();
-#else
- assert((*i)->isReachable());
-#endif
- }
-#endif
-
}
#endif // GNASH_USE_GC
@@ -2052,10 +2035,10 @@
#endif
needScan=false;
- // Remove unloaded DisplayObjects from the _liveChars list
+ // Remove unloaded MovieClips from the _liveChars list
for (LiveChars::iterator i=_liveChars.begin(), e=_liveChars.end();
i!=e;)
{
- DisplayObject* ch = *i;
+ MovieClip* ch = *i;
if (ch->unloaded()) {
// the sprite might have been destroyed already
// by effect of an unload() call with no onUnload
@@ -2105,24 +2088,6 @@
}
void
-movie_root::advanceLiveChar(DisplayObject* ch)
-{
- if (!ch->unloaded())
- {
-#ifdef GNASH_DEBUG
- log_debug(" advancing DisplayObject %s", ch->getTarget());
-#endif
- ch->advance();
- }
-#ifdef GNASH_DEBUG
- else {
- log_debug(" DisplayObject %s is unloaded, not advancing it",
- ch->getTarget());
- }
-#endif
-}
-
-void
movie_root::advanceLiveChars()
{
@@ -2539,7 +2504,6 @@
namespace {
// Return whether any action triggered by this event requires display redraw.
-// See page about events_handling (in movie_interface.h)
//
/// TODO: make this code more readable !
bool
@@ -2665,6 +2629,24 @@
return val.to_object(gl);
}
+void
+advanceLiveChar(MovieClip* mo)
+{
+ if (!mo->unloaded()) {
+#ifdef GNASH_DEBUG
+ log_debug(" advancing DisplayObject %s", ch->getTarget());
+#endif
+ mo->advance();
+ }
+#ifdef GNASH_DEBUG
+ else {
+ log_debug(" DisplayObject %s is unloaded, not advancing it",
+ mo->getTarget());
+ }
+#endif
+}
+
+
}
=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h 2010-07-10 10:57:31 +0000
+++ b/libcore/movie_root.h 2010-07-10 16:48:34 +0000
@@ -147,8 +147,10 @@
/// The _root object is provided by getAsRoot().
class DSOEXPORT movie_root : boost::noncopyable
{
-
public:
+
+ /// Listeners container
+ typedef std::list<InteractiveObject*> Listeners;
class LoadCallback {
public:
@@ -466,13 +468,13 @@
DSOEXPORT void notify_key_listeners(key::code k, bool down);
/// Push a new DisplayObject listener for key events
- void add_key_listener(DisplayObject* listener)
+ void add_key_listener(InteractiveObject* listener)
{
add_listener(_keyListeners, listener);
}
/// Remove a DisplayObject listener for key events
- void remove_key_listener(DisplayObject* listener)
+ void remove_key_listener(InteractiveObject* listener)
{
remove_listener(_keyListeners, listener);
}
@@ -480,18 +482,6 @@
/// Notify still loaded DisplayObject listeners for mouse events
DSOEXPORT void notify_mouse_listeners(const event_id& event);
- /// Push a new DisplayObject listener for mouse events
- void add_mouse_listener(DisplayObject* listener)
- {
- add_listener(_mouseListeners, listener);
- }
-
- /// Remove a DisplayObject listener for mouse events
- void remove_mouse_listener(DisplayObject* listener)
- {
- remove_listener(_mouseListeners, listener);
- }
-
/// Get the DisplayObject having focus
//
/// The DisplayObject having focus will receive mouse button
@@ -598,7 +588,6 @@
/// Gets the current Access Mode for ExternalInterface.
AllowScriptAccessMode getAllowScriptAccess();
-
typedef std::pair<StageHorizontalAlign, StageVerticalAlign> StageAlign;
/// Returns the current alignment of the stage (left/right/centre, top/
@@ -667,7 +656,6 @@
/// - Timer targets (_intervalTimers)
/// - Resources reachable by ActionQueue code (_actionQueue)
/// - Key listeners (_keyListeners)
- /// - Mouse listeners (_mouseListeners)
/// - Any DisplayObject being dragged
///
void markReachableResources() const;
@@ -681,7 +669,7 @@
/// its turn comes. Characters are advanced in reverse-placement
/// order (first registered is advanced last)
///
- void addLiveChar(DisplayObject* ch)
+ void addLiveChar(MovieClip* ch)
{
// Don't register the object in the list twice
#if GNASH_PARANOIA_LEVEL > 1
@@ -992,9 +980,6 @@
/// Registered FsCommand handler, if any
AbstractFsCallback* _fsCommandHandler;
- /// Listeners container
- typedef std::list<DisplayObject*> Listeners;
-
/// Take care of dragging, if needed
void doMouseDrag();
@@ -1014,7 +999,6 @@
void cleanupUnloadedListeners()
{
cleanupUnloadedListeners(_keyListeners);
- cleanupUnloadedListeners(_mouseListeners);
}
/// Erase unloaded DisplayObjects from the given listeners list
@@ -1025,10 +1009,10 @@
/// Push a DisplayObject listener to the front of given container, if not
/// already present
- static void add_listener(Listeners& ll, DisplayObject* elem);
+ static void add_listener(Listeners& ll, InteractiveObject* elem);
/// Remove a listener from the list
- static void remove_listener(Listeners& ll, DisplayObject* elem);
+ static void remove_listener(Listeners& ll, InteractiveObject* elem);
/// This function should return TRUE iff any action triggered
/// by the event requires redraw, see \ref events_handling for
@@ -1057,13 +1041,6 @@
/// from the display lists
void cleanupDisplayList();
- /// Advance a live DisplayObject
- //
- /// @param ch
- /// The DisplayObject to advance, will NOT be advanced if unloaded
- ///
- static void advanceLiveChar(DisplayObject* ch);
-
/// Advance all non-unloaded live chars
void advanceLiveChars();
@@ -1108,18 +1085,18 @@
DisplayObject* dragging) const;
void handleActionLimitHit(const std::string& ref);
+
/// A list of AdvanceableCharacters
//
/// This is a list (not a vector) as we want to allow
/// ::advance of each element to insert new DisplayObjects before
/// the start w/out invalidating iterators scanning the
/// list forward for proper movie advancement
- typedef std::list<DisplayObject*> LiveChars;
+ typedef std::list<MovieClip*> LiveChars;
/// The list of advanceable DisplayObject, in placement order
LiveChars _liveChars;
-
/// A number of queues of code to execute
//
/// This is a deque because it needs no insertion in the middle but
@@ -1142,7 +1119,6 @@
float m_timer;
boost::int32_t _mouseX;
boost::int32_t _mouseY;
- bool _mouseDown;
MouseButtonState _mouseButtonState;
@@ -1166,9 +1142,6 @@
/// Characters for listening key events
Listeners _keyListeners;
- /// Objects listening for mouse events (down,up,move)
- Listeners _mouseListeners;
-
/// The DisplayObject currently holding focus, or 0 if no focus.
DisplayObject* _currentFocus;
=== modified file 'libcore/vm/ActionExec.cpp'
--- a/libcore/vm/ActionExec.cpp 2010-07-07 09:19:47 +0000
+++ b/libcore/vm/ActionExec.cpp 2010-07-10 14:03:14 +0000
@@ -664,7 +664,7 @@
}
_withStack.push_back(entry);
- _scopeStack.push_back(const_cast<as_object*>(entry.object()));
+ _scopeStack.push_back(entry.object());
return true;
}
=== modified file 'libcore/vm/with_stack_entry.h'
--- a/libcore/vm/with_stack_entry.h 2010-03-12 15:42:07 +0000
+++ b/libcore/vm/with_stack_entry.h 2010-07-10 14:03:14 +0000
@@ -43,17 +43,12 @@
{
}
- size_t end_pc()
+ size_t end_pc() const
{
return _block_end_pc;
}
- const as_object* object() const
- {
- return _object;
- }
-
- as_object* object()
+ as_object* object() const
{
return _object;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r12292: Cleanups, simplification and rationalization of DisplayObjects and movie_root.,
Benjamin Wolsey <=