Merge branch 'devel/master' into devel/graphics
[platform/core/uifw/dali-adaptor.git] / dali / internal / canvas-renderer / common / drawable-impl.h
1 #ifndef DALI_INTERNAL_DRAWABLE_IMPL_H
2 #define DALI_INTERNAL_DRAWABLE_IMPL_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #ifdef THORVG_SUPPORT
23 #include <thorvg.h>
24 #endif
25 #include <dali/public-api/object/base-object.h>
26
27 // INTERNAL INCLUDES
28 #include <dali/devel-api/adaptor-framework/canvas-renderer-drawable.h>
29 #include <dali/devel-api/adaptor-framework/canvas-renderer.h>
30
31 namespace Dali
32 {
33 namespace Internal
34 {
35 namespace Adaptor
36 {
37 /**
38  * Dali internal Drawable.
39  */
40 class Drawable : public Dali::BaseObject
41 {
42 public:
43   /**
44    * @brief Constructor
45    */
46   Drawable();
47
48   /**
49    * @brief Destructor.
50    */
51   virtual ~Drawable() override;
52
53   /**
54    * @brief Create factory item(implementation) object.
55    */
56   void Create();
57
58   /**
59    * @copydoc Dali::CanvasRenderer::Drawable::SetOpacity
60    */
61   virtual bool SetOpacity(float opacity);
62
63   /**
64    * @copydoc Dali::CanvasRenderer::Drawable::GetOpacity
65    */
66   virtual float GetOpacity() const;
67
68   /**
69    * @copydoc Dali::CanvasRenderer::Drawable::Rotate
70    */
71   virtual bool Rotate(Degree degree);
72
73   /**
74    * @copydoc Dali::CanvasRenderer::Drawable::Scale
75    */
76   virtual bool Scale(float factor);
77
78   /**
79    * @copydoc Dali::CanvasRenderer::Drawable::Translate
80    */
81   virtual bool Translate(Vector2 translate);
82
83   /**
84    * @copydoc Dali::CanvasRenderer::Drawable::Transform
85    */
86   virtual bool Transform(const Dali::Matrix3& matrix);
87
88   /**
89    * @brief Set whether drawable added to the other object(canvas or drawable) or not.
90    * @param[in] added Ture if added, false otherwise.
91    */
92   virtual void SetDrawableAdded(bool added);
93
94   /**
95    * @brief Returns a drawable object pointer.
96    * @return Returns a drawable object pointer.
97    */
98   virtual void* GetObject() const;
99
100   /**
101    * @brief Set a drawable object
102    * @param[in] object drawable object
103    */
104   virtual void SetObject(const void* object);
105
106   /**
107    * @brief Set a changed state.
108    * @param[in] changed The state of changed.
109    */
110   virtual void SetChanged(bool changed);
111
112   /**
113    * @brief Get a changed state.
114    * @return Returns state of changed.
115    */
116   virtual bool GetChanged() const;
117
118   /**
119    * @brief Returns a drawable's implements object pointer.
120    * @return Returns a drawable's implements object pointer.
121    */
122   Dali::Internal::Adaptor::Drawable* GetImplementation();
123
124   Drawable(const Drawable&) = delete;
125   Drawable& operator=(Drawable&) = delete;
126   Drawable(Drawable&&)           = delete;
127   Drawable& operator=(Drawable&&) = delete;
128
129 private:
130   Dali::Internal::Adaptor::Drawable* pImpl = nullptr;
131 };
132
133 } // namespace Adaptor
134
135 } // namespace Internal
136
137 inline static Internal::Adaptor::Drawable& GetImplementation(Dali::CanvasRenderer::Drawable& drawable)
138 {
139   DALI_ASSERT_ALWAYS(drawable && "Drawable handle is empty.");
140
141   BaseObject& handle = drawable.GetBaseObject();
142
143   return static_cast<Internal::Adaptor::Drawable&>(handle);
144 }
145
146 inline static const Internal::Adaptor::Drawable& GetImplementation(const Dali::CanvasRenderer::Drawable& drawable)
147 {
148   DALI_ASSERT_ALWAYS(drawable && "Drawable handle is empty.");
149
150   const BaseObject& handle = drawable.GetBaseObject();
151
152   return static_cast<const Internal::Adaptor::Drawable&>(handle);
153 }
154
155 } // namespace Dali
156
157 #endif // DALI_INTERNAL_DRAWABLE_IMPL_H