|
Panda3D
|
This represents a unique collection of RenderAttrib objects that correspond to a particular renderable state. More...
#include "renderState.h"
Public Types | |
| typedef RenderAttribRegistry::SlotMask | SlotMask |
Public Types inherited from NodeCachedReferenceCount | |
| enum | Referenced { R_node = 0x001 , R_cache = 0x002 } |
Public Member Functions | |
| virtual | ~RenderState () |
| The destructor is responsible for removing the RenderState from the global set if it is there. | |
| ConstPointerTo< RenderState > | add_attrib (const RenderAttrib *attrib, int override=0) const |
| Returns a new RenderState object that represents the same as the source state, with the new RenderAttrib added. | |
| ConstPointerTo< RenderState > | adjust_all_priorities (int adjustment) const |
| Returns a new RenderState object that represents the same as the source state, with all attributes' override values incremented (or decremented, if negative) by the indicated amount. | |
| void | cache_ref () const |
| void | cache_ref_only () const |
| Overrides this method to update PStats appropriately. | |
| bool | cache_unref () const |
| int | compare_mask (const RenderState &other, SlotMask compare_mask) const |
| This version of compare_to takes a slot mask that indicates which attributes to include in the comparison. | |
| int | compare_sort (const RenderState &other) const |
| Returns -1, 0, or 1 according to the relative sorting of these two RenderStates, with regards to rendering performance, so that "heavier" RenderAttribs (as defined by RenderAttribRegistry::get_slot_sort()) are more likely to be grouped together. | |
| int | compare_to (const RenderState &other) const |
| Provides an arbitrary ordering among all unique RenderStates, so we can store the essentially different ones in a big set and throw away the rest. | |
| virtual int | complete_pointers (TypedWritable **plist, BamReader *manager) |
| Receives an array of pointers, one for each time manager->read_pointer() was called in fillin(). | |
| ConstPointerTo< RenderState > | compose (const RenderState *other) const |
| Returns a new RenderState object that represents the composition of this state with the other state. | |
| bool | cull_callback (CullTraverser *trav, const CullTraverserData &data) const |
| Calls cull_callback() on each attrib. | |
| virtual void | finalize (BamReader *manager) |
| Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed. | |
| virtual TypeHandle | force_init_type () |
| template<class AttribType> | |
| bool | get_attrib (const AttribType *&attrib) const |
| Handy templated version of get_attrib that casts to the right type. | |
| template<class AttribType> | |
| bool | get_attrib (ConstPointerTo< AttribType > &attrib) const |
| template<class AttribType> | |
| bool | get_attrib (CPT(AttribType) &attrib) const |
| const RenderAttrib * | get_attrib (int slot) const |
| const RenderAttrib * | get_attrib (TypeHandle type) const |
| template<class AttribType> | |
| void | get_attrib_def (const AttribType *&attrib) const |
| Handy templated version of get_attrib_def that casts to the right type. | |
| template<class AttribType> | |
| void | get_attrib_def (ConstPointerTo< AttribType > &attrib) const |
| template<class AttribType> | |
| void | get_attrib_def (CPT(AttribType) &attrib) const |
| const RenderAttrib * | get_attrib_def (int slot) const |
| int | get_bin_index () const |
| size_t | get_composition_cache_num_entries () const |
| const RenderState * | get_composition_cache_result (size_t n) const |
| size_t | get_composition_cache_size () const |
| const RenderState * | get_composition_cache_source (size_t n) const |
| int | get_draw_order () const |
| int | get_geom_rendering (int geom_rendering) const |
| Returns the union of the Geom::GeomRendering bits that will be required once this RenderState is applied to a geom which includes the indicated geom_rendering bits. | |
| size_t | get_hash () const |
| Returns a suitable hash value for phash_map. | |
| size_t | get_invert_composition_cache_num_entries () const |
| const RenderState * | get_invert_composition_cache_result (size_t n) const |
| size_t | get_invert_composition_cache_size () const |
| const RenderState * | get_invert_composition_cache_source (size_t n) const |
| int | get_override (int slot) const |
| int | get_override (TypeHandle type) const |
| virtual TypeHandle | get_type () const |
| ConstPointerTo< RenderState > | get_unique () const |
| bool | has_attrib (int slot) const |
| bool | has_attrib (TypeHandle type) const |
| bool | has_cull_callback () const |
| Returns true if any of the RenderAttribs in this state request a cull_callback(), false if none of them do. | |
| ConstPointerTo< RenderState > | invert_compose (const RenderState *other) const |
| Returns a new RenderState object that represents the composition of this state's inverse with the other state. | |
| bool | is_empty () const |
| Returns true if the state is empty, false otherwise. | |
| void | node_ref () const |
| bool | node_unref () const |
| RenderState & | operator= (const RenderState ©)=delete |
| void | output (std::ostream &out) const |
| ConstPointerTo< RenderState > | remove_attrib (int slot) const |
| Returns a new RenderState object that represents the same as the source state, with the indicated RenderAttrib removed. | |
| ConstPointerTo< RenderState > | remove_attrib (TypeHandle type) const |
| ConstPointerTo< RenderState > | set_attrib (const RenderAttrib *attrib) const |
| Returns a new RenderState object that represents the same as the source state, with the new RenderAttrib added. | |
| ConstPointerTo< RenderState > | set_attrib (const RenderAttrib *attrib, int override) const |
| Returns a new RenderState object that represents the same as the source state, with the new RenderAttrib added. | |
| virtual bool | unref () const |
| This method overrides ReferenceCount::unref() to check whether the remaining reference count is entirely in the cache, and if so, it checks for and breaks a cycle in the cache involving this object. | |
| void | write (std::ostream &out, int indent_level) const |
| virtual void | write_datagram (BamWriter *manager, Datagram &dg) |
| Writes the contents of this object to the datagram for shipping out to a Bam file. | |
Public Member Functions inherited from NodeCachedReferenceCount | |
| int | get_node_ref_count () const |
| Returns the current reference count. | |
| int | get_referenced_bits () const |
| Returns the union of the values defined in the Referenced enum that represents the various things that appear to be holding a pointer to this object. | |
| void | node_ref () const |
| Explicitly increments the reference count. | |
| bool | node_unref () const |
| Explicitly decrements the node reference count and the normal reference count simultaneously. | |
| bool | test_ref_count_integrity () const |
| Does some easy checks to make sure that the reference count isn't completely bogus. | |
Public Member Functions inherited from CachedTypedWritableReferenceCount | |
| void | cache_ref () const |
| Explicitly increments the cache reference count and the normal reference count simultaneously. | |
| void | cache_ref_only () const |
| Decrements the cache reference count without affecting the normal reference count. | |
| bool | cache_unref () const |
| Explicitly decrements the cache reference count and the normal reference count simultaneously. | |
| int | get_cache_ref_count () const |
| bool | test_ref_count_integrity () const |
| Does some easy checks to make sure that the reference count isn't completely bogus. | |
Public Member Functions inherited from TypedWritableReferenceCount | |
| TypedWritableReferenceCount (const TypedWritableReferenceCount ©) | |
| virtual ReferenceCount * | as_reference_count () |
| Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type. | |
| void | operator= (const TypedWritableReferenceCount ©) |
Public Member Functions inherited from TypedWritable | |
| TypedWritable (const TypedWritable ©) | |
| vector_uchar | encode_to_bam_stream () const |
| Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a bytes object. | |
| bool | encode_to_bam_stream (vector_uchar &data, BamWriter *writer=nullptr) const |
| Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. | |
| UpdateSeq | get_bam_modified () const |
| Returns the current bam_modified counter. | |
| void | mark_bam_modified () |
| Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. | |
| void | operator= (const TypedWritable ©) |
| virtual bool | require_fully_complete () const |
| Some objects require all of their nested pointers to have been completed before the objects themselves can be completed. | |
| virtual void | update_bam_nested (BamWriter *manager) |
| Called by the BamWriter when this object has not itself been modified recently, but it should check its nested objects for updates. | |
Public Member Functions inherited from TypedObject | |
| TypedObject (const TypedObject ©)=default | |
| TypedObject * | as_typed_object () |
| Returns the object, upcast (if necessary) to a TypedObject pointer. | |
| const TypedObject * | as_typed_object () const |
| Returns the object, upcast (if necessary) to a TypedObject pointer. | |
| int | get_best_parent_from_Set (const std::set< int > &) const |
| int | get_type_index () const |
| Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. | |
| bool | is_exact_type (TypeHandle handle) const |
| Returns true if the current object is the indicated type exactly. | |
| bool | is_of_type (TypeHandle handle) const |
| Returns true if the current object is or derives from the indicated type. | |
| TypedObject & | operator= (const TypedObject ©)=default |
Public Member Functions inherited from MemoryBase | |
| void | operator delete (void *, void *) |
| void | operator delete (void *ptr) |
| void | operator delete[] (void *, void *) |
| void | operator delete[] (void *ptr) |
| void * | operator new (size_t size) |
| void * | operator new (size_t size, void *ptr) |
| void * | operator new[] (size_t size) |
| void * | operator new[] (size_t size, void *ptr) |
Public Member Functions inherited from ReferenceCount | |
| int | get_ref_count () const |
| WeakReferenceList * | get_weak_list () const |
| Returns the WeakReferenceList associated with this ReferenceCount object. | |
| bool | has_weak_list () const |
| Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. | |
| void | local_object () |
| This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. | |
| void | ref () const |
| Explicitly increments the reference count. | |
| bool | ref_if_nonzero () const |
| Atomically increases the reference count of this object if it is not zero. | |
| bool | test_ref_count_integrity () const |
| Does some easy checks to make sure that the reference count isn't completely bogus. | |
| bool | test_ref_count_nonzero () const |
| Does some easy checks to make sure that the reference count isn't zero, or completely bogus. | |
| bool | unref_if_one () const |
| Atomically decreases the reference count of this object if it is one. | |
| WeakReferenceList * | weak_ref () |
| Adds the indicated PointerToVoid as a weak reference to this object. | |
| void | weak_unref () |
| Removes the indicated PointerToVoid as a weak reference to this object. | |
Static Public Member Functions | |
| static void | bin_removed (int bin_index) |
| Intended to be called by CullBinManager::remove_bin(), this informs all the RenderStates in the world to remove the indicated bin_index from their cache if it has been cached. | |
| static TypedWritable * | change_this (TypedWritable *old_ptr, BamReader *manager) |
| Called immediately after complete_pointers(), this gives the object a chance to adjust its own pointer if desired. | |
| static int | clear_cache () |
| Empties the cache of composed RenderStates. | |
| static void | clear_munger_cache () |
| Completely empties the cache of state + gsg -> munger, for all states and all gsg's. | |
| static void | flush_level () |
| Flushes the PStatCollectors used during traversal. | |
| static int | garbage_collect () |
| Performs a garbage-collection cycle. | |
| static TypeHandle | get_class_type () |
| static int | get_max_priority () |
| Returns the maximum priority number (sometimes called override) that may be set on any node. | |
| static int | get_num_states () |
| Returns the total number of unique RenderState objects allocated in the world. | |
| static int | get_num_unused_states () |
| Returns the total number of RenderState objects that have been allocated but have no references outside of the internal RenderState cache. | |
| static void | init_states () |
| Make sure the global _states map is allocated. | |
| static void | init_type () |
| static void | list_cycles (std::ostream &out) |
| Detects all of the reference-count cycles in the cache and reports them to standard output. | |
| static void | list_states (std::ostream &out) |
| Lists all of the RenderStates in the cache to the output stream, one per line. | |
| static ConstPointerTo< RenderState > | make (const RenderAttrib *attrib, int override=0) |
| Returns a RenderState with one attribute set. | |
| static ConstPointerTo< RenderState > | make (const RenderAttrib *attrib1, const RenderAttrib *attrib2, const RenderAttrib *attrib3, const RenderAttrib *attrib4, const RenderAttrib *attrib5, int override=0) |
| Returns a RenderState with five attributes set. | |
| static ConstPointerTo< RenderState > | make (const RenderAttrib *attrib1, const RenderAttrib *attrib2, const RenderAttrib *attrib3, const RenderAttrib *attrib4, int override=0) |
| Returns a RenderState with four attributes set. | |
| static ConstPointerTo< RenderState > | make (const RenderAttrib *attrib1, const RenderAttrib *attrib2, const RenderAttrib *attrib3, int override=0) |
| Returns a RenderState with three attributes set. | |
| static ConstPointerTo< RenderState > | make (const RenderAttrib *attrib1, const RenderAttrib *attrib2, int override=0) |
| Returns a RenderState with two attributes set. | |
| static ConstPointerTo< RenderState > | make (const RenderAttrib *const *attrib, int num_attribs, int override=0) |
| Returns a RenderState with n attributes set. | |
| static ConstPointerTo< RenderState > | make_empty () |
| static void | register_with_read_factory () |
| Tells the BamReader how to create objects of type RenderState. | |
| static bool | validate_states () |
| Ensures that the cache is still stored in sorted order, and that none of the cache elements have been inadvertently deleted. | |
Static Public Member Functions inherited from NodeCachedReferenceCount | |
| static TypeHandle | get_class_type () |
| static void | init_type () |
Static Public Member Functions inherited from CachedTypedWritableReferenceCount | |
| static TypeHandle | get_class_type () |
| static void | init_type () |
Static Public Member Functions inherited from TypedWritableReferenceCount | |
| static TypeHandle | get_class_type () |
| static void | init_type () |
| static | PT (TypedWritableReferenceCount) decode_from_bam_stream(vector_uchar data |
Static Public Member Functions inherited from TypedWritable | |
| static bool | decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, vector_uchar data, BamReader *reader=nullptr) |
| Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts the single object on those bytes. | |
| static TypeHandle | get_class_type () |
| static void | init_type () |
Static Public Member Functions inherited from TypedObject | |
| static TypeHandle | get_class_type () |
| static void | init_type () |
| This function is declared non-inline to work around a compiler bug in g++ 2.96. | |
Static Public Member Functions inherited from ReferenceCount | |
| static TypeHandle | get_class_type () |
| static void | init_type () |
Public Attributes | |
| ConstPointerTo< RenderAttrib > | _generated_shader |
| UpdateSeq | _generated_shader_seq |
| get_attrib | |
| has_attrib | |
Public Attributes inherited from CachedTypedWritableReferenceCount | |
| get_cache_ref_count | |
| Returns the current reference count. | |
Public Attributes inherited from TypedWritableReferenceCount | |
| static BamReader * | reader = nullptr) |
Public Attributes inherited from TypedObject | |
| get_type | |
Public Attributes inherited from ReferenceCount | |
| get_ref_count | |
| Returns the current reference count. | |
Friends | |
| class | Extension< RenderState > |
| class | GraphicsStateGuardian |
| class | RenderAttribRegistry |
| class | ShaderGenerator |
| class | StateMunger |
Additional Inherited Members | |
Static Public Attributes inherited from TypedWritable | |
| static TypedWritable *const | Null = nullptr |
This represents a unique collection of RenderAttrib objects that correspond to a particular renderable state.
You should not attempt to create or modify a RenderState object directly. Instead, call one of the make() functions to create one for you. And instead of modifying a RenderState object, create a new one.
Definition at line 47 of file renderState.h.
Definition at line 60 of file renderState.h.
|
virtual |
The destructor is responsible for removing the RenderState from the global set if it is there.
Definition at line 114 of file renderState.cxx.
References ReferenceCount::get_ref_count.
| ConstPointerTo< RenderState > RenderState::add_attrib | ( | const RenderAttrib * | attrib, |
| int | override = 0 ) const |
Returns a new RenderState object that represents the same as the source state, with the new RenderAttrib added.
If there is already a RenderAttrib with the same type, it is replaced (unless the override is lower).
Definition at line 512 of file renderState.cxx.
References BitMask< WType, nbits >::set_bit().
Referenced by CullPlanes::do_cull(), and GeomTransformer::make_compatible_state().
| ConstPointerTo< RenderState > RenderState::adjust_all_priorities | ( | int | adjustment | ) | const |
Returns a new RenderState object that represents the same as the source state, with all attributes' override values incremented (or decremented, if negative) by the indicated amount.
If the override would drop below zero, it is set to zero.
Definition at line 586 of file renderState.cxx.
References BitMask< WType, nbits >::clear_bit(), and BitMask< WType, nbits >::get_lowest_on_bit().
|
static |
Intended to be called by CullBinManager::remove_bin(), this informs all the RenderStates in the world to remove the indicated bin_index from their cache if it has been cached.
Definition at line 1194 of file renderState.cxx.
Referenced by CullBinManager::remove_bin().
|
inline |
Overrides this method to update PStats appropriately.
Definition at line 487 of file renderState.I.
References CachedTypedWritableReferenceCount::cache_ref_only(), and NodeCachedReferenceCount::get_referenced_bits().
Referenced by init_states().
|
static |
Called immediately after complete_pointers(), this gives the object a chance to adjust its own pointer if desired.
Most objects don't change pointers after completion, but some need to.
Once this function has been called, the old pointer will no longer be accessed.
Definition at line 1955 of file renderState.cxx.
References BamReader::register_finalize().
|
static |
Empties the cache of composed RenderStates.
This makes every RenderState forget what results when it is composed with other RenderStates.
This will eliminate any RenderState objects that have been allocated but have no references outside of the internal RenderState map. It will not eliminate RenderState objects that are still in use.
Nowadays, this method should not be necessary, as reference-count cycles in the composition cache should be automatically detected and broken.
The return value is the number of RenderStates freed by this operation.
Definition at line 830 of file renderState.cxx.
References SimpleHashMap< Key, Value, Compare >::clear(), SimpleHashMap< Key, Value, Compare >::get_data(), SimpleHashMap< Key, Value, Compare >::get_num_entries(), and ReferenceCount::get_ref_count.
|
static |
Completely empties the cache of state + gsg -> munger, for all states and all gsg's.
Normally there is no need to empty this cache.
Definition at line 989 of file renderState.cxx.
References SimpleHashMap< Key, Value, Compare >::clear().
| int RenderState::compare_mask | ( | const RenderState & | other, |
| SlotMask | compare_mask ) const |
This version of compare_to takes a slot mask that indicates which attributes to include in the comparison.
Unlike compare_to, this method compares the attributes by pointer.
Definition at line 191 of file renderState.cxx.
References BitMask< WType, nbits >::clear_bit(), compare_mask(), and BitMask< WType, nbits >::get_lowest_on_bit().
Referenced by compare_mask().
| int RenderState::compare_sort | ( | const RenderState & | other | ) | const |
Returns -1, 0, or 1 according to the relative sorting of these two RenderStates, with regards to rendering performance, so that "heavier" RenderAttribs (as defined by RenderAttribRegistry::get_slot_sort()) are more likely to be grouped together.
This is not related to the sorting order defined by compare_to.
Definition at line 163 of file renderState.cxx.
References RenderAttribRegistry::get_num_sorted_slots(), RenderAttribRegistry::get_sorted_slot(), and RenderAttribRegistry::quick_get_global_ptr().
| int RenderState::compare_to | ( | const RenderState & | other | ) | const |
Provides an arbitrary ordering among all unique RenderStates, so we can store the essentially different ones in a big set and throw away the rest.
This method is not needed outside of the RenderState class because all equivalent RenderState objects are guaranteed to share the same pointer; thus, a pointer comparison is always sufficient.
Definition at line 140 of file renderState.cxx.
References BitMask< WType, nbits >::clear_bit(), and BitMask< WType, nbits >::get_lowest_on_bit().
Referenced by validate_states().
|
virtual |
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
Returns the number of pointers processed.
Reimplemented from TypedWritable.
Definition at line 1920 of file renderState.cxx.
References TypedWritable::complete_pointers(), and RenderAttribRegistry::quick_get_global_ptr().
| ConstPointerTo< RenderState > RenderState::compose | ( | const RenderState * | other | ) | const |
Returns a new RenderState object that represents the composition of this state with the other state.
The result of this operation is cached, and will be retained as long as both this RenderState object and the other RenderState object continue to exist. Should one of them destruct, the cached entry will be removed, and its pointer will be allowed to destruct as well.
Definition at line 343 of file renderState.cxx.
References is_empty(), and SimpleHashMap< Key, Value, Compare >::is_empty().
Referenced by GeomTransformer::apply_state(), GeomTransformer::apply_texture_colors(), PolylightEffect::cull_callback(), ScissorEffect::cull_callback(), TexProjectorEffect::cull_callback(), GeomNode::do_premunge(), GeomNode::r_prepare_scene(), PandaNode::r_prepare_scene(), TextNode::r_prepare_scene(), and MultitexReducer::scan().
| bool RenderState::cull_callback | ( | CullTraverser * | trav, |
| const CullTraverserData & | data ) const |
Calls cull_callback() on each attrib.
If any attrib returns false, interrupts the list and returns false immediately; otherwise, completes the list and returns true.
Definition at line 213 of file renderState.cxx.
References BitMask< WType, nbits >::clear_bit(), and BitMask< WType, nbits >::get_lowest_on_bit().
|
virtual |
Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed.
Reimplemented from TypedWritable.
Definition at line 1980 of file renderState.cxx.
References ReferenceCount::get_ref_count, and unref().
|
inlinestatic |
Flushes the PStatCollectors used during traversal.
Definition at line 478 of file renderState.I.
Referenced by GraphicsEngine::render_frame().
|
inlinevirtual |
Reimplemented from TypedWritableReferenceCount.
Definition at line 370 of file renderState.h.
|
static |
Performs a garbage-collection cycle.
This must be called periodically if garbage-collect-states is true to ensure that RenderStates get cleaned up appropriately. It does no harm to call it even if this variable is not true, but there is probably no advantage in that case.
This automatically calls RenderAttrib::garbage_collect() as well.
Definition at line 902 of file renderState.cxx.
References RenderAttrib::garbage_collect(), CachedTypedWritableReferenceCount::get_cache_ref_count, ReferenceCount::get_ref_count, and ReferenceCount::unref_if_one().
Referenced by PandaFramework::task_garbage_collect().
|
inline |
Handy templated version of get_attrib that casts to the right type.
Returns true if the attribute was present, false otherwise.
Definition at line 518 of file renderState.I.
|
inline |
Definition at line 524 of file renderState.I.
|
inline |
Handy templated version of get_attrib_def that casts to the right type.
Definition at line 534 of file renderState.I.
|
inline |
Definition at line 539 of file renderState.I.
|
inlinestatic |
Definition at line 359 of file renderState.h.
| int RenderState::get_geom_rendering | ( | int | geom_rendering | ) | const |
Returns the union of the Geom::GeomRendering bits that will be required once this RenderState is applied to a geom which includes the indicated geom_rendering bits.
Definition at line 1170 of file renderState.cxx.
References RenderModeAttrib::get_geom_rendering(), TexGenAttrib::get_geom_rendering(), and TexMatrixAttrib::get_geom_rendering().
|
inline |
Returns a suitable hash value for phash_map.
Definition at line 17 of file renderState.I.
|
static |
Returns the maximum priority number (sometimes called override) that may be set on any node.
This may or may not be enforced, but the scene graph code assumes that no priority numbers will be larger than this, and some effects may not work properly if you use a larger number.
Definition at line 708 of file renderState.cxx.
Referenced by GraphicsStateGuardian::begin_decal_base_first(), GraphicsStateGuardian::begin_decal_base_second(), and GraphicsStateGuardian::begin_decal_nested().
|
static |
Returns the total number of unique RenderState objects allocated in the world.
This will go up and down during normal operations.
Definition at line 717 of file renderState.cxx.
Referenced by GraphicsEngine::render_frame().
|
static |
Returns the total number of RenderState objects that have been allocated but have no references outside of the internal RenderState cache.
A nonzero return value is not necessarily indicative of leaked references; it is normal for two RenderState objects, both of which have references held outside the cache, to have to result of their composition stored within the cache. This result will be retained within the cache until one of the base RenderStates is released.
Use list_cycles() to get an idea of the number of actual "leaked" RenderState objects.
Definition at line 739 of file renderState.cxx.
References CachedTypedWritableReferenceCount::get_cache_ref_count, SimpleHashMap< Key, Value, Compare >::get_data(), SimpleHashMap< Key, Value, Compare >::get_num_entries(), and ReferenceCount::get_ref_count.
Referenced by GraphicsEngine::render_frame().
|
inlinevirtual |
Reimplemented from TypedWritableReferenceCount.
Definition at line 367 of file renderState.h.
|
inline |
Returns true if any of the RenderAttribs in this state request a cull_callback(), false if none of them do.
Definition at line 35 of file renderState.I.
|
static |
Make sure the global _states map is allocated.
This only has to be done once. We could make this map static, but then we run into problems if anyone creates a RenderState object at static init time; it also seems to cause problems when the Panda shared library is unloaded at application exit time.
Definition at line 1860 of file renderState.cxx.
References cache_ref_only(), Thread::get_current_thread, Thread::get_main_thread, and ReferenceCount::local_object().
Referenced by init_libpgraph().
|
inlinestatic |
Definition at line 362 of file renderState.h.
| ConstPointerTo< RenderState > RenderState::invert_compose | ( | const RenderState * | other | ) | const |
Returns a new RenderState object that represents the composition of this state's inverse with the other state.
This is similar to compose(), but is particularly useful for computing the relative state of a node as viewed from some other node.
Definition at line 428 of file renderState.cxx.
References is_empty(), and SimpleHashMap< Key, Value, Compare >::is_empty().
|
inline |
Returns true if the state is empty, false otherwise.
Definition at line 26 of file renderState.I.
Referenced by compose(), and invert_compose().
|
static |
Detects all of the reference-count cycles in the cache and reports them to standard output.
These cycles may be inadvertently created when state compositions cycle back to a starting point. Nowadays, these cycles should be automatically detected and broken, so this method should never list any cycles unless there is a bug in that detection logic.
The cycles listed here are not leaks in the strictest sense of the word, since they can be reclaimed by a call to clear_cache(); but they will not be reclaimed automatically.
Definition at line 1015 of file renderState.cxx.
References ReferenceCount::get_ref_count.
|
static |
Lists all of the RenderStates in the cache to the output stream, one per line.
This can be quite a lot of output if the cache is large, so be prepared.
Definition at line 1092 of file renderState.cxx.
|
static |
Returns a RenderState with one attribute set.
Definition at line 234 of file renderState.cxx.
References BitMask< WType, nbits >::set_bit().
Referenced by GraphicsStateGuardian::begin_decal_base_first(), GraphicsStateGuardian::begin_decal_base_second(), GraphicsStateGuardian::begin_decal_nested(), CPT(), LineSegs::create(), PolylightEffect::cull_callback(), ScissorEffect::cull_callback(), TexProjectorEffect::cull_callback(), GraphicsEngine::dispatch_compute(), osxGraphicsStateGuardian::draw_resize_box(), PortalNode::enable_clipping_planes(), CullableObject::munge_geom(), PT(), PT(), and RocketRenderInterface::render().
|
static |
Returns a RenderState with five attributes set.
Definition at line 297 of file renderState.cxx.
References BitMask< WType, nbits >::set_bit().
|
static |
Returns a RenderState with four attributes set.
Definition at line 277 of file renderState.cxx.
References BitMask< WType, nbits >::set_bit().
|
static |
Returns a RenderState with three attributes set.
Definition at line 260 of file renderState.cxx.
References BitMask< WType, nbits >::set_bit().
|
static |
Returns a RenderState with two attributes set.
Definition at line 246 of file renderState.cxx.
References BitMask< WType, nbits >::set_bit().
|
static |
Returns a RenderState with n attributes set.
Definition at line 320 of file renderState.cxx.
References BitMask< WType, nbits >::set_bit().
| void RenderState::output | ( | std::ostream & | out | ) | const |
Definition at line 655 of file renderState.cxx.
|
static |
Tells the BamReader how to create objects of type RenderState.
Definition at line 1884 of file renderState.cxx.
References BamReader::get_factory(), and Factory< Type >::register_factory().
Referenced by init_libpgraph().
| ConstPointerTo< RenderState > RenderState::remove_attrib | ( | int | slot | ) | const |
Returns a new RenderState object that represents the same as the source state, with the indicated RenderAttrib removed.
Definition at line 562 of file renderState.cxx.
References BitMask< WType, nbits >::clear_bit().
| ConstPointerTo< RenderState > RenderState::set_attrib | ( | const RenderAttrib * | attrib | ) | const |
Returns a new RenderState object that represents the same as the source state, with the new RenderAttrib added.
If there is already a RenderAttrib with the same type, it is replaced unconditionally. The override is not changed.
Definition at line 534 of file renderState.cxx.
References BitMask< WType, nbits >::set_bit().
Referenced by NodePath::copy_to().
| ConstPointerTo< RenderState > RenderState::set_attrib | ( | const RenderAttrib * | attrib, |
| int | override ) const |
Returns a new RenderState object that represents the same as the source state, with the new RenderAttrib added.
If there is already a RenderAttrib with the same type, it is replaced unconditionally. The override is also replaced unconditionally.
Definition at line 549 of file renderState.cxx.
References BitMask< WType, nbits >::set_bit().
|
virtual |
This method overrides ReferenceCount::unref() to check whether the remaining reference count is entirely in the cache, and if so, it checks for and breaks a cycle in the cache involving this object.
This is designed to prevent leaks from cyclical references within the cache.
Reimplemented from ReferenceCount.
Definition at line 610 of file renderState.cxx.
References CachedTypedWritableReferenceCount::get_cache_ref_count, ReferenceCount::get_ref_count, and ReferenceCount::unref().
Referenced by finalize().
|
static |
Ensures that the cache is still stored in sorted order, and that none of the cache elements have been inadvertently deleted.
Returns true if so, false if there is a problem (which implies someone has modified one of the supposedly-const RenderState objects).
Definition at line 1114 of file renderState.cxx.
References compare_to().
| void RenderState::write | ( | std::ostream & | out, |
| int | indent_level ) const |
Definition at line 683 of file renderState.cxx.
Writes the contents of this object to the datagram for shipping out to a Bam file.
Reimplemented from TypedWritable.
Definition at line 1893 of file renderState.cxx.
References Datagram::add_int32(), Datagram::add_uint16(), BitMask< WType, nbits >::clear_bit(), BitMask< WType, nbits >::get_lowest_on_bit(), TypedWritable::write_datagram(), and BamWriter::write_pointer().
|
friend |
Definition at line 376 of file renderState.h.
|
friend |
Definition at line 375 of file renderState.h.
|
friend |
Definition at line 376 of file renderState.h.
|
friend |
Definition at line 378 of file renderState.h.
|
friend |
Definition at line 379 of file renderState.h.
|
mutable |
Definition at line 232 of file renderState.h.
|
mutable |
Definition at line 233 of file renderState.h.
| RenderState::get_attrib |
Definition at line 111 of file renderState.h.
| RenderState::has_attrib |
Definition at line 111 of file renderState.h.