Implements CanvasRenderer that can draw Vector Primitives using ThorVG
[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(pImpl)
33   {
34     delete pImpl;
35   }
36 }
37
38 void Drawable::Create()
39 {
40   if(!pImpl)
41   {
42     pImpl = Internal::Adaptor::DrawableFactory::New();
43   }
44 }
45
46 bool Drawable::SetOpacity(float opacity)
47 {
48   if(!pImpl)
49   {
50     return false;
51   }
52   return pImpl->SetOpacity(opacity);
53 }
54
55 float Drawable::GetOpacity() const
56 {
57   if(!pImpl)
58   {
59     return 0.0f;
60   }
61   return pImpl->GetOpacity();
62 }
63
64 bool Drawable::Rotate(Degree degree)
65 {
66   if(!pImpl)
67   {
68     return false;
69   }
70   return pImpl->Rotate(degree);
71 }
72
73 bool Drawable::Scale(float factor)
74 {
75   if(!pImpl)
76   {
77     return false;
78   }
79   return pImpl->Scale(factor);
80 }
81
82 bool Drawable::Translate(Vector2 translate)
83 {
84   if(!pImpl)
85   {
86     return false;
87   }
88   return pImpl->Translate(translate);
89 }
90
91 bool Drawable::Transform(const Dali::Matrix3& matrix)
92 {
93   if(!pImpl)
94   {
95     return false;
96   }
97   return pImpl->Transform(matrix);
98 }
99
100 void Drawable::SetDrawableAdded(bool added)
101 {
102   if(!pImpl)
103   {
104     return;
105   }
106   pImpl->SetDrawableAdded(added);
107 }
108
109 void* Drawable::GetObject() const
110 {
111   if(!pImpl)
112   {
113     return nullptr;
114   }
115   return pImpl->GetObject();
116 }
117
118 void Drawable::SetObject(const void* object)
119 {
120   if(!pImpl)
121   {
122     return;
123   }
124   pImpl->SetObject(object);
125 }
126
127 void Drawable::SetChanged(bool changed)
128 {
129   if(!pImpl)
130   {
131     return;
132   }
133   pImpl->SetChanged(changed);
134 }
135
136 bool Drawable::GetChanged() const
137 {
138   if(!pImpl)
139   {
140     return false;
141   }
142   return pImpl->GetChanged();
143 }
144
145 Dali::Internal::Adaptor::Drawable* Drawable::GetImplementation()
146 {
147   return pImpl;
148 }
149
150 } // namespace Adaptor
151
152 } // namespace Internal
153
154 } // namespace Dali