Tizen 2.4.0 rev3 SDK Public Release
[framework/graphics/dali.git] / dali / public-api / images / frame-buffer-image.h
1 #ifndef __DALI_FRAME_BUFFER_IMAGE_H__
2 #define __DALI_FRAME_BUFFER_IMAGE_H__
3
4 /*
5  * Copyright (c) 2015 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/images/image.h>
23 #include <dali/public-api/images/native-image-interface.h>
24 #include <dali/public-api/images/pixel.h>
25
26 namespace Dali
27 {
28 /**
29  * @addtogroup dali_core_images
30  * @{
31  */
32
33 namespace Internal DALI_INTERNAL
34 {
35 class FrameBufferImage;
36 }
37
38 /**
39  * @brief Render Buffer formats
40  * @since_tizen 2.4
41  */
42 namespace RenderBuffer
43 {
44 /**
45  * @brief Render Buffer formats
46  *
47  * The default format for framebuffer creation is COLOR, so If a depth buffer for 3D rendering is required use
48  * COLOR_DEPTH instead
49  * @since_tizen 2.4
50  */
51 enum Format ///< Framebuffer format, default color depth is RGBA 32 bit with alpha @since_tizen 2.4
52 {
53   COLOR,                ///< Framebuffer will be created with color buffer. @since_tizen 2.4
54   COLOR_DEPTH,          ///< Framebuffer will be created with color and depth buffer @since_tizen 2.4
55   COLOR_STENCIL,        ///< Framebuffer will be created with color and stencil buffer @since_tizen 2.4
56   COLOR_DEPTH_STENCIL   ///< Framebuffer will be created with color, depth and stencil buffer. @note May be not supported in all devices @since_tizen 2.4
57 };
58 }
59
60 /**
61  * @brief FrameBufferImage represents a GLES Frame Buffer Object and contains the result
62  * of an 'off screen' render pass of a RenderTask.
63  *
64  * The FrameBufferImage can then be used with an @ref Dali::Toolkit::ImageView (with optional shader
65  * effects) and rendered to the screen.
66  * @since_tizen 2.4
67  */
68 class DALI_IMPORT_API FrameBufferImage : public Image
69 {
70 public:
71   /**
72    * @brief Constructor which creates an uninitialized FrameBufferImage object.
73    *
74    * Use @ref Image::New to create an initialised object.
75    * @since_tizen 2.4
76    */
77   FrameBufferImage();
78
79   /**
80    * @brief Create a new FrameBufferImage.
81    *
82    * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
83    * @since_tizen 2.4
84    * @param [in] width       The width in pixels. Setting to zero will use the width of the stage.
85    * @param [in] height      The height in pixels. Setting to zero will use the height of the stage.
86    * @param [in] pixelFormat The pixel format (rgba 32 bit by default)
87    * @param [in] bufferFormat The format of the buffers that are going to be created for the FBO, (COLOR and DEPTH buffer as default)
88    * @return A handle to a new instance of a FrameBufferImage.
89    * @post When the FrameBufferImage is first used as a render target, an exception may be thrown if pixelFormat is not supported on the hardware platform.
90    */
91   static FrameBufferImage New(unsigned int width = 0, unsigned int height = 0, Pixel::Format pixelFormat = Pixel::RGBA8888,
92                               RenderBuffer::Format bufferFormat = RenderBuffer::COLOR);
93
94   /**
95    * @brief Create a new FrameBufferImage.
96    *
97    * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
98    * @since_tizen 2.4
99    * @remarks Image::ReleasePolicy is an experimental feature and might not be supported in the next release.
100    * We do recommend not to use this method.
101    * Please refer the Remarks of ReleasePolicy for more information.
102    * @param [in] width       The width in pixels. Setting to zero will use the width of the stage.
103    * @param [in] height      The height in pixels. Setting to zero will use the height of the stage.
104    * @param [in] pixelFormat The pixel format.
105    * @param [in] releasePolicy The releasePolicy to apply to the FrameBufferImage.
106    * @param [in] bufferFormat The format of the buffers that are going to be created for the FBO, (COLOR and DEPTH buffer as default)
107    *
108    * @return A handle to a new instance of a FrameBufferImage.
109    * @post When the FrameBufferImage is first used as a render target, an exception may be thrown if pixelFormat is not supported on the hardware platform.
110    */
111   static FrameBufferImage New(unsigned int width, unsigned int height, Pixel::Format pixelFormat, ReleasePolicy releasePolicy,
112                               RenderBuffer::Format bufferFormat = RenderBuffer::COLOR);
113
114   /**
115    * @brief Create a new FrameBufferImage.
116    *
117    * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
118    * @since_tizen 2.4
119    * @param [in] image       The native image.
120    *
121    * @return A handle to a new instance of a FrameBufferImage.
122    * @post When the FrameBufferImage is first used as a render target, an exception may be thrown if the NativeImage cannot be mapped to a texture.
123    */
124   static FrameBufferImage New(NativeImageInterface& image);
125
126   /**
127    * @brief Create a new FrameBufferImage.
128    *
129    * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
130    * @since_tizen 2.4
131    * @remarks Image::ReleasePolicy is an experimental feature and might not be supported in the next release.
132    * We do recommend not to use this method.
133    * Please refer the remarks of ReleasePolicy for more information.
134    * @param [in] image       The native image.
135    * @param [in] releasePolicy The releasePolicy to apply to the FrameBufferImage.
136    *
137    * @return A handle to a new instance of a FrameBufferImage.
138    * @post When the FrameBufferImage is first used as a render target, an exception may be thrown if the NativeImage cannot be mapped to a texture.
139    */
140   static FrameBufferImage New(NativeImageInterface& image, ReleasePolicy releasePolicy);
141
142   /**
143    * @brief Downcast a handle to FrameBufferImage handle.
144    *
145    * If handle points to a FrameBufferImage object the
146    * downcast produces valid handle. If not the returned handle is left uninitialized.
147    * @since_tizen 2.4
148    * @param[in] handle Handle to an object
149    * @return Handle to a FrameBufferImage object or an uninitialized handle
150    */
151   static FrameBufferImage DownCast( BaseHandle handle );
152
153   /**
154    * @brief Destructor
155    *
156    * This is non-virtual since derived Handle types must not contain data or virtual methods.
157    * @since_tizen 2.4
158    */
159   ~FrameBufferImage();
160
161   /**
162    * @brief This copy constructor is required for (smart) pointer semantics.
163    *
164    * @since_tizen 2.4
165    * @param [in] handle A reference to the copied handle
166    */
167   FrameBufferImage(const FrameBufferImage& handle);
168
169   /**
170    * @brief This assignment operator is required for (smart) pointer semantics.
171    *
172    * @since_tizen 2.4
173    * @param [in] rhs  A reference to the copied handle
174    * @return A reference to this
175    */
176   FrameBufferImage& operator=(const FrameBufferImage& rhs);
177
178 public: // Not intended for application developers
179
180   explicit DALI_INTERNAL FrameBufferImage(Internal::FrameBufferImage*);
181 }; //class FrameBufferImage
182
183 /**
184  * @}
185  */
186 } // namespace Dali
187
188 #endif // __DALI_FRAME_BUFFER_IMAGE_H__