void SetRenderer( Dali::Renderer renderer )
{
mRenderer = renderer;
+
+ if( mWidth != 0 && mHeight != 0 )
+ {
+ Dali::TextureSet textureSet = mRenderer.GetTextures();
+ Dali::Texture texture = Dali::Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, mWidth, mHeight );
+ textureSet.SetTexture( 0, texture );
+ }
}
void SetSize( uint32_t width, uint32_t height )
{
mWidth = width;
mHeight = height;
- }
- bool StartRender()
- {
- return true;
+ if( mRenderer )
+ {
+ Dali::TextureSet textureSet = mRenderer.GetTextures();
+ Dali::Texture texture = Dali::Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, mWidth, mHeight );
+ textureSet.SetTexture( 0, texture );
+ }
}
void StopRender()
return 60.0f;
}
+ void GetDefaultSize( uint32_t& width, uint32_t& height ) const
+ {
+ width = 100;
+ height = 100;
+ }
+
public:
std::string mUrl;
Dali::Renderer mRenderer;
uint32_t mWidth;
uint32_t mHeight;
-
};
inline VectorAnimationRenderer& GetImplementation( Dali::VectorAnimationRenderer& renderer )
Internal::Adaptor::GetImplementation( *this ).SetSize( width, height );
}
-bool VectorAnimationRenderer::StartRender()
-{
- return Internal::Adaptor::GetImplementation( *this ).StartRender();
-}
-
void VectorAnimationRenderer::StopRender()
{
Internal::Adaptor::GetImplementation( *this ).StopRender();
return Internal::Adaptor::GetImplementation( *this ).GetFrameRate();
}
+void VectorAnimationRenderer::GetDefaultSize( uint32_t& width, uint32_t& height ) const
+{
+ Internal::Adaptor::GetImplementation( *this ).GetDefaultSize( width, height );
+}
+
} // namespace Dali;
Vector2 controlSize( 20.f, 30.f );
Vector2 naturalSize;
- actor.SetSize( controlSize );
Stage::GetCurrent().Add( actor );
application.SendNotification();
visual.GetNaturalSize( naturalSize );
+ DALI_TEST_EQUALS( naturalSize, Vector2( 100.0f, 100.0f ), TEST_LOCATION ); // 100x100 is the content default size.
+
+ actor.SetSize( controlSize );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ visual.GetNaturalSize( naturalSize );
+
DALI_TEST_EQUALS( naturalSize, controlSize, TEST_LOCATION );
END_TEST;
void AnimatedVectorImageVisual::GetNaturalSize( Vector2& naturalSize )
{
- naturalSize = mVisualSize;
+ if( mImpl->mRenderer ) // Check if we have a rendered image
+ {
+ auto textureSet = mImpl->mRenderer.GetTextures();
+ if( textureSet )
+ {
+ if( textureSet.GetTextureCount() > 0 )
+ {
+ auto texture = textureSet.GetTexture( 0 );
+ naturalSize.x = texture.GetWidth();
+ naturalSize.y = texture.GetHeight();
+ return;
+ }
+ }
+ }
+
+ uint32_t width, height;
+ mVectorRasterizeThread.GetDefaultSize( width, height );
+ naturalSize.x = width;
+ naturalSize.y = height;
}
void AnimatedVectorImageVisual::DoCreatePropertyMap( Property::Map& map ) const
mCurrentFrameUpdated( false ),
mLogFactory( Dali::Adaptor::Get().GetLogFactory() )
{
- mVectorRenderer = VectorAnimationRenderer::New( mUrl );
+ Initialize();
}
VectorRasterizeThread::~VectorRasterizeThread()
{
mLogFactory.InstallLogFunction();
- //TODO: check the return value
- StartRender();
-
while( !mDestroyThread )
{
Rasterize();
mPlayRange = orderedRange;
- if( mTotalFrame != 0 )
- {
- mStartFrame = static_cast< uint32_t >( mPlayRange.x * mTotalFrame + 0.5f );
- mEndFrame = static_cast< uint32_t >( mPlayRange.y * mTotalFrame + 0.5f );
+ mStartFrame = static_cast< uint32_t >( mPlayRange.x * mTotalFrame + 0.5f );
+ mEndFrame = static_cast< uint32_t >( mPlayRange.y * mTotalFrame + 0.5f );
- // If the current frame is out of the range, change the current frame also.
- if( mStartFrame > mCurrentFrame )
- {
- mCurrentFrame = mStartFrame;
+ // If the current frame is out of the range, change the current frame also.
+ if( mStartFrame > mCurrentFrame )
+ {
+ mCurrentFrame = mStartFrame;
- mCurrentFrameUpdated = true;
- mResourceReady = false;
- }
- else if( mEndFrame < mCurrentFrame )
- {
- mCurrentFrame = mEndFrame;
+ mCurrentFrameUpdated = true;
+ mResourceReady = false;
+ }
+ else if( mEndFrame < mCurrentFrame )
+ {
+ mCurrentFrame = mEndFrame;
- mCurrentFrameUpdated = true;
- mResourceReady = false;
- }
+ mCurrentFrameUpdated = true;
+ mResourceReady = false;
}
}
}
{
mProgress = progress;
- if( mTotalFrame != 0 )
- {
- mCurrentFrame = static_cast< uint32_t >( mTotalFrame * progress + 0.5f );
- mCurrentFrameUpdated = true;
- }
+ mCurrentFrame = static_cast< uint32_t >( mTotalFrame * progress + 0.5f );
+ mCurrentFrameUpdated = true;
mResourceReady = false;
return ( static_cast< float >( mCurrentFrame ) / static_cast< float >( mTotalFrame ) );
}
+void VectorRasterizeThread::GetDefaultSize( uint32_t& width, uint32_t& height ) const
+{
+ mVectorRenderer.GetDefaultSize( width, height );
+}
+
DevelImageVisual::PlayState VectorRasterizeThread::GetPlayState() const
{
return mPlayState;
return mResourceReady;
}
-bool VectorRasterizeThread::StartRender()
+void VectorRasterizeThread::Initialize()
{
- //TODO: check the return value
- mVectorRenderer.StartRender();
+ mVectorRenderer = VectorAnimationRenderer::New( mUrl );
mTotalFrame = mVectorRenderer.GetTotalFrameNumber();
mFrameRate = mVectorRenderer.GetFrameRate();
mFrameDurationNanoSeconds = NANOSECONDS_PER_SECOND / mFrameRate;
- DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::StartRender: Renderer is started [%d, %f fps]\n", mTotalFrame, mFrameRate );
-
- return true;
+ DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::Initialize: file = %s [%d frames, %f fps]\n", mUrl.c_str(), mTotalFrame, mFrameRate );
}
void VectorRasterizeThread::Rasterize()