Skip to content

Commit

Permalink
Refactor|Texture: Renamed methods of Texture and Textures for consist…
Browse files Browse the repository at this point in the history
…ency
  • Loading branch information
danij-deng committed Nov 26, 2012
1 parent b3bd7b5 commit 7a8d538
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 50 deletions.
32 changes: 16 additions & 16 deletions doomsday/engine/include/resource/texture.h
Expand Up @@ -79,7 +79,7 @@ class Texture
* for the resultant texture.
* @param userData User data to associate with the resultant texture.
*/
Texture(textureid_t bindId, void* userData=NULL);
Texture(textureid_t bindId, void *userData = 0);

/**
* @param bindId Unique identifier of the primary binding in the owning
Expand All @@ -90,7 +90,7 @@ class Texture
* image at load time.
* @param userData User data to associate with the resultant texture.
*/
Texture(textureid_t bindId, const Size2Raw& size, void* userData=NULL);
Texture(textureid_t bindId, Size2Raw const &dimensions, void *userData = 0);

~Texture();

Expand All @@ -107,8 +107,8 @@ class Texture
/**
* Retrieve the value of the associated user data pointer.
* @return Associated data pointer value.
**/
void* userDataPointer() const;
*/
void *userDataPointer() const;

/**
* Set the user data pointer value. Ownership of the data is not given to
Expand All @@ -120,15 +120,15 @@ class Texture
*
* @param userData User data pointer value.
*/
void setUserDataPointer(void* userData);
void setUserDataPointer(void *userData);

/**
* Add a new prepared variant to the list of resources for this Texture.
* Texture takes ownership of the variant.
*
* @param variant Variant instance to add to the resource list.
*/
de::TextureVariant& addVariant(de::TextureVariant& variant);
TextureVariant &addVariant(TextureVariant &variant);

/// @return Number of variants for this texture.
uint variantCount() const;
Expand All @@ -140,7 +140,7 @@ class Texture
* Retrieve the value of an identified @a analysis data pointer.
* @return Associated data pointer value.
**/
void* analysisDataPointer(texture_analysisid_t analysis) const;
void *analysisDataPointer(texture_analysisid_t analysis) const;

/**
* Set the value of an identified @a analysis data pointer. Ownership of
Expand All @@ -153,7 +153,7 @@ class Texture
* @param analysis Identifier of the data being attached.
* @param data Data to be attached.
*/
void setAnalysisDataPointer(texture_analysisid_t analysis, void* data);
void setAnalysisDataPointer(texture_analysisid_t analysis, void *data);

/// @return Logical width (not necessarily the same as pixel width).
int width() const;
Expand All @@ -162,7 +162,7 @@ class Texture
int height() const;

/// Retrieve logical dimensions (not necessarily the same as pixel dimensions).
const Size2Raw& size() const { return dimensions; }
Size2Raw const &dimensions() const { return dimensions_; }

/**
* Change logical width.
Expand All @@ -180,12 +180,12 @@ class Texture
* Change logical pixel dimensions.
* @param size New size.
*/
void setSize(const Size2Raw& size);
void setDimensions(Size2Raw const &dimensions);

/**
* Provides access to the list of variant textures for efficent traversals.
*/
const Variants& variantList() const { return variants; }
Variants const &variantList() const { return variants; }

private:
Flags flags;
Expand All @@ -197,14 +197,14 @@ class Texture
Variants variants;

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

/// Dimensions in logical pixels.
Size2Raw dimensions;
Size2Raw dimensions_;

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

} // namespace de
Expand Down Expand Up @@ -241,10 +241,10 @@ void Texture_FlagCustom(Texture* tex, boolean yes);

int Texture_Width(const Texture* tex);
int Texture_Height(const Texture* tex);
const Size2Raw* Texture_Size(const Texture* tex);
const Size2Raw* Texture_Dimensions(const Texture* tex);
void Texture_SetWidth(Texture* tex, int width);
void Texture_SetHeight(Texture* tex, int height);
void Texture_SetSize(Texture* tex, const Size2Raw* size);
void Texture_SetDimensions(Texture* tex, const Size2Raw* size);

