ElementRenderer.cpp
Go to the documentation of this file.
1 #include "ElementRenderer.hpp"
2 
3 #include "Elem.hpp"
4 #include "../Defs.hpp"
5 
6 namespace iv
7 {
8 
9 //-------------- ElementRenderer ----------------------------------
11  cm( inst, this, "ElementRenderer" ),
12  inst( inst ),
13  _first_passes( 0 ),
14  _second_passes( 0 )
15 {
16 }
17 
19 {
20  return this->inst;
21 }
22 
24 {
25  this->second_pass.push_back( node );
26 }
27 
29 {
30  // This relies on the fact that items are popped in the opposite order than they were inserted.
31  // Elements must ensure that this condition is satisfied.
32  if( this->second_pass.size() && this->second_pass.back() == node )
33  {
34  this->cm.log( SRC_INFO, Defs::Log::ElementSecondPass, "Dequeue ", node->cm, "." );
35  this->second_pass.pop_back();
36  }
37 }
38 
40 {
41  while( this->second_pass.size() )
42  {
43  Elem * node = this->second_pass.back();
44  this->cm.log( SRC_INFO, Defs::Log::ElementSecondPass, "Start second pass on ", node->cm, "." );
45  node->second_pass( this );
46  }
47 }
48 
50 {
51  this->_first_passes = 0;
52  this->_second_passes = 0;
53 
54  this->FrameStart();
55 
56  if( !this->second_pass.empty() )
57  {
58  this->cm.warning( SRC_INFO, "Second pass queue was not cleared in previous frame. Problem in Elements scene tree." );
59  this->second_pass.clear();
60  }
61 }
62 
64 {
65  // print stats
66  this->cm.log( SRC_INFO, Defs::Log::ElementRefreshSummary, this->_first_passes, " first pass refreshes, ", this->_second_passes, " second pass refreshes" );
67 }
68 
70 {
71  this->_first_passes++;
72 }
73 
75 {
76  this->_second_passes++;
77 }
78 
79 }