Make blend for the opaque renderer when advanced blend equation is applied.
[platform/core/uifw/dali-core.git] / dali / internal / common / blending-options.h
1 #ifndef DALI_BLENDING_OPTIONS_H
2 #define DALI_BLENDING_OPTIONS_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 // INTERNAL INCLUDES
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/devel-api/rendering/renderer-devel.h>
24 #include <dali/public-api/math/vector4.h>
25 #include <dali/internal/common/owner-pointer.h>
26
27 namespace Dali
28 {
29
30 namespace Internal
31 {
32
33 // This is an optimization to avoid storing 6 separate blending values
34 struct BlendingOptions
35 {
36   /**
37    * Create some default blending options.
38    */
39   BlendingOptions();
40
41   /**
42    * Non-virtual destructor.
43    */
44   ~BlendingOptions();
45
46   /**
47    * Set the blending options.
48    * @param[in] A bitmask of blending options.
49    */
50   void SetBitmask( unsigned int bitmask );
51
52   /**
53    * Retrieve the blending options as a bitmask.
54    * @return A bitmask of blending options.
55    */
56   unsigned int GetBitmask() const;
57
58   /**
59    * @copydoc Dali::RenderableActor::SetBlendFunc()
60    */
61   void SetBlendFunc( BlendFactor::Type srcFactorRgb,   BlendFactor::Type destFactorRgb,
62                      BlendFactor::Type srcFactorAlpha, BlendFactor::Type destFactorAlpha );
63
64   /**
65    * @copydoc Dali::RenderableActor::GetBlendFunc()
66    */
67   BlendFactor::Type GetBlendSrcFactorRgb() const;
68
69   /**
70    * @copydoc Dali::RenderableActor::GetBlendFunc()
71    */
72   BlendFactor::Type GetBlendDestFactorRgb() const;
73
74   /**
75    * @copydoc Dali::RenderableActor::GetBlendFunc()
76    */
77   BlendFactor::Type GetBlendSrcFactorAlpha() const;
78
79   /**
80    * @copydoc Dali::RenderableActor::GetBlendFunc()
81    */
82   BlendFactor::Type GetBlendDestFactorAlpha() const;
83
84   /**
85    * @copydoc Dali::RenderableActor::SetBlendEquation()
86    */
87   void SetBlendEquation( DevelBlendEquation::Type equationRgb, DevelBlendEquation::Type equationAlpha );
88
89   /**
90    * @copydoc Dali::RenderableActor::GetBlendEquation()
91    */
92   DevelBlendEquation::Type GetBlendEquationRgb() const;
93
94   /**
95    * @copydoc Dali::RenderableActor::GetBlendEquation()
96    */
97   DevelBlendEquation::Type GetBlendEquationAlpha() const;
98
99   /**
100    * Set the blend color.
101    * @param[in] color The blend color.
102    * @return True if the blend color changed, otherwise it was already the same color.
103    */
104   void SetBlendColor( const Vector4& color );
105
106   /**
107    * Query the blend color.
108    * The blend color, or NULL if no blend color was set.
109    */
110   const Vector4* GetBlendColor() const;
111
112   /**
113    * Query whether current blend equation is advanced option.
114    * @return True if current blend equation is advanced.
115    */
116   bool IsAdvancedBlendEquationApplied();
117
118   /**
119    * Query whether input bit mask include advanced blend equation.
120    * @return True if the bit mask include advanced blend equation.
121    */
122   static bool IsAdvancedBlendEquationIncluded( unsigned int bitmask );
123
124   /**
125    * Query whether input blend equation is advanced option.
126    * @return True if input blend equation is advanced.
127    */
128   static bool IsAdvancedBlendEquation( DevelBlendEquation::Type equation );
129
130 private:
131
132   // Undefined copy constructor.
133   BlendingOptions(const BlendingOptions& typePath);
134
135   // Undefined copy constructor.
136   BlendingOptions& operator=(const BlendingOptions& rhs);
137
138 private:
139
140   unsigned int mBitmask; ///< A bitmask of blending options
141
142   OwnerPointer< Vector4> mBlendColor; ///< A heap-allocated color (owned)
143
144 };
145
146 } // namespace Internal
147
148 } // namespace Dali
149
150 #endif // DALI_BLENDING_OPTIONS_H