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 );
53 mUploadCompletedSignal.Emit();
57 void SetSize( uint32_t width, uint32_t height )
64 Dali::TextureSet textureSet = mRenderer.GetTextures();
65 Dali::Texture texture = Dali::Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, mWidth, mHeight );
66 textureSet.SetTexture( 0, texture );
67 mUploadCompletedSignal.Emit();
71 bool Render( uint32_t frameNumber )
73 if( frameNumber == 1 && mPreviousFrame != frameNumber )
75 mPreviousFrame = frameNumber;
79 mPreviousFrame = frameNumber;
83 uint32_t GetTotalFrameNumber() const
88 float GetFrameRate() const
93 void GetDefaultSize( uint32_t& width, uint32_t& height ) const
99 Dali::VectorAnimationRenderer::UploadCompletedSignalType& UploadCompletedSignal()
101 return mUploadCompletedSignal;
107 Dali::Renderer mRenderer;
110 uint32_t mPreviousFrame;
111 Dali::VectorAnimationRenderer::UploadCompletedSignalType mUploadCompletedSignal;
114 inline VectorAnimationRenderer& GetImplementation( Dali::VectorAnimationRenderer& renderer )
116 DALI_ASSERT_ALWAYS( renderer && "VectorAnimationRenderer handle is empty." );
117 BaseObject& handle = renderer.GetBaseObject();
118 return static_cast< Internal::Adaptor::VectorAnimationRenderer& >( handle );
121 inline const VectorAnimationRenderer& GetImplementation( const Dali::VectorAnimationRenderer& renderer )
123 DALI_ASSERT_ALWAYS( renderer && "VectorAnimationRenderer handle is empty." );
124 const BaseObject& handle = renderer.GetBaseObject();
125 return static_cast< const Internal::Adaptor::VectorAnimationRenderer& >( handle );
128 } // namespace Adaptor
130 } // namespace Internal
133 /********************************************************************************/
134 /********************************* PUBLIC CLASS *******************************/
135 /********************************************************************************/
137 VectorAnimationRenderer VectorAnimationRenderer::New( const std::string& url )
139 Internal::Adaptor::VectorAnimationRenderer* animationRenderer = new Internal::Adaptor::VectorAnimationRenderer( url );
141 return VectorAnimationRenderer( animationRenderer );
144 VectorAnimationRenderer::VectorAnimationRenderer()
148 VectorAnimationRenderer::~VectorAnimationRenderer()
152 VectorAnimationRenderer::VectorAnimationRenderer( Internal::Adaptor::VectorAnimationRenderer* internal )
153 : BaseHandle( internal )
157 VectorAnimationRenderer::VectorAnimationRenderer( const VectorAnimationRenderer& handle )
158 : BaseHandle( handle )
162 VectorAnimationRenderer& VectorAnimationRenderer::operator=( const VectorAnimationRenderer& rhs )
164 BaseHandle::operator=( rhs );
168 void VectorAnimationRenderer::SetRenderer( Renderer renderer )
170 Internal::Adaptor::GetImplementation( *this ).SetRenderer( renderer );
173 void VectorAnimationRenderer::SetSize( uint32_t width, uint32_t height )
175 Internal::Adaptor::GetImplementation( *this ).SetSize( width, height );
178 bool VectorAnimationRenderer::Render( uint32_t frameNumber )
180 return Internal::Adaptor::GetImplementation( *this ).Render( frameNumber );
183 uint32_t VectorAnimationRenderer::GetTotalFrameNumber() const
185 return Internal::Adaptor::GetImplementation( *this ).GetTotalFrameNumber();
188 float VectorAnimationRenderer::GetFrameRate() const
190 return Internal::Adaptor::GetImplementation( *this ).GetFrameRate();
193 void VectorAnimationRenderer::GetDefaultSize( uint32_t& width, uint32_t& height ) const
195 Internal::Adaptor::GetImplementation( *this ).GetDefaultSize( width, height );
198 VectorAnimationRenderer::UploadCompletedSignalType& VectorAnimationRenderer::UploadCompletedSignal()
200 return Internal::Adaptor::GetImplementation( *this ).UploadCompletedSignal();