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>
23 #include <dali/public-api/object/property-map.h>
26 #include <dali-toolkit/devel-api/visual-factory/visual.h>
36 namespace Internal DALI_INTERNAL
42 * @brief VisualFactory is a singleton object that provides and shares visuals between controls
44 * By setting environment variable 'DALI_DEBUG_RENDERING', all concrete renderer is replaced with the debug renderer which renders a quad wireframe.
46 * The renderer type is required in the property map for requesting a control renderer.
48 * | %Property Name | Type |
49 * |--------------------------|------------------|
50 * | rendererType | STRING |
52 class DALI_IMPORT_API VisualFactory : public BaseHandle
57 * @brief Create or retrieve VisualFactory singleton.
59 * @return A handle to the VisualFactory control.
61 static VisualFactory Get();
64 * @brief Create a VisualFactory handle.
66 * Calling member functions with an uninitialised handle is not allowed.
73 * This is non-virtual since derived Handle types must not contain data or virtual methods.
78 * @brief This copy constructor is required for (smart) pointer semantics.
80 * @param[in] handle A reference to the copied handle.
82 VisualFactory( const VisualFactory& handle );
85 * @brief This assignment operator is required for (smart) pointer semantics.
87 * @param [in] handle A reference to the copied handle.
88 * @return A reference to this.
90 VisualFactory& operator=( const VisualFactory& handle );
93 * @brief Request the control renderer
95 * @param[in] propertyMap The map contains the properties required by the control renderer
96 * Depends on the content of the map, different kind of renderer would be returned.
97 * @return The pointer pointing to control renderer
99 Visual CreateVisual( const Property::Map& propertyMap );
102 * @brief Request the control renderer to render the image.
104 * @param[in] image The image to be rendered.
105 * @return The pointer pointing to the control renderer
107 Visual CreateVisual( const Image& image );
110 * @brief Request the control renderer to render the given resource at the url.
112 * @param[in] url The URL to the resource to be rendered.
113 * @param[in] size The width and height to fit the loaded image to.
114 * @return The pointer pointing to the control renderer
116 Visual CreateVisual( const std::string& url, ImageDimensions size );
120 explicit DALI_INTERNAL VisualFactory(Internal::VisualFactory *impl);
126 * @brief Template to allow discard old renderer, get new one and set it on stage if possible
128 * @tparam ParameterType0 The type of first argument passed to the CreateVisual()
129 * @tparam ParameterType1 The type of second argument passed to the CreateVisual()
131 * @param[in] actor Actor for which the renderer will be replaced
132 * @param[in,out] renderer The renderer object to be replaced
133 * @param[in] param0 First template based argument passed to the renderer factory
134 * @param[in] param1 Second template based argument passed to the renderer factory
136 template< class ParameterType0, class ParameterType1 >
137 void InitializeVisual( Actor& actor, Visual& renderer, ParameterType0& param0, ParameterType1& param1 )
139 renderer.RemoveAndReset( actor );
140 renderer = Toolkit::VisualFactory::Get().CreateVisual( param0, param1 );
141 if( renderer && actor && actor.OnStage() )
143 renderer.SetOnStage( actor );
148 * @brief Template to allow discard old renderer, get new one and set it on stage if possible
150 * @tparam ParameterType The type of argument passed to the CreateVisual()
152 * @param[in] actor Actor for which the renderer will be replaced
153 * @param[in,out] renderer The renderer object to be replaced
154 * @param[in] param Template based argument passed to the renderer factory
156 template< class ParameterType >
157 void InitializeVisual( Actor& actor, Visual& renderer, ParameterType& param )
159 renderer.RemoveAndReset( actor );
160 renderer = Toolkit::VisualFactory::Get().CreateVisual( param );
161 if( renderer && actor && actor.OnStage() )
163 renderer.SetOnStage( actor );
167 } // namespace Toolkit
172 #endif /* __DALI_TOOLKIT_RENDERER_FACTORY_H__ */