Skip to content
This repository has been archived by the owner on Sep 30, 2018. It is now read-only.

Commit

Permalink
use IN_PROGRESS to indicate the allocated state of a texture in progr…
Browse files Browse the repository at this point in the history
…ess, and split out the removal of inprogress from allocated or failed textures
  • Loading branch information
Jonathan Marshall committed May 2, 2012
1 parent 8d44b24 commit 76a1193
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
6 changes: 6 additions & 0 deletions xbmc/GUILargeTextureManager.cpp
Expand Up @@ -198,6 +198,12 @@ void CGUILargeTextureManager::ReleaseImage(const CStdString &path, bool immediat
return;
}
}
assert(false);
}

void CGUILargeTextureManager::ReleaseQueuedImage(const CStdString &path)
{
CSingleLock lock(m_listSection);
for (queueIterator it = m_queued.begin(); it != m_queued.end(); ++it)
{
unsigned int id = it->first;
Expand Down
3 changes: 2 additions & 1 deletion xbmc/GUILargeTextureManager.h
Expand Up @@ -93,13 +93,14 @@ class CGUILargeTextureManager : public IJobCallback
When textures are finished with, this function should be called. This decrements the texture's
reference count, and schedules it to be unloaded once the reference count reaches zero. If the
texture is still queued for loading, or is in the process of loading, the image load is cancelled.
texture is still queued for loading, or is in the process of loading, use ReleaseQueuedImage instead
\param path path of the image to release.
\param immediately if set true the image is immediately unloaded once its reference count reaches zero
rather than being unloaded after a delay.
*/
void ReleaseImage(const CStdString &path, bool immediately = false);
void ReleaseQueuedImage(const CStdString &path);

/*!
\brief Cleanup images that are no longer in use.
Expand Down
9 changes: 6 additions & 3 deletions xbmc/guilib/GUITexture.cpp
Expand Up @@ -130,7 +130,7 @@ bool CGUITextureBase::AllocateOnDemand()
{
if (m_visible)
{ // visible, so make sure we're allocated
if (!IsAllocated() || (m_isAllocated == LARGE && !m_texture.size()))
if (!IsAllocated() || (m_isAllocated == IN_PROGRESS))
return AllocResources();
}
else
Expand Down Expand Up @@ -315,11 +315,12 @@ bool CGUITextureBase::AllocResources()
CTextureArray texture;
if (g_largeTextureManager.GetImage(m_info.filename, texture, !IsAllocated()))
{
m_isAllocated = LARGE;
m_isAllocated = IN_PROGRESS;

if (!texture.size()) // not ready as yet
return false;

m_isAllocated = LARGE;
m_texture = texture;
changed = true;
}
Expand Down Expand Up @@ -455,7 +456,9 @@ bool CGUITextureBase::CalculateSize()

void CGUITextureBase::FreeResources(bool immediately /* = false */)
{
if (m_isAllocated == LARGE || m_isAllocated == LARGE_FAILED)
if (m_isAllocated == IN_PROGRESS)
g_largeTextureManager.ReleaseQueuedImage(m_info.filename);
else if (m_isAllocated == LARGE || m_isAllocated == LARGE_FAILED)
g_largeTextureManager.ReleaseImage(m_info.filename, immediately || (m_isAllocated == LARGE_FAILED));
else if (m_isAllocated == NORMAL && m_texture.size())
g_TextureManager.ReleaseTexture(m_info.filename);
Expand Down
2 changes: 1 addition & 1 deletion xbmc/guilib/GUITexture.h
Expand Up @@ -161,7 +161,7 @@ class CGUITextureBase
CPoint m_diffuseOffset; // offset into the diffuse frame (it's not always the origin)

bool m_allocateDynamically;
enum ALLOCATE_TYPE { NO = 0, NORMAL, LARGE, NORMAL_FAILED, LARGE_FAILED };
enum ALLOCATE_TYPE { NO = 0, NORMAL, IN_PROGRESS, LARGE, NORMAL_FAILED, LARGE_FAILED };
ALLOCATE_TYPE m_isAllocated;

CTextureInfo m_info;
Expand Down

0 comments on commit 76a1193

Please sign in to comment.