void DisplayList::replaceDisplayObject(DisplayObject* ch, int depth, bool use_old_cxform, bool use_old_matrix) { testInvariant(); //GNASH_REPORT_FUNCTION; assert(!ch->unloaded()); ch->set_invalidated(); ch->set_depth(depth); container_type::iterator it = std::find_if(_charsByDepth.begin(), _charsByDepth.end(), boost::bind(std::not2(DepthLessThan()), _1, depth)); if (it == _charsByDepth.end() || (*it)->get_depth() != depth) { _charsByDepth.insert(it, ch); } else { // Make a copy (before replacing) DisplayObject* oldch = *it; InvalidatedRanges old_ranges; if (use_old_cxform) { // Use the SWFCxForm from the old DisplayObject. ch->setCxForm(getCxForm(*oldch)); } if (use_old_matrix) { // Use the SWFMatrix from the old DisplayObject. ch->setMatrix(getMatrix(*oldch), true); } // remember bounds of old char oldch->add_invalidated_bounds(old_ranges, true); // replace existing char (before calling unload) *it = ch; // Unload old char if (oldch->unload()) { // reinsert removed DisplayObject if needed reinsertRemovedCharacter(oldch); } else oldch->destroy(); // extend invalidated bounds // WARNING: when a new Button DisplayObject is added, // the invalidated bounds computation will likely // be bogus, as the actual DisplayObject shown is not // instantiated until stagePlacementCallback for buttons // (I'd say this is a bug in Button). ch->extend_invalidated_bounds(old_ranges); } testInvariant(); }
const SWFCxForm& colorTransform() const { return getCxForm(_movieClip); }