Seperate the API macros
[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) 2018 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_CORE_API FrameBuffer : public BaseHandle
38 {
39 public:
40
41   /**
42    * @brief The initial attachments to create the FrameBuffer with.
43    * @note The color attachment is created on calling AttachColorTexture(). If a color attachment is not required, omit this call.
44    * @note With "NONE", no attachments are created initially. However color attachments can still be added as described above.
45    *
46    * @SINCE_1_1.45
47    */
48   struct Attachment
49   {
50     /**
51      * @brief Enumeration for the bit-mask value.
52      * @SINCE_1_1.45
53      */
54     enum Mask
55     {
56       NONE          = 0,               ///< No attachments are created initially                            @SINCE_1_1.45
57
58       DEPTH         = 1 << 0,          ///< Depth buffer bit-mask value                                     @SINCE_1_1.45
59       STENCIL       = 1 << 1,          ///< Stencil buffer bit-mask value                                   @SINCE_1_1.45
60
61       // Preset bit-mask combinations:
62       DEPTH_STENCIL = DEPTH | STENCIL  ///< The Framebuffer will be created with depth and stencil buffer   @SINCE_1_1.45
63     };
64   };
65
66   /**
67    * @brief Creates a new FrameBuffer object.
68    *
69    * @SINCE_1_1.43
70    * @param[in] width The width of the FrameBuffer
71    * @param[in] height The height of the FrameBuffer
72    * @param[in] attachments The attachments comprising the format of the FrameBuffer (the type is int to allow multiple bitmasks to be ORd)
73    * @return A handle to a newly allocated FrameBuffer
74    */
75   static FrameBuffer New( unsigned int width, unsigned int height, unsigned int attachments );
76
77   /**
78    * @brief Default constructor, creates an empty handle.
79    */
80   FrameBuffer();
81
82   /**
83    * @brief Destructor.
84    * @SINCE_1_1.43
85    */
86   ~FrameBuffer();
87
88   /**
89    * @brief Copy constructor, creates a new handle to the same object.
90    *
91    * @SINCE_1_1.43
92    * @param[in] handle Handle to an object
93    */
94   FrameBuffer( const FrameBuffer& handle );
95
96   /**
97    * @brief Downcasts to a FrameBuffer.
98    * If not, the returned handle is left uninitialized.
99    * @SINCE_1_1.43
100    * @param[in] handle Handle to an object
101    * @return FrameBuffer handle or an uninitialized handle
102    */
103   static FrameBuffer DownCast( BaseHandle handle );
104
105   /**
106    * @brief Assignment operator, changes this handle to point at the same object.
107    *
108    * @SINCE_1_1.43
109    * @param[in] handle Handle to an object
110    * @return Reference to the assigned object
111    */
112   FrameBuffer& operator=( const FrameBuffer& handle );
113
114   /**
115    * @brief Attach the base LOD of a 2D texture to the framebuffer for color rendering.
116    * @note This causes a color attachment to be added.
117    *
118    * @SINCE_1_1.43
119    * @param[in] texture The texture that will be used as output when rendering
120    * @note The texture has to have the same size than the FrameBuffer
121    * otherwise it won't be attached.
122    */
123   void AttachColorTexture( Texture& texture );
124
125   /**
126    * @brief Attach a texture to the framebuffer for color rendering.
127    * @note This causes a color attachment to be added.
128    *
129    * @SINCE_1_1.43
130    * @param[in] texture The texture that will be used as output when rendering
131    * @param[in] mipmapLevel The mipmap of the texture to be attached
132    * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
133    * @note The specified texture mipmap has to have the same size than the FrameBuffer
134    * otherwise it won't be attached.
135    */
136   void AttachColorTexture( Texture& texture, unsigned int mipmapLevel, unsigned int layer );
137
138   /**
139    * @brief Gets the color texture used as output in the FrameBuffer.
140    *
141    * @SINCE_1_1.43
142    * @returns A handle to the texture used as color output, or an uninitialized handle
143    */
144   Texture GetColorTexture();
145
146 public:
147
148   /**
149    * @brief The constructor.
150    * @note  Not intended for application developers.
151    * @SINCE_1_1.43
152    * @param[in] pointer A pointer to a newly allocated FrameBuffer
153    */
154   explicit DALI_INTERNAL FrameBuffer( Internal::FrameBuffer* pointer );
155 };
156
157 } //namespace Dali
158
159 #endif // DALI_FRAMEBUFFER_H