Channel Copying

When an object flows through the geometry pipeline a shallow copy is made of the object, also called the shell. This shallow copy contains a full copy of modified channels and a shallow copy of unmodified channels, in order to optimize the memory footprint and performance.

The geometry pipeline calls Object::MakeShallowCopy() to make a shallow copy of the object. This method specifies the channels that must be shallow copied, the other channels will be deep copied. A typical implementation of Object::MakeShallowCopy() will call Object::ShallowCopy() on the newly created object shell, to perform the actual copy of the pointers.

Object* TriObject::MakeShallowCopy(ChannelMask channels) {
  TriObject* newob = CreateNewTriObject();
  newob->ShallowCopy(this, channels);
  return newob;
}

Some channels are always present in the shallow copy. For example the SUBSEL_TYPE_CHANNEL, SELECT_CHANNEL and DISP_ATTRIB_CHANNEL state channel are each just a single value. These are not allocated or de-allocated dynamically, and are always present. Other channels like the GEOM_CHANNEL, TOPO_CHANNEL, and TEXMAP_CHANNEL are allocated dynamically so the system tries to not have extra copies of them when possible.

A deep copy (clone) of channels is requested by the pipeline by calling the plug-in implemented method Object::NewAndCopyChannels(). The pipeline will not call this method for unlocked channels.