1 #ifndef __DALI_TOOLKIT_INTERNAL_GRADIENT_RENDERER_H__
2 #define __DALI_TOOLKIT_INTERNAL_GRADIENT_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.
22 #include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
23 #include <dali-toolkit/internal/controls/renderers/gradient/gradient.h>
38 * The renderer which renders smooth transition of colors to the control's quad.
39 * It supports two types of gradients: linear and radial.
41 * The following properties are essential for create a LINEAR GradientRender
43 * | %Property Name | Type |
44 * |-------------------------|------------------|
45 * | gradientStartPosition | VECTOR2 |
46 * | gradientEndPosition | VECTOR2 |
47 * | gradientStopOffset | ARRAY of FLOAT |
48 * | gradientStopColor | ARRAY of VECTOR4 |
50 * The following properties are essential for create a RADIAL GradientRender
52 * | %Property Name | Type |
53 * |-------------------------|------------------|
54 * | gradientCenter | VECTOR2 |
55 * | gradientRadius | FLOAT |
56 * | gradientStopOffset | ARRAY of FLOAT |
57 * | gradientStopColor | ARRAY of VECTOR4 |
59 * The following properties are optional for both LINEAR and RADIAL GradientRender.
61 * | %Property Name | Type |
62 * |-------------------------|------------------|
63 * | gradientUnits | STRING |
64 * | gradientSpreadMethod | STRING |
66 * Valid values for gradientUnits are 'userSpace' and 'objectBoundingBox'.
67 * Valid values for gradientSpreadMethod are 'pad', 'repeat' and 'reflect.'
68 * If not provided, 'objectBoundingBox' is used as default gradient units, and 'pad' is used as default spread method.
70 class GradientRenderer: public ControlRenderer
75 * Types of the gradient
86 * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
88 GradientRenderer( RendererFactoryCache& factoryCache );
91 * @brief A reference counted object may only be deleted by calling Unreference().
95 public: // from ControlRenderer
98 * @copydoc ControlRenderer::SetSize
100 virtual void SetSize( const Vector2& size );
103 * @copydoc ControlRenderer::SetClipRect
105 virtual void SetClipRect( const Rect<int>& clipRect );
108 * @copydoc ControlRenderer::SetOffset
110 virtual void SetOffset( const Vector2& offset );
113 * @copydoc ControlRenderer::CreatePropertyMap
115 virtual void DoCreatePropertyMap( Property::Map& map ) const;
119 * @copydoc ControlRenderer::DoInitialize
121 virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
124 * @copydoc ControlRenderer::DoSetOnStage
126 virtual void DoSetOnStage( Actor& actor );
131 * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
133 void InitializeRenderer();
136 * New a gradient object with the given property map.
138 * @return True if the property map provides valid properties to create a gradient. Otherwise, returns false.
140 bool NewGradient(Type gradientType, const Property::Map& propertyMap);
143 * Get the stop-offsets from the property.
144 * The valid property type are ARRAY, VECTOR2, VECTOR3, VECTOR4.
146 * @param[in] value The property value of stop-offsets
147 * @param[out] stopOffsets The vector contains the stop offset values.
149 static bool GetStopOffsets(const Property::Value* value, Vector<float>& stopOffsets);
152 GradientRenderer( const GradientRenderer& gradientRenderer );
155 GradientRenderer& operator=( const GradientRenderer& gradientRenderer );
159 Matrix3 mGradientTransform;
160 IntrusivePtr<Gradient> mGradient;
164 } // namespace Internal
166 } // namespace Toolkit
170 #endif /* __DALI_TOOLKIT_INTERNAL_GRADIENT_RENDERER_H__ */