+ // If there is a mask texture ID associated with this texture, then apply the mask
+ // if it's already loaded. If it hasn't, and the mask is still loading,
+ // wait for the mask to finish loading.
+ // note, If the texture is already uploaded synchronously during loading,
+ // we don't need to apply mask.
+ if(textureInfo.loadState != LoadState::UPLOADED &&
+ textureInfo.maskTextureId != INVALID_TEXTURE_ID)
+ {
+ if(textureInfo.loadState == LoadState::MASK_APPLYING)
+ {
+ textureInfo.loadState = LoadState::MASK_APPLIED;
+ UploadTextures(pixelBuffers, textureInfo);
+ NotifyObservers(textureInfo, true);
+ }
+ else
+ {
+ LoadState maskLoadState = mTextureCacheManager.GetTextureStateInternal(textureInfo.maskTextureId);
+ textureInfo.pixelBuffer = pixelBuffer; // Store the pixel buffer temporarily
+ if(maskLoadState == LoadState::LOADING)
+ {
+ textureInfo.loadState = LoadState::WAITING_FOR_MASK;
+ }
+ else if(maskLoadState == LoadState::LOAD_FINISHED || maskLoadState == LoadState::UPLOADED)
+ {
+ // Send New Task to Thread
+ TextureCacheIndex maskCacheIndex = mTextureCacheManager.GetCacheIndexFromId(textureInfo.maskTextureId);
+ if(maskCacheIndex != INVALID_CACHE_INDEX)
+ {
+ TextureInfo& maskTextureInfo(mTextureCacheManager[maskCacheIndex]);
+ if(maskTextureInfo.storageType == StorageType::KEEP_PIXEL_BUFFER)
+ {
+ // Send New Task to Thread
+ ApplyMask(textureInfo, textureInfo.maskTextureId);
+ }
+ else if(maskTextureInfo.storageType == StorageType::KEEP_TEXTURE)
+ {
+ // Upload image texture. textureInfo.loadState will be UPLOADED.
+ UploadTextures(pixelBuffers, textureInfo);
+ if(maskTextureInfo.textureSet.GetTextureCount() > 0u)
+ {
+ Texture maskTexture = maskTextureInfo.textureSet.GetTexture(0u);
+ textureInfo.textureSet.SetTexture(1u, maskTexture);
+ }
+ // notify mask texture set.
+ NotifyObservers(textureInfo, true);
+ }
+ }
+ }
+ else // maskLoadState == LoadState::LOAD_FAILED
+ {
+ // Url texture load success, But alpha mask texture load failed. Run as normal image upload.
+ DALI_LOG_ERROR("Alpha mask image loading failed! Image will not be masked\n");
+ UploadTextures(pixelBuffers, textureInfo);
+ NotifyObservers(textureInfo, true);
+ }
+ }
+ }
+ else
+ {
+ UploadTextures(pixelBuffers, textureInfo);
+ NotifyObservers(textureInfo, true);
+ }