CanvasRenderer: Refactoring tvgObject management
[platform/core/uifw/dali-adaptor.git] / dali / internal / canvas-renderer / common / drawable-impl.cpp
1 /*
2  * Copyright (c) 2021 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 // CLASS HEADER
19 #include <dali/internal/canvas-renderer/common/drawable-factory.h>
20 #include <dali/internal/canvas-renderer/common/drawable-impl.h>
21
22 namespace Dali
23 {
24 namespace Internal
25 {
26 namespace Adaptor
27 {
28 Drawable::Drawable() = default;
29
30 Drawable::~Drawable()
31 {
32   if(mImpl)
33   {
34     delete mImpl;
35   }
36 }
37
38 void Drawable::Create()
39 {
40   if(!mImpl)
41   {
42     mImpl = Internal::Adaptor::DrawableFactory::New();
43   }
44 }
45
46 bool Drawable::SetOpacity(float opacity)
47 {
48   if(!mImpl)
49   {
50     return false;
51   }
52   return mImpl->SetOpacity(opacity);
53 }
54
55 float Drawable::GetOpacity() const
56 {
57   if(!mImpl)
58   {
59     return 0.0f;
60   }
61   return mImpl->GetOpacity();
62 }
63
64 bool Drawable::Rotate(Degree degree)
65 {
66   if(!mImpl)
67   {
68     return false;
69   }
70   return mImpl->Rotate(degree);
71 }
72
73 bool Drawable::Scale(float factor)
74 {
75   if(!mImpl)
76   {
77     return false;
78   }
79   return mImpl->Scale(factor);
80 }
81
82 bool Drawable::Translate(Vector2 translate)
83 {
84   if(!mImpl)
85   {
86     return false;
87   }
88   return mImpl->Translate(translate);
89 }
90
91 bool Drawable::Transform(const Dali::Matrix3& matrix)
92 {
93   if(!mImpl)
94   {
95     return false;
96   }
97   return mImpl->Transform(matrix);
98 }
99
100 Rect<float> Drawable::GetBoundingBox() const
101 {
102   if(!mImpl)
103   {
104     return Rect<float>(0, 0, 0, 0);
105   }
106   return mImpl->GetBoundingBox();
107 }
108
109 void Drawable::SetAdded(bool added)
110 {
111   if(!mImpl)
112   {
113     return;
114   }
115   mImpl->SetAdded(added);
116 }
117
118 bool Drawable::IsAdded() const
119 {
120   if(!mImpl)
121   {
122     return false;
123   }
124   return mImpl->IsAdded();
125 }
126
127 void* Drawable::GetObject() const
128 {
129   if(!mImpl)
130   {
131     return nullptr;
132   }
133   return mImpl->GetObject();
134 }
135
136 void Drawable::SetObject(const void* object)
137 {
138   if(!mImpl)
139   {
140     return;
141   }
142   mImpl->SetObject(object);
143 }
144
145 void Drawable::SetChanged(bool changed)
146 {
147   if(!mImpl)
148   {
149     return;
150   }
151   mImpl->SetChanged(changed);
152 }
153
154 bool Drawable::GetChanged() const
155 {
156   if(!mImpl)
157   {
158     return false;
159   }
160   return mImpl->GetChanged();
161 }
162
163 void Drawable::SetType(Drawable::Types type)
164 {
165   if(!mImpl)
166   {
167     return;
168   }
169   mImpl->SetType(type);
170 }
171
172 Drawable::Types Drawable::GetType() const
173 {
174   if(!mImpl)
175   {
176     return Drawable::Types::NONE;
177   }
178   return mImpl->GetType();
179 }
180
181 Dali::Internal::Adaptor::Drawable* Drawable::GetImplementation()
182 {
183   return mImpl;
184 }
185
186 } // namespace Adaptor
187
188 } // namespace Internal
189
190 } // namespace Dali