1 #ifndef __DALI_TOOLKIT_RENDERER_FACTORY_H__
2 #define __DALI_TOOLKIT_RENDERER_FACTORY_H__
4 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <dali/public-api/object/base-handle.h>
22 #include <dali/public-api/images/image-operations.h>
25 #include <dali-toolkit/devel-api/controls/renderer-factory/control-renderer.h>
35 namespace Internal DALI_INTERNAL
37 class RendererFactory;
41 * @brief RendererFactory is a singleton object that provides and shares renderers for controls
43 * By setting environment variable 'DALI_DEBUG_RENDERING', all concrete renderer is replaced with the debug renderer which renders a quad wireframe.
45 * The renderer type is required in the property map for requesting a control renderer.
47 * | %Property Name | Type |
48 * |--------------------------|------------------|
49 * | rendererType | STRING |
51 class DALI_IMPORT_API RendererFactory : public BaseHandle
56 * @brief Create or retrieve RendererFactory singleton.
58 * @return A handle to the RendererFactory control.
60 static RendererFactory Get();
63 * @brief Create a RendererFactory handle.
65 * Calling member functions with an uninitialised handle is not allowed.
72 * This is non-virtual since derived Handle types must not contain data or virtual methods.
77 * @brief This copy constructor is required for (smart) pointer semantics.
79 * @param[in] handle A reference to the copied handle.
81 RendererFactory( const RendererFactory& handle );
84 * @brief This assignment operator is required for (smart) pointer semantics.
86 * @param [in] handle A reference to the copied handle.
87 * @return A reference to this.
89 RendererFactory& operator=( const RendererFactory& handle );
92 * @brief Request the control renderer
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
98 ControlRenderer GetControlRenderer( const Property::Map& propertyMap );
101 * @brief Request the control renderer to render the given color
103 * @param[in] color The color to be rendered
104 * @return The pointer pointing to the control renderer
106 ControlRenderer GetControlRenderer( const Vector4& color );
109 * @brief Request the current control renderer to render the given color
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.
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.
118 void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Vector4& color );
121 * @brief Request the control renderer to renderer the border with the given size and color.
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
127 ControlRenderer GetControlRenderer( float borderSize, const Vector4& borderColor );
130 * @brief Request the control renderer to renderer the border with the given size and color, and specify whether anti-aliasing is needed.
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
137 ControlRenderer GetControlRenderer( float borderSize, const Vector4& borderColor, bool antiAliasing );
140 * @brief Request the control renderer to render the image.
142 * @param[in] image The image to be rendered.
143 * @return The pointer pointing to the control renderer
145 ControlRenderer GetControlRenderer( const Image& image );
148 * @brief Request the current control renderer to render the given image
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.
153 * @param[in] renderer The ControlRenderer to reset
154 * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
155 * @param[in] image The Image to be rendered.
157 void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Image& image );
160 * @brief Request the control renderer to render the given resource at the url.
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
166 ControlRenderer GetControlRenderer( const std::string& url,
167 ImageDimensions size = ImageDimensions() );
170 * @brief Request the current control renderer to render the given resource at the url
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.
175 * @param[in] renderer The ControlRenderer to reset
176 * @param[in] actor The Actor the renderer is applied to if, 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.
180 void ResetRenderer( ControlRenderer& renderer, Actor& actor, const std::string& url,
181 ImageDimensions size = ImageDimensions() );
185 * @brief Request the current control renderer from the property map, merging the property map with the renderer
187 * if the current renderer is capable of merging with the property map the reset the renderer with the merged properties
188 * else the renderer would be a handle to a newly created internal renderer.
190 * @param[in] renderer The ControlRenderer to reset
191 * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
192 * @param[in] propertyMap The map contains the properties required by the control renderer
193 * Depends on the content of the map, different kind of renderer would be returned.
195 void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Property::Map& propertyMap );
199 explicit DALI_INTERNAL RendererFactory(Internal::RendererFactory *impl);
203 } // namespace Toolkit
207 #endif /* __DALI_TOOLKIT_RENDERER_FACTORY_H__ */