Merge "Fix issue using broken image" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / animated-image / rolling-image-cache.cpp
index 390af53..99e12e6 100644 (file)
@@ -58,13 +58,17 @@ namespace Toolkit
 namespace Internal
 {
 RollingImageCache::RollingImageCache(TextureManager&                     textureManager,
+                                     ImageDimensions                     size,
+                                     Dali::FittingMode::Type             fittingMode,
+                                     Dali::SamplingMode::Type            samplingMode,
                                      UrlList&                            urlList,
                                      TextureManager::MaskingDataPointer& maskingData,
                                      ImageCache::FrameReadyObserver&     observer,
                                      uint16_t                            cacheSize,
                                      uint16_t                            batchSize,
-                                     uint32_t                            interval)
-: ImageCache(textureManager, maskingData, observer, batchSize, interval),
+                                     uint32_t                            interval,
+                                     bool                                preMultiplyOnLoad)
+: ImageCache(textureManager, size, fittingMode, samplingMode, maskingData, observer, batchSize, interval, preMultiplyOnLoad),
   mImageUrls(urlList),
   mQueue(cacheSize)
 {
@@ -92,7 +96,7 @@ TextureSet RollingImageCache::Frame(uint32_t frameIndex)
     // If the frame of frameIndex was already loaded, load batch from the last frame of queue
     if(!mQueue.IsEmpty())
     {
-      batchFrameIndex = (mQueue.Back().mUrlIndex + 1) % mImageUrls.size();
+      batchFrameIndex = (mQueue.Back().mUrlIndex + 1) % static_cast<uint32_t>(mImageUrls.size());
     }
     LoadBatch(batchFrameIndex);
   }
@@ -164,11 +168,13 @@ void RollingImageCache::LoadBatch(uint32_t frameIndex)
     ImageAtlasManagerPtr  imageAtlasManager  = nullptr;
     Vector4               textureRect;
     Dali::ImageDimensions textureRectSize;
-    auto                  preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
+
+    auto preMultiplyOnLoading = mPreMultiplyOnLoad ? TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD
+                                                   : TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
 
     TextureManager::TextureId loadTextureId = TextureManager::INVALID_TEXTURE_ID;
     TextureSet                textureSet    = mTextureManager.LoadTexture(
-      url, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, mMaskingData, synchronousLoading, loadTextureId, textureRect, textureRectSize, atlasingStatus, loadingStatus, this, atlasObserver, imageAtlasManager, ENABLE_ORIENTATION_CORRECTION, TextureManager::ReloadPolicy::CACHED, preMultiply);
+      url, mDesiredSize, mFittingMode, mSamplingMode, mMaskingData, synchronousLoading, loadTextureId, textureRect, textureRectSize, atlasingStatus, loadingStatus, this, atlasObserver, imageAtlasManager, ENABLE_ORIENTATION_CORRECTION, TextureManager::ReloadPolicy::CACHED, preMultiplyOnLoading);
     mImageUrls[imageFrame.mUrlIndex].mTextureId = loadTextureId;
 
     mRequestingLoad = false;
@@ -180,8 +186,8 @@ void RollingImageCache::LoadBatch(uint32_t frameIndex)
 
 TextureSet RollingImageCache::GetFrontTextureSet() const
 {
-  TextureManager::TextureId textureId = GetCachedTextureId(0);
-  TextureSet textureSet = mTextureManager.GetTextureSet(textureId);
+  TextureManager::TextureId textureId  = GetCachedTextureId(0);
+  TextureSet                textureSet = mTextureManager.GetTextureSet(textureId);
   if(textureSet)
   {
     Sampler sampler = Sampler::New();
@@ -256,13 +262,14 @@ void RollingImageCache::LoadComplete(bool loadSuccess, TextureInformation textur
         sampler.SetWrapMode(Dali::WrapMode::Type::DEFAULT, Dali::WrapMode::Type::DEFAULT);
         textureInformation.textureSet.SetSampler(0u, sampler);
       }
-      mObserver.FrameReady(textureInformation.textureSet, mInterval);
+      mObserver.FrameReady(textureInformation.textureSet, mInterval, textureInformation.preMultiplied);
     }
   }
   else
   {
     mLoadState = TextureManager::LoadState::LOAD_FAILED;
-    mObserver.FrameReady(TextureSet(), 0);
+    // preMultiplied should be false because broken image don't premultiply alpha on load
+    mObserver.FrameReady(TextureSet(), 0, false);
   }
 
   LOG_CACHE;