Gnash  0.8.10
Public Types | Public Member Functions | Friends
gnash::DisplayList Class Reference

A list of on-stage DisplayObjects, ordered by depth. More...

#include <DisplayList.h>

List of all members.

Public Types

typedef std::list
< DisplayObject * > 
container_type
typedef container_type::iterator iterator
typedef
container_type::const_iterator 
const_iterator
typedef
container_type::reverse_iterator 
reverse_iterator
typedef
container_type::const_reverse_iterator 
const_reverse_iterator

Public Member Functions

 DisplayList ()
 ~DisplayList ()
void placeDisplayObject (DisplayObject *ch, int depth)
 Place a new DisplayObject at the specified depth, replacing any existing DisplayObject at the same depth.
void replaceDisplayObject (DisplayObject *ch, int depth, bool use_old_cxform, bool use_old_matrix)
 Replace the old DisplayObject at the specified depth with the given new DisplayObject.
void swapDepths (DisplayObject *ch, int depth)
 Change depth of the given DisplayObjects in the list, swapping with any existing DisplayObject at target depth.
void moveDisplayObject (int depth, const SWFCxForm *color_xform, const SWFMatrix *mat, boost::uint16_t *ratio)
 Updates the transform properties of the object at the specified depth, unless its get_accept_anim_moves() returns false.
void removeDisplayObject (int depth)
 Removes the object at the specified depth.
void removeUnloaded ()
 Remove all unloaded DisplayObject from the list.
bool unload ()
void destroy ()
 destroy all DisplayObjects in this DisplayList
void add (DisplayObject *ch, bool replace)
 Add a DisplayObject in the list, maintaining depth-order.
void insertDisplayObject (DisplayObject *obj, int index)
 Inserts a DisplayObject at the specified index (depth)
void display (Renderer &renderer, const Transform &xform)
 Display the list's DisplayObjects.
void omit_display ()
DisplayObjectgetDisplayObjectAtDepth (int depth) const
 May return NULL.
DisplayObjectgetDisplayObjectByName (string_table &st, const ObjectURI &uri, bool caseless) const
 If there are multiples, returns the *first* match only!
template<class V >
void visitBackward (V &visitor)
 Visit each DisplayObject in the list in reverse depth order (higher depth first).
template<class V >
void visitBackward (V &visitor) const
template<class V >
void visitAll (V &visitor)
 Visit each and all DisplayObject in the list.
template<class V >
void visitAll (V &visitor) const
void add_invalidated_bounds (InvalidatedRanges &ranges, bool force)
size_t size () const
 Return number of elements in the list.
bool empty () const
 Return true if the list contains no elements.
int getNextHighestDepth () const
 Return the next highest available depth.
void mergeDisplayList (DisplayList &newList, DisplayObject &o)
 Merge the given display list.
bool operator== (const DisplayList &other) const
bool operator!= (const DisplayList &other) const
void testInvariant () const

Friends

std::ostream & operator<< (std::ostream &, const DisplayList &)
 Output operator.

Detailed Description

A list of on-stage DisplayObjects, ordered by depth.

Any MovieClip has an associated DisplayList that may change from frame to frame due to control tags instructing when to add or remove DisplayObjects from the stage.


Member Typedef Documentation

typedef container_type::const_iterator gnash::DisplayList::const_iterator
typedef container_type::const_reverse_iterator gnash::DisplayList::const_reverse_iterator
typedef container_type::iterator gnash::DisplayList::iterator
typedef container_type::reverse_iterator gnash::DisplayList::reverse_iterator

Constructor & Destructor Documentation

gnash::DisplayList::DisplayList ( ) [inline]
gnash::DisplayList::~DisplayList ( ) [inline]

Member Function Documentation

void gnash::DisplayList::add ( DisplayObject ch,
bool  replace 
)

Add a DisplayObject in the list, maintaining depth-order.

Parameters:
chThe DisplayObject to add
replaceIf true the given DisplayObject would replace any pre-existing DisplayObject at the same depth.

References gnash::DisplayObject::get_depth(), gnash::key::_1, and testInvariant().

void gnash::DisplayList::add_invalidated_bounds ( InvalidatedRanges ranges,
bool  force 
)
void gnash::DisplayList::destroy ( )
void gnash::DisplayList::display ( Renderer renderer,
const Transform xform 
)
bool gnash::DisplayList::empty ( ) const [inline]

Return true if the list contains no elements.

