2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <dali/devel-api/adaptor-framework/vector-animation-renderer.h>
19 #include <dali/public-api/object/base-object.h>
20 #include <toolkit-application.h>
31 class VectorAnimationRenderer: public Dali::BaseObject
35 VectorAnimationRenderer( const std::string& url )
44 void SetRenderer( Dali::Renderer renderer )
48 if( mWidth != 0 && mHeight != 0 )
50 Dali::TextureSet textureSet = mRenderer.GetTextures();
51 Dali::Texture texture = Dali::Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, mWidth, mHeight );
52 textureSet.SetTexture( 0, texture );
56 void SetSize( uint32_t width, uint32_t height )
63 Dali::TextureSet textureSet = mRenderer.GetTextures();
64 Dali::Texture texture = Dali::Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, mWidth, mHeight );
65 textureSet.SetTexture( 0, texture );
69 bool Render( uint32_t frameNumber )
71 if( frameNumber == 1 && mPreviousFrame != frameNumber )
73 mPreviousFrame = frameNumber;
77 mPreviousFrame = frameNumber;
81 uint32_t GetTotalFrameNumber() const
86 float GetFrameRate() const
91 void GetDefaultSize( uint32_t& width, uint32_t& height ) const
100 Dali::Renderer mRenderer;
103 uint32_t mPreviousFrame;
106 inline VectorAnimationRenderer& GetImplementation( Dali::VectorAnimationRenderer& renderer )
108 DALI_ASSERT_ALWAYS( renderer && "VectorAnimationRenderer handle is empty." );
109 BaseObject& handle = renderer.GetBaseObject();
110 return static_cast< Internal::Adaptor::VectorAnimationRenderer& >( handle );
113 inline const VectorAnimationRenderer& GetImplementation( const Dali::VectorAnimationRenderer& renderer )
115 DALI_ASSERT_ALWAYS( renderer && "VectorAnimationRenderer handle is empty." );
116 const BaseObject& handle = renderer.GetBaseObject();
117 return static_cast< const Internal::Adaptor::VectorAnimationRenderer& >( handle );
120 } // namespace Adaptor
122 } // namespace Internal
125 /********************************************************************************/
126 /********************************* PUBLIC CLASS *******************************/
127 /********************************************************************************/
129 VectorAnimationRenderer VectorAnimationRenderer::New( const std::string& url )
131 Internal::Adaptor::VectorAnimationRenderer* animationRenderer = new Internal::Adaptor::VectorAnimationRenderer( url );
133 return VectorAnimationRenderer( animationRenderer );
136 VectorAnimationRenderer::VectorAnimationRenderer()
140 VectorAnimationRenderer::~VectorAnimationRenderer()
144 VectorAnimationRenderer::VectorAnimationRenderer( Internal::Adaptor::VectorAnimationRenderer* internal )
145 : BaseHandle( internal )
149 VectorAnimationRenderer::VectorAnimationRenderer( const VectorAnimationRenderer& handle )
150 : BaseHandle( handle )
154 VectorAnimationRenderer& VectorAnimationRenderer::operator=( const VectorAnimationRenderer& rhs )
156 BaseHandle::operator=( rhs );
160 void VectorAnimationRenderer::SetRenderer( Renderer renderer )
162 Internal::Adaptor::GetImplementation( *this ).SetRenderer( renderer );
165 void VectorAnimationRenderer::SetSize( uint32_t width, uint32_t height )
167 Internal::Adaptor::GetImplementation( *this ).SetSize( width, height );
170 bool VectorAnimationRenderer::Render( uint32_t frameNumber )
172 return Internal::Adaptor::GetImplementation( *this ).Render( frameNumber );
175 uint32_t VectorAnimationRenderer::GetTotalFrameNumber() const
177 return Internal::Adaptor::GetImplementation( *this ).GetTotalFrameNumber();
180 float VectorAnimationRenderer::GetFrameRate() const
182 return Internal::Adaptor::GetImplementation( *this ).GetFrameRate();
185 void VectorAnimationRenderer::GetDefaultSize( uint32_t& width, uint32_t& height ) const
187 Internal::Adaptor::GetImplementation( *this ).GetDefaultSize( width, height );