Anti-Aliasing of BorderRenderer
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / renderers / border / border-renderer.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_BORDER_RENDERER_H__
2 #define __DALI_TOOLKIT_INTERNAL_BORDER_RENDERER_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20 // EXTERNAL INCLUDES
21 #include <dali/devel-api/rendering/geometry.h>
22
23 // INTERNAL INCLUDES
24 #include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
25
26 namespace Dali
27 {
28
29 namespace Toolkit
30 {
31
32 namespace Internal
33 {
34
35 /**
36  * The renderer which renders a solid color to the control's quad border fixed to a specified size.
37  *
38  * The following properties are required for create a BorderRender
39  *
40  * | %Property Name  | Type        |
41  * |-----------------|-------------|
42  * | borderColor     | VECTOR4     |
43  * | borderSize      | FLOAT       |
44  * | antiAliasing    | BOOLEAN     |
45  */
46
47 class BorderRenderer : public ControlRenderer
48 {
49 public:
50
51   /**
52    * @brief Constructor.
53    *
54    * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
55    */
56   BorderRenderer( RendererFactoryCache& factoryCache );
57
58   /**
59    * @brief A reference counted object may only be deleted by calling Unreference().
60    */
61   virtual ~BorderRenderer();
62
63 public:  // from ControlRenderer
64
65   /**
66    * @copydoc ControlRenderer::SetClipRect
67    */
68   virtual void SetClipRect( const Rect<int>& clipRect );
69
70 protected:
71
72   /**
73    * @copydoc ControlRenderer::DoInitialize
74    */
75   virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
76
77   /**
78    * @copydoc ControlRenderer::DoSetOnStage
79    */
80   virtual void DoSetOnStage( Actor& actor );
81
82   /**
83    * @copydoc ControlRenderer::CreatePropertyMap
84    */
85   virtual void DoCreatePropertyMap( Property::Map& map ) const;
86
87 public:
88
89   /**
90    * Set the color of the border.
91    * @param[in] color The border color.
92    */
93   void SetBorderColor( const Vector4& color);
94
95   /**
96    * Set the size of the border.
97    * @param[in] size The border size.
98    */
99   void SetBorderSize( float size );
100
101   /**
102    * Enable/Disable the anti-aliasing.
103    * @param[in] enable Whether the anti-aliasing be enabled or not.
104    */
105   void RequireAntiAliasing( bool antiAliasing );
106
107 private:
108
109   /**
110    * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
111    */
112   void InitializeRenderer();
113
114   /**
115    * Request the border shader from the factory cache. If fail, create tha shader and add it to cache.
116    * @return The border shader.
117    */
118   Shader GetBorderShader();
119
120   /**
121    * Create the geometry which presents the border.
122    * @return The border geometry
123    */
124   Geometry CreateBorderGeometry();
125
126   // Undefined
127   BorderRenderer( const BorderRenderer& borderRenderer );
128
129   // Undefined
130   BorderRenderer& operator=( const BorderRenderer& borderRenderer );
131
132 private:
133
134   Vector4 mBorderColor;
135   float   mBorderSize;
136
137   Property::Index mBorderColorIndex;
138   Property::Index mBorderSizeIndex;
139
140   bool mAntiAliasing;
141 };
142
143 } // namespace Internal
144
145 } // namespace Toolkit
146
147 } // namespace Dali
148
149 #endif /* __DALI_TOOLKIT_INTERNAL_BORDER_RENDERER_H__ */