Skip to content

Commit

Permalink
Refactor texture namespace type names inline with the conventions alr…
Browse files Browse the repository at this point in the history
…eady in

use with materials (and now fonts too).
  • Loading branch information
danij-deng committed Jul 19, 2011
1 parent 13c1872 commit f2bdbd7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions doomsday/engine/portable/include/texture.h
Expand Up @@ -26,7 +26,7 @@
#define LIBDENG_GL_TEXTURE_H

struct texturevariant_s;
struct texturenamespace_hashnode_s;
struct texturenamespace_namehash_node_s;

typedef enum {
TEXTURE_ANALYSIS_FIRST = 0,
Expand Down Expand Up @@ -58,7 +58,7 @@ typedef struct texture_s {
/// Unique Texture Namespace Identifier.
/// \todo make external.
texturenamespaceid_t _texNamespace;
struct texturenamespace_hashnode_s* _texNamespaceHashNode;
struct texturenamespace_namehash_node_s* _texNamespaceHashNode;

/// List of variants (e.g., color translations).
struct texture_variantlist_node_s* _variants;
Expand Down Expand Up @@ -161,8 +161,8 @@ int Texture_TypeIndex(const texture_t* tex);
texturenamespaceid_t Texture_Namespace(const texture_t* tex);

/// @return Texture namespace hash node.
struct texturenamespace_hashnode_s* Texture_NamespaceHashNode(const texture_t* tex);
struct texturenamespace_namehash_node_s* Texture_NamespaceHashNode(const texture_t* tex);

void Texture_SetNamespace(texture_t* tex, texturenamespaceid_t texNamespace,
struct texturenamespace_hashnode_s* texNamespaceHashNode);
struct texturenamespace_namehash_node_s* texNamespaceHashNode);
#endif /* LIBDENG_GL_TEXTURE_H */
44 changes: 22 additions & 22 deletions doomsday/engine/portable/src/gl_texmanager.c
Expand Up @@ -77,25 +77,25 @@ typedef struct texturevariantspecificationlist_node_s {

typedef texturevariantspecificationlist_node_t variantspecificationlist_t;

typedef struct texturenamespace_hashnode_s {
struct texturenamespace_hashnode_s* next;
texture_t* tex;
} texturenamespace_hashnode_t;

#define TEXTURENAMESPACE_HASH_SIZE (512)
#define TEXTURENAMESPACE_NAMEHASH_SIZE (512)

static int hashDetailVariantSpecification(const detailvariantspecification_t* spec);
typedef struct texturenamespace_namehash_node_s {
struct texturenamespace_namehash_node_s* next;
texture_t* tex;
} texturenamespace_namehash_node_t;
typedef texturenamespace_namehash_node_t* texturenamespace_namehash_t[TEXTURENAMESPACE_NAMEHASH_SIZE];

typedef struct texturenamespace_s {
texturenamespace_hashnode_t* hashTable[TEXTURENAMESPACE_HASH_SIZE];
texturenamespace_namehash_t hashTable;
} texturenamespace_t;

D_CMD(LowRes);
D_CMD(ResetTextures);
D_CMD(MipMap);

static uint hashForTextureName(const char* name);
static texturenamespace_hashnode_t* findNamespaceHashNodeForTextureByName(const char* name, uint hash, texturenamespaceid_t texNamespace);
static int hashDetailVariantSpecification(const detailvariantspecification_t* spec);
static texturenamespace_namehash_node_t* findNamespaceHashNodeForTextureByName(const char* name, uint hash, texturenamespaceid_t texNamespace);

void GL_DoResetDetailTextures(void);

Expand Down Expand Up @@ -692,7 +692,7 @@ static void unlinkTextureFromGlobalList(texture_t* tex)
}
else
{
texturenamespace_hashnode_t* node = Texture_NamespaceHashNode(tex);
texturenamespace_namehash_node_t* node = Texture_NamespaceHashNode(tex);
if(NULL == node)
{
Con_Error("unlinkTextureFromGlobalList: Internal error, mistracked textures!");
Expand All @@ -716,7 +716,7 @@ static void unlinkTextureFromTextureNamespace(texture_t* tex)
{
assert(NULL != tex);
{
texturenamespace_hashnode_t* node = Texture_NamespaceHashNode(tex);
texturenamespace_namehash_node_t* node = Texture_NamespaceHashNode(tex);
texturenamespace_t* tn;
uint hash;

Expand All @@ -732,7 +732,7 @@ static void unlinkTextureFromTextureNamespace(texture_t* tex)
else
{
// Find the node previous.
texturenamespace_hashnode_t* prevNode;
texturenamespace_namehash_node_t* prevNode;
for(prevNode = tn->hashTable[hash]; prevNode->next && prevNode->next != node;
prevNode = prevNode->next) {}

Expand Down Expand Up @@ -772,10 +772,10 @@ static void destroyTextures(texturenamespaceid_t texNamespace)
{
texturenamespace_t* tn = textureNamespaceForId(texNamespace);
uint i;
for(i = 0; i < TEXTURENAMESPACE_HASH_SIZE; ++i)
for(i = 0; i < TEXTURENAMESPACE_NAMEHASH_SIZE; ++i)
{
texturenamespace_hashnode_t* node = tn->hashTable[i];
texturenamespace_hashnode_t* next;
texturenamespace_namehash_node_t* node = tn->hashTable[i];
texturenamespace_namehash_node_t* next;
while(node)
{
next = node->next;
Expand Down Expand Up @@ -1286,7 +1286,7 @@ static uploadcontentmethod_t prepareDetailVariant(texturevariant_t* tex, image_t

/**
* This is a hash function. Given a texture name it generates a
* somewhat-random number between 0 and TEXTURENAMESPACE_HASH_SIZE.
* somewhat-random number between 0 and TEXTURENAMESPACE_NAMEHASH_SIZE.
*
* @return The generated hash index.
*/
Expand All @@ -1310,7 +1310,7 @@ static uint hashForTextureName(const char* name)
}
}

return key % TEXTURENAMESPACE_HASH_SIZE;
return key % TEXTURENAMESPACE_NAMEHASH_SIZE;
}

/**
Expand All @@ -1322,15 +1322,15 @@ static uint hashForTextureName(const char* name)
* @param type Specific texture data.
* @return Ptr to the found texture_t else, @c NULL.
*/
static texturenamespace_hashnode_t* findNamespaceHashNodeForTextureByName(
static texturenamespace_namehash_node_t* findNamespaceHashNodeForTextureByName(
const char* name, uint hash, texturenamespaceid_t texNamespace)
{
texturenamespace_t* tn = NULL;
if(name && name[0])
tn = textureNamespaceForId(texNamespace);
if(tn != NULL)
{
texturenamespace_hashnode_t* node;
texturenamespace_namehash_node_t* node;
for(node = tn->hashTable[hash]; node; node = node->next)
{
if(!strnicmp(Texture_Name(node->tex), name, 8))
Expand All @@ -1342,7 +1342,7 @@ static texturenamespace_hashnode_t* findNamespaceHashNodeForTextureByName(

static const texture_t* findTextureByName(const char* name, texturenamespaceid_t texNamespace)
{
texturenamespace_hashnode_t* node =
texturenamespace_namehash_node_t* node =
findNamespaceHashNodeForTextureByName(name, hashForTextureName(name), texNamespace);
return ((node != NULL)? node->tex : 0);
}
Expand Down Expand Up @@ -3301,7 +3301,7 @@ const texture_t* GL_CreateTexture2(const char* name, uint index,
{
assert(VALID_TEXTURENAMESPACE(texNamespace));
{
texturenamespace_hashnode_t* node;
texturenamespace_namehash_node_t* node;
texturenamespace_t* tn;
texture_t* tex;
uint hash;
Expand All @@ -3326,7 +3326,7 @@ const texture_t* GL_CreateTexture2(const char* name, uint index,
hash = hashForTextureName(name);
tn = textureNamespaceForId(texNamespace);

if(NULL == (node = (texturenamespace_hashnode_t*) malloc(sizeof(*node))))
if(NULL == (node = (texturenamespace_namehash_node_t*) malloc(sizeof(*node))))
Con_Error("GL_CreateTexture: Failed on allocation of %lu bytes for "
"namespace hashnode.", (unsigned long) sizeof(*node));
node->tex = tex;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/texture.c
Expand Up @@ -229,14 +229,14 @@ texturenamespaceid_t Texture_Namespace(const texture_t* tex)
return tex->_texNamespace;
}

struct texturenamespace_hashnode_s* Texture_NamespaceHashNode(const texture_t* tex)
struct texturenamespace_namehash_node_s* Texture_NamespaceHashNode(const texture_t* tex)
{
assert(tex);
return tex->_texNamespaceHashNode;
}

void Texture_SetNamespace(texture_t* tex, texturenamespaceid_t texNamespace,
struct texturenamespace_hashnode_s* texNamespaceHashNode)
struct texturenamespace_namehash_node_s* texNamespaceHashNode)
{
assert(tex && VALID_TEXTURENAMESPACE(texNamespace) && texNamespaceHashNode);
tex->_texNamespace = texNamespace;
Expand Down

0 comments on commit f2bdbd7

Please sign in to comment.