Implement WebView APIs
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-vector-animation-renderer.cpp
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
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>
21
22 namespace Dali
23 {
24
25 namespace Internal
26 {
27
28 namespace Adaptor
29 {
30
31 class VectorAnimationRenderer: public Dali::BaseObject
32 {
33 public:
34
35   VectorAnimationRenderer( const std::string& url )
36   : mUrl( url ),
37     mRenderer(),
38     mWidth( 0 ),
39     mHeight( 0 )
40   {
41   }
42
43   void SetRenderer( Dali::Renderer renderer )
44   {
45     mRenderer = renderer;
46
47     if( mWidth != 0 && mHeight != 0 )
48     {
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 );
52     }
53   }
54
55   void SetSize( uint32_t width, uint32_t height )
56   {
57     mWidth = width;
58     mHeight = height;
59
60     if( mRenderer )
61     {
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 );
65     }
66   }
67
68   void StopRender()
69   {
70   }
71
72   void Render( uint32_t frameNumber )
73   {
74   }
75
76   uint32_t GetTotalFrameNumber() const
77   {
78     return 5;
79   }
80
81   float GetFrameRate() const
82   {
83     return 60.0f;
84   }
85
86   void GetDefaultSize( uint32_t& width, uint32_t& height ) const
87   {
88     width = 100;
89     height = 100;
90   }
91
92 public:
93
94   std::string mUrl;
95   Dali::Renderer mRenderer;
96   uint32_t mWidth;
97   uint32_t mHeight;
98 };
99
100 inline VectorAnimationRenderer& GetImplementation( Dali::VectorAnimationRenderer& renderer )
101 {
102   DALI_ASSERT_ALWAYS( renderer && "VectorAnimationRenderer handle is empty." );
103   BaseObject& handle = renderer.GetBaseObject();
104   return static_cast< Internal::Adaptor::VectorAnimationRenderer& >( handle );
105 }
106
107 inline const VectorAnimationRenderer& GetImplementation( const Dali::VectorAnimationRenderer& renderer )
108 {
109   DALI_ASSERT_ALWAYS( renderer && "VectorAnimationRenderer handle is empty." );
110   const BaseObject& handle = renderer.GetBaseObject();
111   return static_cast< const Internal::Adaptor::VectorAnimationRenderer& >( handle );
112 }
113
114 } // namespace Adaptor
115
116 } // namespace Internal
117
118
119 /********************************************************************************/
120 /*********************************  PUBLIC CLASS  *******************************/
121 /********************************************************************************/
122
123 VectorAnimationRenderer VectorAnimationRenderer::New( const std::string& url )
124 {
125   Internal::Adaptor::VectorAnimationRenderer* animationRenderer = new Internal::Adaptor::VectorAnimationRenderer( url );
126
127   return VectorAnimationRenderer( animationRenderer );
128 }
129
130 VectorAnimationRenderer::VectorAnimationRenderer()
131 {
132 }
133
134 VectorAnimationRenderer::~VectorAnimationRenderer()
135 {
136 }
137
138 VectorAnimationRenderer::VectorAnimationRenderer( Internal::Adaptor::VectorAnimationRenderer* internal )
139 : BaseHandle( internal )
140 {
141 }
142
143 VectorAnimationRenderer::VectorAnimationRenderer( const VectorAnimationRenderer& handle )
144 : BaseHandle( handle )
145 {
146 }
147
148 VectorAnimationRenderer& VectorAnimationRenderer::operator=( const VectorAnimationRenderer& rhs )
149 {
150   BaseHandle::operator=( rhs );
151   return *this;
152 }
153
154 void VectorAnimationRenderer::SetRenderer( Renderer renderer )
155 {
156   Internal::Adaptor::GetImplementation( *this ).SetRenderer( renderer );
157 }
158
159 void VectorAnimationRenderer::SetSize( uint32_t width, uint32_t height )
160 {
161   Internal::Adaptor::GetImplementation( *this ).SetSize( width, height );
162 }
163
164 void VectorAnimationRenderer::StopRender()
165 {
166   Internal::Adaptor::GetImplementation( *this ).StopRender();
167 }
168
169 void VectorAnimationRenderer::Render( uint32_t frameNumber )
170 {
171   Internal::Adaptor::GetImplementation( *this ).Render( frameNumber );
172 }
173
174 uint32_t VectorAnimationRenderer::GetTotalFrameNumber() const
175 {
176   return Internal::Adaptor::GetImplementation( *this ).GetTotalFrameNumber();
177 }
178
179 float VectorAnimationRenderer::GetFrameRate() const
180 {
181   return Internal::Adaptor::GetImplementation( *this ).GetFrameRate();
182 }
183
184 void VectorAnimationRenderer::GetDefaultSize( uint32_t& width, uint32_t& height ) const
185 {
186   Internal::Adaptor::GetImplementation( *this ).GetDefaultSize( width, height );
187 }
188
189 } // namespace Dali;
190