+ 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)
+{
+ // make sure an observer doesn't observe the same object twice
+ // otherwise it will get multiple calls to ObjectDestroyed()
+ DALI_ASSERT_DEBUG(mLifecycleObservers.End() == std::find(mLifecycleObservers.Begin(), mLifecycleObservers.End(), &observer));
+ mLifecycleObservers.PushBack(&observer);
+}
+
+void TextureManager::RemoveObserver(TextureManager::LifecycleObserver& observer)
+{
+ // Find the observer...
+ auto endIter = mLifecycleObservers.End();
+ for(auto iter = mLifecycleObservers.Begin(); iter != endIter; ++iter)
+ {
+ if((*iter) == &observer)
+ {
+ mLifecycleObservers.Erase(iter);
+ break;
+ }
+ }
+ DALI_ASSERT_DEBUG(endIter != mLifecycleObservers.End());
+}
+
+void TextureManager::LoadOrQueueTexture(TextureInfo& textureInfo, TextureUploadObserver* observer)
+{
+ switch(textureInfo.loadState)
+ {
+ case LoadState::NOT_STARTED:
+ case LoadState::LOAD_FAILED:
+ {
+ if(mQueueLoadFlag)
+ {
+ QueueLoadTexture(textureInfo, observer);
+ }
+ else
+ {
+ LoadTexture(textureInfo, observer);
+ }
+ break;
+ }
+ case LoadState::UPLOADED:
+ {
+ if(mQueueLoadFlag)
+ {
+ QueueLoadTexture(textureInfo, observer);
+ }
+ else
+ {
+ // The Texture has already loaded. The other observers have already been notified.
+ // We need to send a "late" loaded notification for this observer.
+ observer->UploadComplete(true, textureInfo.textureId, textureInfo.textureSet, textureInfo.useAtlas, textureInfo.atlasRect, textureInfo.preMultiplied);
+ }
+ break;
+ }
+ case LoadState::LOADING:
+ case LoadState::CANCELLED:
+ case LoadState::LOAD_FINISHED:
+ case LoadState::WAITING_FOR_MASK:
+ case LoadState::MASK_APPLYING:
+ case LoadState::MASK_APPLIED:
+ {
+ break;
+ }
+ }
+}
+
+void TextureManager::QueueLoadTexture(TextureInfo& textureInfo, TextureUploadObserver* observer)
+{
+ auto textureId = textureInfo.textureId;
+ mLoadQueue.PushBack(LoadQueueElement(textureId, observer));
+
+ observer->DestructionSignal().Connect(this, &TextureManager::ObserverDestroyed);
+}
+
+void TextureManager::LoadTexture(TextureInfo& textureInfo, TextureUploadObserver* observer)
+{
+ DALI_LOG_INFO(gTextureManagerLogFilter, Debug::Concise, "TextureManager::LoadTexture(): url:%s sync:%s\n", textureInfo.url.GetUrl().c_str(), textureInfo.loadSynchronously ? "T" : "F");