{
element.mObserver->LoadComplete( true, textureInfo.pixelBuffer, textureInfo.url, textureInfo.preMultiplied );
}
+ else if(textureInfo.loadState == LOADING)
+ {
+ // Note : LOADING state texture cannot be queue.
+ // This case be occured when same texture id are queue in mLoadQueue.
+ ObserveTexture( textureInfo, element.mObserver );
+ }
else
{
LoadTexture( textureInfo, element.mObserver );
{
// @todo If the load was unsuccessful, upload the broken image.
textureInfo.loadState = LOAD_FAILED;
- CheckForWaitingTexture( textureInfo );
- NotifyObservers( textureInfo, false );
+ if(textureInfo.storageType == StorageType::KEEP_PIXEL_BUFFER)
+ {
+ // Check if there was another texture waiting for this load to complete
+ // (e.g. if this was an image mask, and its load is on a different thread)
+ CheckForWaitingTexture(textureInfo);
+ }
+ else
+ {
+ NotifyObservers(textureInfo, false);
+ }
}
}
// maskTextureId:
const unsigned int size = mTextureInfoContainer.size();
+ // Keep notify observer required textureIds.
+ // Note : NotifyObservers can change mTextureInfoContainer cache struct. We should check id's validation before notify.
+ std::vector<TextureId> notifyRequiredTextureIds;
+
for( unsigned int cacheIndex = 0; cacheIndex < size; ++cacheIndex )
{
if( mTextureInfoContainer[cacheIndex].maskTextureId == maskTextureInfo.textureId &&
// Send New Task to Thread
ApplyMask( textureInfo, maskTextureInfo.textureId );
}
- else
+ else // maskTextureInfo.loadState == LoadState::LOAD_FAILED
{
+ // Increase reference counts for notify required textureId.
+ // Now we can assume that we don't remove & re-assign this textureId
+ // during NotifyObserver signal emit.
+ textureInfo.referenceCount++;
+
textureInfo.pixelBuffer.Reset();
textureInfo.loadState = LOAD_FAILED;
- NotifyObservers( textureInfo, false );
+
+ notifyRequiredTextureIds.push_back(textureInfo.textureId);
}
}
}
+
+ // Notify textures are masked
+ for(const auto textureId : notifyRequiredTextureIds)
+ {
+ int textureCacheIndex = GetCacheIndexFromId(textureId);
+ if(textureCacheIndex != INVALID_CACHE_INDEX)
+ {
+ TextureInfo& textureInfo(mTextureInfoContainer[textureCacheIndex]);
+ NotifyObservers(textureInfo, false);
+ }
+ }
+
+ // Decrease reference count
+ for(const auto textureId : notifyRequiredTextureIds)
+ {
+ Remove(textureId, nullptr);
+ }
}
void TextureManager::ApplyMask( TextureInfo& textureInfo, TextureId maskTextureId )