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 );
73 bool Render( uint32_t frameNumber )
75 if( frameNumber == 1 && mPreviousFrame != frameNumber )
77 mPreviousFrame = frameNumber;
81 mPreviousFrame = frameNumber;
85 uint32_t GetTotalFrameNumber() const
90 float GetFrameRate() const
95 void GetDefaultSize( uint32_t& width, uint32_t& height ) const
104 Dali::Renderer mRenderer;
107 uint32_t mPreviousFrame;
110 inline VectorAnimationRenderer& GetImplementation( Dali::VectorAnimationRenderer& renderer )
112 DALI_ASSERT_ALWAYS( renderer && "VectorAnimationRenderer handle is empty." );
113 BaseObject& handle = renderer.GetBaseObject();
114 return static_cast< Internal::Adaptor::VectorAnimationRenderer& >( handle );
117 inline const VectorAnimationRenderer& GetImplementation( const Dali::VectorAnimationRenderer& renderer )
119 DALI_ASSERT_ALWAYS( renderer && "VectorAnimationRenderer handle is empty." );
120 const BaseObject& handle = renderer.GetBaseObject();
121 return static_cast< const Internal::Adaptor::VectorAnimationRenderer& >( handle );
124 } // namespace Adaptor
126 } // namespace Internal
129 /********************************************************************************/
130 /********************************* PUBLIC CLASS *******************************/
131 /********************************************************************************/
133 VectorAnimationRenderer VectorAnimationRenderer::New( const std::string& url )
135 Internal::Adaptor::VectorAnimationRenderer* animationRenderer = new Internal::Adaptor::VectorAnimationRenderer( url );
137 return VectorAnimationRenderer( animationRenderer );
140 VectorAnimationRenderer::VectorAnimationRenderer()
144 VectorAnimationRenderer::~VectorAnimationRenderer()
148 VectorAnimationRenderer::VectorAnimationRenderer( Internal::Adaptor::VectorAnimationRenderer* internal )
149 : BaseHandle( internal )
153 VectorAnimationRenderer::VectorAnimationRenderer( const VectorAnimationRenderer& handle )
154 : BaseHandle( handle )
158 VectorAnimationRenderer& VectorAnimationRenderer::operator=( const VectorAnimationRenderer& rhs )
160 BaseHandle::operator=( rhs );
164 void VectorAnimationRenderer::SetRenderer( Renderer renderer )
166 Internal::Adaptor::GetImplementation( *this ).SetRenderer( renderer );
169 void VectorAnimationRenderer::SetSize( uint32_t width, uint32_t height )
171 Internal::Adaptor::GetImplementation( *this ).SetSize( width, height );
174 void VectorAnimationRenderer::StopRender()
176 Internal::Adaptor::GetImplementation( *this ).StopRender();
179 bool VectorAnimationRenderer::Render( uint32_t frameNumber )
181 return Internal::Adaptor::GetImplementation( *this ).Render( frameNumber );
184 uint32_t VectorAnimationRenderer::GetTotalFrameNumber() const
186 return Internal::Adaptor::GetImplementation( *this ).GetTotalFrameNumber();
189 float VectorAnimationRenderer::GetFrameRate() const
191 return Internal::Adaptor::GetImplementation( *this ).GetFrameRate();
194 void VectorAnimationRenderer::GetDefaultSize( uint32_t& width, uint32_t& height ) const
196 Internal::Adaptor::GetImplementation( *this ).GetDefaultSize( width, height );