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 * | customShader | MAP |
52 * where custom-shader is a map with the following properties:
53 * | %Property Name | Type |
54 * |-------------------------|------------------|
55 * | vertexShader | STRING |
56 * | fragmentShader | STRING |
57 * | subdivideGridX | INT |
58 * | subdivideGridY | INT |
59 * | shaderHints | 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] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
71 * @param[in] propertyMap The properties for the requested ControlRenderer object.
73 void Initialize( Actor& actor, const Property::Map& propertyMap );
76 * @copydoc Toolkit::ControlRenderer::SetSize
78 virtual void SetSize( const Vector2& size );
81 * @copydoc Toolkit::ControlRenderer::GetSize
83 const Vector2& GetSize() const;
86 * @copydoc Toolkit::ControlRenderer::GetNaturalSize
88 virtual void GetNaturalSize( Vector2& naturalSize ) const;
91 * ToDo: Add this function to Toolkit::ControlRenderer when it is fully implemented.
93 * Set the clip rectangular of this renderer.
94 * The contents of the renderer will not be visible outside this rectangular.
96 * @param [in] clipRect The clipping rectangular.
98 virtual void SetClipRect( const Rect<int>& clipRect );
101 *ToDo: Add this function to Toolkit::ControlRenderer when it is fully implemented.
103 * Reposition this renderer with a 2D offset.
105 * @param[in] offset The offset to reposition the renderer.
107 virtual void SetOffset( const Vector2& offset );
110 * @copydoc Toolkit::ControlRenderer::SetDepthIndex
112 void SetDepthIndex( float index );
115 * @copydoc Toolkit::ControlRenderer::GetDepthIndex
117 float GetDepthIndex() const;
120 * @copydoc Toolkit::ControlRenderer::SetOnStage
121 * @pre Impl->mGeometry must be created before this method is called
123 void SetOnStage( Actor& actor );
126 * @copydoc Toolkit::ControlRenderer::SetOffStage
128 void SetOffStage( Actor& actor );
131 * @copydoc Toolkit::ControlRenderer::CreatePropertyMap
133 void CreatePropertyMap( Property::Map& map ) const;
138 * @brief Constructor.
140 * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
142 ControlRenderer( RendererFactoryCache& factoryCache );
145 * @brief A reference counted object may only be deleted by calling Unreference().
147 virtual ~ControlRenderer();
151 * @brief Called by CreatePropertyMap() allowing sub classes to respond to the CreatePropertyMap event
153 * @param[out] map The renderer property map.
155 virtual void DoCreatePropertyMap( Property::Map& map ) const = 0;
158 * @brief Called by Initialize() allowing sub classes to respond to the Initialize event
160 * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
161 * @param[in] propertyMap The properties for the requested ControlRenderer object.
163 virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap ) = 0;
168 * @brief Called by SetOnStage() allowing sub classes to respond to the SetOnStage event
170 * @param[in] actor The actor applying this renderer.
172 virtual void DoSetOnStage( Actor& actor );
175 * @brief Called by SetOffStage() allowing sub classes to respond to the SetOffStage event
177 * @param[in] actor The actor applying this renderer.
179 virtual void DoSetOffStage( Actor& actor );
183 * @brief Gets the on stage state for this ControlRenderer
185 * @return Returns true if this ControlRenderer is on stage, false if it is off the stage
187 bool GetIsOnStage() const;
190 * @brief Gets whether the Dali::Renderer is from a shared cache (and therefore any modifications will affect other users of that renderer)
192 * @return Returns true if the renderer is from shared cache, false otherwise
194 bool GetIsFromCache() const;
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___ */