Gnash
0.8.10
|
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 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 () |
DisplayObject * | getDisplayObjectAtDepth (int depth) const |
May return NULL. | |
DisplayObject * | getDisplayObjectByName (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. |
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(), gnash::key::_1, 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 testInvariant(), gnash::DisplayObject::get_depth(), gnash::DisplayObject::isMaskLayer(), gnash::DisplayObject::get_clip_depth(), assert, gnash::DisplayObject::add_invalidated_bounds(), gnash::geometry::SnappingRanges2d::inheritConfig(), gnash::geometry::SnappingRanges2d::intersect(), and gnash::geometry::SnappingRanges2d::add().
Referenced by gnash::MovieClip::add_invalidated_bounds().
void gnash::DisplayList::destroy | ( | ) |
destroy all DisplayObjects in this DisplayList
References testInvariant(), gnash::DisplayObject::isDestroyed(), and gnash::DisplayObject::destroy().
Referenced by gnash::MovieClip::destroy().
Display the list's DisplayObjects.
Lower depths are obscured by higher depths.
References testInvariant(), assert, gnash::DisplayObject::isDestroyed(), gnash::DisplayObject::isDynamicMask(), gnash::DisplayObject::unloaded(), gnash::key::p, gnash::DisplayObject::parent(), gnash::DisplayObject::isMaskLayer(), gnash::DisplayObject::visible(), gnash::DisplayObject::omit_display(), gnash::DisplayObject::get_depth(), gnash::Renderer::disable_mask(), gnash::DisplayObject::get_clip_depth(), gnash::Renderer::begin_submit_mask(), gnash::DisplayObject::boundsInClippingArea(), gnash::DisplayObject::display(), and gnash::Renderer::end_submit_mask().
Referenced by gnash::MovieClip::draw().
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 testInvariant(), gnash::DisplayObject::isDestroyed(), and gnash::DisplayObject::get_depth().
Referenced by moveDisplayObject(), gnash::MovieClip::getDisplayObjectAtDepth(), gnash::MovieClip::add_display_object(), and gnash::MovieClip::replace_display_object().
DisplayObject * gnash::DisplayList::getDisplayObjectByName | ( | string_table & | st, |
const ObjectURI & | uri, | ||
bool | caseless | ||
) | const |
If there are multiples, returns the *first* match only!
st | The string_table to use for finding lowercase equivalent of names if `caseless' parameter is true. |
uri | Object identifier |
caseless | Wheter 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().
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 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 | ||
) |
Merge the given display list.
Call set_invalidated on the given DisplayObject if this list changes
References testInvariant(), gnash::DisplayObject::get_depth(), gnash::DisplayObject::set_invalidated(), gnash::DisplayObject::unload(), gnash::DisplayObject::destroy(), gnash::DisplayObject::get_ratio(), gnash::DisplayObject::isDynamic(), gnash::isReferenceable(), gnash::DisplayObject::get_accept_anim_moves(), gnash::DisplayObject::setMatrix(), gnash::getMatrix(), gnash::DisplayObject::setCxForm(), gnash::getCxForm(), gnash::DisplayObject::unloaded(), gnash::key::_1, gnash::key::i, gnash::key::e, _, gnash::DisplayObject::getTarget(), and gnash::typeName().
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()
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. |
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 | ( | ) |
References gnash::DisplayObject::omit_display().
Referenced by gnash::MovieClip::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 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 | ) |
Removes the object at the specified depth.
Calls unload on the removed DisplayObject.
References testInvariant(), size(), gnash::key::_1, gnash::DisplayObject::unload(), gnash::DisplayObject::destroy(), and assert.
Referenced by gnash::MovieClip::remove_display_object(), and gnash::SWF::RemoveObjectTag::executeState().
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.
ch | the new DisplayObject to be put |
depth | depth to be replaced |
use_old_cxform | true: set the new DisplayObject's SWFCxForm to the old one. false: keep the new DisplayObject's SWFCxForm. |
use_old_matrix | true: 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:
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 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] |
Referenced by getNextHighestDepth(), getDisplayObjectAtDepth(), getDisplayObjectByName(), placeDisplayObject(), add(), replaceDisplayObject(), moveDisplayObject(), removeDisplayObject(), swapDepths(), insertDisplayObject(), unload(), destroy(), display(), add_invalidated_bounds(), mergeDisplayList(), and removeUnloaded().
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().
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().
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
Referenced by gnash::MovieClip::pointInShape(), gnash::MovieClip::pointInVisibleShape(), and gnash::MovieClip::pointInHitableShape().
void gnash::DisplayList::visitBackward | ( | V & | visitor | ) | const [inline] |
std::ostream& operator<< | ( | std::ostream & | , |
const DisplayList & | |||
) | [friend] |
Output operator.