/**
* Iterate over all derived TextureVariants, making a callback for each.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/include/resource/textures.h
Expand Up @@ -160,7 +160,7 @@ textureid_t Textures_Declare(Uri* uri, int uniqueId, Uri const* resourcePath);
* be inherited from the actual pixel size of the texture at load time.
* @param userData User data to associate with the resultant texture.
*/
struct texture_s* Textures_CreateWithSize(textureid_t id, boolean custom, const Size2Raw* size, void* userData);
struct texture_s* Textures_CreateWithDimensions(textureid_t id, boolean custom, const Size2Raw* size, void* userData);
struct texture_s* Textures_Create(textureid_t id, boolean custom, void* userData); /* width=0, height=0*/

/**
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/src/gl/gl_texmanager.c
Expand Up @@ -3350,7 +3350,7 @@ static boolean tryLoadImageAndPrepareVariant(Texture* tex,
Str_Text(path), image.size.width, image.size.height) )
Uri_Delete(uri);
#endif
Texture_SetSize(tex, &image.size);
Texture_SetDimensions(tex, &image.size);
}

performImageAnalyses(tex, &image, spec, true /*Always update*/);
Expand Down
56 changes: 28 additions & 28 deletions doomsday/engine/src/resource/texture.cpp
Expand Up @@ -36,16 +36,16 @@
#include <de/memory.h>

de::Texture::Texture(textureid_t bindId, void* _userData)
: flags(), primaryBindId(bindId), variants(), userData(_userData), dimensions()
: flags(), primaryBindId(bindId), variants(), userData(_userData), dimensions_()
{
memset(analyses, 0, sizeof(analyses));
}

de::Texture::Texture(textureid_t bindId, const Size2Raw& size, void* _userData)
: flags(), primaryBindId(bindId), variants(), userData(_userData), dimensions()
: flags(), primaryBindId(bindId), variants(), userData(_userData), dimensions_()
{
memset(analyses, 0, sizeof(analyses));
setSize(size);
setDimensions(size);
}

de::Texture::~Texture()
Expand Down Expand Up @@ -116,30 +116,30 @@ void de::Texture::flagCustom(bool yes)

int de::Texture::width() const
{
return dimensions.width;
return dimensions_.width;
}

void de::Texture::setWidth(int newWidth)
{
dimensions.width = newWidth;
dimensions_.width = newWidth;
/// @todo Update any Materials (and thus Surfaces) which reference this.
}

int de::Texture::height() const
{
return dimensions.height;
return dimensions_.height;
}

void de::Texture::setHeight(int newHeight)
{
dimensions.height = newHeight;
dimensions_.height = newHeight;
/// @todo Update any Materials (and thus Surfaces) which reference this.
}

void de::Texture::setSize(const Size2Raw& newSize)
void de::Texture::setDimensions(const Size2Raw& newSize)
{
dimensions.width = newSize.width;
dimensions.height = newSize.height;
dimensions_.width = newSize.width;
dimensions_.height = newSize.height;
/// @todo Update any Materials (and thus Surfaces) which reference this.
}

Expand All @@ -158,8 +158,8 @@ void de::Texture::setAnalysisDataPointer(texture_analysisid_t analysisId, void*
textureid_t textureId = Textures_Id(reinterpret_cast<struct texture_s*>(this));
de::Uri* uri = reinterpret_cast<de::Uri*>(Textures_ComposeUri(textureId));
LOG_AS("Texture::attachAnalysis");
LOG_WARNING("Image analysis (id:%i) already present for \"%s\", will replace.")
<< int(analysisId) << uri;
LOG_DEBUG("Image analysis (id:%i) already present for \"%s\" (replaced).")
<< int(analysisId) << *uri;
delete uri;
#endif
}
Expand Down Expand Up @@ -260,73 +260,73 @@ void* Texture_AnalysisDataPointer(const Texture* tex, texture_analysisid_t analy
return self->analysisDataPointer(analysisId);
}

void Texture_SetAnalysisDataPointer(Texture* tex, texture_analysisid_t analysis, void* data)
void Texture_SetAnalysisDataPointer(Texture *tex, texture_analysisid_t analysis, void *data)
{
SELF(tex);
self->setAnalysisDataPointer(analysis, data);
}

