Skip to content

Commit

Permalink
Refactor|Resources: ResourceSystem has ownership of texture variant s…
Browse files Browse the repository at this point in the history
…pecs
  • Loading branch information
danij-deng committed Nov 25, 2013
1 parent 94bbf11 commit 66a0adf
Show file tree
Hide file tree
Showing 16 changed files with 396 additions and 409 deletions.
40 changes: 1 addition & 39 deletions doomsday/client/include/gl/gl_texmanager.h
Expand Up @@ -25,10 +25,6 @@
# error "GL Texture Manager only exists in the Client"
#endif

#ifndef __cplusplus
# error "gl/gl_texmanager.h requires C++"
#endif

#include "api_gl.h"
#include "resource/image.h"
#include "resource/rawtexture.h"
Expand All @@ -39,7 +35,7 @@
* Textures used in the lighting system.
*/
typedef enum lightingtexid_e {
LST_DYNAMIC, ///< Round dynamic light
LST_DYNAMIC, ///< Round dynamic light
LST_GRADIENT, ///< Top-down gradient
LST_RADIO_CO, ///< FakeRadio closed/open corner shadow
LST_RADIO_CC, ///< FakeRadio closed/closed corner shadow
Expand All @@ -59,42 +55,8 @@ typedef enum flaretexid_e {

void GL_InitTextureManager();

void GL_ShutdownTextureManager();

/**
* Call this if a full cleanup of the textures is required (engine update).
*/
void GL_ResetTextureManager();

void GL_TexReset();

void GL_PruneTextureVariantSpecifications();

/**
* Prepare a TextureVariantSpecification according to usage context. If incomplete
* context information is supplied, suitable defaults are chosen in their place.
*
* @param tc Usage context.
* @param flags @ref textureVariantSpecificationFlags
* @param border Border size in pixels (all edges).
* @param tClass Color palette translation class.
* @param tMap Color palette translation map.
*
* @return A rationalized and valid TextureVariantSpecification.
*/
TextureVariantSpec &GL_TextureVariantSpec(
texturevariantusagecontext_t tc, int flags, byte border, int tClass,
int tMap, int wrapS, int wrapT, int minFilter, int magFilter, int anisoFilter,
boolean mipmapped, boolean gammaCorrection, boolean noStretch, boolean toAlpha);

/**
* Prepare a TextureVariantSpecification according to usage context. If incomplete
* context information is supplied, suitable defaults are chosen in their place.
*
* @return A rationalized and valid TextureVariantSpecification.
*/
TextureVariantSpec &GL_DetailTextureSpec(float contrast);

/*
* Here follows miscellaneous routines currently awaiting refactoring into the
* revised texture management APIs.
Expand Down
29 changes: 29 additions & 0 deletions doomsday/client/include/resource/resourcesystem.h
Expand Up @@ -230,6 +230,35 @@ class ResourceSystem : public de::System
*/
void releaseGLTexturesFor(de::Texture &texture, TextureVariantSpec &spec);

void clearAllTextureSpecs();

void pruneUnusedTextureSpecs();

/**
* Prepare a TextureVariantSpecification according to usage context. If the
* specification is incomplete suitable defaults are chosen automatically.
*
* @param tc Usage context.
* @param flags @ref textureVariantSpecificationFlags
* @param border Border size in pixels (all edges).
* @param tClass Color palette translation class.
* @param tMap Color palette translation map.
*
* @return A rationalized and valid TextureVariantSpecification.
*/
TextureVariantSpec &textureSpec(texturevariantusagecontext_t tc, int flags,
byte border, int tClass, int tMap, int wrapS, int wrapT, int minFilter,
int magFilter, int anisoFilter, boolean mipmapped, boolean gammaCorrection,
boolean noStretch, boolean toAlpha);

/**
* Prepare a TextureVariantSpecification according to usage context. If the
* specification is incomplete suitable defaults are chosen automatically.
*
* @return A rationalized and valid TextureVariantSpecification.
*/
TextureVariantSpec &detailTextureSpec(float contrast);

/**
* Provides access to the Fonts collection.
*/
Expand Down
6 changes: 5 additions & 1 deletion doomsday/client/src/dd_main.cpp
Expand Up @@ -1380,7 +1380,11 @@ bool App_ChangeGame(Game &game, bool allowReload)
Demo_StopPlayback();

GL_PurgeDeferredTasks();
GL_ResetTextureManager();
App_ResourceSystem().releaseAllGLTextures();
App_ResourceSystem().pruneUnusedTextureSpecs();
GL_LoadLightingSystemTextures();
GL_LoadFlareTextures();
Rend_ParticleLoadSystemTextures();
GL_SetFilter(false);

if(!game.isNull())
Expand Down
11 changes: 8 additions & 3 deletions doomsday/client/src/gl/gl_main.cpp
Expand Up @@ -377,6 +377,7 @@ void GL_InitRefresh()
{
if(novideo) return;
GL_InitTextureManager();
App_ResourceSystem().clearAllTextureSpecs();

// Register/create Texture objects for the system textures.
App_ResourceSystem().initSystemTextures();
Expand All @@ -389,8 +390,7 @@ void GL_ShutdownRefresh()
initFullGLOk = false;

App_ResourceSystem().clearAllColorPalettes();

GL_ShutdownTextureManager();
App_ResourceSystem().clearAllTextureSpecs();
}

void GL_Shutdown()
Expand Down Expand Up @@ -657,7 +657,12 @@ void GL_TotalReset()
//Rend_ConsoleUpdateTitle();

// Release all texture memory.
GL_ResetTextureManager();
App_ResourceSystem().releaseAllGLTextures();
App_ResourceSystem().pruneUnusedTextureSpecs();
GL_LoadLightingSystemTextures();
GL_LoadFlareTextures();
Rend_ParticleLoadSystemTextures();

GL_ReleaseReservedNames();

#if _DEBUG
Expand Down

0 comments on commit 66a0adf

Please sign in to comment.