Merge "Add a TextEditor property to limit input to maximum characters" into devel...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / animated-image / animated-image-visual.cpp
index fdde260..456b89e 100755 (executable)
@@ -82,7 +82,7 @@ Debug::Filter* gAnimImgLogFilter = Debug::Filter::New(Debug::NoLogging, false, "
  *   |     new cache
  *   |       cache->LoadBatch()
  *   |
- *   | DoSetOnStage()
+ *   | DoSetOnScene()
  *   |   PrepareTextureSet()
  *   |     cache->FirstFrame()
  *   |   CreateRenderer()    (Doesn't become ready until first frame loads)
@@ -177,8 +177,8 @@ AnimatedImageVisual::AnimatedImageVisual( VisualFactoryCache& factoryCache, Imag
   mCurrentFrameIndex( 0 ),
   mImageUrls( NULL ),
   mImageCache( NULL ),
-  mCacheSize( 1 ),
-  mBatchSize( 1 ),
+  mCacheSize( 2 ),
+  mBatchSize( 2 ),
   mFrameDelay( 100 ),
   mLoopCount( LOOP_FOREVER ),
   mCurrentLoopIndex( 0 ),
@@ -221,6 +221,9 @@ void AnimatedImageVisual::DoCreatePropertyMap( Property::Map& map ) const
 {
   map.Clear();
 
+  bool sync = IsSynchronousLoadingRequired();
+  map.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, sync );
+
   map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::ANIMATED_IMAGE );
 
   if( mImageUrl.IsValid() )
@@ -269,7 +272,7 @@ void AnimatedImageVisual::OnDoAction( const Dali::Property::Index actionId, cons
     }
     case DevelAnimatedImageVisual::Action::PLAY:
     {
-      if( mFrameDelayTimer && IsOnStage() && mActionStatus != DevelAnimatedImageVisual::Action::PLAY )
+      if( mFrameDelayTimer && IsOnScene() && mActionStatus != DevelAnimatedImageVisual::Action::PLAY )
       {
         mFrameDelayTimer.Start();
       }
@@ -281,7 +284,7 @@ void AnimatedImageVisual::OnDoAction( const Dali::Property::Index actionId, cons
       // STOP reset functionality will actually be done in a future change
       // Stop will be executed on next timer tick
       mActionStatus = DevelAnimatedImageVisual::Action::STOP;
-      if( IsOnStage() )
+      if( IsOnScene() )
       {
         DisplayNextFrame();
       }
@@ -300,7 +303,7 @@ void AnimatedImageVisual::OnDoAction( const Dali::Property::Index actionId, cons
         {
           mIsJumpTo = true;
           mCurrentFrameIndex = frameNumber;
-          if( IsOnStage() )
+          if( IsOnScene() )
           {
             DisplayNextFrame();
           }
@@ -402,7 +405,14 @@ void AnimatedImageVisual::DoSetProperty( Property::Index index,
       int batchSize;
       if( value.Get( batchSize ) )
       {
-        mBatchSize = batchSize;
+        if( batchSize < 2 )
+        {
+          DALI_LOG_ERROR( "The minimum value of batch size is 2." );
+        }
+        else
+        {
+          mBatchSize = batchSize;
+        }
       }
       break;
     }
@@ -412,7 +422,14 @@ void AnimatedImageVisual::DoSetProperty( Property::Index index,
       int cacheSize;
       if( value.Get( cacheSize ) )
       {
-        mCacheSize = cacheSize;
+        if( cacheSize < 2 )
+        {
+          DALI_LOG_ERROR( "The minimum value of cache size is 2." );
+        }
+        else
+        {
+          mCacheSize = cacheSize;
+        }
       }
       break;
     }
@@ -446,10 +463,25 @@ void AnimatedImageVisual::DoSetProperty( Property::Index index,
       }
       break;
     }
+
+    case Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING:
+    {
+      bool sync = false;
+      value.Get( sync );
+      if( sync )
+      {
+        mImpl->mFlags |= Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
+      }
+      else
+      {
+        mImpl->mFlags &= ~Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
+      }
+      break;
+    }
   }
 }
 
-void AnimatedImageVisual::DoSetOnStage( Actor& actor )
+void AnimatedImageVisual::DoSetOnScene( Actor& actor )
 {
   mPlacementActor = actor;
   TextureSet textureSet = PrepareTextureSet();
@@ -465,7 +497,7 @@ void AnimatedImageVisual::DoSetOnStage( Actor& actor )
   }
 }
 
-void AnimatedImageVisual::DoSetOffStage( Actor& actor )
+void AnimatedImageVisual::DoSetOffScene( Actor& actor )
 {
   DALI_ASSERT_DEBUG( (bool)mImpl->mRenderer && "There should always be a renderer whilst on stage");
 
@@ -543,7 +575,7 @@ void AnimatedImageVisual::LoadFirstBatch()
 
   if( mAnimatedImageLoading )
   {
-    mImageCache = new RollingAnimatedImageCache( textureManager, mAnimatedImageLoading, mFrameCount, *this, cacheSize, batchSize );
+    mImageCache = new RollingAnimatedImageCache( textureManager, mAnimatedImageLoading, mFrameCount, *this, cacheSize, batchSize, IsSynchronousLoadingRequired() );
   }
   else if( mImageUrls )
   {
@@ -607,14 +639,16 @@ TextureSet AnimatedImageVisual::PrepareTextureSet()
 {
   TextureSet textureSet;
   if (mImageCache)
+  {
     textureSet = mImageCache->FirstFrame();
+  }
   if( textureSet )
   {
     SetImageSize( textureSet );
   }
   else
   {
-    DALI_LOG_INFO(gAnimImgLogFilter,Debug::Concise,"ResourceReady(ResourceStatus::FAILED)\n");
+    DALI_LOG_INFO( gAnimImgLogFilter, Debug::Concise, "ResourceReady(ResourceStatus::FAILED)\n" );
     ResourceReady( Toolkit::Visual::ResourceStatus::FAILED );
   }
 
@@ -644,7 +678,7 @@ void AnimatedImageVisual::FrameReady( TextureSet textureSet )
   }
   else
   {
-    if(mImpl->mRenderer)
+    if( mImpl->mRenderer )
     {
       mImpl->mRenderer.SetTextures( textureSet );
     }