Skip to content

Commit

Permalink
Refactor: Removed '_' prefix from members of Texture
Browse files Browse the repository at this point in the history
These objects no longer expose their internal state so this
naming convention is redundant.
  • Loading branch information
danij-deng committed Jan 10, 2012
1 parent 54e43a8 commit dc5f720
Showing 1 changed file with 43 additions and 43 deletions.
86 changes: 43 additions & 43 deletions doomsday/engine/portable/src/texture.c
Expand Up @@ -40,23 +40,23 @@ typedef struct texture_variantlist_node_s {

struct texture_s {
/// @see textureFlags
int _flags;
int flags;

/// Size in logical pixels (not necessarily the same as pixel dimensions).
Size2* _size;
Size2* size;

/// Unique identifier of the primary binding in the owning collection.
textureid_t _primaryBind;
textureid_t primaryBind;

/// List of variants (e.g., color translations).
struct texture_variantlist_node_s* _variants;
struct texture_variantlist_node_s* variants;

/// Table of analyses object ptrs, used for various purposes depending
/// on the variant specification.
void* _analyses[TEXTURE_ANALYSIS_COUNT];
void* analyses[TEXTURE_ANALYSIS_COUNT];

/// User data associated with this texture.
void* _userData;
void* userData;
};

Texture* Texture_New(int flags, textureid_t bindId, void* userData)
Expand All @@ -66,12 +66,12 @@ Texture* Texture_New(int flags, textureid_t bindId, void* userData)
Con_Error("Texture::New: Failed on allocation of %lu bytes for new Texture.",
(unsigned long) sizeof *tex);

tex->_flags = flags;
tex->_size = Size2_New();
tex->_variants = NULL;
tex->_primaryBind = bindId;
tex->_userData = userData;
memset(tex->_analyses, 0, sizeof(tex->_analyses));
tex->flags = flags;
tex->size = Size2_New();
tex->variants = NULL;
tex->primaryBind = bindId;
tex->userData = userData;
memset(tex->analyses, 0, sizeof(tex->analyses));

return tex;
}
Expand All @@ -87,10 +87,10 @@ Texture* Texture_NewWithSize(int flags, textureid_t bindId, const Size2Raw* size
static void destroyVariants(Texture* tex)
{
assert(tex);
while(tex->_variants)
while(tex->variants)
{
TextureVariant* variant = tex->_variants->variant;
texture_variantlist_node_t* next = tex->_variants->next;
TextureVariant* variant = tex->variants->variant;
texture_variantlist_node_t* next = tex->variants->next;
#if _DEBUG
DGLuint glName = TextureVariant_GLName(variant);
if(glName)
Expand All @@ -106,8 +106,8 @@ static void destroyVariants(Texture* tex)
}
#endif
TextureVariant_Delete(variant);
free(tex->_variants);
tex->_variants = next;
free(tex->variants);
tex->variants = next;
}
}

Expand All @@ -117,7 +117,7 @@ static void destroyAnalyses(Texture* tex)
assert(tex);
for(i = 0; i < TEXTURE_ANALYSIS_COUNT; ++i)
{
if(tex->_analyses[i]) free(tex->_analyses[i]);
if(tex->analyses[i]) free(tex->analyses[i]);
}
}

Expand All @@ -126,47 +126,47 @@ void Texture_Delete(Texture* tex)
assert(tex);
destroyVariants(tex);
destroyAnalyses(tex);
Size2_Delete(tex->_size);
Size2_Delete(tex->size);
free(tex);
}

textureid_t Texture_PrimaryBind(const Texture* tex)
{
assert(tex);
return tex->_primaryBind;
return tex->primaryBind;
}

void Texture_SetPrimaryBind(Texture* tex, textureid_t bindId)
{
assert(tex);
tex->_primaryBind = bindId;
tex->primaryBind = bindId;
}

void Texture_AttachUserData(Texture* tex, void* userData)
{
assert(tex);
#if _DEBUG
if(tex->_userData)
if(tex->userData)
{
Con_Message("Warning:Texture::AttachUserData: User data is already present for [%p id:%i], it will be replaced.\n", (void*)tex, Textures_Id(tex));
}
#endif
tex->_userData = userData;
tex->userData = userData;
}

