6a42d9cfc65841e33b3ca7a1dc336a6b48a58051
[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
48   void SetSize( uint32_t width, uint32_t height )
49   {
50     mWidth = width;
51     mHeight = height;
52   }
53
54   bool StartRender()
55   {
56     return true;
57   }
58
59   void StopRender()
60   {
61   }
62
63   void Render( uint32_t frameNumber )
64   {
65   }
66
67   uint32_t GetTotalFrameNumber()
68   {
69     return 5;
70   }
71
72 public:
73
74   std::string mUrl;
75   Dali::Renderer mRenderer;
76   uint32_t mWidth;
77   uint32_t mHeight;
78
79 };
80
81 inline VectorAnimationRenderer& GetImplementation( Dali::VectorAnimationRenderer& renderer )
82 {
83   DALI_ASSERT_ALWAYS( renderer && "VectorAnimationRenderer handle is empty." );
84   BaseObject& handle = renderer.GetBaseObject();
85   return static_cast< Internal::Adaptor::VectorAnimationRenderer& >( handle );
86 }
87
88 inline const VectorAnimationRenderer& GetImplementation( const Dali::VectorAnimationRenderer& renderer )
89 {
90   DALI_ASSERT_ALWAYS( renderer && "VectorAnimationRenderer handle is empty." );
91   const BaseObject& handle = renderer.GetBaseObject();
92   return static_cast< const Internal::Adaptor::VectorAnimationRenderer& >( handle );
93 }
94
95 } // namespace Adaptor
96
97 } // namespace Internal
98
99
100 /********************************************************************************/
101 /*********************************  PUBLIC CLASS  *******************************/
102 /********************************************************************************/
103
104 VectorAnimationRenderer VectorAnimationRenderer::New( const std::string& url )
105 {
106   Internal::Adaptor::VectorAnimationRenderer* animationRenderer = new Internal::Adaptor::VectorAnimationRenderer( url );
107
108   return VectorAnimationRenderer( animationRenderer );
109 }
110
111 VectorAnimationRenderer::VectorAnimationRenderer()
112 {
113 }
114
115 VectorAnimationRenderer::~VectorAnimationRenderer()
116 {
117 }
118
119 VectorAnimationRenderer::VectorAnimationRenderer( Internal::Adaptor::VectorAnimationRenderer* internal )
120 : BaseHandle( internal )
121 {
122 }
123
124 VectorAnimationRenderer::VectorAnimationRenderer( const VectorAnimationRenderer& handle )
125 : BaseHandle( handle )
126 {
127 }
128
129 VectorAnimationRenderer& VectorAnimationRenderer::operator=( const VectorAnimationRenderer& rhs )
130 {
131   BaseHandle::operator=( rhs );
132   return *this;
133 }
134
135 void VectorAnimationRenderer::SetRenderer( Renderer renderer )
136 {
137   Internal::Adaptor::GetImplementation( *this ).SetRenderer( renderer );
138 }
139
140 void VectorAnimationRenderer::SetSize( uint32_t width, uint32_t height )
141 {
142   Internal::Adaptor::GetImplementation( *this ).SetSize( width, height );
143 }
144
145 bool VectorAnimationRenderer::StartRender()
146 {
147   return Internal::Adaptor::GetImplementation( *this ).StartRender();
148 }
149
150 void VectorAnimationRenderer::StopRender()
151 {
152   Internal::Adaptor::GetImplementation( *this ).StopRender();
153 }
154
155 void VectorAnimationRenderer::Render( uint32_t frameNumber )
156 {
157   Internal::Adaptor::GetImplementation( *this ).Render( frameNumber );
158 }
159
160 uint32_t VectorAnimationRenderer::GetTotalFrameNumber()
161 {
162   return Internal::Adaptor::GetImplementation( *this ).GetTotalFrameNumber();
163 }
164
165 } // namespace Dali;
166