Support WebP format 76/236076/13
authorSeungho, Baek <sbsh.baek@samsung.com>
Fri, 12 Jun 2020 12:43:23 +0000 (21:43 +0900)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 24 Jun 2020 22:36:35 +0000 (22:36 +0000)
 - Modified animated-image-visual to support webp amimated image format
 - Added and removed some functions of image-cache to use rolling-animated-image-cache for the both of gif and webp
 - Checked whether mFrameDelayTimer is null or not for the case that Action::PLAY is entered but the system do not support animated webp

Change-Id: I254c4c8e715772acb6c0725c58e64aba1a6dafc4
Signed-off-by: Seungho, Baek <sbsh.baek@samsung.com>
14 files changed:
automated-tests/src/dali-toolkit/utc-Dali-AnimatedImageVisual.cpp
dali-toolkit/internal/file.list
dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp
dali-toolkit/internal/visuals/animated-image/animated-image-visual.h
dali-toolkit/internal/visuals/animated-image/fixed-image-cache.cpp
dali-toolkit/internal/visuals/animated-image/fixed-image-cache.h
dali-toolkit/internal/visuals/animated-image/image-cache.h
dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.cpp [moved from dali-toolkit/internal/visuals/animated-image/rolling-gif-image-cache.cpp with 68% similarity]
dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.h [moved from dali-toolkit/internal/visuals/animated-image/rolling-gif-image-cache.h with 72% similarity]
dali-toolkit/internal/visuals/animated-image/rolling-image-cache.cpp
dali-toolkit/internal/visuals/animated-image/rolling-image-cache.h
dali-toolkit/internal/visuals/visual-factory-impl.cpp
dali-toolkit/internal/visuals/visual-url.cpp
dali-toolkit/internal/visuals/visual-url.h

index bb591dd..bad5ea0 100644 (file)
@@ -293,7 +293,7 @@ int UtcDaliAnimatedImageVisualStopBehavior(void)
 }
 
 
