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