27 size_t RenderAttrib::_garbage_index = 0;
    29 PStatCollector RenderAttrib::_garbage_collect_pcollector(
"*:State Cache:Garbage Collect");
    36   if (_attribs == 
nullptr) {
    51   nassertv(_saved_entry == -1);
   107   if (!state_cache || garbage_collect_states) {
   140 output(ostream &out)
 const {
   148 write(ostream &out, 
int indent_level)
 const {
   149   indent(out, indent_level) << *
this << 
"\n";
   160   if (_attribs == 
nullptr) {
   176   out << size << 
" attribs:\n";
   177   for (
size_t si = 0; si < size; ++si) {
   179     attrib->write(out, 2);
   189   if (_attribs == 
nullptr || !garbage_collect_states) {
   194   PStatTimer timer(_garbage_collect_pcollector);
   202   size_t size = orig_size;
   203   size_t num_this_pass = std::max(0, 
int(size * garbage_collect_states_rate));
   204   if (num_this_pass <= 0) {
   208   size_t si = _garbage_index;
   213   num_this_pass = std::min(num_this_pass, size);
   214   size_t stop_at_element = (si + num_this_pass) % size;
   224       attrib->release_new();
   232       if (stop_at_element > 0) {
   237     si = (si + 1) % size;
   238   } 
while (si != stop_at_element);
   251   return (
int)orig_size - (int)size;
   268       << 
"RenderAttrib::_attribs cache is invalid!\n";
   271     for (
size_t si = 0; si < size; ++si) {
   274       attrib->write(std::cerr, 2);
   282   nassertr(si < size, 
false);
   283   nassertr(_attribs->
get_key(si)->get_ref_count() >= 0, 
false);
   286   while (snext < size) {
   287     nassertr(_attribs->
get_key(snext)->get_ref_count() >= 0, 
false);
   290     int c = ssi->compare_to(*ssnext);
   291     int ci = ssnext->compare_to(*ssi);
   292     if ((ci < 0) != (c > 0) ||
   293         (ci > 0) != (c < 0) ||
   294         (ci == 0) != (c == 0)) {
   296         << 
"RenderAttrib::compare_to() not defined properly!\n";
   297       pgraph_cat.error(
false)
   298         << 
"(a, b): " << c << 
"\n";
   299       pgraph_cat.error(
false)
   300         << 
"(b, a): " << ci << 
"\n";
   301       ssi->write(pgraph_cat.error(
false), 2);
   302       ssnext->write(pgraph_cat.error(
false), 2);
   321   nassertr(attrib != 
nullptr, attrib);
   322   if (!uniquify_attribs) {
   327   return return_unique(attrib);
   342   nassertr(attrib != 
nullptr, attrib);
   351   if (paranoid_const) {
   358   if (attrib->_saved_entry != -1) {
   364   int si = _attribs->
find(attrib);
   375   if (garbage_collect_states) {
   381   si = _attribs->
store(attrib, 
nullptr);
   384   attrib->_saved_entry = si;
   410 size_t RenderAttrib::
   411 get_hash_impl()
 const {
   446 output_comparefunc(ostream &out, PandaCompareFunc fn)
 const {
   476   case M_greater_equal:
   477     out << 
"greater_equal";
   496   if (_saved_entry != -1) {
   498     nassertv_always(_attribs->
remove(
this));
   517   _attribs_lock = 
new LightReMutex(
"RenderAttrib::_attribs_lock");
   518   nassertv(Thread::get_current_thread() == Thread::get_main_thread());
   548   if (pointer == attrib) {
 static void list_attribs(std::ostream &out)
Lists all of the RenderAttribs in the cache to the output stream, one per line.
 
get_ref_count
Returns the current reference count.
 
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
 
This is the base class for a number of render attributes (other than transform) that may be set on sc...
 
static int get_num_attribs()
Returns the total number of unique RenderAttrib objects allocated in the world.
 
CPT(RenderAttrib) RenderAttrib
This function is used by derived RenderAttrib types to share a common RenderAttrib pointer for all eq...
 
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
 
virtual bool has_cull_callback() const
Should be overridden by derived classes to return true if cull_callback() has been defined.
 
virtual bool unref() const final
This method overrides ReferenceCount::unref() to clear the pointer from the global object pool when i...
 
Base class for objects that can be written to and read from Bam files.
 
bool debug_is_locked() const
Returns true if the current thread has locked the LightReMutex, false otherwise.
 
A lightweight reentrant mutex.
 
This collects together the pieces of data that are accumulated for each node while walking the scene ...
 
int store(const Key &key, const Value &data)
Records the indicated key/data pair in the map.
 
static void init_attribs()
Make sure the global _attribs map is allocated.
 
A lightweight class that can be used to automatically start and stop a PStatCollector around a sectio...
 
This template class implements an unordered map of keys to data, implemented as a hashtable.
 
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
 
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
 
static int garbage_collect()
Performs a garbage-collection cycle.
 
virtual ~RenderAttrib()
The destructor is responsible for removing the RenderAttrib from the global set if it is there.
 
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
 
void register_change_this(ChangeThisFunc func, TypedWritable *whom)
Called by an object reading itself from the bam file to indicate that the object pointer that will be...
 
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
 
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
 
size_t get_num_entries() const
Returns the number of active entries in the table.
 
A lightweight class that represents a single element that may be timed and/or counted via stats.
 
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
 
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
 
const Key & get_key(size_t n) const
Returns the key in the nth entry of the table.
 
void register_finalize(TypedWritable *whom)
Should be called by an object reading itself from the Bam file to indicate that this particular objec...
 
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
 
bool validate() const
Returns true if the internal table appears to be consistent, false if there are some internal errors.
 
virtual bool cull_callback(CullTraverser *trav, const CullTraverserData &data) const
If has_cull_callback() returns true, this function will be called during the cull traversal to perfor...
 
Similar to MutexHolder, but for a light reentrant mutex.
 
void ref() const
Explicitly increments the reference count.
 
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
 
bool consider_shrink_table()
Shrinks the table if the allocated storage is significantly larger than the number of elements in it.
 
static TypedWritable * change_this(TypedWritable *old_ptr, BamReader *manager)
Called immediately after complete_pointers(), this gives the object a chance to adjust its own pointe...
 
static bool validate_attribs()
Ensures that the cache is still stored in sorted order.
 
bool is_empty() const
Returns true if the table is empty; i.e.
 
virtual void finalize(BamReader *manager)
Called by the BamReader to perform any final actions needed for setting up the object after all objec...
 
A class to retrieve the individual data elements previously stored in a Datagram.
 
TypeHandle is the identifier used to differentiate C++ class types.
 
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
 
virtual bool lower_attrib_can_override() const
Intended to be overridden by derived RenderAttrib types to specify how two consecutive RenderAttrib o...
 
void unref_delete(RefCountType *ptr)
This global helper function will unref the given ReferenceCount object, and if the reference count re...
 
bool remove(const Key &key)
Removes the indicated key and its associated data from the table.
 
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
 
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
 
virtual bool unref() const
Explicitly decrements the reference count.
 
int find(const Key &key) const
Searches for the indicated key in the table.