CanvasRenderer: Add Drawable::SetClipPath() Api
[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 bool Drawable::SetClipPath(Dali::CanvasRenderer::Drawable& clip)
110 {
111   if(!mImpl)
112   {
113     return false;
114   }
115   return mImpl->SetClipPath(clip);
116 }
117
118 Dali::CanvasRenderer::Drawable Drawable::GetCompositionDrawable() const
119 {
120   if(!mImpl)
121   {
122     return Dali::CanvasRenderer::Drawable();
123   }
124   return mImpl->GetCompositionDrawable();
125 }
126
127 Dali::Internal::Adaptor::Drawable::CompositionType Drawable::GetCompositionType() const
128 {
129   if(!mImpl)
130   {
131     return Dali::Internal::Adaptor::Drawable::CompositionType::NONE;
132   }
133   return mImpl->GetCompositionType();
134 }
135
136 void Drawable::SetAdded(bool added)
137 {
138   if(!mImpl)
139   {
140     return;
141   }
142   mImpl->SetAdded(added);
143 }
144
145 bool Drawable::IsAdded() const
146 {
147   if(!mImpl)
148   {
149     return false;
150   }
151   return mImpl->IsAdded();
152 }
153
154 void* Drawable::GetObject() const
155 {
156   if(!mImpl)
157   {
158     return nullptr;
159   }
160   return mImpl->GetObject();
161 }
162
163 void Drawable::SetObject(const void* object)
164 {
165   if(!mImpl)
166   {
167     return;
168   }
169   mImpl->SetObject(object);
170 }
171
172 void Drawable::SetChanged(bool changed)
173 {
174   if(!mImpl)
175   {
176     return;
177   }
178   mImpl->SetChanged(changed);
179 }
180
181 bool Drawable::GetChanged() const
182 {
183   if(!mImpl)
184   {
185     return false;
186   }
187   return mImpl->GetChanged();
188 }
189
190 void Drawable::SetType(Drawable::Types type)
191 {
192   if(!mImpl)
193   {
194     return;
195   }
196   mImpl->SetType(type);
197 }
198
199 Drawable::Types Drawable::GetType() const
200 {
201   if(!mImpl)
202   {
203     return Drawable::Types::NONE;
204   }
205   return mImpl->GetType();
206 }
207
208 Dali::Internal::Adaptor::Drawable* Drawable::GetImplementation()
209 {
210   return mImpl;
211 }
212
213 } // namespace Adaptor
214
215 } // namespace Internal
216
217 } // namespace Dali