Changeset 13041 for OpenSceneGraph/trunk/src/osgDB/SharedStateManager.cpp
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgDB/SharedStateManager.cpp
r12006 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 18 18 19 19 SharedStateManager::SharedStateManager(unsigned int mode): 20 osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) 20 osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) 21 21 { 22 22 setShareMode(mode); … … 61 61 } 62 62 63 } 63 } 64 64 65 65 … … 71 71 // const osg::Timer& timer = *osg::Timer::instance(); 72 72 // osg::Timer_t start_tick = timer.tick(); 73 73 74 74 _mutex = mt; 75 75 node->accept(*this); … … 108 108 } 109 109 } 110 110 111 111 bool SharedStateManager::isShared(osg::StateSet* ss) 112 112 { … … 156 156 return result->get(); 157 157 } 158 158 159 159 160 160 //---------------------------------------------------------------- … … 195 195 if(titr==tmpSharedTextureList.end()) 196 196 { 197 // Texture is not in tmp list: 197 // Texture is not in tmp list: 198 198 // First time it appears in this file, search Texture in sharedAttributeList 199 199 osg::StateAttribute *textureFromSharedList = find(texture); 200 200 if(textureFromSharedList) 201 201 { 202 // Texture is in sharedAttributeList: 202 // Texture is in sharedAttributeList: 203 203 // Share now. Required to be shared all next times 204 204 if(_mutex) _mutex->lock(); … … 209 209 else 210 210 { 211 // Texture is not in _sharedAttributeList: 211 // Texture is not in _sharedAttributeList: 212 212 // Add to _sharedAttributeList. Not needed to be 213 213 // shared all next times. 214 214 OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_listMutex); 215 _sharedTextureList.insert(texture); 216 tmpSharedTextureList[texture] = TextureSharePair(texture, false); 215 _sharedTextureList.insert(texture); 216 tmpSharedTextureList[texture] = TextureSharePair(texture, false); 217 217 } 218 218 } … … 241 241 if (sitr==tmpSharedStateSetList.end()) 242 242 { 243 // StateSet is not in tmp list: 243 // StateSet is not in tmp list: 244 244 // First time it appears in this file, search StateSet in sharedObjectList 245 245 osg::StateSet *ssFromSharedList = find(ss); 246 246 if (ssFromSharedList) 247 247 { 248 // StateSet is in sharedStateSetList: 248 // StateSet is in sharedStateSetList: 249 249 // Share now. Required to be shared all next times 250 250 if (_mutex) _mutex->lock(); … … 255 255 else 256 256 { 257 // StateSet is not in sharedStateSetList: 257 // StateSet is not in sharedStateSetList: 258 258 // Add to sharedStateSetList. Not needed to be shared all next times. 259 259 { 260 260 OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_listMutex); 261 _sharedStateSetList.insert(ss); 261 _sharedStateSetList.insert(ss); 262 262 tmpSharedStateSetList[ss] 263 = StateSetSharePair(ss, false); 263 = StateSetSharePair(ss, false); 264 264 } 265 265 // Only in this case sharing textures is also required
