Add DesiredWidth/Height and samplingMode in animated image visual
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / animated-image / rolling-animated-image-cache.cpp
index 74ec088..995ea60 100644 (file)
@@ -61,20 +61,27 @@ static constexpr uint32_t FIRST_FRAME_INDEX  = 0u;
 } // namespace
 
 RollingAnimatedImageCache::RollingAnimatedImageCache(TextureManager&                     textureManager,
+                                                     ImageDimensions                     size,
+                                                     Dali::FittingMode::Type             fittingMode,
+                                                     Dali::SamplingMode::Type            samplingMode,
                                                      AnimatedImageLoading&               animatedImageLoading,
                                                      TextureManager::MaskingDataPointer& maskingData,
                                                      ImageCache::FrameReadyObserver&     observer,
                                                      uint16_t                            cacheSize,
                                                      uint16_t                            batchSize,
+                                                     const Dali::WrapMode::Type&         wrapModeU,
+                                                     const Dali::WrapMode::Type&         wrapModeV,
                                                      bool                                isSynchronousLoading,
                                                      bool                                preMultiplyOnLoad)
-: ImageCache(textureManager, maskingData, observer, batchSize, 0u),
+: ImageCache(textureManager, size, fittingMode, samplingMode, maskingData, observer, batchSize, 0u),
   mImageUrl(animatedImageLoading.GetUrl()),
   mAnimatedImageLoading(animatedImageLoading),
   mFrameCount(SINGLE_IMAGE_COUNT),
   mFrameIndex(FIRST_FRAME_INDEX),
   mCacheSize(cacheSize),
   mQueue(cacheSize),
+  mWrapModeU(wrapModeU),
+  mWrapModeV(wrapModeV),
   mIsSynchronousLoading(isSynchronousLoading),
   mPreMultiplyOnLoad(preMultiplyOnLoad)
 {
@@ -203,12 +210,18 @@ TextureSet RollingAnimatedImageCache::RequestFrameLoading(uint32_t frameIndex, b
                                                                    frameIndex,
                                                                    loadTextureId,
                                                                    mMaskingData,
-                                                                   SamplingMode::BOX_THEN_LINEAR,
-                                                                   Dali::WrapMode::Type::DEFAULT,
-                                                                   Dali::WrapMode::Type::DEFAULT,
+                                                                   mDesiredSize,
+                                                                   mFittingMode,
+                                                                   mSamplingMode,
                                                                    synchronousLoading,
                                                                    this,
                                                                    preMultiplyOnLoading);
+  if(textureSet)
+  {
+    Sampler sampler = Sampler::New();
+    sampler.SetWrapMode(mWrapModeU, mWrapModeV);
+    textureSet.SetSampler(0u, sampler);
+  }
 
   mTextureIds[frameIndex] = loadTextureId;
 
@@ -255,8 +268,15 @@ TextureSet RollingAnimatedImageCache::GetFrontTextureSet() const
 {
   DALI_LOG_INFO(gAnimImgLogFilter, Debug::Concise, "RollingAnimatedImageCache::GetFrontTextureSet() FrameNumber:%d\n", mQueue[0].mFrameNumber);
 
-  TextureManager::TextureId textureId = GetCachedTextureId(0);
-  return mTextureManager.GetTextureSet(textureId);
+  TextureManager::TextureId textureId  = GetCachedTextureId(0);
+  TextureSet                textureSet = mTextureManager.GetTextureSet(textureId);
+  if(textureSet)
+  {
+    Sampler sampler = Sampler::New();
+    sampler.SetWrapMode(mWrapModeU, mWrapModeV);
+    textureSet.SetSampler(0u, sampler);
+  }
+  return textureSet;
 }
 
 TextureManager::TextureId RollingAnimatedImageCache::GetCachedTextureId(int index) const
@@ -272,7 +292,6 @@ void RollingAnimatedImageCache::PopFrontCache()
 
   if(mMaskingData && mMaskingData->mAlphaMaskId != TextureManager::INVALID_TEXTURE_ID)
   {
-    mTextureManager.Remove(mMaskingData->mAlphaMaskId, this);
     if(mQueue.IsEmpty())
     {
       mMaskingData->mAlphaMaskId = TextureManager::INVALID_TEXTURE_ID;
@@ -328,7 +347,14 @@ void RollingAnimatedImageCache::LoadComplete(bool loadSuccess, TextureInformatio
   DALI_LOG_INFO(gAnimImgLogFilter, Debug::Concise, "AnimatedImageVisual::LoadComplete(textureId:%d) start\n", textureInformation.textureId);
   LOG_CACHE;
 
-  MakeFrameReady(loadSuccess, mTextureManager.GetTextureSet(textureInformation.textureId), textureInformation.interval);
+  if(textureInformation.textureSet)
+  {
+    Sampler sampler = Sampler::New();
+    sampler.SetWrapMode(mWrapModeU, mWrapModeV);
+    textureInformation.textureSet.SetSampler(0u, sampler);
+  }
+
+  MakeFrameReady(loadSuccess, textureInformation.textureSet, textureInformation.interval);
 
   if(loadSuccess)
   {