Ticket #695: ro_695_r2.patch
File ro_695_r2.patch, 7.5 KB (added by , 13 years ago) |
---|
-
graphics/SkeletonAnimManager.cpp
41 41 // CSkeletonAnimManager destructor 42 42 CSkeletonAnimManager::~CSkeletonAnimManager() 43 43 { 44 typedef std::map<VfsPath,CSkeletonAnimDef*>::iterator Iter;44 typedef boost::unordered_map<VfsPath,CSkeletonAnimDef*>::iterator Iter; 45 45 for (Iter i = m_Animations.begin(); i != m_Animations.end(); ++i) 46 46 delete i->second; 47 47 } … … 54 54 VfsPath name = fs::change_extension(pathname, L""); 55 55 56 56 // Find if it's already been loaded 57 std::map<VfsPath, CSkeletonAnimDef*>::iterator iter = m_Animations.find(name);57 boost::unordered_map<VfsPath, CSkeletonAnimDef*>::iterator iter = m_Animations.find(name); 58 58 if (iter != m_Animations.end()) 59 59 return iter->second; 60 60 -
graphics/TextureManager.h
121 121 { 122 122 friend class CTextureManagerImpl; 123 123 friend struct TextureCacheCmp; 124 friend struct TPequal_to; 125 friend struct TPhash; 124 126 125 127 public: 126 128 /** … … 151 153 // easily tweaked in an Options menu? e.g. the caller just specifies 152 154 // "terrain texture mode" and we combine it with the user's options. 153 155 // That'd let us dynamically change texture properties easily. 154 // 156 //std::size_t hash_value(const CTexturePtr& a) 155 157 // enum EQualityMode 156 158 // { 157 159 // NONE, … … 180 182 { 181 183 friend class CTextureManagerImpl; 182 184 friend struct TextureCacheCmp; 185 friend struct TPequal_to; 186 friend struct TPhash; 183 187 184 188 // Only the texture manager can create these 185 189 explicit CTexture(Handle handle, const CTextureProperties& props, CTextureManagerImpl* textureManager); … … 187 191 NONCOPYABLE(CTexture); 188 192 189 193 public: 194 190 195 ~CTexture(); 191 196 192 197 /** -
graphics/SkeletonAnimManager.h
25 25 #include <map> 26 26 #include <set> 27 27 #include "lib/file/vfs/vfs_path.h" 28 #include <boost/unordered_map.hpp> 28 29 29 30 class CColladaManager; 30 31 class CSkeletonAnimDef; … … 47 48 48 49 private: 49 50 // map of all known animations. Value is NULL if it failed to load. 50 std::map<VfsPath, CSkeletonAnimDef*> m_Animations;51 boost::unordered_map<VfsPath, CSkeletonAnimDef*> m_Animations; 51 52 52 53 CColladaManager& m_ColladaManager; 53 54 }; -
graphics/TextureManager.cpp
31 31 #include "ps/Filesystem.h" 32 32 33 33 #include <iomanip> 34 #include <boost/unordered_map.hpp> 35 #include <boost/unordered_set.hpp> 36 #include <boost/functional/hash.hpp> 34 37 35 // Comparison functor that operates over texture properties, or 36 // over the properties of a CTexturePtr (ignoring the mutable state like Handle). 37 struct TextureCacheCmp 38 struct TPhash 39 : std::unary_function<CTextureProperties, std::size_t>, 40 std::unary_function<CTexturePtr, std::size_t> 38 41 { 39 bool operator()(const CTexturePtr& a, const CTexturePtr& b) const42 std::size_t operator()(CTextureProperties const& a) const 40 43 { 41 return (*this)(a->m_Properties, b->m_Properties); 44 std::size_t seed = 0; 45 boost::hash_combine(seed, a.m_Path.string()); 46 boost::hash_combine(seed, a.m_Filter); 47 boost::hash_combine(seed, a.m_Wrap); 48 boost::hash_combine(seed, a.m_Aniso); 49 return seed; 42 50 } 43 44 bool operator()(const CTextureProperties& a, const CTextureProperties& b) const 51 std::size_t operator()(CTexturePtr const& a) const 45 52 { 46 if (a.m_Path < b.m_Path) 47 return true; 48 if (b.m_Path < a.m_Path) 49 return false; 50 51 if (a.m_Filter < b.m_Filter) 52 return true; 53 if (b.m_Filter < a.m_Filter) 54 return false; 55 56 if (a.m_Wrap < b.m_Wrap) 57 return true; 58 if (b.m_Wrap < a.m_Wrap) 59 return false; 60 61 if (a.m_Aniso < b.m_Aniso) 62 return true; 63 if (b.m_Aniso < a.m_Aniso) 64 return false; 65 66 return false; 53 return (*this)(a->m_Properties); 67 54 } 68 55 }; 56 struct TPequal_to 57 : std::binary_function<CTextureProperties, CTextureProperties, bool>, 58 std::binary_function<CTexturePtr, CTexturePtr, bool> 59 { 60 bool operator()(CTextureProperties const& a, CTextureProperties const& b) const 61 { 62 return a.m_Path == b.m_Path && a.m_Filter == b.m_Filter 63 && a.m_Wrap == b.m_Wrap && a.m_Aniso == b.m_Aniso; 64 } 65 bool operator()(CTexturePtr const& a, CTexturePtr const& b) const 66 { 67 return (*this)(a->m_Properties, b->m_Properties); 68 } 69 }; 69 70 71 70 72 class CTextureManagerImpl 71 73 { 72 74 friend class CTexture; … … 479 481 CTexturePtr m_ErrorTexture; 480 482 481 483 // Cache of all loaded textures 482 typedef std::set<CTexturePtr, TextureCacheCmp> TextureCache;484 typedef boost::unordered_set<CTexturePtr, TPhash, TPequal_to > TextureCache; 483 485 TextureCache m_TextureCache; 484 486 // TODO: we ought to expire unused textures from the cache eventually 485 487 486 488 // Store the set of textures that need to be reloaded when the given file 487 489 // (a source file or settings.xml) is modified 488 typedef std::map<VfsPath, std::set<boost::weak_ptr<CTexture> > > HotloadFilesMap;490 typedef boost::unordered_map<VfsPath, std::set<boost::weak_ptr<CTexture> > > HotloadFilesMap; 489 491 HotloadFilesMap m_HotloadFiles; 490 492 491 493 // Cache for the conversion settings files 492 typedef std::map<VfsPath, shared_ptr<CTextureConverter::SettingsFile> > SettingsFilesMap;494 typedef boost::unordered_map<VfsPath, shared_ptr<CTextureConverter::SettingsFile> > SettingsFilesMap; 493 495 SettingsFilesMap m_SettingsFiles; 494 496 }; 495 497 496 497 498 CTexture::CTexture(Handle handle, const CTextureProperties& props, CTextureManagerImpl* textureManager) : 498 499 m_Handle(handle), m_BaseColour(0), m_State(UNLOADED), m_Properties(props), m_TextureManager(textureManager) 499 500 { -
lib/file/vfs/vfs_path.h
23 23 #ifndef INCLUDED_VFS_PATH 24 24 #define INCLUDED_VFS_PATH 25 25 26 #include <boost/functional/hash.hpp> 27 26 28 struct VfsPathTraits; 27 29 28 30 /** … … 43 45 44 46 typedef std::vector<VfsPath> VfsPaths; 45 47 48 std::size_t hash_value(VfsPath const& b); 49 46 50 struct VfsPathTraits 47 51 { 48 52 typedef std::wstring internal_string_type; -
lib/file/vfs/vfs_path.cpp
22 22 23 23 #include "precompiled.h" 24 24 #include "lib/file/vfs/vfs_path.h" 25 26 #include <iostream> 27 #include <string> 28 29 std::size_t hash_value(VfsPath const& b) 30 { 31 boost::hash<std::wstring> hasher; 32 return hasher(b.string()); 33 } 34 -
lib/cache_adt.h
32 32 #include <list> 33 33 #include <map> 34 34 #include <queue> // std::priority_queue 35 #include <boost/unordered_map.hpp> 35 36 36 37 /* 37 38 Cache for items of variable size and value/"cost". … … 306 307 } 307 308 308 309 protected: 309 // note: hash_map is probably better in terms of locality 310 // (relevant when iterating over all items in remove_least_valuable), 311 // but would require a hash comparator for VfsPath. 312 class Map : public std::map<Key, Entry> 310 class Map : public boost::unordered_map<Key, Entry> 313 311 { 314 312 public: 315 313 static Entry& entry_from_it(typename Map::iterator it) { return it->second; }