[dali_1.1.40] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / renderer-factory / renderer-factory.h
1 #ifndef __DALI_TOOLKIT_RENDERER_FACTORY_H__
2 #define __DALI_TOOLKIT_RENDERER_FACTORY_H__
3 /*
4  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 // EXTERNAL INCLUDES
21 #include <dali/public-api/object/base-handle.h>
22 #include <dali/public-api/images/image-operations.h>
23
24 // INTERNAK INCLUDES
25 #include <dali-toolkit/devel-api/controls/renderer-factory/control-renderer.h>
26
27 namespace Dali
28 {
29 class Image;
30 class Vector4;
31
32 namespace Toolkit
33 {
34
35 namespace Internal DALI_INTERNAL
36 {
37 class RendererFactory;
38 }
39
40 /**
41  * @brief RendererFactory is a singleton object that provides and shares renderers for controls
42  *
43  * By setting environment variable 'DALI_DEBUG_RENDERING', all concrete renderer is replaced with the debug renderer which renders a quad wireframe.
44  *
45  * The renderer type is required in the property map for requesting a control renderer.
46  *
47  * | %Property Name           | Type             |
48  * |--------------------------|------------------|
49  * | rendererType             | STRING           |
50  */
51 class DALI_IMPORT_API RendererFactory : public BaseHandle
52 {
53 public:
54
55   /**
56    * @brief Create or retrieve RendererFactory singleton.
57    *
58    * @return A handle to the RendererFactory control.
59    */
60   static RendererFactory Get();
61
62   /**
63    * @brief Create a RendererFactory handle.
64    *
65    * Calling member functions with an uninitialised handle is not allowed.
66    */
67   RendererFactory();
68
69   /**
70    * @brief Destructor
71    *
72    * This is non-virtual since derived Handle types must not contain data or virtual methods.
73    */
74   ~RendererFactory();
75
76   /**
77    * @brief This copy constructor is required for (smart) pointer semantics.
78    *
79    * @param[in] handle A reference to the copied handle.
80    */
81   RendererFactory( const RendererFactory& handle );
82
83   /**
84    * @brief This assignment operator is required for (smart) pointer semantics.
85    *
86    * @param [in] handle  A reference to the copied handle.
87    * @return A reference to this.
88    */
89   RendererFactory& operator=( const RendererFactory& handle );
90
91   /**
92    * @brief Request the control renderer
93    *
94    * @param[in] propertyMap The map contains the properties required by the control renderer
95    *            Depends on the content of the map, different kind of renderer would be returned.
96    * @return The pointer pointing to control renderer
97    */
98   ControlRenderer GetControlRenderer( const Property::Map& propertyMap  );
99
100   /**
101    * @brief Request the control renderer to render the given color
102    *
103    * @param[in] color The color to be rendered
104    * @return The pointer pointing to the control renderer
105    */
106   ControlRenderer GetControlRenderer( const Vector4& color );
107
108   /**
109    * @brief Request the current control renderer to render the given color
110    *
111    * if the current renderer is a handle to an internal color renderer, set this color to it,
112    * else the renderer would be a handle to a newly created internal color renderer.
113    *
114    * @param[in] renderer The ControlRenderer to reset
115    * @param[in] actor The Actor the renderer is applied to, empty if the renderer has not been applied to any Actor
116    * @param[in] color The color to be rendered.
117    */
118   void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Vector4& color );
119
120   /**
121    * @brief Request the control renderer to renderer the border with the given size and color.
122    *
123    * @param[in] borderSize The size of the border. Border size is the same along all edges.
124    * @param[in] borderColor The color of the border.
125    * @return The pointer pointing to the control renderer
126    */
127   ControlRenderer GetControlRenderer( float borderSize, const Vector4& borderColor );
128
129   /**
130    * @brief Request the control renderer to renderer the border with the given size and color, and specify whether anti-aliasing is needed.
131    *
132    * @param[in] borderSize The size of the border. Border size is the same along all edges.
133    * @param[in] borderColor The color of the border.
134    * @param[in] antiAliasing Whether anti-aliasing is required for border rendering.
135    * @return The pointer pointing to the control renderer
136    */
137   ControlRenderer GetControlRenderer( float borderSize, const Vector4& borderColor, bool antiAliasing );
138
139   /**
140    * @brief Request the control renderer to render the image.
141    *
142    * @param[in] image The image to be rendered.
143    * @return The pointer pointing to the control renderer
144    */
145   ControlRenderer GetControlRenderer( const Image& image );
146
147   /**
148    * @brief Request the current control renderer to render the given image
149    *
150    * if the current renderer is a handle to an internal image renderer, set this image to it,
151    * else the renderer would be a handle to a newly created internal image renderer.
152    *
153    * @param[in] renderer The ControlRenderer to reset
154    * @param[in] actor The Actor the renderer is applied to, empty if the renderer has not been applied to any Actor
155    * @param[in] image The Image to be rendered.
156    */
157   void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Image& image );
158
159   /**
160    * @brief Request the control renderer to render the given resource at the url.
161    *
162    * @param[in] url The URL to the resource to be rendered.
163    * @param[in] size The width and height to fit the loaded image to.
164    * @return The pointer pointing to the control renderer
165    */
166   ControlRenderer GetControlRenderer( const std::string& url,
167                                       ImageDimensions size = ImageDimensions() );
168
169   /**
170    * @brief Request the current control renderer to render the given resource at the url
171    *
172    * if the current renderer is a handle to an internal image renderer, set this image to it,
173    * else the renderer would be a handle to a newly created internal image renderer.
174    *
175    * @param[in] renderer The ControlRenderer to reset
176    * @param[in] actor The Actor the renderer is applied to, empty if the renderer has not been applied to any Actor
177    * @param[in] url The URL to the resource to be rendered.
178    * @param[in] size The width and height to fit the loaded image to.
179    */
180   void ResetRenderer( ControlRenderer& renderer, Actor& actor, const std::string& url,
181                       ImageDimensions size = ImageDimensions() );
182
183   /**
184    * @brief Request the current control renderer from the property map, merging the property map with the renderer
185    *
186    * if the current renderer is capable of merging with the property map the reset the renderer with the merged properties
187    * else the renderer would be a handle to a newly created internal renderer.
188    *
189    * @param[in] renderer The ControlRenderer to reset
190    * @param[in] actor The Actor the renderer is applied to, empty if the renderer has not been applied to any Actor
191    * @param[in] propertyMap The map contains the properties required by the control renderer
192    *            Depends on the content of the map, different kind of renderer would be returned.
193    */
194   void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Property::Map& propertyMap );
195
196 private:
197
198   explicit DALI_INTERNAL RendererFactory(Internal::RendererFactory *impl);
199
200 };
201
202 } // namespace Toolkit
203
204 } // namespace Dali
205
206 #endif /* __DALI_TOOLKIT_RENDERER_FACTORY_H__ */