[dali_1.1.43] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / public-api / rendering / frame-buffer.h
1 #ifndef DALI_FRAMEBUFFER_H
2 #define DALI_FRAMEBUFFER_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/object/base-handle.h>
23 #include <dali/public-api/rendering/texture.h>
24
25 namespace Dali
26 {
27
28 namespace Internal DALI_INTERNAL
29 {
30 class FrameBuffer;
31 }
32
33 /**
34  * @brief FrameBuffer is a collection of textures that can be used as the destination for rendering
35  * @SINCE_1_1.43
36  */
37 class DALI_IMPORT_API FrameBuffer : public BaseHandle
38 {
39 public:
40
41   /**
42    * @brief Format of the FrameBuffer to be created.
43    * @SINCE_1_1.43
44    */
45   enum Format
46   {
47     COLOR,                ///< Framebuffer will be created with color buffer                                                               @SINCE_1_1.43
48     COLOR_DEPTH,          ///< Framebuffer will be created with color and depth buffer                                                     @SINCE_1_1.43
49     COLOR_STENCIL,        ///< Framebuffer will be created with color and stencil buffer                                                   @SINCE_1_1.43
50     COLOR_DEPTH_STENCIL   ///< Framebuffer will be created with color, depth and stencil buffer. @note May be not supported in all devices @SINCE_1_1.43
51   };
52
53   /**
54    * @brief Creates a new FrameBuffer object
55    *
56    * @SINCE_1_1.43
57    * @param[in] width The width of the FrameBuffer
58    * @param[in] height The height of the FrameBuffer
59    * @param[in] format The format of the FrameBuffer
60    * @return A handle to a newly allocated FrameBuffer
61    */
62   static FrameBuffer New( unsigned int width, unsigned int height, Format format );
63
64   /**
65    * @brief Default constructor, creates an empty handle
66    */
67   FrameBuffer();
68
69   /**
70    * @brief Destructor
71    * @SINCE_1_1.43
72    */
73   ~FrameBuffer();
74
75   /**
76    * @brief Copy constructor, creates a new handle to the same object
77    *
78    * @SINCE_1_1.43
79    * @param[in] handle Handle to an object
80    */
81   FrameBuffer( const FrameBuffer& handle );
82
83   /**
84    * @brief Downcast to a FrameBuffer.
85    *
86    * @SINCE_1_1.43
87    * If not the returned handle is left uninitialized.
88    * @param[in] handle Handle to an object
89    * @return FrameBuffer handle or an uninitialized handle
90    */
91   static FrameBuffer DownCast( BaseHandle handle );
92
93   /**
94    * @brief Assignment operator, changes this handle to point at the same object
95    *
96    * @SINCE_1_1.43
97    * @param[in] handle Handle to an object
98    * @return Reference to the assigned object
99    */
100   FrameBuffer& operator=( const FrameBuffer& handle );
101
102   /**
103    * @brief Attach the base LOD of a 2D texture to the framebuffer for color rendering
104    *
105    * @SINCE_1_1.43
106    * @param[in] texture The texture that will be used as output when rendering
107    * @note The texture has to have the same size than the FrameBuffer
108    * otherwise it won't be attached
109    */
110   void AttachColorTexture( Texture& texture );
111
112   /**
113    * @brief Attach a texture to the framebuffer for color rendering
114    *
115    * @SINCE_1_1.43
116    * @param[in] texture The texture that will be used as output when rendering
117    * @param[in] mipmapLevel The mipmap of the texture to be attached
118    * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
119    * @note The specified texture mipmap has to have the same size than the FrameBuffer
120    * otherwise it won't be attached
121    */
122   void AttachColorTexture( Texture& texture, unsigned int mipmapLevel, unsigned int layer );
123
124   /**
125    * @brief Get the color texture used as output in the FrameBuffer
126    *
127    * @SINCE_1_1.43
128    * @returns A handle to the texture used as color output, or an uninitialized handle
129    */
130   Texture GetColorTexture();
131
132 public:
133
134   /**
135    * @brief The constructor.
136    * @note  Not intended for application developers.
137    * @SINCE_1_1.43
138    * @param[in] pointer A pointer to a newly allocated FrameBuffer
139    */
140   explicit DALI_INTERNAL FrameBuffer( Internal::FrameBuffer* pointer );
141 };
142
143 } //namespace Dali
144
145 #endif // DALI_FRAMEBUFFER_H