boolean Texture_IsCustom(const Texture* tex)
boolean Texture_IsCustom(Texture const *tex)
{
SELF_CONST(tex);
return CPP_BOOL(self->isCustom());
}

void Texture_FlagCustom(Texture* tex, boolean yes)
void Texture_FlagCustom(Texture *tex, boolean yes)
{
SELF(tex);
self->flagCustom(bool(yes));
}

void Texture_SetSize(Texture* tex, const Size2Raw* newSize)
void Texture_SetDimensions(Texture *tex, Size2Raw const *newSize)
{
SELF(tex);
if(!newSize)
LegacyCore_FatalError("Texture_SetSize: Attempted with invalid newSize argument (=NULL).");
self->setSize(*newSize);
LegacyCore_FatalError("Texture_SetDimensions: Attempted with invalid newSize argument (=NULL).");
self->setDimensions(*newSize);
}

int Texture_Width(const Texture* tex)
int Texture_Width(Texture const *tex)
{
SELF_CONST(tex);
return self->width();
}

void Texture_SetWidth(Texture* tex, int newWidth)
void Texture_SetWidth(Texture *tex, int newWidth)
{
SELF(tex);
self->setWidth(newWidth);
}

int Texture_Height(const Texture* tex)
int Texture_Height(Texture const *tex)
{
SELF_CONST(tex);
return self->height();
}

const Size2Raw* Texture_Size(const Texture* tex)
Size2Raw const *Texture_Dimensions(Texture const *tex)
{
SELF_CONST(tex);
return &self->size();
return &self->dimensions();
}

void Texture_SetHeight(Texture* tex, int newHeight)
void Texture_SetHeight(Texture *tex, int newHeight)
{
SELF(tex);
self->setHeight(newHeight);
}

int Texture_IterateVariants(struct texture_s* tex,
int (*callback)(struct texturevariant_s* variant, void* parameters), void* parameters)
int Texture_IterateVariants(Texture *tex,
int (*callback)(TextureVariant *variant, void *parameters), void *parameters)
{
SELF(tex);
int result = 0;
if(callback)
{
DENG2_FOR_EACH_CONST(de::Texture::Variants, i, self->variantList())
{
de::TextureVariant* variant = const_cast<de::TextureVariant*>(*i);
result = callback(reinterpret_cast<TextureVariant*>(variant), parameters);
de::TextureVariant *variant = const_cast<de::TextureVariant *>(*i);
result = callback(reinterpret_cast<TextureVariant *>(variant), parameters);
if(result) break;
}
}
Expand Down
8 changes: 4 additions & 4 deletions doomsday/engine/src/resource/textures.cpp
Expand Up @@ -902,10 +902,10 @@ textureid_t Textures_Declare(Uri* uri, int uniqueId, Uri const* resourcePath)
return Textures_Declare2(reinterpret_cast<de::Uri&>(*uri), uniqueId, reinterpret_cast<de::Uri const*>(resourcePath));
}

Texture* Textures_CreateWithSize(textureid_t id, boolean custom, const Size2Raw* size,
Texture* Textures_CreateWithDimensions(textureid_t id, boolean custom, const Size2Raw* size,
void* userData)
{
LOG_AS("Textures_CreateWithSize");
LOG_AS("Textures_CreateWithDimensions");

if(!size)
{
Expand Down Expand Up @@ -933,7 +933,7 @@ Texture* Textures_CreateWithSize(textureid_t id, boolean custom, const Size2Raw*
delete uri;
#endif
Texture_FlagCustom(tex, custom);
Texture_SetSize(tex, size);
Texture_SetDimensions(tex, size);
Texture_SetUserDataPointer(tex, userData);
/// @todo Materials and Surfaces should be notified of this!
return tex;
Expand All @@ -948,7 +948,7 @@ Texture* Textures_CreateWithSize(textureid_t id, boolean custom, const Size2Raw*
Texture* Textures_Create(textureid_t id, boolean custom, void* userData)
{
Size2Raw size(0, 0);
return Textures_CreateWithSize(id, custom, &size, userData);
return Textures_CreateWithDimensions(id, custom, &size, userData);
}

int Textures_UniqueId(textureid_t id)
Expand Down

0 comments on commit 7a8d538

Please sign in to comment.