16 #include "textureStagePool.h" 17 #include "config_gobj.h" 18 #include "mutexHolder.h" 19 #include "configVariableEnum.h" 20 #include "string_utils.h" 33 get_global_ptr()->ns_list_contents(out);
46 (
"texture-stage-pool-mode", M_none,
47 PRC_DESC(
"Defines the initial value of TextureStagePool::set_mode(). " 48 "Set this to 'none' to disable the use of the TextureStagePool, " 49 "to 'name' to group TextureStages by name only, or 'unique' " 50 "to group together only identical TextureStages."));
51 _mode = texture_stage_pool_mode.
get_value();
69 StagesByName::iterator ni = _stages_by_name.find(temp->
get_name());
70 if (ni == _stages_by_name.end()) {
71 ni = _stages_by_name.insert(StagesByName::value_type(temp->
get_name(), temp)).first;
73 if ((*ni).first != (*ni).second->get_name()) {
85 StagesByProperties::iterator si = _stages_by_properties.find(cpttemp);
86 if (si == _stages_by_properties.end()) {
87 si = _stages_by_properties.insert(StagesByProperties::value_type(
new TextureStage(*temp), temp)).first;
89 if (*(*si).first != *(*si).second) {
107 void TextureStagePool::
116 _stages_by_name.erase(temp->
get_name());
122 _stages_by_properties.erase(cpttemp);
133 void TextureStagePool::
134 ns_release_all_stages() {
137 _stages_by_name.clear();
138 _stages_by_properties.clear();
146 void TextureStagePool::
147 ns_set_mode(TextureStagePool::Mode mode) {
151 _stages_by_name.clear();
152 _stages_by_properties.clear();
162 TextureStagePool::Mode TextureStagePool::
174 int TextureStagePool::
175 ns_garbage_collect() {
184 int num_released = 0;
187 StagesByName::iterator ni;
188 for (ni = _stages_by_name.begin(); ni != _stages_by_name.end(); ++ni) {
189 const string &name = (*ni).first;
192 if (gobj_cat.is_debug()) {
194 <<
"Releasing " << name <<
"\n";
198 new_set.insert(new_set.end(), *ni);
202 _stages_by_name.swap(new_set);
208 int num_released = 0;
211 StagesByProperties::iterator si;
212 for (si = _stages_by_properties.begin(); si != _stages_by_properties.end(); ++si) {
216 if (gobj_cat.is_debug()) {
218 <<
"Releasing " << *ts1 <<
"\n";
222 new_set.insert(new_set.end(), *si);
226 _stages_by_properties.swap(new_set);
239 void TextureStagePool::
240 ns_list_contents(ostream &out)
const {
243 out <<
"TextureStagePool in mode " << _mode <<
"\n";
251 out << _stages_by_name.size() <<
" TextureStages:\n";
252 StagesByName::const_iterator ni;
253 for (ni = _stages_by_name.begin(); ni != _stages_by_name.end(); ++ni) {
254 const string &name = (*ni).first;
264 out << _stages_by_properties.size() <<
" TextureStages:\n";
265 StagesByProperties::const_iterator si;
266 for (si = _stages_by_properties.begin(); si != _stages_by_properties.end(); ++si) {
296 operator << (ostream &out, TextureStagePool::Mode mode) {
298 case TextureStagePool::M_none:
299 return out <<
"none";
301 case TextureStagePool::M_name:
302 return out <<
"name";
304 case TextureStagePool::M_unique:
305 return out <<
"unique";
308 return out <<
"**invalid mode (" << (int)mode <<
")**";
316 operator >> (istream &in, TextureStagePool::Mode &mode) {
320 if (cmp_nocase(word,
"none") == 0) {
321 mode = TextureStagePool::M_none;
322 }
else if (cmp_nocase(word,
"name") == 0) {
323 mode = TextureStagePool::M_name;
324 }
else if (cmp_nocase(word,
"unique") == 0) {
325 mode = TextureStagePool::M_unique;
328 gobj_cat->error() <<
"Invalid TextureStagePool mode value: " << word <<
"\n";
329 mode = TextureStagePool::M_none;
static void write(ostream &out)
Lists the contents of the TextureStage pool to the indicated output stream.
A lightweight C++ object whose constructor calls acquire() and whose destructor calls release() on a ...
The TextureStagePool (there is only one in the universe) serves to unify different pointers to the sa...
This class specializes ConfigVariable as an enumerated type.
int get_ref_count() const
Returns the current reference count.
const string & get_name() const
Returns the name of this texture stage.
EnumType get_value() const
Returns the variable's value.
Defines the properties of a named stage of the multitexture pipeline.