Merge "Move native-image-interface.h and image-operations.h to public-api" into tizen
[platform/core/uifw/dali-core.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 namespace Internal DALI_INTERNAL
30 {
31 class FrameBufferImage;
32 }
33
34 /**
35  * @brief FrameBufferImage represents a GLES Frame Buffer Object and contains the result
36  * of an 'off screen' render pass of a RenderTask.
37  * The FrameBufferImage can then be used with an ImageActor (with optional shader
38  * effects) and rendered to the screen.
39  */
40 class DALI_IMPORT_API FrameBufferImage : public Image
41 {
42 public:
43   /**
44    * @brief Constructor which creates an uninitialized FrameBufferImage object.
45    *
46    * Use Image::New(...) to create an initialised object.
47    */
48   FrameBufferImage();
49
50   /**
51    * @brief Create a new FrameBufferImage.
52    *
53    * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
54    * The ReleasePolicy defaults to Dali::Image::Never.
55    * @param [in] width       The width in pixels. Setting to zero will use the width of the stage.
56    * @param [in] height      The height in pixels. Setting to zero will use the height of the stage.
57    * @param [in] pixelformat The pixel format (rgba 32 bit by default)
58    * @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.
59    * @return A handle to a new instance of a FrameBufferImage.
60    */
61   static FrameBufferImage New(unsigned int width = 0, unsigned int height = 0, Pixel::Format pixelformat = Pixel::RGBA8888);
62
63   /**
64    * @brief Create a new FrameBufferImage.
65    *
66    * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
67    * @param [in] width       The width in pixels. Setting to zero will use the width of the stage.
68    * @param [in] height      The height in pixels. Setting to zero will use the height of the stage.
69    * @param [in] pixelformat The pixel format.
70    * @param [in] releasePolicy The ReleasePolicy to apply to the FrameBufferImage.
71    *
72    * Note that there is no need for a LoadPolicy - by definition it is always OnDemand, since there is no point in the FrameBufferImage existing unless someone is rendering to
73    * it, or it is being used as an input (e.g. ShaderEffect / ImageActor).
74    *
75    * @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.
76    * @return A handle to a new instance of a FrameBufferImage.
77    */
78   static FrameBufferImage New(unsigned int width, unsigned int height, Pixel::Format pixelformat, ReleasePolicy releasePolicy );
79
80   /**
81    * @brief Create a new FrameBufferImage.
82    *
83    * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
84    * @param [in] image       The native image.
85    *
86    * Note that there is no need for a LoadPolicy - by definition it is always OnDemand, since there is no point in the FrameBufferImage existing unless someone is rendering to
87    * it, or it is being used as an input (e.g. ShaderEffect / ImageActor).
88    *
89    * @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.
90    * @return A handle to a new instance of a FrameBufferImage.
91    */
92   static FrameBufferImage New(NativeImageInterface& image);
93
94   /**
95    * @brief Create a new FrameBufferImage.
96    *
97    * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
98    * @param [in] image       The native image.
99    * @param [in] releasePolicy The ReleasePolicy to apply to the FrameBufferImage.
100    *
101    * Note that there is no need for a LoadPolicy - by definition it is always OnDemand, since there is no point in the FrameBufferImage existing unless someone is rendering to
102    * it, or it is being used as an input (e.g. ShaderEffect / ImageActor).
103    *
104    * @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.
105    * @return A handle to a new instance of a FrameBufferImage.
106    */
107   static FrameBufferImage New(NativeImageInterface& image, ReleasePolicy releasePolicy);
108
109   /**
110    * @brief Downcast an Object handle to FrameBufferImage handle.
111    *
112    * If handle points to a FrameBufferImage object the
113    * downcast produces valid handle. If not the returned handle is left uninitialized.
114    * @param[in] handle to An object
115    * @return handle to a FrameBufferImage object or an uninitialized handle
116    */
117   static FrameBufferImage DownCast( BaseHandle handle );
118
119   /**
120    * @brief Destructor
121    *
122    * This is non-virtual since derived Handle types must not contain data or virtual methods.
123    */
124   ~FrameBufferImage();
125
126   /**
127    * @brief This copy constructor is required for (smart) pointer semantics.
128    *
129    * @param [in] handle A reference to the copied handle
130    */
131   FrameBufferImage(const FrameBufferImage& handle);
132
133   /**
134    * @brief This assignment operator is required for (smart) pointer semantics.
135    *
136    * @param [in] rhs  A reference to the copied handle
137    * @return A reference to this
138    */
139   FrameBufferImage& operator=(const FrameBufferImage& rhs);
140
141 public: // Not intended for application developers
142
143   explicit DALI_INTERNAL FrameBufferImage(Internal::FrameBufferImage*);
144 }; //class FrameBufferImage
145
146 } // namespace Dali
147
148 #endif // __DALI_FRAME_BUFFER_IMAGE_H__