1 #ifndef __DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_H__
2 #define __DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #include <dali/public-api/object/base-object.h>
24 #include <dali/public-api/images/image-operations.h>
25 #include <dali/devel-api/rendering/shader.h>
28 #include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
29 #include <dali-toolkit/devel-api/controls/renderer-factory/control-renderer.h>
30 #include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
42 * Base class for all Control rendering logic. A control may have multiple control renderers.
44 * Note: The control renderer responds to the the Actor::COLOR by blending it with the 'Multiply' operator.
46 * The following properties are optional
48 * | %Property Name | Type |
49 * |---------------------------|------------------|
50 * | custom-shader | MAP |
52 * where custom-shader is a map with the following properties:
53 * | %Property Name | Type |
54 * |---------------------------|------------------|
55 * | vertex-shader | STRING |
56 * | fragment-shader | STRING |
57 * | subdivide-grid-x | INT |
58 * | subdivide-grid-y | INT |
59 * | shader-hints | INT |
61 class ControlRenderer : public BaseObject
66 * Initialisation of the renderer, this API should only called by the RendererFactory:
67 * request the geometry and shader from the cache, if not available, create and save to the cache for sharing;
68 * record the property values.
70 * @param[in] propertyMap The properties for the requested ControlRenderer object.
72 void Initialize( const Property::Map& propertyMap );
75 * @copydoc Toolkit::ControlRenderer::SetSize
77 virtual void SetSize( const Vector2& size );
80 * @copydoc Toolkit::ControlRenderer::GetSize
82 const Vector2& GetSize() const;
85 * @copydoc Toolkit::ControlRenderer::GetNaturalSize
87 virtual void GetNaturalSize( Vector2& naturalSize ) const;
90 * ToDo: Add this function to Toolkit::ControlRenderer when it is fully implemented.
92 * Set the clip rectangular of this renderer.
93 * The contents of the renderer will not be visible outside this rectangular.
95 * @param [in] clipRect The clipping rectangular.
97 virtual void SetClipRect( const Rect<int>& clipRect );
100 *ToDo: Add this function to Toolkit::ControlRenderer when it is fully implemented.
102 * Reposition this renderer with a 2D offset.
104 * @param[in] offset The offset to reposition the renderer.
106 virtual void SetOffset( const Vector2& offset );
109 * @copydoc Toolkit::ControlRenderer::SetDepthIndex
111 void SetDepthIndex( float index );
114 * @copydoc Toolkit::ControlRenderer::GetDepthIndex
116 float GetDepthIndex() const;
119 * @copydoc Toolkit::ControlRenderer::SetOnStage
120 * @pre Impl->mGeometry must be created before this method is called
122 void SetOnStage( Actor& actor );
125 * @copydoc Toolkit::ControlRenderer::SetOffStage
127 void SetOffStage( Actor& actor );
130 * @copydoc Toolkit::ControlRenderer::CreatePropertyMap
132 void CreatePropertyMap( Property::Map& map ) const;
137 * @brief Constructor.
139 * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
141 ControlRenderer( RendererFactoryCache& factoryCache );
144 * @brief A reference counted object may only be deleted by calling Unreference().
146 virtual ~ControlRenderer();
150 * @brief Called by CreatePropertyMap() allowing sub classes to respond to the CreatePropertyMap event
152 * @param[out] map The renderer property map.
154 virtual void DoCreatePropertyMap( Property::Map& map ) const = 0;
157 * @brief Called by Initialize() allowing sub classes to respond to the Initialize event
159 * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
160 * @param[in] propertyMap The properties for the requested ControlRenderer object.
162 virtual void DoInitialize( const Property::Map& propertyMap ) = 0;
165 * @brief Initialises a renderer ready to be put on stage.
167 * @param[inout] renderer The Renderer to initialise. If the renderer is not empty then re-initialise the renderer
169 virtual void InitializeRenderer( Renderer& renderer ) = 0;
174 * @brief Called by SetOnStage() allowing sub classes to respond to the SetOnStage event
176 * @param[in] actor The actor applying this renderer.
178 virtual void DoSetOnStage( Actor& actor );
181 * @brief Called by SetOffStage() allowing sub classes to respond to the SetOffStage event
183 * @param[in] actor The actor applying this renderer.
185 virtual void DoSetOffStage( Actor& actor );
190 * @brief Sets the key to use for caching the renderer. If this is empty then no caching will occur
192 * @param[in] cachedRendererKey The key to use for caching the renderer.
194 void SetCachedRendererKey( const std::string& cachedRendererKey );
199 ControlRenderer( const ControlRenderer& renderer );
202 ControlRenderer& operator=( const ControlRenderer& renderer );
207 RendererFactoryCache& mFactoryCache;
210 } // namespace Internal
212 inline const Internal::ControlRenderer& GetImplementation(const Toolkit::ControlRenderer& renderer)
214 DALI_ASSERT_ALWAYS( renderer && "ControlRenderer handle is empty" );
216 const BaseObject& handle = renderer.GetBaseObject();
218 return static_cast<const Internal::ControlRenderer&>(handle);
221 inline Internal::ControlRenderer& GetImplementation(Toolkit::ControlRenderer& renderer)
223 DALI_ASSERT_ALWAYS( renderer && "ControlRenderer handle is empty" );
225 BaseObject& handle = renderer.GetBaseObject();
227 return static_cast<Internal::ControlRenderer&>(handle);
230 } // namespace Toolkit
234 #endif /* __DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_H___ */