2 * Copyright (c) 2018 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 )
43 void SetRenderer( Dali::Renderer renderer )
47 if( mWidth != 0 && mHeight != 0 )
49 Dali::TextureSet textureSet = mRenderer.GetTextures();
50 Dali::Texture texture = Dali::Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, mWidth, mHeight );
51 textureSet.SetTexture( 0, texture );
55 void SetSize( uint32_t width, uint32_t height )
62 Dali::TextureSet textureSet = mRenderer.GetTextures();
63 Dali::Texture texture = Dali::Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, mWidth, mHeight );
64 textureSet.SetTexture( 0, texture );
72 void Render( uint32_t frameNumber )
76 uint32_t GetTotalFrameNumber() const
81 float GetFrameRate() const
86 void GetDefaultSize( uint32_t& width, uint32_t& height ) const
95 Dali::Renderer mRenderer;
100 inline VectorAnimationRenderer& GetImplementation( Dali::VectorAnimationRenderer& renderer )
102 DALI_ASSERT_ALWAYS( renderer && "VectorAnimationRenderer handle is empty." );
103 BaseObject& handle = renderer.GetBaseObject();
104 return static_cast< Internal::Adaptor::VectorAnimationRenderer& >( handle );
107 inline const VectorAnimationRenderer& GetImplementation( const Dali::VectorAnimationRenderer& renderer )
109 DALI_ASSERT_ALWAYS( renderer && "VectorAnimationRenderer handle is empty." );
110 const BaseObject& handle = renderer.GetBaseObject();
111 return static_cast< const Internal::Adaptor::VectorAnimationRenderer& >( handle );
114 } // namespace Adaptor
116 } // namespace Internal
119 /********************************************************************************/
120 /********************************* PUBLIC CLASS *******************************/
121 /********************************************************************************/
123 VectorAnimationRenderer VectorAnimationRenderer::New( const std::string& url )
125 Internal::Adaptor::VectorAnimationRenderer* animationRenderer = new Internal::Adaptor::VectorAnimationRenderer( url );
127 return VectorAnimationRenderer( animationRenderer );
130 VectorAnimationRenderer::VectorAnimationRenderer()
134 VectorAnimationRenderer::~VectorAnimationRenderer()
138 VectorAnimationRenderer::VectorAnimationRenderer( Internal::Adaptor::VectorAnimationRenderer* internal )
139 : BaseHandle( internal )
143 VectorAnimationRenderer::VectorAnimationRenderer( const VectorAnimationRenderer& handle )
144 : BaseHandle( handle )
148 VectorAnimationRenderer& VectorAnimationRenderer::operator=( const VectorAnimationRenderer& rhs )
150 BaseHandle::operator=( rhs );
154 void VectorAnimationRenderer::SetRenderer( Renderer renderer )
156 Internal::Adaptor::GetImplementation( *this ).SetRenderer( renderer );
159 void VectorAnimationRenderer::SetSize( uint32_t width, uint32_t height )
161 Internal::Adaptor::GetImplementation( *this ).SetSize( width, height );
164 void VectorAnimationRenderer::StopRender()
166 Internal::Adaptor::GetImplementation( *this ).StopRender();
169 void VectorAnimationRenderer::Render( uint32_t frameNumber )
171 Internal::Adaptor::GetImplementation( *this ).Render( frameNumber );
174 uint32_t VectorAnimationRenderer::GetTotalFrameNumber() const
176 return Internal::Adaptor::GetImplementation( *this ).GetTotalFrameNumber();
179 float VectorAnimationRenderer::GetFrameRate() const
181 return Internal::Adaptor::GetImplementation( *this ).GetFrameRate();
184 void VectorAnimationRenderer::GetDefaultSize( uint32_t& width, uint32_t& height ) const
186 Internal::Adaptor::GetImplementation( *this ).GetDefaultSize( width, height );