void* Texture_DetachUserData(Texture* tex)
{
void* data;
assert(tex);
data = tex->_userData;
tex->_userData = NULL;
data = tex->userData;
tex->userData = NULL;
return data;
}

void* Texture_UserData(const Texture* tex)
{
assert(tex);
return tex->_userData;
return tex->userData;
}

void Texture_ClearVariants(Texture* tex)
Expand All @@ -193,66 +193,66 @@ TextureVariant* Texture_AddVariant(Texture* tex, TextureVariant* variant)
Con_Error("Texture::AddVariant: Failed on allocation of %lu bytes for new node.", (unsigned long) sizeof *node);

node->variant = variant;
node->next = tex->_variants;
tex->_variants = node;
node->next = tex->variants;
tex->variants = node;
return variant;
}

boolean Texture_IsCustom(const Texture* tex)
{
assert(tex);
return (tex->_flags & TXF_CUSTOM) != 0;
return (tex->flags & TXF_CUSTOM) != 0;
}

int Texture_Flags(const Texture* tex)
{
assert(tex);
return tex->_flags;
return tex->flags;
}

void Texture_SetFlags(Texture* tex, int flags)
{
assert(tex);
tex->_flags = flags;
tex->flags = flags;
/// \fixme Update any Materials (and thus Surfaces) which reference this.
}

int Texture_Width(const Texture* tex)
{
assert(tex);
return Size2_Width(tex->_size);
return Size2_Width(tex->size);
}

void Texture_SetWidth(Texture* tex, int width)
{
assert(tex);
Size2_SetWidth(tex->_size, width);
Size2_SetWidth(tex->size, width);
/// \fixme Update any Materials (and thus Surfaces) which reference this.
}

int Texture_Height(const Texture* tex)
{
assert(tex);
return Size2_Height(tex->_size);
return Size2_Height(tex->size);
}

void Texture_SetHeight(Texture* tex, int height)
{
assert(tex);
Size2_SetHeight(tex->_size, height);
Size2_SetHeight(tex->size, height);
/// \fixme Update any Materials (and thus Surfaces) which reference this.
}

const Size2* Texture_Size(const Texture* tex)
{
assert(tex);
return tex->_size;
return tex->size;
}

void Texture_SetSize(Texture* tex, const Size2Raw* size)
{
assert(tex && size);
Size2_SetWidthHeight(tex->_size, size->width, size->height);
Size2_SetWidthHeight(tex->size, size->width, size->height);
/// \fixme Update any Materials (and thus Surfaces) which reference this.
}

Expand All @@ -264,7 +264,7 @@ int Texture_IterateVariants(Texture* tex,

if(callback)
{
texture_variantlist_node_t* node = tex->_variants;
texture_variantlist_node_t* node = tex->variants;
while(node)
{
texture_variantlist_node_t* next = node->next;
Expand All @@ -279,15 +279,15 @@ int Texture_IterateVariants(Texture* tex,
void* Texture_Analysis(const Texture* tex, texture_analysisid_t analysis)
{
assert(tex && VALID_TEXTURE_ANALYSISID(analysis));
return tex->_analyses[analysis];
return tex->analyses[analysis];
}

void Texture_AttachAnalysis(Texture* tex, texture_analysisid_t analysis,
void* data)
{
assert(tex && VALID_TEXTURE_ANALYSISID(analysis));
#if _DEBUG
if(tex->_analyses[analysis])
if(tex->analyses[analysis])
{
Uri* uri = Textures_ComposeUri(Textures_Id(tex));
ddstring_t* path = Uri_ToString(uri);
Expand All @@ -297,15 +297,15 @@ void Texture_AttachAnalysis(Texture* tex, texture_analysisid_t analysis,
Uri_Delete(uri);
}
#endif
tex->_analyses[analysis] = data;
tex->analyses[analysis] = data;
}

void* Texture_DetachAnalysis(Texture* tex, texture_analysisid_t analysis)
{
void* data;
assert(tex && VALID_TEXTURE_ANALYSISID(analysis));

data = tex->_analyses[analysis];
tex->_analyses[analysis] = NULL;
data = tex->analyses[analysis];
tex->analyses[analysis] = NULL;
return data;
}

0 comments on commit dc5f720

Please sign in to comment.