DisplayObject * gnash::DisplayList::getDisplayObjectAtDepth ( int  depth) const
DisplayObject * gnash::DisplayList::getDisplayObjectByName ( string_table st,
const ObjectURI uri,
bool  caseless 
) const

If there are multiples, returns the *first* match only!

Parameters:
stThe string_table to use for finding lowercase equivalent of names if `caseless' parameter is true.
uriObject identifier
caselessWheter comparison must be case-insensitive.

References testInvariant(), and gnash::key::e.

Referenced by gnash::MovieClip::getDisplayListObject().

int gnash::DisplayList::getNextHighestDepth ( ) const

Return the next highest available depth.

Placing an object at the depth returned by this function should result in a DisplayObject that is displayd above all others

References testInvariant(), and gnash::DisplayObject::get_depth().

Referenced by gnash::MovieClip::getNextHighestDepth().

void gnash::DisplayList::insertDisplayObject ( DisplayObject obj,
int  index 
)

Inserts a DisplayObject at the specified index (depth)

If a DisplayObject is already at that index, it is moved up. This implements AS3 DisplayObjectContainer.addChildAt().

Parameters:
objThe DisplayObject to insert. This should already be removed from any other DisplayLists. It should not be the owner of this DisplayList or any parent of that owner.
indexThe index at which to insert the DisplayObject.

References testInvariant(), assert, gnash::DisplayObject::unloaded(), gnash::DisplayObject::set_invalidated(), gnash::DisplayObject::set_depth(), and gnash::key::_1.

void gnash::DisplayList::mergeDisplayList ( DisplayList newList,
DisplayObject o 
)
void gnash::DisplayList::moveDisplayObject ( int  depth,
const SWFCxForm color_xform,
const SWFMatrix mat,
boost::uint16_t *  ratio 
)

Updates the transform properties of the object at the specified depth, unless its get_accept_anim_moves() returns false.

See DisplayObject::get_accept_anim_moves()

Parameters:
color_xformThe color tranform to assign to the DisplayObject at the given depth. If NULL the orignial color transform will be kept.
matThe SWFMatrix tranform to assign to the DisplayObject at the given depth. If NULL the orignial SWFMatrix will be kept.
ratioThe new ratio value to assign to the DisplayObject at the given depth. If NULL the original ratio will be kept.

References testInvariant(), getDisplayObjectAtDepth(), IF_VERBOSE_MALFORMED_SWF, _, gnash::DisplayObject::unloaded(), assert, gnash::DisplayObject::get_accept_anim_moves(), gnash::DisplayObject::setCxForm(), gnash::DisplayObject::setMatrix(), and gnash::DisplayObject::set_ratio().

Referenced by gnash::MovieClip::move_display_object().

void gnash::DisplayList::omit_display ( )
bool gnash::DisplayList::operator!= ( const DisplayList other) const [inline]
bool gnash::DisplayList::operator== ( const DisplayList other) const [inline]
void gnash::DisplayList::placeDisplayObject ( DisplayObject ch,
int  depth 
)

Place a new DisplayObject at the specified depth, replacing any existing DisplayObject at the same depth.

If a DisplayObject is replaced, it's unload() method is invoked.

If applicable, the event_id::LOAD event associated with the given DisplayObject is called as last step of addition.

Parameters:
chthe new DisplayObject to be added into the list.
depthdepth at which the new DisplayObject is placed.

References assert, gnash::DisplayObject::unloaded(), gnash::DisplayObject::set_invalidated(), gnash::DisplayObject::set_depth(), gnash::key::_1, gnash::DisplayObject::unload(), gnash::DisplayObject::destroy(), gnash::DisplayObject::extend_invalidated_bounds(), and testInvariant().

Referenced by gnash::MovieClip::addDisplayListObject(), gnash::MovieClip::duplicateMovieClip(), gnash::MovieClip::attachCharacter(), gnash::MovieClip::add_display_object(), and gnash::MovieClip::placeDisplayObject().

void gnash::DisplayList::removeDisplayObject ( int  depth)
void gnash::DisplayList::removeUnloaded ( )

Remove all unloaded DisplayObject from the list.

Removed DisplayObjects still in the list are those on which onUnload event handlers were defined..

NOTE: we don't call the function recursively in the contained elements, as that should not be needed (ie: any inned thing will not be accessible anyway)

References testInvariant(), and gnash::DisplayObject::unloaded().

Referenced by gnash::MovieClip::cleanupDisplayList().

void gnash::DisplayList::replaceDisplayObject ( DisplayObject ch,
int  depth,
bool  use_old_cxform,
bool  use_old_matrix 
)

Replace the old DisplayObject at the specified depth with the given new DisplayObject.

Calls unload on the removed DisplayObject.

Parameters:
chthe new DisplayObject to be put
depthdepth to be replaced
use_old_cxformtrue: set the new DisplayObject's SWFCxForm to the old one. false: keep the new DisplayObject's SWFCxForm.
use_old_matrixtrue: set the new DisplayObject's transformation SWFMatrix to the old one. false: keep the new DisplayObject's transformation SWFMatrix.

References testInvariant(), assert, gnash::DisplayObject::unloaded(), gnash::DisplayObject::set_invalidated(), gnash::DisplayObject::set_depth(), gnash::key::_1, gnash::DisplayObject::setCxForm(), gnash::getCxForm(), gnash::DisplayObject::setMatrix(), gnash::getMatrix(), gnash::DisplayObject::add_invalidated_bounds(), gnash::DisplayObject::unload(), gnash::DisplayObject::destroy(), and gnash::DisplayObject::extend_invalidated_bounds().

Referenced by gnash::MovieClip::replace_display_object(), and gnash::MovieClip::getLoadedMovie().

size_t gnash::DisplayList::size ( ) const [inline]

Return number of elements in the list.

Referenced by removeDisplayObject(), and gnash::DisplayObjectContainer::numChildren().

void gnash::DisplayList::swapDepths ( DisplayObject ch,
int  depth 
)

Change depth of the given DisplayObjects in the list, swapping with any existing DisplayObject at target depth.

List ordering will be maintained by this function.

Any DisplayObject affected by this operation (none on invalid call, 1 if new depth is not occupied, 2 otherwise) will be:

Parameters:
chThe DisplayObject to apply depth swapping to. If not found in the list, an error is raised and no other action is taken.
depthThe new depth to assign to the given DisplayObject. If occupied by another DisplayObject, the target DisplayObject will get the current depth of the first. If target depth equals the current depth of DisplayObject, an assertion fails, as I think the caller should check this instead.

References testInvariant(), gnash::DisplayObject::staticDepthOffset, IF_VERBOSE_ASCODING_ERRORS, _, gnash::DisplayObject::getTarget(), gnash::DisplayObject::get_depth(), assert, gnash::key::_1, gnash::DisplayObject::set_depth(), gnash::DisplayObject::set_invalidated(), and gnash::DisplayObject::transformedByScript().

Referenced by gnash::MovieClip::swapDepths().

void gnash::DisplayList::testInvariant ( ) const [inline]
bool gnash::DisplayList::unload ( )

Unload the DisplayObjects in this DisplayList removing all but the ones with on onUnload event defined (checked by calling ::unload on them) and keeping the others, w/out depth-shifting them.

Return true if any child was kept (as they had onUnload defined)

References testInvariant(), assert, gnash::DisplayObject::isDestroyed(), gnash::DisplayObject::unload(), and gnash::DisplayObject::destroy().

Referenced by gnash::MovieClip::unloadChildren().

template<class V >
void gnash::DisplayList::visitAll ( V &  visitor) [inline]

Visit each and all DisplayObject in the list.

Scan happens in arbitrary order, if order is important use visitBackward or visitForward

The visitor functor will receive a DisplayObject pointer, it's return value is not used so can return void.

NOTE: all elements in the list are visited, even the removed ones (unloaded) TODO: inspect if worth providing an arg to skip removed

Referenced by gnash::MovieClip::topmostMouseEntity(), gnash::MovieClip::findDropTarget(), gnash::MovieClip::getBounds(), gnash::MovieClip::visitNonProperties(), and gnash::MovieClip::markOwnResources().

template<class V >
void gnash::DisplayList::visitAll ( V &  visitor) const [inline]
template<class V >
void gnash::DisplayList::visitBackward ( V &  visitor) [inline]

Visit each DisplayObject in the list in reverse depth order (higher depth first).

The visitor functor will receive a DisplayObject pointer; must return true if it wants next item or false to exit the loop.

NOTE: all elements in the list are visited, even the removed ones (unloaded) TODO: inspect if worth providing an arg to skip removed

Referenced by gnash::MovieClip::pointInShape(), gnash::MovieClip::pointInVisibleShape(), and gnash::MovieClip::pointInHitableShape().

template<class V >
void gnash::DisplayList::visitBackward ( V &  visitor) const [inline]

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  ,
const DisplayList  
) [friend]

Output operator.


The documentation for this class was generated from the following files: