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;
136 * @brief Set whether the Pre-multiplied Alpha Blending is required
138 * @param[in] preMultipled whether alpha is pre-multiplied.
140 void EnablePreMultipliedAlpha( bool preMultipled );
143 * @brief Query whether alpha is pre-multiplied.
145 * @return True is alpha is pre-multiplied, false otherwise.
147 bool IsPreMultipliedAlphaEnabled() const;
150 * @brief Sets properties of custom shader
151 * @param[in] propertyMap Property map containing the custom shader data
153 void SetCustomShader( const Property::Map& propertyMap );
158 * @brief Constructor.
160 * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
162 ControlRenderer( RendererFactoryCache& factoryCache );
165 * @brief A reference counted object may only be deleted by calling Unreference().
167 virtual ~ControlRenderer();
171 * @brief Called by CreatePropertyMap() allowing sub classes to respond to the CreatePropertyMap event
173 * @param[out] map The renderer property map.
175 virtual void DoCreatePropertyMap( Property::Map& map ) const = 0;
178 * @brief Called by Initialize() allowing sub classes to respond to the Initialize event
180 * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
181 * @param[in] propertyMap The properties for the requested ControlRenderer object.
183 virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap ) {};
188 * @brief Called by SetOnStage() allowing sub classes to respond to the SetOnStage event
190 * @param[in] actor The actor applying this renderer.
192 virtual void DoSetOnStage( Actor& actor );
195 * @brief Called by SetOffStage() allowing sub classes to respond to the SetOffStage event
197 * @param[in] actor The actor applying this renderer.
199 virtual void DoSetOffStage( Actor& actor );
203 * @brief Gets the on stage state for this ControlRenderer
205 * @return Returns true if this ControlRenderer is on stage, false if it is off the stage
207 bool GetIsOnStage() const;
210 * @brief Gets whether the Dali::Renderer is from a shared cache (and therefore any modifications will affect other users of that renderer)
212 * @return Returns true if the renderer is from shared cache, false otherwise
214 bool GetIsFromCache() const;
219 ControlRenderer( const ControlRenderer& renderer );
222 ControlRenderer& operator=( const ControlRenderer& renderer );
227 RendererFactoryCache& mFactoryCache;
230 } // namespace Internal
232 inline const Internal::ControlRenderer& GetImplementation(const Toolkit::ControlRenderer& renderer)
234 DALI_ASSERT_ALWAYS( renderer && "ControlRenderer handle is empty" );
236 const BaseObject& handle = renderer.GetBaseObject();
238 return static_cast<const Internal::ControlRenderer&>(handle);
241 inline Internal::ControlRenderer& GetImplementation(Toolkit::ControlRenderer& renderer)
243 DALI_ASSERT_ALWAYS( renderer && "ControlRenderer handle is empty" );
245 BaseObject& handle = renderer.GetBaseObject();
247 return static_cast<Internal::ControlRenderer&>(handle);
250 } // namespace Toolkit
254 #endif /* __DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_H___ */