TexturePool.findTexture(), findAllTextures()
This commit is contained in:
parent
e47fdbe424
commit
2d887a630e
|
|
@ -55,6 +55,7 @@
|
|||
simpleLru.h simpleLru.I \
|
||||
sliderTable.I sliderTable.h \
|
||||
texture.I texture.h \
|
||||
textureCollection.I textureCollection.h \
|
||||
textureContext.I textureContext.h \
|
||||
texturePeeker.I texturePeeker.h \
|
||||
texturePool.I texturePool.h \
|
||||
|
|
@ -120,7 +121,9 @@
|
|||
simpleAllocator.cxx \
|
||||
simpleLru.cxx \
|
||||
sliderTable.cxx \
|
||||
texture.cxx textureContext.cxx \
|
||||
texture.cxx \
|
||||
textureCollection.cxx \
|
||||
textureContext.cxx \
|
||||
texturePeeker.cxx \
|
||||
texturePool.cxx \
|
||||
texturePoolFilter.cxx \
|
||||
|
|
@ -188,6 +191,7 @@
|
|||
simpleLru.h simpleLru.I \
|
||||
sliderTable.I sliderTable.h \
|
||||
texture.I texture.h \
|
||||
textureCollection.I textureCollection.h \
|
||||
textureContext.I textureContext.h \
|
||||
texturePeeker.I texturePeeker.h \
|
||||
texturePool.I texturePool.h \
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include "simpleLru.cxx"
|
||||
#include "sliderTable.cxx"
|
||||
#include "texture.cxx"
|
||||
#include "textureCollection.cxx"
|
||||
#include "textureContext.cxx"
|
||||
#include "texturePeeker.cxx"
|
||||
#include "texturePool.cxx"
|
||||
|
|
|
|||
|
|
@ -21,9 +21,10 @@
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : TextureCollection
|
||||
// Description :
|
||||
// Description : Manages a list of Texture objects, as returned by
|
||||
// TexturePool::find_all_textures().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA_PGRAPH TextureCollection {
|
||||
class EXPCL_PANDA_GOBJ TextureCollection {
|
||||
PUBLISHED:
|
||||
TextureCollection();
|
||||
TextureCollection(const TextureCollection ©);
|
||||
|
|
@ -248,6 +248,31 @@ list_contents() {
|
|||
get_global_ptr()->ns_list_contents(cout);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexturePool::find_texture
|
||||
// Access: Published, Static
|
||||
// Description: Returns the first texture found in the pool that
|
||||
// matches the indicated name (which may contain
|
||||
// wildcards). Returns the texture if it is found, or
|
||||
// NULL if it is not.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Texture *TexturePool::
|
||||
find_texture(const string &name) {
|
||||
return get_global_ptr()->ns_find_texture(name);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexturePool::find_all_textures
|
||||
// Access: Published, Static
|
||||
// Description: Returns the set of all textures found in the pool
|
||||
// that match the indicated name (which may contain
|
||||
// wildcards).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE TextureCollection TexturePool::
|
||||
find_all_textures(const string &name) {
|
||||
return get_global_ptr()->ns_find_all_textures(name);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexturePool::set_fake_texture_image
|
||||
// Access: Published, Static
|
||||
|
|
|
|||
|
|
@ -854,6 +854,49 @@ ns_list_contents(ostream &out) const {
|
|||
out << "texture pool size - texture pool ram: " << total_size - total_ram_size << "\n";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexturePool::ns_find_texture
|
||||
// Access: Private
|
||||
// Description: The nonstatic implementation of find_texture().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
Texture *TexturePool::
|
||||
ns_find_texture(const string &name) const {
|
||||
MutexHolder holder(_lock);
|
||||
GlobPattern glob(name);
|
||||
|
||||
Textures::const_iterator ti;
|
||||
for (ti = _textures.begin(); ti != _textures.end(); ++ti) {
|
||||
Texture *tex = (*ti).second;
|
||||
if (glob.matches(tex->get_name())) {
|
||||
return tex;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexturePool::ns_find_all_textures
|
||||
// Access: Private
|
||||
// Description: The nonstatic implementation of find_all_textures().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
TextureCollection TexturePool::
|
||||
ns_find_all_textures(const string &name) const {
|
||||
MutexHolder holder(_lock);
|
||||
TextureCollection result;
|
||||
GlobPattern glob(name);
|
||||
|
||||
Textures::const_iterator ti;
|
||||
for (ti = _textures.begin(); ti != _textures.end(); ++ti) {
|
||||
Texture *tex = (*ti).second;
|
||||
if (glob.matches(tex->get_name())) {
|
||||
result.add_texture(tex);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexturePool::resolve_filename
|
||||
// Access: Private
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include "loaderOptions.h"
|
||||
#include "pmutex.h"
|
||||
#include "pmap.h"
|
||||
#include "textureCollection.h"
|
||||
|
||||
class TexturePoolFilter;
|
||||
class BamCache;
|
||||
|
|
@ -69,6 +70,9 @@ PUBLISHED:
|
|||
INLINE static void list_contents(ostream &out);
|
||||
INLINE static void list_contents();
|
||||
|
||||
INLINE static Texture *find_texture(const string &name);
|
||||
INLINE static TextureCollection find_all_textures(const string &name = "*");
|
||||
|
||||
INLINE static void set_fake_texture_image(const Filename &filename);
|
||||
INLINE static void clear_fake_texture_image();
|
||||
INLINE static bool has_fake_texture_image();
|
||||
|
|
@ -115,6 +119,8 @@ private:
|
|||
void ns_release_all_textures();
|
||||
int ns_garbage_collect();
|
||||
void ns_list_contents(ostream &out) const;
|
||||
Texture *ns_find_texture(const string &name) const;
|
||||
TextureCollection ns_find_all_textures(const string &name) const;
|
||||
|
||||
void resolve_filename(Filename &new_filename, const Filename &orig_filename);
|
||||
|
||||
|
|
|
|||
|
|
@ -108,7 +108,6 @@
|
|||
texProjectorEffect.I texProjectorEffect.h \
|
||||
textureAttrib.I textureAttrib.h \
|
||||
texGenAttrib.I texGenAttrib.h \
|
||||
textureCollection.I textureCollection.h \
|
||||
textureStageCollection.I textureStageCollection.h \
|
||||
transformState.I transformState.h \
|
||||
transparencyAttrib.I transparencyAttrib.h \
|
||||
|
|
@ -211,7 +210,6 @@
|
|||
texProjectorEffect.cxx \
|
||||
textureAttrib.cxx \
|
||||
texGenAttrib.cxx \
|
||||
textureCollection.cxx \
|
||||
textureStageCollection.cxx \
|
||||
transformState.cxx \
|
||||
transparencyAttrib.cxx \
|
||||
|
|
@ -312,7 +310,6 @@
|
|||
texProjectorEffect.I texProjectorEffect.h \
|
||||
textureAttrib.I textureAttrib.h \
|
||||
texGenAttrib.I texGenAttrib.h \
|
||||
textureCollection.I textureCollection.h \
|
||||
textureStageCollection.I textureStageCollection.h \
|
||||
transformState.I transformState.h \
|
||||
transparencyAttrib.I transparencyAttrib.h \
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
#include "texProjectorEffect.cxx"
|
||||
#include "textureAttrib.cxx"
|
||||
#include "texGenAttrib.cxx"
|
||||
#include "textureCollection.cxx"
|
||||
#include "textureStageCollection.cxx"
|
||||
#include "transformState.cxx"
|
||||
#include "transparencyAttrib.cxx"
|
||||
|
|
|
|||
Loading…
Reference in New Issue