-int UtcDaliAnimatedImageVisualGif01(void)
+int UtcDaliAnimatedImageVisualAnimatedImage01(void)
 {
   ToolkitTestApplication application;
   TestGlAbstraction& gl = application.GetGlAbstraction();
index 8f3b2f2..246ba89 100644 (file)
@@ -17,7 +17,7 @@ SET( toolkit_src_files
    ${toolkit_src_dir}/visuals/animated-image/image-cache.cpp
    ${toolkit_src_dir}/visuals/animated-image/fixed-image-cache.cpp
    ${toolkit_src_dir}/visuals/animated-image/rolling-image-cache.cpp
-   ${toolkit_src_dir}/visuals/animated-image/rolling-gif-image-cache.cpp
+   ${toolkit_src_dir}/visuals/animated-image/rolling-animated-image-cache.cpp
    ${toolkit_src_dir}/visuals/animated-vector-image/animated-vector-image-visual.cpp
    ${toolkit_src_dir}/visuals/animated-vector-image/vector-animation-task.cpp
    ${toolkit_src_dir}/visuals/animated-vector-image/vector-animation-thread.cpp
index 386013a..fdde260 100755 (executable)
@@ -33,7 +33,7 @@
 #include <dali-toolkit/internal/visuals/image-visual-shader-factory.h>
 #include <dali-toolkit/internal/visuals/animated-image/fixed-image-cache.h>
 #include <dali-toolkit/internal/visuals/animated-image/rolling-image-cache.h>
-#include <dali-toolkit/internal/visuals/animated-image/rolling-gif-image-cache.h>
+#include <dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.h>
 #include <dali-toolkit/devel-api/image-loader/image-atlas.h>
 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
@@ -111,7 +111,7 @@ Debug::Filter* gAnimImgLogFilter = Debug::Filter::New(Debug::NoLogging, false, "
 AnimatedImageVisualPtr AnimatedImageVisual::New( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, const Property::Map& properties )
 {
   AnimatedImageVisualPtr visual( new AnimatedImageVisual( factoryCache, shaderFactory ) );
-  visual->InitializeGif( imageUrl );
+  visual->InitializeAnimatedImage( imageUrl );
   visual->SetProperties( properties );
 
   if( visual->mFrameCount > 0 )
@@ -149,7 +149,7 @@ AnimatedImageVisualPtr AnimatedImageVisual::New( VisualFactoryCache& factoryCach
 AnimatedImageVisualPtr AnimatedImageVisual::New( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl )
 {
   AnimatedImageVisualPtr visual( new AnimatedImageVisual( factoryCache, shaderFactory ) );
-  visual->InitializeGif( imageUrl );
+  visual->InitializeAnimatedImage( imageUrl );
 
   if( visual->mFrameCount > 0 )
   {
@@ -159,12 +159,11 @@ AnimatedImageVisualPtr AnimatedImageVisual::New( VisualFactoryCache& factoryCach
   return visual;
 }
 
-void AnimatedImageVisual::InitializeGif( const VisualUrl& imageUrl )
+void AnimatedImageVisual::InitializeAnimatedImage( const VisualUrl& imageUrl )
 {
   mImageUrl = imageUrl;
-  mGifLoading = GifLoading::New( imageUrl.GetUrl(), imageUrl.IsLocalResource() );
-  mFrameCount = mGifLoading->GetImageCount();
-  mGifLoading->LoadFrameDelays( mFrameDelayContainer );
+  mAnimatedImageLoading = AnimatedImageLoading::New( imageUrl.GetUrl(), imageUrl.IsLocalResource() );
+  mFrameCount = mAnimatedImageLoading.GetImageCount();
 }
 
 AnimatedImageVisual::AnimatedImageVisual( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory )
@@ -174,7 +173,7 @@ AnimatedImageVisual::AnimatedImageVisual( VisualFactoryCache& factoryCache, Imag
   mImageVisualShaderFactory( shaderFactory ),
   mPixelArea( FULL_TEXTURE_RECT ),
   mImageUrl(),
-  mGifLoading( nullptr ),
+  mAnimatedImageLoading(),
   mCurrentFrameIndex( 0 ),
   mImageUrls( NULL ),
   mImageCache( NULL ),
@@ -206,7 +205,7 @@ void AnimatedImageVisual::GetNaturalSize( Vector2& naturalSize )
   {
     if( mImageUrl.IsValid() )
     {
-      mImageSize = mGifLoading->GetImageSize();
+      mImageSize = mAnimatedImageLoading.GetImageSize();
     }
     else if( mImageUrls && mImageUrls->size() > 0 )
     {
@@ -270,7 +269,7 @@ void AnimatedImageVisual::OnDoAction( const Dali::Property::Index actionId, cons
     }
     case DevelAnimatedImageVisual::Action::PLAY:
     {
-      if( IsOnStage() && mActionStatus != DevelAnimatedImageVisual::Action::PLAY )
+      if( mFrameDelayTimer && IsOnStage() && mActionStatus != DevelAnimatedImageVisual::Action::PLAY )
       {
         mFrameDelayTimer.Start();
       }
@@ -542,9 +541,9 @@ void AnimatedImageVisual::LoadFirstBatch()
   mUrlIndex = 0;
   TextureManager& textureManager = mFactoryCache.GetTextureManager();
 
-  if( mGifLoading != nullptr )
+  if( mAnimatedImageLoading )
   {
-    mImageCache = new RollingGifImageCache( textureManager, *mGifLoading, mFrameCount, *this, cacheSize, batchSize );
+    mImageCache = new RollingAnimatedImageCache( textureManager, mAnimatedImageLoading, mFrameCount, *this, cacheSize, batchSize );
   }
   else if( mImageUrls )
   {
@@ -592,11 +591,10 @@ void AnimatedImageVisual::StartFirstFrame( TextureSet& textureSet )
   if( mFrameCount > 1 )
   {
     int frameDelay = mFrameDelay; // from URL array
-    if( mFrameDelayContainer.Count() > 0 ) // from GIF
+    if( mAnimatedImageLoading && mImageCache )
     {
-      frameDelay = mFrameDelayContainer[0];
+      frameDelay = mImageCache->GetFrameInterval( 0 );
     }
-
     mFrameDelayTimer = Timer::New( frameDelay );
     mFrameDelayTimer.TickSignal().Connect( this, &AnimatedImageVisual::DisplayNextFrame );
     mFrameDelayTimer.Start();
@@ -706,11 +704,10 @@ bool AnimatedImageVisual::DisplayNextFrame()
         return DisplayNextFrame();
       }
     }
-
-    if( mFrameDelayContainer.Count() > 0 )
+    // TODO : newly added one.
+    if( mAnimatedImageLoading && mImageCache )
     {
-      unsigned int delay = mFrameDelayContainer[mCurrentFrameIndex];
-
+      unsigned int delay = mImageCache->GetFrameInterval( mCurrentFrameIndex );
       if( mFrameDelayTimer.GetInterval() != delay )
       {
         mFrameDelayTimer.SetInterval( delay );
index 0d21f97..7c0764e 100755 (executable)
@@ -24,7 +24,7 @@
 #include <dali/public-api/math/vector4.h>
 #include <dali/public-api/object/weak-handle.h>
 #include <dali/public-api/adaptor-framework/timer.h>
-#include <dali/devel-api/adaptor-framework/gif-loading.h>
+#include <dali/devel-api/adaptor-framework/animated-image-loading.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
@@ -92,7 +92,7 @@ public:
    *
    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
    * @param[in] shaderFactory The ImageVisualShaderFactory object
-   * @param[in] imageUrl The URL to gif resource to use
+   * @param[in] imageUrl The URL to animated image resource to use
    * @param[in] properties A Property::Map containing settings for this visual
    * @return A smart-pointer to the newly allocated visual.
    */
@@ -224,10 +224,10 @@ private:
   bool DisplayNextFrame();
 
   /**
-   * Initialize the gif variables.
-   * @param[in] imageUrl The url of the animated gif
+   * Initialize the animated image variables.
+   * @param[in] imageUrl The url of the animated image
    */
-  void InitializeGif( const VisualUrl& imageUrl );
+  void InitializeAnimatedImage( const VisualUrl& imageUrl );
 
   // Undefined
   AnimatedImageVisual( const AnimatedImageVisual& animatedImageVisual );
@@ -241,11 +241,10 @@ private:
   WeakHandle<Actor> mPlacementActor;
   ImageVisualShaderFactory& mImageVisualShaderFactory;
 
-  // Variables for GIF player
-  Dali::Vector<uint32_t> mFrameDelayContainer;
+  // Variables for Animated Image player
   Vector4 mPixelArea;
   VisualUrl mImageUrl;
-  std::unique_ptr<Dali::GifLoading> mGifLoading; // Only needed for animated gifs
+  Dali::AnimatedImageLoading mAnimatedImageLoading; // Only needed for animated image
   uint32_t mCurrentFrameIndex; // Frame index into textureRects
 
   // Variables for Multi-Image player
index d71ee94..726cd39 100644 (file)
@@ -58,8 +58,14 @@ TextureSet FixedImageCache::Frame( uint32_t frameIndex )
 {
   while( frameIndex > mFront )
   {
-    NextFrame();
+    ++mFront;
+    if( mFront >= mImageUrls.size() )
+    {
+      mFront = 0;
+    }
+    LoadBatch();
   }
+
   mFront = frameIndex;
 
   TextureSet textureSet;
@@ -87,23 +93,9 @@ TextureSet FixedImageCache::FirstFrame()
   return textureSet;
 }
 
-TextureSet FixedImageCache::NextFrame()
+uint32_t FixedImageCache::GetFrameInterval( uint32_t frameIndex )
 {
-  TextureSet textureSet;
-  ++mFront;
-  mFront %= mImageUrls.size();
-
-  if( IsFrontReady() == true )
-  {
-    textureSet = GetFrontTextureSet();
-  }
-  else
-  {
-    mWaitingForReadyFrame = true;
-  }
-  LoadBatch();
-
-  return textureSet;
+  return 0u;
 }
 
 bool FixedImageCache::IsFrontReady() const
index d884e28..5063232 100644 (file)
@@ -61,11 +61,9 @@ public:
   TextureSet FirstFrame() override;
 
   /**
-   * Get the next frame. If it's not ready, this will trigger the
-   * sending of FrameReady() when the image becomes ready.
-   * This will trigger the loading of the next batch.
+   * Get the interval of Nth frame.
    */
-  TextureSet NextFrame() override;
+  uint32_t GetFrameInterval( uint32_t frameIndex ) override;
 
 private:
   /**
index 7354992..1d385c8 100644 (file)
@@ -79,17 +79,15 @@ public:
   virtual TextureSet FirstFrame() = 0;
 
   /**
-   * Get the next frame. If it's not ready, this will trigger the
+   * Get the Nth frame. If it's not ready, this will trigger the
    * sending of FrameReady() when the image becomes ready.
-   * This will trigger the loading of the next batch.
    */
-  virtual TextureSet NextFrame() = 0;
+  virtual TextureSet Frame( uint32_t frameIndex ) = 0;
 
   /**
-   * Get the Nth frame. If it's not ready, this will trigger the
-   * sending of FrameReady() when the image becomes ready.
+   * Get the interval of Nth frame.
    */
-  virtual TextureSet Frame( uint32_t frameIndex ) = 0;
+  virtual uint32_t GetFrameInterval( uint32_t frameIndex ) = 0;
 
 private:
 
@@ -15,7 +15,7 @@
  */
 
 // CLASS HEADER
-#include "rolling-gif-image-cache.h"
+#include "rolling-animated-image-cache.h"
 
 // EXTERNAL HEADERS
 
@@ -58,11 +58,11 @@ namespace Toolkit
 namespace Internal
 {
 
-RollingGifImageCache::RollingGifImageCache(
-  TextureManager& textureManager, GifLoading& gifLoading, uint32_t frameCount, ImageCache::FrameReadyObserver& observer,
+RollingAnimatedImageCache::RollingAnimatedImageCache(
+  TextureManager& textureManager, AnimatedImageLoading& animatedImageLoading, uint32_t frameCount, ImageCache::FrameReadyObserver& observer,
   uint16_t cacheSize, uint16_t batchSize )
 : ImageCache( textureManager, observer, batchSize ),
-  mGifLoading( gifLoading ),
+  mAnimatedImageLoading( animatedImageLoading ),
   mFrameCount( frameCount ),
   mFrameIndex( 0 ),
   mCacheSize( cacheSize ),
@@ -72,11 +72,11 @@ RollingGifImageCache::RollingGifImageCache(
   LoadBatch();
 }
 
-RollingGifImageCache::~RollingGifImageCache()
+RollingAnimatedImageCache::~RollingAnimatedImageCache()
 {
   if( mTextureManagerAlive )
   {
-    while( !mQueue.IsEmpty() )
+    while( IsFrontReady() )
     {
       ImageFrame imageFrame = mQueue.PopFront();
       Dali::Toolkit::TextureManager::RemoveTexture( mImageUrls[ imageFrame.mFrameNumber ].mUrl );
@@ -84,64 +84,51 @@ RollingGifImageCache::~RollingGifImageCache()
   }
 }
 
-TextureSet RollingGifImageCache::Frame( uint32_t frameIndex )
+TextureSet RollingAnimatedImageCache::Frame( uint32_t frameIndex )
 {
-  // If a frame of frameIndex is not loaded, clear the queue and remove all loaded textures.
-  if( mImageUrls[ frameIndex ].mTextureId == TextureManager::INVALID_TEXTURE_ID )
+  bool popExist = false;
+  while( IsFrontReady() && mQueue.Front().mFrameNumber != frameIndex )
   {
-    mFrameIndex = frameIndex;
-    while( !mQueue.IsEmpty() )
-    {
-      ImageFrame imageFrame = mQueue.PopFront();
-      Dali::Toolkit::TextureManager::RemoveTexture( mImageUrls[ imageFrame.mFrameNumber ].mUrl );
-      mImageUrls[ imageFrame.mFrameNumber ].mTextureId = TextureManager::INVALID_TEXTURE_ID;
-    }
-    LoadBatch();
+    ImageFrame imageFrame = mQueue.PopFront();
+    Dali::Toolkit::TextureManager::RemoveTexture( mImageUrls[ imageFrame.mFrameNumber ].mUrl );
+    mImageUrls[ imageFrame.mFrameNumber ].mTextureId = TextureManager::INVALID_TEXTURE_ID;
+    popExist = true;
   }
-  // If the frame is already loaded, remove previous frames of the frame in the queue
-  // and load new frames amount of removed frames.
-  else
+  if( popExist || mImageUrls[ frameIndex ].mTextureId == TextureManager::INVALID_TEXTURE_ID )
   {
-    bool popExist = false;
-    while( !mQueue.IsEmpty() && mQueue.Front().mFrameNumber != frameIndex )
+    // If the frame of frameIndex was already loaded, load batch from the last frame of queue
+    if( IsFrontReady() )
     {
-      ImageFrame imageFrame = mQueue.PopFront();
-      Dali::Toolkit::TextureManager::RemoveTexture( mImageUrls[ imageFrame.mFrameNumber ].mUrl );
-      mImageUrls[ imageFrame.mFrameNumber ].mTextureId = TextureManager::INVALID_TEXTURE_ID;
-      popExist = true;
+      mFrameIndex = ( mQueue.Back().mFrameNumber + 1 ) % mFrameCount;
     }
-    if( popExist )
+    // If the queue is empty, load batch from the frame of frameIndex
+    else
     {
-      mFrameIndex = ( mQueue.Back().mFrameNumber + 1 ) % mFrameCount;
-      LoadBatch();
+      mFrameIndex = frameIndex;
     }
+    LoadBatch();
   }
 
   return GetFrontTextureSet();
 }
 
-TextureSet RollingGifImageCache::FirstFrame()
+TextureSet RollingAnimatedImageCache::FirstFrame()
 {
   return Frame( 0u );
 }
 
-TextureSet RollingGifImageCache::NextFrame()
+uint32_t RollingAnimatedImageCache::GetFrameInterval( uint32_t frameIndex )
 {
-  ImageFrame imageFrame = mQueue.PopFront();
-  Dali::Toolkit::TextureManager::RemoveTexture( mImageUrls[ imageFrame.mFrameNumber ].mUrl );
-  mImageUrls[ imageFrame.mFrameNumber ].mTextureId = TextureManager::INVALID_TEXTURE_ID;
-
-  LoadBatch();
-
-  return GetFrontTextureSet();
+  Frame( frameIndex );
+  return mAnimatedImageLoading.GetFrameInterval( frameIndex );
 }
 
-bool RollingGifImageCache::IsFrontReady() const
+bool RollingAnimatedImageCache::IsFrontReady() const
 {
   return ( !mQueue.IsEmpty() );
 }
 
-void RollingGifImageCache::LoadBatch()
+void RollingAnimatedImageCache::LoadBatch()
 {
   // Try and load up to mBatchSize images, until the cache is filled.
   // Once the cache is filled, as frames progress, the old frame is
@@ -151,9 +138,8 @@ void RollingGifImageCache::LoadBatch()
 
   // Get the smallest number of frames we need to load
   int batchSize = std::min( std::size_t(mBatchSize), mCacheSize - mQueue.Count() );
-  DALI_LOG_INFO( gAnimImgLogFilter, Debug::Concise, "RollingGifImageCache::LoadBatch() mFrameIndex:%d  batchSize:%d\n", mFrameIndex, batchSize );
-
-  if( mGifLoading.LoadNextNFrames( mFrameIndex, batchSize, pixelDataList) )
+  DALI_LOG_INFO( gAnimImgLogFilter, Debug::Concise, "RollingAnimatedImageCache::LoadBatch() mFrameIndex:%d  batchSize:%d\n", mFrameIndex, batchSize );
+  if( mAnimatedImageLoading.LoadNextNFrames( mFrameIndex, batchSize, pixelDataList) )
   {
     unsigned int pixelDataListCount = pixelDataList.size();
 
@@ -203,15 +189,15 @@ void RollingGifImageCache::LoadBatch()
   LOG_CACHE;
 }
 
-TextureSet RollingGifImageCache::GetFrontTextureSet() const
+TextureSet RollingAnimatedImageCache::GetFrontTextureSet() const
 {
-  DALI_LOG_INFO( gAnimImgLogFilter, Debug::Concise, "RollingGifImageCache::GetFrontTextureSet() FrameNumber:%d\n", mQueue[ 0 ].mFrameNumber );
+  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 RollingGifImageCache::GetCachedTextureId( int index ) const
+TextureManager::TextureId RollingAnimatedImageCache::GetCachedTextureId( int index ) const
 {
   return mImageUrls[ mQueue[ index ].mFrameNumber ].mTextureId;
 }
@@ -1,5 +1,5 @@
-#ifndef DALI_TOOLKIT_INTERNAL_ROLLING_GIF_IMAGE_CACHE_H
-#define DALI_TOOLKIT_INTERNAL_ROLLING_GIF_IMAGE_CACHE_H
+#ifndef DALI_TOOLKIT_INTERNAL_ROLLING_ANIMATED_IMAGE_CACHE_H
+#define DALI_TOOLKIT_INTERNAL_ROLLING_ANIMATED_IMAGE_CACHE_H
 
 /*
  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
@@ -18,7 +18,7 @@
  */
 
 // EXTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/gif-loading.h>
+#include <dali/devel-api/adaptor-framework/animated-image-loading.h>
 #include <dali/devel-api/common/circular-queue.h>
 #include <dali-toolkit/internal/visuals/animated-image/image-cache.h>
 #include <dali-toolkit/internal/visuals/texture-manager-impl.h>
@@ -31,20 +31,20 @@ namespace Internal
 {
 
 /**
- * Class to manage a rolling cache of GIF images, where the cache size
+ * Class to manage a rolling cache of Animated images, where the cache size
  * is smaller than the total number of images.
  *
  * Frames are always ready, so the observer.FrameReady callback is never triggered;
  * the FirstFrame and NextFrame APIs will always return a texture.
  */
-class RollingGifImageCache : public ImageCache
+class RollingAnimatedImageCache : public ImageCache
 {
 public:
   /**
    * Constructor.
    * @param[in] textureManager The texture manager
-   * @param[in] gifLoader The loaded gif image
-   * @param[in] frameCount The number of frames in the gif
+   * @param[in] animatedImageLoader The loaded animated image
+   * @param[in] frameCount The number of frames in the animated image
    * @param[in] observer FrameReady observer
    * @param[in] cacheSize The size of the cache
    * @param[in] batchSize The size of a batch to load
@@ -52,8 +52,8 @@ public:
    * This will start loading textures immediately, according to the
    * batch and cache sizes.
    */
-  RollingGifImageCache( TextureManager&                 textureManager,
-                        GifLoading&                     gifLoader,
+  RollingAnimatedImageCache( TextureManager&                 textureManager,
+                        AnimatedImageLoading&           animatedImageLoader,
                         uint32_t                        frameCount,
                         ImageCache::FrameReadyObserver& observer,
                         uint16_t                        cacheSize,
@@ -62,7 +62,7 @@ public:
   /**
    * Destructor
    */
-  virtual ~RollingGifImageCache();
+  virtual ~RollingAnimatedImageCache();
 
   /**
    * Get the Nth frame. If it's not ready, this will trigger the
@@ -77,11 +77,9 @@ public:
   TextureSet FirstFrame() override;
 
   /**
-   * Get the next frame. If it's not ready, this will trigger the
-   * sending of FrameReady() when the image becomes ready.
-   * This will trigger the loading of the next batch.
+   * Get the interval of Nth frame.
    */
-  TextureSet NextFrame() override;
+  uint32_t GetFrameInterval( uint32_t frameIndex ) override;
 
 private:
   /**
@@ -114,16 +112,18 @@ private:
     unsigned int mFrameNumber = 0u;
   };
 
-  GifLoading&               mGifLoading;
-  uint32_t                  mFrameCount;
-  int                       mFrameIndex;
-  std::vector<UrlStore>     mImageUrls;
-  uint16_t                  mCacheSize;
-  CircularQueue<ImageFrame> mQueue;
+  Dali::AnimatedImageLoading& mAnimatedImageLoading;
+  uint32_t                   mFrameCount;
+  int                        mFrameIndex;
+  std::vector<UrlStore>      mImageUrls;
+  uint16_t                   mCacheSize;
+  CircularQueue<ImageFrame>  mQueue;
 };
 
 } // namespace Internal
+
 } // namespace Toolkit
+
 } // namespace Dali
 
-#endif
+#endif //DALI_TOOLKIT_INTERNAL_ROLLING_ANIMATED_IMAGE_CACHE_H
index 21f81b7..2284778 100644 (file)
@@ -131,26 +131,9 @@ TextureSet RollingImageCache::FirstFrame()
   return Frame( 0u );
 }
 
-TextureSet RollingImageCache::NextFrame()
+uint32_t RollingImageCache::GetFrameInterval( uint32_t frameIndex )
 {
-  TextureSet textureSet;
-
-  ImageFrame imageFrame = mQueue.PopFront();
-  mTextureManager.Remove( mImageUrls[ imageFrame.mUrlIndex ].mTextureId, this );
-  mImageUrls[ imageFrame.mUrlIndex ].mTextureId = TextureManager::INVALID_TEXTURE_ID;
-
-  LoadBatch();
-
-  if( IsFrontReady() == true )
-  {
-    textureSet = GetFrontTextureSet();
-  }
-  else
-  {
-    mWaitingForReadyFrame = true;
-  }
-
-  return textureSet;
+  return 0u;
 }
 
 bool RollingImageCache::IsFrontReady() const
index 47a5155..f57b5c2 100644 (file)
@@ -72,11 +72,9 @@ public:
   TextureSet FirstFrame() override;
 
   /**
-   * Get the next frame. If it's not ready, this will trigger the
-   * sending of FrameReady() when the image becomes ready.
-   * This will trigger the loading of the next batch.
+   * Get the interval of Nth frame.
    */
-  TextureSet NextFrame() override;
+  uint32_t GetFrameInterval( uint32_t frameIndex ) override;
 
 private:
   /**
index 2531a84..9e5238d 100644 (file)
@@ -164,6 +164,7 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property
                 break;
               }
               case VisualUrl::GIF:
+              case VisualUrl::WEBP:
               {
                 visualPtr = AnimatedImageVisual::New( GetFactoryCache(), GetImageVisualShaderFactory(), visualUrl, propertyMap );
                 break;
@@ -334,6 +335,7 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const std::string& url, Image
         break;
       }
       case VisualUrl::GIF:
+      case VisualUrl::WEBP:
       {
         visualPtr = AnimatedImageVisual::New( GetFactoryCache(), GetImageVisualShaderFactory(), visualUrl );
         break;
index 731ed20..451ac06 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -99,9 +99,11 @@ VisualUrl::Type ResolveType( const std::string& url )
     enum { SUFFIX, HASH, HASH_DOT } state = SUFFIX;
     char SVG[ 4 ] = { 'g', 'v', 's', '.' };
     char GIF[ 4 ] = { 'f', 'i', 'g', '.' };
+    char WEBP[ 5 ] = { 'p', 'b', 'e', 'w', '.' };
     char JSON[ 5 ] = { 'n', 'o', 's', 'j', '.' };
     unsigned int svgScore = 0;
     unsigned int gifScore = 0;
+    unsigned int webpScore = 0;
     unsigned int jsonScore = 0;
     int index = count;
     while( --index >= 0 )
@@ -124,6 +126,14 @@ VisualUrl::Type ResolveType( const std::string& url )
           return VisualUrl::GIF;
         }
       }
+      if( ( offsetFromEnd < sizeof(WEBP) )&&( currentChar == WEBP[ offsetFromEnd ] ) )
+      {
+        // early out if WEBP as can't be used in N patch for now
+        if( ++webpScore == sizeof(WEBP) )
+        {
+          return VisualUrl::WEBP;
+        }
+      }
       if( ( offsetFromEnd < sizeof(JSON) )&&( currentChar == JSON[ offsetFromEnd ] ) )
       {
         // early out if JSON as can't be used in N patch for now
index f3af2e0..63ad5e4 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_INTERNAL_VISUAL_URL_H
 
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -41,6 +41,7 @@ public:
     N_PATCH,
     SVG,
     GIF,
+    WEBP,
     JSON
   };