Merge "Fix webp&gif issue" 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) 2022 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 namespace Toolkit
30 {
31 namespace Internal
32 {
33 class ColorVisual;
34 typedef IntrusivePtr<ColorVisual> ColorVisualPtr;
35
36 /**
37  * The visual which renders a solid color to the control's quad
38  *
39  * The following properties are required for create a ColorRender
40  *
41  * | %Property Name  | Type        |
42  * |-----------------|-------------|
43  * | mixColor        | VECTOR4     |
44  */
45 class ColorVisual : public Visual::Base
46 {
47 public:
48   /**
49    * @brief Create a new color visual.
50    *
51    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
52    * @param[in] properties A Property::Map containing settings for this visual
53    * @return A smart-pointer to the newly allocated visual.
54    */
55   static ColorVisualPtr New(VisualFactoryCache& factoryCache, const Property::Map& properties);
56
57 public: // from Visual
58   /**
59    * @copydoc Visual::Base::CreatePropertyMap
60    */
61   void DoCreatePropertyMap(Property::Map& map) const override;
62
63   /**
64    * @copydoc Visual::Base::CreateInstancePropertyMap
65    */
66   void DoCreateInstancePropertyMap(Property::Map& map) const override;
67
68   /**
69    * @copydoc Visual::Base::EnablePreMultipliedAlpha
70    */
71   void EnablePreMultipliedAlpha(bool preMultiplied) override;
72
73 protected:
74   /**
75    * @brief Constructor.
76    *
77    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
78    */
79   ColorVisual(VisualFactoryCache& factoryCache);
80
81   /**
82    * @brief A reference counted object may only be deleted by calling Unreference().
83    */
84   virtual ~ColorVisual();
85
86   /**
87    * @copydoc Visual::Base::OnInitialize
88    */
89   void OnInitialize() override;
90
91   /**
92    * @copydoc Visual::Base::DoSetProperties
93    */
94   void DoSetProperties(const Property::Map& propertyMap) override;
95
96   /**
97    * @copydoc Visual::Base::DoSetOnScene
98    */
99   void DoSetOnScene(Actor& actor) override;
100
101   /**
102    * @copydoc Visual::Base::DoSetOffScene
103    */
104   void DoSetOffScene(Actor& actor) override;
105
106   /**
107    * @copydoc Visual::Base::OnSetTransform
108    */
109   void OnSetTransform() override;
110
111   /**
112    * @copydoc Visual::Base::UpdateShader
113    */
114   void UpdateShader() override;
115
116   /**
117    * @copydoc Visual::Base::GenerateShader
118    */
119   Shader GenerateShader() const override;
120
121   /**
122    * @copydoc Visual::Base::OnGetPropertyObject
123    */
124   Dali::Property OnGetPropertyObject(Dali::Property::Key key) override;
125
126 private:
127   // Undefined
128   ColorVisual(const ColorVisual& colorRenderer);
129
130   // Undefined
131   ColorVisual& operator=(const ColorVisual& colorRenderer);
132
133 private:
134   float           mBlurRadius;                ///< The blur radius
135   Property::Index mBlurRadiusIndex;           ///< The blur radius property index
136   bool            mAlwaysUsingBlurRadius : 1; ///< Whether we need the blur radius in shader always.
137 };
138
139 } // namespace Internal
140
141 } // namespace Toolkit
142
143 } // namespace Dali
144
145 #endif /* DALI_TOOLKIT_INTERNAL_COLOR_VISUAL_H */