// if available, increment reference count, and return the image. // else, add to the queue list if appropriate. bool CGUILargeTextureManager::GetImage(const CStdString &path, CTextureArray &texture, bool firstRequest) { CSingleLock lock(m_listSection); if (path == "image://http%3a%2f%2fcf2.imgobject.com%2ft%2fp%2foriginal%2frXhuBgQyRKB7cW5BRImyVkO89K7.jpg/") { int a = 0; } for (listIterator it = m_allocated.begin(); it != m_allocated.end(); ++it) { CLargeTexture *image = *it; if (image->GetPath() == path) { if (firstRequest) image->AddRef(); texture = image->GetTexture(); return texture.size() > 0; } } if (firstRequest) QueueImage(path); return true; }
// if available, increment reference count, and return the image. // else, add to the queue list if appropriate. bool CGUILargeTextureManager::GetImage(const std::string &path, CTextureArray &texture, bool firstRequest, const bool useCache) { CSingleLock lock(m_listSection); for (listIterator it = m_allocated.begin(); it != m_allocated.end(); ++it) { CLargeTexture *image = *it; if (image->GetPath() == path) { if (firstRequest) image->AddRef(); texture = image->GetTexture(); return texture.size() > 0; } } if (firstRequest) QueueImage(path, useCache); return true; }
// if available, increment reference count, and return the image. // else, add to the queue list if appropriate. bool CGUILargeTextureManager::GetImage(const CStdString &path, CTextureArray &texture, bool firstRequest) { // note: max size to load images: 2048x1024? (8MB) CSingleLock lock(m_listSection); for (listIterator it = m_allocated.begin(); it != m_allocated.end(); ++it) { CLargeTexture *image = *it; if (image->GetPath() == path) { if (firstRequest) image->AddRef(); texture = image->GetTexture(); return texture.size() > 0; } } if (firstRequest) QueueImage(path); return true; }
bool CGUITextureBase::AllocResources() { if (m_info.filename.empty()) return false; if (m_texture.size()) return false; // already have our texture // reset our animstate m_frameCounter = 0; m_currentFrame = 0; m_currentLoop = 0; bool changed = false; bool useLarge = m_info.useLarge || !g_TextureManager.CanLoad(m_info.filename); if (useLarge) { // we want to use the large image loader, but we first check for bundled textures if (!IsAllocated()) { CTextureArray texture; texture = g_TextureManager.Load(m_info.filename, true); if (texture.size()) { m_isAllocated = NORMAL; m_texture = texture; changed = true; } } if (m_isAllocated != NORMAL) { // use our large image background loader CTextureArray texture; if (g_largeTextureManager.GetImage(m_info.filename, texture, !IsAllocated(), m_use_cache)) { m_isAllocated = LARGE; if (!texture.size()) // not ready as yet return false; m_texture = texture; changed = true; } else m_isAllocated = LARGE_FAILED; } } else if (!IsAllocated()) { CTextureArray texture = g_TextureManager.Load(m_info.filename); // set allocated to true even if we couldn't load the image to save // us hitting the disk every frame m_isAllocated = texture.size() ? NORMAL : NORMAL_FAILED; if (!texture.size()) return false; m_texture = texture; changed = true; } m_frameWidth = (float)m_texture.m_width; m_frameHeight = (float)m_texture.m_height; // load the diffuse texture (if necessary) if (!m_info.diffuse.empty()) { m_diffuse = g_TextureManager.Load(m_info.diffuse); } CalculateSize(); // call our implementation Allocate(); return changed; }