Added GetImage() and GetSampler() and GetTextureCount() to TextureSet
[platform/core/uifw/dali-core.git] / dali / devel-api / rendering / renderer.h
1 #ifndef DALI_RENDERER_H
2 #define DALI_RENDERER_H
3
4 /*
5  * Copyright (c) 2016 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/actors/blending.h> // Dali::BlendingMode, Dali::BlendingEquation, Dali::BlendingFactor
23 #include <dali/public-api/object/handle.h> // Dali::Handle
24 #include <dali/public-api/object/property-index-ranges.h> // DEFAULT_OBJECT_PROPERTY_START_INDEX
25 #include <dali/devel-api/rendering/geometry.h> // Dali::Geometry
26 #include <dali/devel-api/rendering/texture-set.h> // Dali::TextureSet
27
28 namespace Dali
29 {
30
31 namespace Internal DALI_INTERNAL
32 {
33 class Renderer;
34 }
35
36 /**
37  * @brief Renderer is a handle to an object used to show content by combining a Geometry, a TextureSet and a shader
38  */
39 class DALI_IMPORT_API Renderer : public Handle
40 {
41 public:
42
43   /**
44    * @brief Set face culling mode.
45    */
46   enum FaceCullingMode
47   {
48     NONE,                     ///< None of the faces should be culled
49     CULL_FRONT,               ///< Cull front face, back face should never be shown
50     CULL_BACK,                ///< Cull back face, back face should never be shown
51     CULL_BACK_AND_FRONT,      ///< Cull back and front faces, if the geometry is composed of triangles none of the faces will be shown
52   };
53
54   /**
55    * @brief An enumeration of properties belonging to the Renderer class.
56    */
57   struct Property
58   {
59     enum
60     {
61       DEPTH_INDEX = DEFAULT_OBJECT_PROPERTY_START_INDEX,  ///< name "depthIndex",                     type INTEGER
62       FACE_CULLING_MODE,                                  ///< name "faceCullingMode",                type INTEGER
63       BLENDING_MODE,                                      ///< name "blendingMode",                   type INTEGER
64       BLEND_EQUATION_RGB,                                 ///< name "blendEquationRgb",               type INTEGER
65       BLEND_EQUATION_ALPHA,                               ///< name "blendEquationAlpha",             type INTEGER
66       BLENDING_SRC_FACTOR_RGB,                            ///< name "sourceBlendFactorRgb",           type INTEGER
67       BLENDING_DEST_FACTOR_RGB,                           ///< name "destinationBlendFactorRgb",      type INTEGER
68       BLENDING_SRC_FACTOR_ALPHA,                          ///< name "sourceBlendFactorAlpha",         type INTEGER
69       BLENDING_DEST_FACTOR_ALPHA,                         ///< name "destinationBlendFactorAlpha",    type INTEGER
70       BLENDING_COLOR,                                     ///< name "blendingColor",                  type VECTOR4
71       BLEND_PRE_MULTIPLIED_ALPHA,                         ///< name "blendPreMultipledAlpha",         type BOOLEAN
72     };
73   };
74
75   /**
76    * @brief Creates a new Renderer object
77    *
78    * @param[in] geometry Geometry to be used by this renderer
79    * @param[in] shader Shader to be used by this renderer
80    */
81   static Renderer New( Geometry& geometry, Shader& shader );
82
83   /**
84    * @brief Default constructor, creates an empty handle
85    */
86   Renderer();
87
88   /**
89    * @brief Destructor
90    */
91   ~Renderer();
92
93   /**
94    * @brief Copy constructor, creates a new handle to the same object
95    *
96    * @param[in] handle Handle to an object
97    */
98   Renderer( const Renderer& handle );
99
100   /**
101    * @brief Downcast to a renderer handle.
102    *
103    * If not a renderer the returned renderer handle is left uninitialized.
104    * @param[in] handle to an object
105    * @return renderer handle or an uninitialized handle
106    */
107   static Renderer DownCast( BaseHandle handle );
108
109   /**
110    * @brief Assignment operator, changes this handle to point at the same object
111    *
112    * @param[in] handle Handle to an object
113    * @return Reference to the assigned object
114    */
115   Renderer& operator=( const Renderer& handle );
116
117   /**
118    * @brief Sets the geometry to be used by this renderer
119    *
120    * @param[in] geometry The geometry to be used by this renderer
121    */
122   void SetGeometry( Geometry& geometry );
123
124   /**
125    * @brief Gets the geometry used by this renderer
126    *
127    * @return The geometry used by the renderer
128    */
129   Geometry GetGeometry() const;
130
131   /**
132    * @brief Sets the texture set to be used by this renderer
133    *
134    * @param[in] textureSet The texture set to be used by this renderer
135    */
136   void SetTextures( TextureSet& textureSet );
137
138   /**
139    * @brief Gets the texture set used by this renderer
140    *
141    * @return The texture set used by the renderer
142    */
143   TextureSet GetTextures() const;
144
145   /**
146    * @brief Set the shader used by this renderer
147    * @param[in] shader The shader to be used by this renderer
148    */
149   void SetShader( Shader& shader );
150
151   /**
152    * @brief Get the shader used by this renderer
153    * @return THe shader used by the renderer
154    */
155   Shader GetShader() const;
156
157   /**
158    * @brief Specify the pixel arithmetic used when the actor is blended.
159    *
160    * @param[in] srcFactorRgba Specifies how the red, green, blue, and alpha source blending factors are computed.
161    * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
162    * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
163    * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE.
164    *
165    * @param[in] destFactorRgba Specifies how the red, green, blue, and alpha destination blending factors are computed.
166    * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
167    * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
168    * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA.
169    */
170   void SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba );
171
172   /**
173    * @brief Specify the pixel arithmetic used when the actor is blended.
174    *
175    * @param[in] srcFactorRgb Specifies how the red, green, and blue source blending factors are computed.
176    * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
177    * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
178    * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE.
179    *
180    * @param[in] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed.
181    * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
182    * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
183    * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA.
184    *
185    * @param[in] srcFactorAlpha Specifies how the alpha source blending factor is computed.
186    * The options are the same as for srcFactorRgb.
187    *
188    * @param[in] destFactorAlpha Specifies how the alpha source blending factor is computed.
189    * The options are the same as for destFactorRgb.
190    */
191   void SetBlendFunc( BlendingFactor::Type srcFactorRgb,   BlendingFactor::Type destFactorRgb,
192                      BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha );
193
194   /**
195    * @brief Query the pixel arithmetic used when the actor is blended.
196    *
197    * @param[out] srcFactorRgb Specifies how the red, green, blue, and alpha source blending factors are computed.
198    * @param[out] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed.
199    * @param[out] srcFactorAlpha Specifies how the red, green, blue, and alpha source blending factors are computed.
200    * @param[out] destFactorAlpha Specifies how the red, green, blue, and alpha destination blending factors are computed.
201    */
202   void GetBlendFunc( BlendingFactor::Type& srcFactorRgb,   BlendingFactor::Type& destFactorRgb,
203                      BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const;
204
205   /**
206    * @brief Specify the equation used when the actor is blended.
207    *
208    * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT.
209    * @param[in] equationRgba The equation used for combining red, green, blue, and alpha components.
210    */
211   void SetBlendEquation( BlendingEquation::Type equationRgba );
212
213   /**
214    * @brief Specify the equation used when the actor is blended.
215    *
216    * @param[in] equationRgb The equation used for combining red, green, and blue components.
217    * @param[in] equationAlpha The equation used for combining the alpha component.
218    * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT.
219    */
220   void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha );
221
222   /**
223    * @brief Query the equation used when the actor is blended.
224    *
225    * @param[out] equationRgb The equation used for combining red, green, and blue components.
226    * @param[out] equationAlpha The equation used for combining the alpha component.
227    */
228   void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const;
229
230 public:
231   /**
232    * @brief The constructor
233    *
234    * @param [in] pointer A pointer to a newly allocated Renderer
235    */
236   explicit DALI_INTERNAL Renderer( Internal::Renderer* pointer );
237 };
238
239 } //namespace Dali
240
241 #endif // DALI_RENDERER_H