28 return _filled_slots.is_zero();
37 if ((_flags & F_checked_cull_callback) == 0) {
40 ((RenderState *)
this)->determine_cull_callback();
42 return (_flags & F_has_cull_callback) != 0;
61 return remove_attrib(slot);
68INLINE
bool RenderState::
70 return get_attrib(type) !=
nullptr;
77INLINE
bool RenderState::
78has_attrib(
int slot)
const {
79 return get_attrib(slot) !=
nullptr;
88 RenderAttribRegistry *reg = RenderAttribRegistry::get_global_ptr();
90 return _attributes[slot]._attrib;
98get_attrib(
int slot)
const {
99 return _attributes[slot]._attrib;
107get_attrib_def(
int slot)
const {
108 if (_attributes[slot]._attrib !=
nullptr) {
109 return _attributes[slot]._attrib;
119INLINE
int RenderState::
121 RenderAttribRegistry *reg = RenderAttribRegistry::get_global_ptr();
123 return _attributes[slot]._override;
130INLINE
int RenderState::
131get_override(
int slot)
const {
132 return _attributes[slot]._override;
144 return return_unique((RenderState *)
this);
150INLINE
void RenderState::
155 consider_update_pstats(old_referenced_bits);
164INLINE
bool RenderState::
168 bool result = do_cache_unref();
169 consider_update_pstats(old_referenced_bits);
172 return do_cache_unref();
179INLINE
void RenderState::
184 consider_update_pstats(old_referenced_bits);
193INLINE
bool RenderState::
197 bool result = do_node_unref();
198 consider_update_pstats(old_referenced_bits);
201 return do_node_unref();
211INLINE
size_t RenderState::
212get_composition_cache_num_entries()
const {
213 LightReMutexHolder holder(*_states_lock);
214 return _composition_cache.get_num_entries();
223INLINE
size_t RenderState::
224get_invert_composition_cache_num_entries()
const {
225 LightReMutexHolder holder(*_states_lock);
226 return _invert_composition_cache.get_num_entries();
237INLINE
size_t RenderState::
238get_composition_cache_size()
const {
239 LightReMutexHolder holder(*_states_lock);
240 return _composition_cache.get_num_entries();
252get_composition_cache_source(
size_t n)
const {
253 LightReMutexHolder holder(*_states_lock);
254 return _composition_cache.get_key(n);
268get_composition_cache_result(
size_t n)
const {
269 LightReMutexHolder holder(*_states_lock);
270 return _composition_cache.get_data(n)._result;
282INLINE
size_t RenderState::
283get_invert_composition_cache_size()
const {
284 LightReMutexHolder holder(*_states_lock);
285 return _invert_composition_cache.get_num_entries();
297get_invert_composition_cache_source(
size_t n)
const {
298 LightReMutexHolder holder(*_states_lock);
299 return _invert_composition_cache.get_key(n);
314get_invert_composition_cache_result(
size_t n)
const {
315 LightReMutexHolder holder(*_states_lock);
316 return _invert_composition_cache.get_data(n)._result;
323INLINE
int RenderState::
324get_draw_order()
const {
325 if ((_flags & F_checked_bin_index) == 0) {
328 ((RenderState *)
this)->determine_bin_index();
339INLINE
int RenderState::
340get_bin_index()
const {
341 if ((_flags & F_checked_bin_index) == 0) {
344 ((RenderState *)
this)->determine_bin_index();
354INLINE
void RenderState::
357 _flags |= F_is_destructing;
366INLINE
bool RenderState::
367is_destructing()
const {
369 return (_flags & F_is_destructing) != 0;
379INLINE
void RenderState::
380consider_update_pstats(
int old_referenced_bits)
const {
383 if (old_referenced_bits != new_referenced_bits) {
384 update_pstats(old_referenced_bits, new_referenced_bits);
392INLINE RenderState::Composition::
399INLINE RenderState::Composition::
400Composition(
const RenderState::Composition ©) :
401 _result(copy._result)
408INLINE RenderState::Attribute::
418INLINE RenderState::Attribute::
419Attribute(
int override) :
427INLINE RenderState::Attribute::
428Attribute(
const Attribute ©) :
429 _attrib(copy._attrib),
430 _override(copy._override)
437INLINE
void RenderState::Attribute::
438operator = (
const Attribute ©) {
439 _attrib = copy._attrib;
440 _override = copy._override;
448INLINE
int RenderState::Attribute::
449compare_to(
const Attribute &other)
const {
450 if (_attrib != other._attrib) {
451 if (_attrib ==
nullptr) {
453 }
else if (other._attrib ==
nullptr) {
457 int c = _attrib->compare_to(*other._attrib);
463 return _override - other._override;
469INLINE
void RenderState::Attribute::
470set(
const RenderAttrib *attrib,
int override) {
472 _override =
override;
480 _node_counter.flush_level();
481 _cache_counter.flush_level();
492 consider_update_pstats(old_referenced_bits);
501INLINE
void RenderState::
502cache_unref_only()
const {
505 NodeCachedReferenceCount::cache_unref_only();
506 consider_update_pstats(old_referenced_bits);
508 NodeCachedReferenceCount::cache_unref_only();
517template<
class AttribType>
518INLINE
bool RenderState::
519get_attrib(
const AttribType *&attrib)
const {
520 attrib = (
const AttribType *)get_attrib((
int)AttribType::get_class_slot());
521 return (attrib !=
nullptr);
523template<
class AttribType>
524INLINE
bool RenderState::
525get_attrib(CPT(AttribType) &attrib)
const {
526 attrib = (
const AttribType *)get_attrib((
int)AttribType::get_class_slot());
527 return (attrib !=
nullptr);
533template<
class AttribType>
534INLINE
void RenderState::
535get_attrib_def(
const AttribType *&attrib)
const {
536 attrib = (
const AttribType *)get_attrib_def((
int)AttribType::get_class_slot());
538template<
class AttribType>
539INLINE
void RenderState::
540get_attrib_def(CPT(AttribType) &attrib)
const {
541 attrib = (
const AttribType *)get_attrib_def((
int)AttribType::get_class_slot());
548INLINE
void RenderState::
552 if ((_flags & F_hash_known) != 0) {
554 ((RenderState *)
this)->calc_hash();
562INLINE
bool RenderState::
563do_cache_unref()
const {
564 NodeCachedReferenceCount::cache_unref_only();
572INLINE
bool RenderState::
573do_node_unref()
const {
581INLINE
void RenderState::
583 LightMutexHolder holder(_lock);
590INLINE RenderState::CompositionCycleDescEntry::
591CompositionCycleDescEntry(
const RenderState *obj,
592 const RenderState *result,
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.
void node_ref() const
Explicitly increments the reference count.
int get_referenced_bits() const
Returns the union of the values defined in the Referenced enum that represents the various things tha...
const RenderAttrib * get_slot_default(int slot) const
Returns the default RenderAttrib object associated with slot n.
static RenderAttribRegistry * quick_get_global_ptr()
Returns the global_ptr without first ensuring it has been initialized.
int get_slot(TypeHandle type_handle) const
Returns the slot number assigned to the indicated TypeHandle, or 0 if no slot number has been assigne...
This is the base class for a number of render attributes (other than transform) that may be set on sc...
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
size_t get_hash() const
Returns a suitable hash value for phash_map.
void cache_ref_only() const
Overrides this method to update PStats appropriately.
bool is_empty() const
Returns true if the state is empty, false otherwise.
bool has_cull_callback() const
Returns true if any of the RenderAttribs in this state request a cull_callback(), false if none of th...
virtual bool unref() const
This method overrides ReferenceCount::unref() to check whether the remaining reference count is entir...
static void flush_level()
Flushes the PStatCollectors used during traversal.
TypeHandle is the identifier used to differentiate C++ class types.