Panda3D
renderState.I
1 // Filename: renderState.I
2 // Created by: drose (21Feb02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: RenderState::get_hash
18 // Access: Published
19 // Description: Returns a suitable hash value for phash_map.
20 ////////////////////////////////////////////////////////////////////
21 INLINE size_t RenderState::
22 get_hash() const {
23  check_hash();
24  return _hash;
25 }
26 
27 ////////////////////////////////////////////////////////////////////
28 // Function: RenderState::is_empty
29 // Access: Published
30 // Description: Returns true if the state is empty, false otherwise.
31 ////////////////////////////////////////////////////////////////////
32 INLINE bool RenderState::
33 is_empty() const {
34  return _filled_slots.is_zero();
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: RenderState::has_cull_callback
39 // Access: Published
40 // Description: Returns true if any of the RenderAttribs in this
41 // state request a cull_callback(), false if none of
42 // them do.
43 ////////////////////////////////////////////////////////////////////
44 INLINE bool RenderState::
46  if ((_flags & F_checked_cull_callback) == 0) {
47  // We pretend this function is const, even though it transparently
48  // modifies the internal shader cache.
49  ((RenderState *)this)->determine_cull_callback();
50  }
51  return (_flags & F_has_cull_callback) != 0;
52 }
53 
54 ////////////////////////////////////////////////////////////////////
55 // Function: RenderState::make_empty
56 // Access: Published, Static
57 // Description: Returns a RenderState with no attributes set.
58 ////////////////////////////////////////////////////////////////////
59 INLINE CPT(RenderState) RenderState::
60 make_empty() {
61  // The empty state is asked for so often, we make it a special case
62  // and store a pointer forever once we find it the first time.
63  if (_empty_state == (RenderState *)NULL) {
64  RenderState *state = new RenderState;
65  _empty_state = return_unique(state);
66  }
67 
68  return _empty_state;
69 }
70 
71 ////////////////////////////////////////////////////////////////////
72 // Function: RenderState::make_full_default
73 // Access: Published, Static
74 // Description: Returns a RenderState with all possible attributes
75 // set to their default value.
76 ////////////////////////////////////////////////////////////////////
77 INLINE CPT(RenderState) RenderState::
78 make_full_default() {
79  // The empty state is asked for so often, we make it a special case
80  // and store a pointer forever once we find it the first time.
81  if (_full_default_state == (RenderState *)NULL) {
82  RenderState *state = new RenderState;
83  state->fill_default();
84  _full_default_state = return_unique(state);
85  }
86 
87  return _full_default_state;
88 }
89 
90 ////////////////////////////////////////////////////////////////////
91 // Function: RenderState::remove_attrib
92 // Access: Published
93 // Description: Returns a new RenderState object that represents the
94 // same as the source state, with the indicated
95 // RenderAttrib removed.
96 ////////////////////////////////////////////////////////////////////
97 INLINE CPT(RenderState) RenderState::
98 remove_attrib(TypeHandle type) const {
100  int slot = reg->get_slot(type);
101  return remove_attrib(slot);
102 }
103 
104 ////////////////////////////////////////////////////////////////////
105 // Function: RenderState::has_attrib
106 // Access: Published
107 // Description: Returns true if an attrib of the indicated type is
108 // present, false otherwise.
109 ////////////////////////////////////////////////////////////////////
110 INLINE bool RenderState::
111 has_attrib(TypeHandle type) const {
112  return get_attrib(type) != (RenderAttrib *)NULL;
113 }
114 
115 ////////////////////////////////////////////////////////////////////
116 // Function: RenderState::has_attrib
117 // Access: Published
118 // Description: Returns true if an attrib of the indicated type is
119 // present, false otherwise.
120 ////////////////////////////////////////////////////////////////////
121 INLINE bool RenderState::
122 has_attrib(int slot) const {
123  return get_attrib(slot) != (RenderAttrib *)NULL;
124 }
125 
126 ////////////////////////////////////////////////////////////////////
127 // Function: RenderState::get_attrib
128 // Access: Published
129 // Description: Looks for a RenderAttrib of the indicated type in the
130 // state, and returns it if it is found, or NULL if it
131 // is not.
132 ////////////////////////////////////////////////////////////////////
133 INLINE const RenderAttrib *RenderState::
134 get_attrib(TypeHandle type) const {
135  RenderAttribRegistry *reg = RenderAttribRegistry::get_global_ptr();
136  int slot = reg->get_slot(type);
137  return _attributes[slot]._attrib;
138 }
139 
140 ////////////////////////////////////////////////////////////////////
141 // Function: RenderState::get_attrib
142 // Access: Published
143 // Description: Returns the RenderAttrib with the indicated slot
144 // index, or NULL if there is no such RenderAttrib in
145 // the state.
146 ////////////////////////////////////////////////////////////////////
147 INLINE const RenderAttrib *RenderState::
148 get_attrib(int slot) const {
149  return _attributes[slot]._attrib;
150 }
151 
152 ////////////////////////////////////////////////////////////////////
153 // Function: RenderState::get_attrib_def
154 // Access: Published
155 // Description: Returns the RenderAttrib with the indicated slot
156 // index, or the default attrib for that slot if there
157 // is no such RenderAttrib in the state.
158 ////////////////////////////////////////////////////////////////////
159 INLINE const RenderAttrib *RenderState::
160 get_attrib_def(int slot) const {
161  if (_attributes[slot]._attrib != (RenderAttrib *)NULL) {
162  return _attributes[slot]._attrib;
163  }
164  return make_full_default()->get_attrib(slot);
165 }
166 
167 ////////////////////////////////////////////////////////////////////
168 // Function: RenderState::get_override
169 // Access: Published
170 // Description: Looks for a RenderAttrib of the indicated type in the
171 // state, and returns its override value if it is found,
172 // or 0 if it is not.
173 ////////////////////////////////////////////////////////////////////
174 INLINE int RenderState::
175 get_override(TypeHandle type) const {
176  RenderAttribRegistry *reg = RenderAttribRegistry::get_global_ptr();
177  int slot = reg->get_slot(type);
178  return _attributes[slot]._override;
179 }
180 
181 ////////////////////////////////////////////////////////////////////
182 // Function: RenderState::get_override
183 // Access: Published
184 // Description: Looks for a RenderAttrib of the indicated type in the
185 // state, and returns its override value if it is found,
186 // or 0 if it is not.
187 ////////////////////////////////////////////////////////////////////
188 INLINE int RenderState::
189 get_override(int slot) const {
190  return _attributes[slot]._override;
191 }
192 
193 ////////////////////////////////////////////////////////////////////
194 // Function: RenderState::get_unique
195 // Access: Published
196 // Description: Returns the pointer to the unique RenderState in
197 // the cache that is equivalent to this one. This may
198 // be the same pointer as this object, or it may be a
199 // different pointer; but it will be an equivalent
200 // object, and it will be a shared pointer. This may be
201 // called from time to time to improve cache benefits.
202 ////////////////////////////////////////////////////////////////////
203 INLINE CPT(RenderState) RenderState::
204 get_unique() const {
205  return return_unique((RenderState *)this);
206 }
207 
208 ////////////////////////////////////////////////////////////////////
209 // Function: RenderState::cache_ref
210 // Access: Published
211 // Description: Overrides this method to update PStats appropriately.
212 ////////////////////////////////////////////////////////////////////
213 INLINE void RenderState::
214 cache_ref() const {
215 #ifdef DO_PSTATS
216  int old_referenced_bits = get_referenced_bits();
218  consider_update_pstats(old_referenced_bits);
219 #else // DO_PSTATS
221 #endif // DO_PSTATS
222 }
223 
224 ////////////////////////////////////////////////////////////////////
225 // Function: RenderState::cache_unref
226 // Access: Published
227 // Description: Overrides this method to update PStats appropriately.
228 ////////////////////////////////////////////////////////////////////
229 INLINE bool RenderState::
230 cache_unref() const {
231 #ifdef DO_PSTATS
232  int old_referenced_bits = get_referenced_bits();
233  bool result = do_cache_unref();
234  consider_update_pstats(old_referenced_bits);
235  return result;
236 #else // DO_PSTATS
237  return do_cache_unref();
238 #endif // DO_PSTATS
239 }
240 
241 ////////////////////////////////////////////////////////////////////
242 // Function: RenderState::node_ref
243 // Access: Published
244 // Description: Overrides this method to update PStats appropriately.
245 ////////////////////////////////////////////////////////////////////
246 INLINE void RenderState::
247 node_ref() const {
248 #ifdef DO_PSTATS
249  int old_referenced_bits = get_referenced_bits();
251  consider_update_pstats(old_referenced_bits);
252 #else // DO_PSTATS
254 #endif // DO_PSTATS
255 }
256 
257 ////////////////////////////////////////////////////////////////////
258 // Function: RenderState::node_unref
259 // Access: Published
260 // Description: Overrides this method to update PStats appropriately.
261 ////////////////////////////////////////////////////////////////////
262 INLINE bool RenderState::
263 node_unref() const {
264 #ifdef DO_PSTATS
265  int old_referenced_bits = get_referenced_bits();
266  bool result = do_node_unref();
267  consider_update_pstats(old_referenced_bits);
268  return result;
269 #else // DO_PSTATS
270  return do_node_unref();
271 #endif // DO_PSTATS
272 }
273 
274 ////////////////////////////////////////////////////////////////////
275 // Function: RenderState::get_composition_cache_num_entries
276 // Access: Published
277 // Description: Returns the number of entries in the composition
278 // cache for this RenderState. This is the number of
279 // other RenderStates whose composition with this one
280 // has been cached. This number is not useful for any
281 // practical reason other than performance analysis.
282 ////////////////////////////////////////////////////////////////////
283 INLINE int RenderState::
284 get_composition_cache_num_entries() const {
285  LightReMutexHolder holder(*_states_lock);
286  return _composition_cache.get_num_entries();
287 }
288 
289 ////////////////////////////////////////////////////////////////////
290 // Function: RenderState::get_invert_composition_cache_num_entries
291 // Access: Published
292 // Description: Returns the number of entries in the
293 // invert_composition cache for this RenderState.
294 // This is similar to the composition cache, but it
295 // records cache entries for the invert_compose()
296 // operation. See get_composition_cache_num_entries().
297 ////////////////////////////////////////////////////////////////////
298 INLINE int RenderState::
299 get_invert_composition_cache_num_entries() const {
300  LightReMutexHolder holder(*_states_lock);
301  return _invert_composition_cache.get_num_entries();
302 }
303 
304 ////////////////////////////////////////////////////////////////////
305 // Function: RenderState::get_composition_cache_size
306 // Access: Published
307 // Description: Returns the number of slots in the composition
308 // cache for this RenderState. You may use this as
309 // an upper bound when walking through all of the
310 // composition cache results via
311 // get_composition_cache_source() or result().
312 //
313 // This has no practical value other than for examining
314 // the cache for performance analysis.
315 ////////////////////////////////////////////////////////////////////
316 INLINE int RenderState::
317 get_composition_cache_size() const {
318  LightReMutexHolder holder(*_states_lock);
319  return _composition_cache.get_size();
320 }
321 
322 ////////////////////////////////////////////////////////////////////
323 // Function: RenderState::get_composition_cache_source
324 // Access: Published
325 // Description: Returns the source RenderState of the nth element
326 // in the composition cache. Returns NULL if there
327 // doesn't happen to be an entry in the nth element.
328 // See get_composition_cache_result().
329 //
330 // This has no practical value other than for examining
331 // the cache for performance analysis.
332 ////////////////////////////////////////////////////////////////////
333 INLINE const RenderState *RenderState::
334 get_composition_cache_source(int n) const {
335  LightReMutexHolder holder(*_states_lock);
336  if (!_composition_cache.has_element(n)) {
337  return NULL;
338  }
339  return _composition_cache.get_key(n);
340 }
341 
342 ////////////////////////////////////////////////////////////////////
343 // Function: RenderState::get_composition_cache_result
344 // Access: Published
345 // Description: Returns the result RenderState of the nth element
346 // in the composition cache. Returns NULL if there
347 // doesn't happen to be an entry in the nth element.
348 //
349 // In general,
350 // a->compose(a->get_composition_cache_source(n)) ==
351 // a->get_composition_cache_result(n).
352 //
353 // This has no practical value other than for examining
354 // the cache for performance analysis.
355 ////////////////////////////////////////////////////////////////////
356 INLINE const RenderState *RenderState::
357 get_composition_cache_result(int n) const {
358  LightReMutexHolder holder(*_states_lock);
359  if (!_composition_cache.has_element(n)) {
360  return NULL;
361  }
362  return _composition_cache.get_data(n)._result;
363 }
364 
365 ////////////////////////////////////////////////////////////////////
366 // Function: RenderState::get_invert_composition_cache_size
367 // Access: Published
368 // Description: Returns the number of slots in the composition
369 // cache for this RenderState. You may use this as
370 // an upper bound when walking through all of the
371 // composition cache results via
372 // get_invert_composition_cache_source() or result().
373 //
374 // This has no practical value other than for examining
375 // the cache for performance analysis.
376 ////////////////////////////////////////////////////////////////////
377 INLINE int RenderState::
378 get_invert_composition_cache_size() const {
379  LightReMutexHolder holder(*_states_lock);
380  return _invert_composition_cache.get_size();
381 }
382 
383 ////////////////////////////////////////////////////////////////////
384 // Function: RenderState::get_invert_composition_cache_source
385 // Access: Published
386 // Description: Returns the source RenderState of the nth element
387 // in the invert composition cache. Returns NULL if
388 // there doesn't happen to be an entry in the nth
389 // element. See get_invert_composition_cache_result().
390 //
391 // This has no practical value other than for examining
392 // the cache for performance analysis.
393 ////////////////////////////////////////////////////////////////////
394 INLINE const RenderState *RenderState::
395 get_invert_composition_cache_source(int n) const {
396  LightReMutexHolder holder(*_states_lock);
397  if (!_invert_composition_cache.has_element(n)) {
398  return NULL;
399  }
400  return _invert_composition_cache.get_key(n);
401 }
402 
403 ////////////////////////////////////////////////////////////////////
404 // Function: RenderState::get_invert_composition_cache_result
405 // Access: Published
406 // Description: Returns the result RenderState of the nth element
407 // in the invert composition cache. Returns NULL if
408 // there doesn't happen to be an entry in the nth
409 // element.
410 //
411 // In general,
412 // a->invert_compose(a->get_invert_composition_cache_source(n))
413 // == a->get_invert_composition_cache_result(n).
414 //
415 // This has no practical value other than for examining
416 // the cache for performance analysis.
417 ////////////////////////////////////////////////////////////////////
418 INLINE const RenderState *RenderState::
419 get_invert_composition_cache_result(int n) const {
420  LightReMutexHolder holder(*_states_lock);
421  if (!_invert_composition_cache.has_element(n)) {
422  return NULL;
423  }
424  return _invert_composition_cache.get_data(n)._result;
425 }
426 
427 ////////////////////////////////////////////////////////////////////
428 // Function: RenderState::get_draw_order
429 // Access: Published
430 // Description: Returns the draw order indicated by the
431 // CullBinAttrib, if any, associated by this state (or 0
432 // if there is no CullBinAttrib). See get_bin_index().
433 ////////////////////////////////////////////////////////////////////
434 INLINE int RenderState::
435 get_draw_order() const {
436  if ((_flags & F_checked_bin_index) == 0) {
437  // We pretend this function is const, even though it transparently
438  // modifies the internal draw_order cache.
439  ((RenderState *)this)->determine_bin_index();
440  }
441  return _draw_order;
442 }
443 
444 ////////////////////////////////////////////////////////////////////
445 // Function: RenderState::get_bin_index
446 // Access: Published
447 // Description: Returns the bin index indicated by the CullBinAttrib,
448 // if any, associated by this state (or the default bin
449 // index if there is no CullBinAttrib). This function
450 // is provided as an optimization for determining this
451 // at render time.
452 ////////////////////////////////////////////////////////////////////
453 INLINE int RenderState::
454 get_bin_index() const {
455  if ((_flags & F_checked_bin_index) == 0) {
456  // We pretend this function is const, even though it transparently
457  // modifies the internal bin_index cache.
458  ((RenderState *)this)->determine_bin_index();
459  }
460  return _bin_index;
461 }
462 
463 ////////////////////////////////////////////////////////////////////
464 // Function: RenderState::set_destructing
465 // Access: Private
466 // Description: This function should only be called from the
467 // destructor; it indicates that this RenderState
468 // object is beginning destruction. It is only used as
469 // a sanity check, and is only meaningful when NDEBUG is
470 // not defined.
471 ////////////////////////////////////////////////////////////////////
472 INLINE void RenderState::
473 set_destructing() {
474 #ifndef NDEBUG
475  _flags |= F_is_destructing;
476 #endif
477 }
478 
479 ////////////////////////////////////////////////////////////////////
480 // Function: RenderState::is_destructing
481 // Access: Private
482 // Description: Returns true if the RenderState object is
483 // currently within its destructor
484 // (i.e. set_destructing() has been called). This is
485 // only used as a sanity check, and is only meaningful
486 // when NDEBUG is not defined.
487 ////////////////////////////////////////////////////////////////////
488 INLINE bool RenderState::
489 is_destructing() const {
490 #ifndef NDEBUG
491  return (_flags & F_is_destructing) != 0;
492 #else
493  return false;
494 #endif
495 }
496 
497 ////////////////////////////////////////////////////////////////////
498 // Function: RenderState::consider_update_pstats
499 // Access: Private
500 // Description: Calls update_pstats() if the state of the referenced
501 // bits has changed from the indicated value.
502 ////////////////////////////////////////////////////////////////////
503 INLINE void RenderState::
504 consider_update_pstats(int old_referenced_bits) const {
505 #ifdef DO_PSTATS
506  int new_referenced_bits = get_referenced_bits();
507  if (old_referenced_bits != new_referenced_bits) {
508  update_pstats(old_referenced_bits, new_referenced_bits);
509  }
510 #endif // DO_PSTATS
511 }
512 
513 ////////////////////////////////////////////////////////////////////
514 // Function: RenderState::Composition::Constructor
515 // Access: Public
516 // Description:
517 ////////////////////////////////////////////////////////////////////
518 INLINE RenderState::Composition::
519 Composition() {
520 }
521 
522 ////////////////////////////////////////////////////////////////////
523 // Function: RenderState::Composition::Copy Constructor
524 // Access: Public
525 // Description:
526 ////////////////////////////////////////////////////////////////////
527 INLINE RenderState::Composition::
528 Composition(const RenderState::Composition &copy) :
529  _result(copy._result)
530 {
531 }
532 
533 ////////////////////////////////////////////////////////////////////
534 // Function: RenderState::Attribute::Constructor
535 // Access: Public
536 // Description:
537 ////////////////////////////////////////////////////////////////////
538 INLINE RenderState::Attribute::
539 Attribute(const RenderAttrib *attrib, int override) :
540  _attrib(attrib),
541  _override(override)
542 {
543 }
544 
545 ////////////////////////////////////////////////////////////////////
546 // Function: RenderState::Attribute::Constructor
547 // Access: Public
548 // Description:
549 ////////////////////////////////////////////////////////////////////
550 INLINE RenderState::Attribute::
551 Attribute(int override) :
552  _override(override)
553 {
554 }
555 
556 ////////////////////////////////////////////////////////////////////
557 // Function: RenderState::Attribute::Copy Constructor
558 // Access: Public
559 // Description:
560 ////////////////////////////////////////////////////////////////////
561 INLINE RenderState::Attribute::
562 Attribute(const Attribute &copy) :
563  _attrib(copy._attrib),
564  _override(copy._override)
565 {
566 }
567 
568 ////////////////////////////////////////////////////////////////////
569 // Function: RenderState::Attribute::Copy Assignment Operator
570 // Access: Public
571 // Description:
572 ////////////////////////////////////////////////////////////////////
573 INLINE void RenderState::Attribute::
574 operator = (const Attribute &copy) {
575  _attrib = copy._attrib;
576  _override = copy._override;
577 }
578 
579 ////////////////////////////////////////////////////////////////////
580 // Function: RenderState::Attribute::compare_to
581 // Access: Public
582 // Description: Provides an indication of whether a particular
583 // attribute is equivalent to another one, for purposes
584 // of generating unique RenderStates. This should
585 // compare all properties of the Attribute.
586 ////////////////////////////////////////////////////////////////////
587 INLINE int RenderState::Attribute::
588 compare_to(const Attribute &other) const {
589  if (_attrib != other._attrib) {
590  if (_attrib == NULL) {
591  return -1;
592  } else if (other._attrib == NULL) {
593  return 1;
594  }
595 
596  int c = _attrib->compare_to(*other._attrib);
597  if (c != 0) {
598  return c;
599  }
600  }
601 
602  return _override - other._override;
603 }
604 
605 ////////////////////////////////////////////////////////////////////
606 // Function: RenderState::Attribute::set
607 // Access: Public
608 // Description:
609 ////////////////////////////////////////////////////////////////////
610 INLINE void RenderState::Attribute::
611 set(const RenderAttrib *attrib, int override) {
612  _attrib = attrib;
613  _override = override;
614 }
615 
616 ////////////////////////////////////////////////////////////////////
617 // Function: RenderState::flush_level
618 // Access: Public, Static
619 // Description: Flushes the PStatCollectors used during traversal.
620 ////////////////////////////////////////////////////////////////////
621 INLINE void RenderState::
623  _node_counter.flush_level();
624  _cache_counter.flush_level();
625 }
626 
627 #ifndef CPPPARSER
628 ////////////////////////////////////////////////////////////////////
629 // Function: RenderState::get_attrib
630 // Access: Public
631 // Description: Handy templated version of get_attrib that
632 // costs to the right type. Returns true if the
633 // attribute was present, false otherwise.
634 ////////////////////////////////////////////////////////////////////
635 template<class AttribType>
636 INLINE bool RenderState::
637 get_attrib(const AttribType *&attrib) const {
638  attrib = (const AttribType *)get_attrib((int)AttribType::get_class_slot());
639  return (attrib != (const AttribType *)NULL);
640 }
641 
642 ////////////////////////////////////////////////////////////////////
643 // Function: RenderState::get_attrib_def
644 // Access: Public
645 // Description: Handy templated version of get_attrib_def that
646 // costs to the right type.
647 ////////////////////////////////////////////////////////////////////
648 template<class AttribType>
649 INLINE void RenderState::
650 get_attrib_def(const AttribType *&attrib) const {
651  attrib = (const AttribType *)get_attrib_def((int)AttribType::get_class_slot());
652 }
653 #endif // CPPPARSER
654 
655 ////////////////////////////////////////////////////////////////////
656 // Function: RenderState::check_hash
657 // Access: Private
658 // Description: Ensures that we know the hash value.
659 ////////////////////////////////////////////////////////////////////
660 INLINE void RenderState::
661 check_hash() const {
662  // This pretends to be a const function, even though it's not,
663  // because it only updates a transparent cache value.
664  if ((_flags & F_hash_known) == 0) {
665  ((RenderState *)this)->calc_hash();
666  }
667 }
668 
669 ////////////////////////////////////////////////////////////////////
670 // Function: RenderState::do_cache_unref
671 // Access: Private
672 // Description: Reimplements
673 // CachedTypedWritableReferenceCount::cache_unref(). We
674 // do this because we have a non-virtual unref() method.
675 ////////////////////////////////////////////////////////////////////
676 INLINE bool RenderState::
677 do_cache_unref() const {
678  cache_unref_only();
679  return unref();
680 }
681 
682 ////////////////////////////////////////////////////////////////////
683 // Function: RenderState::do_node_unref
684 // Access: Private
685 // Description: Reimplements NodeReferenceCount::node_unref(). We do
686 // this because we have a non-virtual unref() method.
687 ////////////////////////////////////////////////////////////////////
688 INLINE bool RenderState::
689 do_node_unref() const {
690  node_unref_only();
691  return unref();
692 }
693 
694 ////////////////////////////////////////////////////////////////////
695 // Function: RenderState::calc_hash
696 // Access: Private
697 // Description: Computes the hash value.
698 ////////////////////////////////////////////////////////////////////
699 INLINE void RenderState::
700 calc_hash() {
701  LightMutexHolder holder(_lock);
702  do_calc_hash();
703 }
704 
705 ////////////////////////////////////////////////////////////////////
706 // Function: RenderState::CompositionCycleDescEntry::Constructor
707 // Access: Public
708 // Description:
709 ////////////////////////////////////////////////////////////////////
710 INLINE RenderState::CompositionCycleDescEntry::
711 CompositionCycleDescEntry(const RenderState *obj,
712  const RenderState *result,
713  bool inverted) :
714  _obj(obj),
715  _result(result),
716  _inverted(inverted)
717 {
718 }
719 
bool is_empty() const
Returns true if the state is empty, false otherwise.
Definition: renderState.I:33
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:60
size_t get_hash() const
Returns a suitable hash value for phash_map.
Definition: renderState.I:22
void node_ref() const
Explicitly increments the reference count.
const Key & get_key(int n) const
Returns the key in the nth slot of the table.
virtual bool unref() const
Explicitly decrements the reference count.
int get_num_entries() const
Returns the number of active entries in the table.
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...
bool has_element(int n) const
Returns true if there is an element stored in the nth slot, false otherwise.
This class is used to associate each RenderAttrib with a different slot index at runtime, so we can store a list of RenderAttribs in the RenderState object, and very quickly look them up by type.
Similar to MutexHolder, but for a light mutex.
void cache_ref() const
Explicitly increments the cache reference count and the normal reference count simultaneously.
Similar to MutexHolder, but for a light reentrant mutex.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
bool has_cull_callback() const
Returns true if any of the RenderAttribs in this state request a cull_callback(), false if none of th...
Definition: renderState.I:45
const Value & get_data(int n) const
Returns the data in the nth slot of the table.
static void flush_level()
Flushes the PStatCollectors used during traversal.
Definition: renderState.I:622
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
int get_referenced_bits() const
Returns the union of the values defined in the Referenced enum that represents the various things tha...
static RenderAttribRegistry * quick_get_global_ptr()
Returns the global_ptr without first ensuring it has been initialized.
int get_size() const
Returns the total number of slots in the table.
bool is_zero() const
Returns true if the entire bitmask is zero, false otherwise.
Definition: bitMask.I:268