void TextureManager::Remove(const TextureManager::TextureId textureId, TextureUploadObserver* observer)
{
int textureInfoIndex = GetCacheIndexFromId(textureId);
+
if(textureInfoIndex != INVALID_INDEX)
{
TextureInfo& textureInfo(mTextureInfoContainer[textureInfoIndex]);
info.textureId = GenerateUniqueTextureId();
info.textureSet = textureSet;
mExternalTextures.emplace_back(info);
+
return VisualUrl::CreateTextureUrl(std::to_string(info.textureId));
}
if(url.size() > 0u)
{
// get the location from the Url
- VisualUrl parseUrl(url);
- if(VisualUrl::TEXTURE == parseUrl.GetProtocolType())
+ if(VisualUrl::TEXTURE == VisualUrl::GetProtocolType(url))
{
- std::string location = parseUrl.GetLocation();
+ std::string location = VisualUrl::GetLocation(url);
if(location.size() > 0u)
{
TextureId id = std::stoi(location);
if(iter->textureId == id)
{
auto textureSet = iter->textureSet;
- mExternalTextures.erase(iter);
+ if(--(iter->referenceCount) <= 0)
+ {
+ mExternalTextures.erase(iter);
+ }
return textureSet;
}
}
return TextureSet();
}
+void TextureManager::UseExternalTexture(const VisualUrl& url)
+{
+ if(VisualUrl::TEXTURE == url.GetProtocolType())
+ {
+ std::string location = url.GetLocation();
+ if(location.size() > 0u)
+ {
+ TextureId id = std::stoi(location);
+ for(auto&& elem : mExternalTextures)
+ {
+ if(elem.textureId == id)
+ {
+ elem.referenceCount++;
+ return;
+ }
+ }
+ }
+ }
+}
+
void TextureManager::AddObserver(TextureManager::LifecycleObserver& observer)
{
// make sure an observer doesn't observe the same object twice