+
+ // If we fail to load the animated image, we will try to load as a normal image.
+ if(!mAnimatedImageLoading)
+ {
+ mImageUrls = new ImageCache::UrlList();
+ mImageUrls->reserve(SINGLE_IMAGE_COUNT);
+
+ for(unsigned int i = 0; i < SINGLE_IMAGE_COUNT; ++i)
+ {
+ ImageCache::UrlStore urlStore;
+ urlStore.mTextureId = TextureManager::INVALID_TEXTURE_ID;
+ urlStore.mUrl = imageUrl;
+ mImageUrls->push_back(urlStore);
+ }
+ mFrameCount = SINGLE_IMAGE_COUNT;
+ }
+}
+
+void AnimatedImageVisual::CreateImageCache()
+{
+ DALI_LOG_INFO(gAnimImgLogFilter, Debug::Concise, "AnimatedImageVisual::CreateImageCache() batchSize:%d cacheSize:%d\n", mBatchSize, mCacheSize);
+
+ TextureManager& textureManager = mFactoryCache.GetTextureManager();
+
+ if(mAnimatedImageLoading)
+ {
+ mImageCache = new RollingAnimatedImageCache(textureManager, mDesiredSize, mFittingMode, mSamplingMode, mAnimatedImageLoading, mMaskingData, *this, mCacheSize, mBatchSize, mWrapModeU, mWrapModeV, IsSynchronousLoadingRequired(), IsPreMultipliedAlphaEnabled());
+ }
+ else if(mImageUrls)
+ {
+ // Ensure the batch size and cache size are no bigger than the number of URLs,
+ // and that the cache is at least as big as the batch size.
+ uint16_t numUrls = mImageUrls->size();
+ uint16_t batchSize = std::max(std::min(mBatchSize, numUrls), MINIMUM_CACHESIZE);
+ uint16_t cacheSize = std::max(std::min(std::max(batchSize, mCacheSize), numUrls), MINIMUM_CACHESIZE);
+ if(cacheSize < numUrls)
+ {
+ mImageCache = new RollingImageCache(textureManager, mDesiredSize, mFittingMode, mSamplingMode, *mImageUrls, mMaskingData, *this, cacheSize, batchSize, mFrameDelay, IsPreMultipliedAlphaEnabled());
+ }
+ else
+ {
+ mImageCache = new FixedImageCache(textureManager, mDesiredSize, mFittingMode, mSamplingMode, *mImageUrls, mMaskingData, *this, batchSize, mFrameDelay, IsPreMultipliedAlphaEnabled());
+ }
+ }
+
+ if(DALI_UNLIKELY(!mImageCache))
+ {
+ DALI_LOG_ERROR("mImageCache is null\n");
+ }