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