6dffc9af6a04facfd73f23cbefacf24e5f8aa5d3
[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 if, 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 render the image.
131    *
132    * @param[in] image The image to be rendered.
133    * @return The pointer pointing to the control renderer
134    */
135   ControlRenderer GetControlRenderer( const Image& image );
136
137   /**
138    * @brief Request the current control renderer to render the given image
139    *
140    * if the current renderer is a handle to an internal image renderer, set this image to it,
141    * else the renderer would be a handle to a newly created internal image renderer.
142    *
143    * @param[in] renderer The ControlRenderer to reset
144    * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
145    * @param[in] image The Image to be rendered.
146    */
147   void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Image& image );
148
149   /**
150    * @brief Request the control renderer to render the given resource at the url.
151    *
152    * @param[in] url The URL to the resource to be rendered.
153    * @param[in] size The width and height to fit the loaded image to.
154    * @return The pointer pointing to the control renderer
155    */
156   ControlRenderer GetControlRenderer( const std::string& url,
157                                       ImageDimensions size = ImageDimensions() );
158
159   /**
160    * @brief Request the current control renderer to render the given resource at the url
161    *
162    * if the current renderer is a handle to an internal image renderer, set this image to it,
163    * else the renderer would be a handle to a newly created internal image renderer.
164    *
165    * @param[in] renderer The ControlRenderer to reset
166    * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
167    * @param[in] url The URL to the resource to be rendered.
168    * @param[in] size The width and height to fit the loaded image to.
169    */
170   void ResetRenderer( ControlRenderer& renderer, Actor& actor, const std::string& url,
171                       ImageDimensions size = ImageDimensions() );
172
173
174   /**
175    * @brief Request the current control renderer from the property map, merging the property map with the renderer
176    *
177    * if the current renderer is capable of merging with the property map the reset the renderer with the merged properties
178    * else the renderer would be a handle to a newly created internal renderer.
179    *
180    * @param[in] renderer The ControlRenderer to reset
181    * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
182    * @param[in] propertyMap The map contains the properties required by the control renderer
183    *            Depends on the content of the map, different kind of renderer would be returned.
184    */
185   void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Property::Map& propertyMap );
186
187 private:
188
189   explicit DALI_INTERNAL RendererFactory(Internal::RendererFactory *impl);
190
191 };
192
193 } // namespace Toolkit
194
195 } // namespace Dali
196
197 #endif /* __DALI_TOOLKIT_RENDERER_FACTORY_H__ */