32 get_global_ptr()->ns_list_contents(out);
43 (
"texture-stage-pool-mode", M_none,
44 PRC_DESC(
"Defines the initial value of TextureStagePool::set_mode(). "
45 "Set this to 'none' to disable the use of the TextureStagePool, "
46 "to 'name' to group TextureStages by name only, or 'unique' "
47 "to group together only identical TextureStages."));
48 _mode = texture_stage_pool_mode.get_value();
56 MutexHolder holder(_lock);
64 StagesByName::iterator ni = _stages_by_name.find(temp->
get_name());
65 if (ni == _stages_by_name.end()) {
66 ni = _stages_by_name.insert(StagesByName::value_type(temp->
get_name(), temp)).first;
68 if ((*ni).first != (*ni).second->get_name()) {
78 CPT(TextureStage) cpttemp = temp;
79 StagesByProperties::iterator si = _stages_by_properties.find(cpttemp);
80 if (si == _stages_by_properties.end()) {
81 si = _stages_by_properties.insert(StagesByProperties::value_type(
new TextureStage(*temp), temp)).first;
83 if (*(*si).first != *(*si).second) {
99void TextureStagePool::
101 MutexHolder holder(_lock);
108 _stages_by_name.erase(temp->
get_name());
113 CPT(TextureStage) cpttemp = temp;
114 _stages_by_properties.erase(cpttemp);
123void TextureStagePool::
124ns_release_all_stages() {
125 MutexHolder holder(_lock);
127 _stages_by_name.clear();
128 _stages_by_properties.clear();
134void TextureStagePool::
135ns_set_mode(TextureStagePool::Mode mode) {
136 MutexHolder holder(_lock);
139 _stages_by_name.clear();
140 _stages_by_properties.clear();
148TextureStagePool::Mode TextureStagePool::
150 MutexHolder holder(_lock);
158int TextureStagePool::
159ns_garbage_collect() {
160 MutexHolder holder(_lock);
168 int num_released = 0;
169 StagesByName new_set;
171 StagesByName::iterator ni;
172 for (ni = _stages_by_name.begin(); ni != _stages_by_name.end(); ++ni) {
173 const string &name = (*ni).first;
174 TextureStage *ts2 = (*ni).second;
176 if (gobj_cat.is_debug()) {
178 <<
"Releasing " << name <<
"\n";
182 new_set.insert(new_set.end(), *ni);
186 _stages_by_name.swap(new_set);
192 int num_released = 0;
193 StagesByProperties new_set;
195 StagesByProperties::iterator si;
196 for (si = _stages_by_properties.begin(); si != _stages_by_properties.end(); ++si) {
197 const TextureStage *ts1 = (*si).first;
198 TextureStage *ts2 = (*si).second;
200 if (gobj_cat.is_debug()) {
202 <<
"Releasing " << *ts1 <<
"\n";
206 new_set.insert(new_set.end(), *si);
210 _stages_by_properties.swap(new_set);
221void TextureStagePool::
222ns_list_contents(ostream &out)
const {
223 MutexHolder holder(_lock);
225 out <<
"TextureStagePool in mode " << _mode <<
"\n";
233 out << _stages_by_name.size() <<
" TextureStages:\n";
234 StagesByName::const_iterator ni;
235 for (ni = _stages_by_name.begin(); ni != _stages_by_name.end(); ++ni) {
236 const string &name = (*ni).first;
237 TextureStage *ts2 = (*ni).second;
246 out << _stages_by_properties.size() <<
" TextureStages:\n";
247 StagesByProperties::const_iterator si;
248 for (si = _stages_by_properties.begin(); si != _stages_by_properties.end(); ++si) {
249 const TextureStage *ts1 = (*si).first;
250 TextureStage *ts2 = (*si).second;
265 if (_global_ptr ==
nullptr) {
266 _global_ptr =
new TextureStagePool;
275operator << (ostream &out, TextureStagePool::Mode mode) {
277 case TextureStagePool::M_none:
278 return out <<
"none";
280 case TextureStagePool::M_name:
281 return out <<
"name";
283 case TextureStagePool::M_unique:
284 return out <<
"unique";
287 return out <<
"**invalid mode (" << (int)mode <<
")**";
294operator >> (istream &in, TextureStagePool::Mode &mode) {
298 if (cmp_nocase(word,
"none") == 0) {
299 mode = TextureStagePool::M_none;
300 }
else if (cmp_nocase(word,
"name") == 0) {
301 mode = TextureStagePool::M_name;
302 }
else if (cmp_nocase(word,
"unique") == 0) {
303 mode = TextureStagePool::M_unique;
306 gobj_cat->error() <<
"Invalid TextureStagePool mode value: " << word <<
"\n";
307 mode = TextureStagePool::M_none;
This class specializes ConfigVariable as an enumerated type.
get_ref_count
Returns the current reference count.
The TextureStagePool (there is only one in the universe) serves to unify different pointers to the sa...
static void write(std::ostream &out)
Lists the contents of the TextureStage pool to the indicated output stream.
Defines the properties of a named stage of the multitexture pipeline.
get_name
Returns the name of this texture stage.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.