+ if (!mImageCache)
+ {
+ DALI_LOG_ERROR("mImageCache is null\n");
+ }
+}
+
+void AnimatedImageVisual::StartFirstFrame( TextureSet& textureSet )
+{
+ DALI_LOG_INFO(gAnimImgLogFilter,Debug::Concise,"AnimatedImageVisual::StartFirstFrame()\n");
+
+ mStartFirstFrame = false;
+ if(mImpl->mRenderer)
+ {
+ mImpl->mRenderer.SetTextures( textureSet );
+ }
+ Actor actor = mPlacementActor.GetHandle();
+ if( actor )
+ {
+ actor.AddRenderer( mImpl->mRenderer );
+ mPlacementActor.Reset();
+ }
+
+ if( mFrameCount > 1 )
+ {
+ int frameDelay = mImageCache->GetFrameInterval( 0 );
+ if( frameDelay == 0u )
+ {
+ frameDelay = mFrameDelay; // from URL array
+ }
+ mFrameDelayTimer = Timer::New( frameDelay );
+ mFrameDelayTimer.TickSignal().Connect( this, &AnimatedImageVisual::DisplayNextFrame );
+ mFrameDelayTimer.Start();
+ }
+ DALI_LOG_INFO(gAnimImgLogFilter,Debug::Concise,"ResourceReady(ResourceStatus::READY)\n");
+ ResourceReady( Toolkit::Visual::ResourceStatus::READY );
+}
+
+TextureSet AnimatedImageVisual::PrepareTextureSet()
+{
+ TextureSet textureSet;
+ if (mImageCache)
+ {
+ textureSet = mImageCache->FirstFrame();
+ }
+
+ if( textureSet )
+ {
+ SetImageSize( textureSet );
+ }
+
+ return textureSet;
+}
+
+void AnimatedImageVisual::SetImageSize( TextureSet& textureSet )
+{
+ if( textureSet )
+ {
+ Texture texture = textureSet.GetTexture( 0 );
+ if( texture )
+ {
+ mImageSize.SetWidth( texture.GetWidth() );
+ mImageSize.SetHeight( texture.GetHeight() );
+ }
+ }
+}
+
+void AnimatedImageVisual::FrameReady( TextureSet textureSet )
+{
+ if(textureSet)
+ {
+ SetImageSize(textureSet);
+
+ if(mStartFirstFrame)
+ {
+ StartFirstFrame(textureSet);
+ }
+ else
+ {
+ if(mImpl->mRenderer)
+ {
+ mImpl->mRenderer.SetTextures(textureSet);
+ }
+ }
+ }
+ else
+ {
+ DALI_LOG_INFO( gAnimImgLogFilter, Debug::Concise, "ResourceReady(ResourceStatus::FAILED)\n" );
+ ResourceReady( Toolkit::Visual::ResourceStatus::FAILED );
+ }