A list of on-stage DisplayObjects, ordered by depth. More...
#include <DisplayList.h>
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 cxform *color_xform, const SWFMatrix *mat, int *ratio, int *clip_depth) |
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 | removeDisplayObject (DisplayObject *obj) |
Removes the specified DisplayObject. | |
DisplayObject * | removeDisplayObjectAt (int index) |
Removes the DisplayObject at the specified index. | |
void | insertDisplayObject (DisplayObject *obj, int index) |
Inserts a DisplayObject at the specified index (depth). | |
void | addDisplayObject (DisplayObject *obj) |
Adds a DisplayObject at the top of the DisplayList. | |
void | display (Renderer &renderer) |
Display the referenced DisplayObjects. Lower depths are obscured by higher depths. | |
void | omit_display () |
DisplayObject * | getDisplayObjectAtDepth (int depth) const |
May return NULL. | |
DisplayObject * | getDisplayObjectByName (string_table &st, string_table::key name, bool caseless) const |
If there are multiples, returns the *first* match only! | |
template<class V > | |
void | visitForward (V &visitor) |
Visit each DisplayObject in the list in depth order (lower depth first). | |
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 | dump () const |
dump list to logfile/stderr | |
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 | sort () |
Sort list by depth (lower depths first). | |
void | mergeDisplayList (DisplayList &newList) |
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. |
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.
typedef container_type::const_iterator gnash::DisplayList::const_iterator |
typedef container_type::const_reverse_iterator gnash::DisplayList::const_reverse_iterator |
typedef std::list<DisplayObject*> gnash::DisplayList::container_type |
typedef container_type::iterator gnash::DisplayList::iterator |
typedef container_type::reverse_iterator gnash::DisplayList::reverse_iterator |
gnash::DisplayList::DisplayList | ( | ) | [inline] |
gnash::DisplayList::~DisplayList | ( | ) | [inline] |
void gnash::DisplayList::add | ( | DisplayObject * | ch, | |
bool | replace | |||
) |
Add a DisplayObject in the list, maintaining depth-order.
ch | The DisplayObject to add | |
replace | If true the given DisplayObject would replace any pre-existing DisplayObject at the same depth. |
References gnash::DisplayObject::get_depth(), and testInvariant().
void gnash::DisplayList::add_invalidated_bounds | ( | InvalidatedRanges & | ranges, | |
bool | force | |||
) |
Like DisplayObject_instance::add_invalidated_bounds() this method calls the method with the same name of all childs.
References gnash::geometry::SnappingRanges2d< T >::add(), gnash::DisplayObject::add_invalidated_bounds(), gnash::DisplayObject::get_clip_depth(), gnash::DisplayObject::get_depth(), gnash::geometry::SnappingRanges2d< T >::inheritConfig(), gnash::geometry::SnappingRanges2d< T >::intersect(), gnash::DisplayObject::isMaskLayer(), and testInvariant().
void gnash::DisplayList::addDisplayObject | ( | DisplayObject * | obj | ) |
Adds a DisplayObject at the top of the DisplayList.
This implements AS3 DisplayObjectContainer.addChild().
obj | The 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. |
References gnash::DisplayObject::set_depth(), gnash::DisplayObject::set_invalidated(), testInvariant(), and gnash::DisplayObject::unloaded().
Referenced by gnash::DisplayObjectContainer::addChild().
void gnash::DisplayList::destroy | ( | ) |
destroy all DisplayObjects in this DisplayList
References gnash::DisplayObject::destroy(), gnash::DisplayObject::isDestroyed(), and testInvariant().
void gnash::DisplayList::display | ( | Renderer & | renderer | ) |
Display the referenced DisplayObjects. Lower depths are obscured by higher depths.
References gnash::Renderer::begin_submit_mask(), gnash::DisplayObject::boundsInClippingArea(), gnash::Renderer::disable_mask(), gnash::DisplayObject::display(), gnash::Renderer::end_submit_mask(), gnash::DisplayObject::get_clip_depth(), gnash::DisplayObject::get_depth(), gnash::DisplayObject::get_parent(), gnash::DisplayObject::getMask(), gnash::DisplayObject::isDestroyed(), gnash::DisplayObject::isDynamicMask(), gnash::DisplayObject::isMaskLayer(), gnash::DisplayObject::omit_display(), testInvariant(), gnash::DisplayObject::unloaded(), and gnash::DisplayObject::visible().
void gnash::DisplayList::dump | ( | ) | const |
dump list to logfile/stderr
References _, gnash::DisplayObject::get_depth(), gnash::DisplayObject::get_name(), gnash::DisplayObject::isDestroyed(), gnash::typeName(), and gnash::DisplayObject::unloaded().
Referenced by main().
bool gnash::DisplayList::empty | ( | ) | const [inline] |
Return true if the list contains no elements.
DisplayObject * gnash::DisplayList::getDisplayObjectAtDepth | ( | int | depth | ) | const |
May return NULL.
References gnash::DisplayObject::get_depth(), gnash::DisplayObject::isDestroyed(), and testInvariant().
Referenced by gnash::MovieTester::findDisplayItemByDepth(), and moveDisplayObject().
DisplayObject * gnash::DisplayList::getDisplayObjectByName | ( | string_table & | st, | |
string_table::key | name, | |||
bool | caseless | |||
) | const |
If there are multiples, returns the *first* match only!
References gnash::key::e, and testInvariant().
Referenced by gnash::MovieTester::findDisplayItemByName().
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 gnash::DisplayObject::get_depth(), and testInvariant().
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().
obj | The 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. | |
index | The index at which to insert the DisplayObject. |
References gnash::DisplayObject::set_depth(), gnash::DisplayObject::set_invalidated(), testInvariant(), and gnash::DisplayObject::unloaded().
Referenced by gnash::DisplayObjectContainer::addChildAt().
void gnash::DisplayList::mergeDisplayList | ( | DisplayList & | newList | ) |
merge the given display list
References gnash::DisplayObject::destroy(), gnash::key::e, gnash::DisplayObject::get_accept_anim_moves(), gnash::DisplayObject::get_cxform(), gnash::DisplayObject::get_depth(), gnash::DisplayObject::get_ratio(), gnash::DisplayObject::getMatrix(), gnash::DisplayObject::getTarget(), gnash::key::i, gnash::DisplayObject::isDynamic(), gnash::isReferenceable(), gnash::DisplayObject::set_cxform(), gnash::DisplayObject::setMatrix(), gnash::DisplayObject::staticDepthOffset, testInvariant(), gnash::typeName(), gnash::DisplayObject::unload(), and gnash::DisplayObject::unloaded().
void gnash::DisplayList::moveDisplayObject | ( | int | depth, | |
const cxform * | color_xform, | |||
const SWFMatrix * | mat, | |||
int * | ratio, | |||
int * | clip_depth | |||
) |
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()
color_xform | The color tranform to assign to the DisplayObject at the given depth. If NULL the orignial color transform will be kept. | |
mat | The SWFMatrix tranform to assign to the DisplayObject at the given depth. If NULL the orignial SWFMatrix will be kept. | |
ratio | The new ratio value to assign to the DisplayObject at the given depth. If NULL the original ratio will be kept. |
Not used at the moment.
References _, gnash::DisplayObject::get_accept_anim_moves(), getDisplayObjectAtDepth(), IF_VERBOSE_MALFORMED_SWF, gnash::DisplayObject::set_cxform(), gnash::DisplayObject::set_ratio(), gnash::DisplayObject::setMatrix(), testInvariant(), and gnash::DisplayObject::unloaded().
void gnash::DisplayList::omit_display | ( | ) |
References gnash::DisplayObject::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.
ch | the new DisplayObject to be added into the list. | |
depth | depth at which the new DisplayObject is placed. |
References gnash::DisplayObject::destroy(), gnash::DisplayObject::extend_invalidated_bounds(), gnash::DisplayObject::set_depth(), gnash::DisplayObject::set_invalidated(), testInvariant(), gnash::DisplayObject::unload(), and gnash::DisplayObject::unloaded().
Referenced by main(), and gnash::MovieClip::placeDisplayObject().
void gnash::DisplayList::removeDisplayObject | ( | DisplayObject * | obj | ) |
Removes the specified DisplayObject.
Other DisplayObjects are left untouched. This implements AS3 DisplayObjectContainer.removeChild().
obj | The DisplayObject to remove. |
void gnash::DisplayList::removeDisplayObject | ( | int | depth | ) |
Removes the object at the specified depth.
Calls unload on the removed DisplayObject.
References gnash::DisplayObject::destroy(), size(), testInvariant(), and gnash::DisplayObject::unload().
Referenced by gnash::SWF::RemoveObjectTag::executeState(), and gnash::DisplayObjectContainer::removeChild().
DisplayObject * gnash::DisplayList::removeDisplayObjectAt | ( | int | index | ) |
Removes the DisplayObject at the specified index.
Other DisplayObjects are left untouched. This implements AS3 DisplayObjectContainer.removeChildAt().
index | The index from which to remove the DisplayObject. |
Referenced by gnash::DisplayObjectContainer::removeChildAt().
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().
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.
ch | the new DisplayObject to be put | |
depth | depth to be replaced | |
use_old_cxform | true: set the new DisplayObject's cxform to the old one. false: keep the new DisplayObject's cxform. | |
use_old_matrix | true: set the new DisplayObject's transformation SWFMatrix to the old one. false: keep the new DisplayObject's transformation SWFMatrix. |
References gnash::DisplayObject::add_invalidated_bounds(), gnash::DisplayObject::destroy(), gnash::DisplayObject::extend_invalidated_bounds(), gnash::DisplayObject::get_cxform(), gnash::DisplayObject::getMatrix(), gnash::DisplayObject::set_cxform(), gnash::DisplayObject::set_depth(), gnash::DisplayObject::set_invalidated(), gnash::DisplayObject::setMatrix(), testInvariant(), gnash::DisplayObject::unload(), and gnash::DisplayObject::unloaded().
size_t gnash::DisplayList::size | ( | ) | const [inline] |
Return number of elements in the list.
Referenced by checkScribbling(), main(), gnash::DisplayObjectContainer::numChildren(), removeDisplayObject(), and testAll().
void gnash::DisplayList::sort | ( | ) |
Sort list by depth (lower depths first).
You only need calling this method if depth of DisplayObjects on the list has been externally changed. Usually it is DisplayList itself assigning depths, so won't need to call it.
A notable use for this is backing up a specific state and restoring it later. Restore step would need reordering.
Referenced by main().
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:
ch | The DisplayObject to apply depth swapping to. If not found in the list, an error is raised and no other action is taken. | |
depth | The 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 gnash::DisplayObject::get_depth(), gnash::DisplayObject::getTarget(), IF_VERBOSE_ASCODING_ERRORS, gnash::DisplayObject::set_depth(), gnash::DisplayObject::set_invalidated(), gnash::DisplayObject::staticDepthOffset, testInvariant(), and gnash::DisplayObject::transformedByScript().
Referenced by gnash::MovieClip::swapDepths().
void gnash::DisplayList::testInvariant | ( | ) | const [inline] |
Referenced by add(), add_invalidated_bounds(), addDisplayObject(), destroy(), display(), getDisplayObjectAtDepth(), getDisplayObjectByName(), getNextHighestDepth(), insertDisplayObject(), mergeDisplayList(), moveDisplayObject(), placeDisplayObject(), removeDisplayObject(), removeUnloaded(), replaceDisplayObject(), swapDepths(), and unload().
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 gnash::DisplayObject::destroy(), gnash::DisplayObject::isDestroyed(), testInvariant(), and gnash::DisplayObject::unload().
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
void gnash::DisplayList::visitAll | ( | V & | visitor | ) | const [inline] |
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
void gnash::DisplayList::visitBackward | ( | V & | visitor | ) | const [inline] |
void gnash::DisplayList::visitForward | ( | V & | visitor | ) | [inline] |
Visit each DisplayObject in the list in depth order (lower 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
std::ostream& operator<< | ( | std::ostream & | , | |
const DisplayList & | ||||
) | [friend] |
Output operator.