+EncodedImageBuffer TextureManager::RemoveExternalEncodedImageBuffer(const std::string& url)
+{
+ if(url.size() > 0u)
+ {
+ if(VisualUrl::BUFFER == VisualUrl::GetProtocolType(url))
+ {
+ // get the location from the Url
+ std::string location = VisualUrl::GetLocation(url);
+ if(location.size() > 0u)
+ {
+ TextureId id = std::stoi(location);
+ const auto end = mEncodedBufferTextures.end();
+ for(auto iter = mEncodedBufferTextures.begin(); iter != end; ++iter)
+ {
+ if(iter->textureId == id)
+ {
+ auto encodedImageBuffer = iter->encodedImageBuffer;
+ if(--(iter->referenceCount) <= 0)
+ {
+ mEncodedBufferTextures.erase(iter);
+ }
+ return encodedImageBuffer;
+ }
+ }
+ }
+ }
+ }
+ return EncodedImageBuffer();
+}
+
+void TextureManager::UseExternalResource(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;
+ }
+ }
+ }
+ }
+ else if(VisualUrl::BUFFER == url.GetProtocolType())
+ {
+ std::string location = url.GetLocation();
+ if(location.size() > 0u)
+ {
+ TextureId id = std::stoi(location);
+ for(auto&& elem : mEncodedBufferTextures)
+ {
+ if(elem.textureId == id)
+ {
+ elem.referenceCount++;
+ return;
+ }
+ }
+ }
+ }
+}
+
+void TextureManager::AddObserver(TextureManager::LifecycleObserver& observer)