[dali_1.1.14] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / internal / render / gl-resources / frame-buffer-texture.h
1 #ifndef __DALI_INTERNAL_FRAME_BUFFER_TEXTURE_H__
2 #define __DALI_INTERNAL_FRAME_BUFFER_TEXTURE_H__
3
4 /*
5  * Copyright (c) 2014 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 // EXTERNAL INCLUDES
22 #include <string>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/images/frame-buffer-image.h>
26 #include <dali/internal/render/gl-resources/texture.h>
27 #include <dali/integration-api/bitmap.h>
28 #include <dali/integration-api/debug.h>
29
30 namespace Dali
31 {
32
33 namespace Internal
34 {
35
36 /**
37  * Texture class.
38  * Used as a frame buffer for RenderTask
39  */
40 class FrameBufferTexture : public Texture
41 {
42 public:
43
44   /**
45    * Creates a new texture object
46    * @param[in] width       The width (pixels)
47    * @param[in] height      The height (pixels)
48    * @param[in] context The GL context
49    */
50   FrameBufferTexture(unsigned int width, unsigned int height, Context& context);
51
52   /**
53    * Creates a new texture object
54    * @param[in] width       The width (pixels)
55    * @param[in] height      The height (pixels)
56    * @param[in] pixelFormat The pixel format
57    * @param[in] context The GL context
58    */
59   FrameBufferTexture(unsigned int width, unsigned int height, Pixel::Format pixelFormat, Context& context);
60
61   /**
62    * Creates a new texture object
63    * @param[in] width         The width (pixels)
64    * @param[in] height        The height (pixels)
65    * @param[in] pixelFormat   The pixel format
66    * @param[in] bufferFormat  The buffer formats to be attached in the FBO
67    * @param[in] context The GL context
68    */
69   FrameBufferTexture(unsigned int width, unsigned int height, Pixel::Format pixelFormat, RenderBuffer::Format bufferFormat, Context& context);
70
71   /**
72    * Creates a new texture object
73    * @param[in] nativeImage The NativeImage
74    * @param     context The GL context
75    */
76   FrameBufferTexture( NativeImageInterfacePtr nativeImage, Context& context );
77
78   /**
79    * Destructor.
80    */
81   virtual ~FrameBufferTexture();
82
83   /**
84    * @copydoc Texture::IsFullyOpaque
85    */
86   virtual bool IsFullyOpaque() const;
87
88   /**
89    * @copydoc Texture::HasAlphaChannel
90    */
91   virtual bool HasAlphaChannel() const;
92
93   /**
94    * @copydoc Texture::Init
95    */
96   virtual bool Init();
97
98   /**
99    * Prepare FBO for rendering.
100    * @return true if the FBO is prepared and its status is GL_FRAMEBUFFER_COMPLETE, otherwise false.
101    */
102   virtual bool Prepare();
103
104 protected:
105   unsigned int mFrameBufferName;
106   unsigned int mRenderBufferName;
107   unsigned int mStencilBufferName;
108   Pixel::Format mPixelFormat;
109   RenderBuffer::Format mBufferFormat;
110   NativeImageInterfacePtr mNativeImage; ///< For native FBOs only
111
112   /**
113    * @copydoc Texture::CreateGlTexture
114    */
115   virtual bool CreateGlTexture();
116
117   /**
118    * @copydoc Texture::GlCleanup
119    */
120   virtual void GlCleanup();
121
122 }; // class FrameBufferTexture
123
124 }  //namespace Internal
125
126 } //namespace Dali
127 #endif //__DALI_INTERNAL_FRAME_BUFFER_TEXTURE_H__
128