Merge "Make -DUSE_DEFAULT_RESOURCE_DIR=OFF compile again" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / color / color-visual.h
1 #ifndef DALI_TOOLKIT_INTERNAL_COLOR_VISUAL_H
2 #define DALI_TOOLKIT_INTERNAL_COLOR_VISUAL_H
3
4 /*
5  * Copyright (c) 2020 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
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/intrusive-ptr.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Internal
34 {
35
36 class ColorVisual;
37 typedef IntrusivePtr< ColorVisual > ColorVisualPtr;
38
39 /**
40  * The visual which renders a solid color to the control's quad
41  *
42  * The following properties are required for create a ColorRender
43  *
44  * | %Property Name  | Type        |
45  * |-----------------|-------------|
46  * | mixColor        | VECTOR4     |
47  */
48 class ColorVisual: public Visual::Base
49 {
50 public:
51
52   /**
53    * @brief Create a new color visual.
54    *
55    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
56    * @param[in] properties A Property::Map containing settings for this visual
57    * @return A smart-pointer to the newly allocated visual.
58    */
59   static ColorVisualPtr New( VisualFactoryCache& factoryCache, const Property::Map& properties );
60
61 public:  // from Visual
62
63   /**
64    * @copydoc Visual::Base::CreatePropertyMap
65    */
66   void DoCreatePropertyMap( Property::Map& map ) const override;
67
68   /**
69    * @copydoc Visual::Base::CreateInstancePropertyMap
70    */
71   void DoCreateInstancePropertyMap( Property::Map& map ) const override;
72
73 protected:
74
75   /**
76    * @brief Constructor.
77    *
78    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
79    */
80   ColorVisual( VisualFactoryCache& factoryCache );
81
82   /**
83    * @brief A reference counted object may only be deleted by calling Unreference().
84    */
85   virtual ~ColorVisual();
86
87   /**
88    * @copydoc Visual::Base::DoSetProperties
89    */
90   void DoSetProperties( const Property::Map& propertyMap ) override;
91
92   /**
93    * @copydoc Visual::Base::DoSetOnScene
94    */
95   void DoSetOnScene( Actor& actor ) override;
96
97   /**
98    * @copydoc Visual::Base::DoSetOffScene
99    */
100   void DoSetOffScene(Actor& actor) override;
101
102   /**
103    * @copydoc Visual::Base::OnSetTransform
104    */
105   void OnSetTransform() override;
106
107   /**
108    * @copydoc Visual::Base::OnDoAction
109    */
110   void OnDoAction( const Property::Index actionId, const Property::Value& attributes ) override;
111
112   /**
113    * @copydoc Visual::Base::UpdateShader
114    */
115   void UpdateShader() override;
116
117   /**
118    * @copydoc Visual::Base::OnGetPropertyObject
119    */
120   Dali::Property OnGetPropertyObject(Dali::Property::Key key) override;
121
122 private:
123   /**
124    * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
125    */
126   void InitializeRenderer();
127
128   /**
129    * @brief Get a shader for the current properties.
130    * @return The shader for the current properties.
131    */
132   Shader GetShader();
133
134 private:
135
136   // Undefined
137   ColorVisual( const ColorVisual& colorRenderer );
138
139   // Undefined
140   ColorVisual& operator=( const ColorVisual& colorRenderer );
141
142 private:
143   float           mBlurRadius;          ///< The blur radius
144   Property::Index mBlurRadiusIndex;     ///< The blur radius property index
145   bool            mRenderIfTransparent; ///< Whether we should render even if the mix-color is transparent.
146   bool            mNeedBlurRadius;      ///< Whether we need the blur radius in shader.
147 };
148
149 } // namespace Internal
150
151 } // namespace Toolkit
152
153 } // namespace Dali
154
155 #endif /* DALI_TOOLKIT_INTERNAL_COLOR_VISUAL_H */