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>
40 class RendererFactoryCache;
43 * Base class for all Control rendering logic. A control may have multiple control renderers.
45 * Note: The control renderer responds to the the Actor::COLOR by blending it with the 'Multiply' operator.
47 * The following properties are optional
49 * | %Property Name | Type |
50 * |---------------------------|------------------|
51 * | custom-shader | MAP |
53 * where custom-shader is a map with the following properties:
54 * | %Property Name | Type |
55 * |---------------------------|------------------|
56 * | vertex-shader | STRING |
57 * | fragment-shader | STRING |
58 * | subdivide-grid-x | INT |
59 * | subdivide-grid-y | INT |
60 * | shader-hints | INT |
62 class ControlRenderer : public BaseObject
67 * Initialisation of the renderer, this API should only called by the RendererFactory:
68 * request the geometry and shader from the cache, if not available, create and save to the cache for sharing;
69 * record the property values.
71 * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
72 * @param[in] propertyMap The properties for the requested ControlRenderer object.
74 void Initialize( RendererFactoryCache& factoryCache, const Property::Map& propertyMap );
77 * @copydoc Toolkit::ControlRenderer::SetSize
79 virtual void SetSize( const Vector2& size );
82 * @copydoc Toolkit::ControlRenderer::GetSize
84 const Vector2& GetSize() const;
87 * @copydoc Toolkit::ControlRenderer::GetNaturalSize
89 virtual void GetNaturalSize( Vector2& naturalSize ) const;
92 * ToDo: Add this function to Toolkit::ControlRenderer when it is fully implemented.
94 * Set the clip rectangular of this renderer.
95 * The contents of the renderer will not be visible outside this rectangular.
97 * @param [in] clipRect The clipping rectangular.
99 virtual void SetClipRect( const Rect<int>& clipRect );
102 *ToDo: Add this function to Toolkit::ControlRenderer when it is fully implemented.
104 * Reposition this renderer with a 2D offset.
106 * @param[in] offset The offset to reposition the renderer.
108 virtual void SetOffset( const Vector2& offset );
111 * @copydoc Toolkit::ControlRenderer::SetDepthIndex
113 void SetDepthIndex( float index );
116 * @copydoc Toolkit::ControlRenderer::GetDepthIndex
118 float GetDepthIndex() const;
121 * @copydoc Toolkit::ControlRenderer::SetOnStage
122 * @pre Impl->mGeometry must be created before this method is called
124 void SetOnStage( Actor& actor );
127 * @copydoc Toolkit::ControlRenderer::SetOffStage
129 void SetOffStage( Actor& actor );
132 * @copydoc Toolkit::ControlRenderer::CreatePropertyMap
134 void CreatePropertyMap( Property::Map& map ) const;
139 * @brief Constructor.
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( RendererFactoryCache& factoryCache, const Property::Map& propertyMap ) = 0;
167 * @brief Called by SetOnStage() allowing sub classes to respond to the SetOnStage event
169 * @param[in] actor The actor applying this renderer.
171 virtual void DoSetOnStage( Actor& actor );
174 * @brief Called by SetOffStage() allowing sub classes to respond to the SetOffStage event
176 * @param[in] actor The actor applying this renderer.
178 virtual void DoSetOffStage( Actor& actor );
183 ControlRenderer( const ControlRenderer& renderer );
186 ControlRenderer& operator=( const ControlRenderer& renderer );
193 } // namespace Internal
195 inline const Internal::ControlRenderer& GetImplementation(const Toolkit::ControlRenderer& renderer)
197 DALI_ASSERT_ALWAYS( renderer && "ControlRenderer handle is empty" );
199 const BaseObject& handle = renderer.GetBaseObject();
201 return static_cast<const Internal::ControlRenderer&>(handle);
204 inline Internal::ControlRenderer& GetImplementation(Toolkit::ControlRenderer& renderer)
206 DALI_ASSERT_ALWAYS( renderer && "ControlRenderer handle is empty" );
208 BaseObject& handle = renderer.GetBaseObject();
210 return static_cast<Internal::ControlRenderer&>(handle);
213 } // namespace Toolkit
217 #endif /* __DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_H___ */