/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
DALI_ENUM_TO_STRING_TABLE_END( WRAP_MODE )
const Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
+constexpr auto LOOP_FOREVER = -1;
#if defined(DEBUG_ENABLED)
Debug::Filter* gAnimImgLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ANIMATED_IMAGE");
mCacheSize( 1 ),
mBatchSize( 1 ),
mFrameDelay( 100 ),
+ mLoopCount( LOOP_FOREVER ),
+ mCurrentLoopIndex( 0 ),
mUrlIndex( 0 ),
mFrameCount( 0 ),
mImageSize(),
map.Insert( Toolkit::ImageVisual::Property::BATCH_SIZE, static_cast<int>(mBatchSize) );
map.Insert( Toolkit::ImageVisual::Property::CACHE_SIZE, static_cast<int>(mCacheSize) );
map.Insert( Toolkit::ImageVisual::Property::FRAME_DELAY, static_cast<int>(mFrameDelay) );
+ map.Insert( Toolkit::DevelImageVisual::Property::LOOP_COUNT, static_cast<int>(mLoopCount) );
}
void AnimatedImageVisual::DoCreateInstancePropertyMap( Property::Map& map ) const
{
DoSetProperty( Toolkit::ImageVisual::Property::FRAME_DELAY, keyValue.second );
}
+ else if( keyValue.first == LOOP_COUNT_NAME )
+ {
+ DoSetProperty( Toolkit::DevelImageVisual::Property::LOOP_COUNT, keyValue.second );
+ }
}
}
}
}
break;
}
+
+ case Toolkit::DevelImageVisual::Property::LOOP_COUNT:
+ {
+ int loopCount;
+ if( value.Get( loopCount ) )
+ {
+ mLoopCount = loopCount;
+ }
+ break;
+ }
}
}
{
// Wrap the frame index
++mCurrentFrameIndex;
- mCurrentFrameIndex %= mFrameCount;
+
+ if( mLoopCount < 0 || mCurrentLoopIndex <= mLoopCount)
+ {
+ mCurrentFrameIndex %= mFrameCount;
+ if( mCurrentFrameIndex == 0 )
+ {
+ ++mCurrentLoopIndex;
+ }
+ }
+ else
+ {
+ // This will stop timer
+ return false;
+ }
}
DALI_LOG_INFO( gAnimImgLogFilter,Debug::Concise,"AnimatedImageVisual::DisplayNextFrame(this:%p) FrameCount:%d\n", this, mCurrentFrameIndex);