9240c699a2bb252b556a161b20b939b7f0f1b666
[platform/core/uifw/dali-core.git] / dali / internal / render / renderers / render-frame-buffer.h
1 #ifndef DALI_INTERNAL_RENDER_FRAME_BUFFER_H
2 #define DALI_INTERNAL_RENDER_FRAME_BUFFER_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 // INTERNAL INCLUDES
21 #include <dali/public-api/rendering/frame-buffer.h>
22 #include <dali/internal/render/gl-resources/context.h>
23 #include <dali/internal/render/renderers/render-sampler.h>
24 #include <dali/integration-api/gl-defines.h>
25 #include <dali/integration-api/resource-declarations.h>
26
27 namespace Dali
28 {
29 namespace Internal
30 {
31 namespace Render
32 {
33 class NewTexture;
34
35 class FrameBuffer
36 {
37 public:
38
39   /**
40    * Constructor
41    * @param[in] width The width of the FrameBuffer
42    * @param[in] height The height of the FrameBuffer
43    * @param[in] attachments The attachments comprising the format of the FrameBuffer (bit-mask)
44    */
45   FrameBuffer( unsigned int width, unsigned int height, unsigned int attachments );
46
47   /**
48    * Destructor
49    */
50   ~FrameBuffer();
51
52   /**
53    * Creates a FrameBuffer object in the GPU.
54    * @param[in] context The GL context
55    */
56   void Initialize(Context& context);
57
58   /**
59    * Deletes the framebuffer object from the GPU
60    * @param[in] context The GL context
61    */
62   void Destroy( Context& context );
63
64   /**
65    * Called by RenderManager to inform the framebuffer that the context has been destroyed
66    */
67   void GlContextDestroyed();
68
69   /**
70    * @brief Attach a texture for color rendering. Valid only for Framebuffers with COLOR attachments.
71    * param[in] context The GL context
72    * @param[in] texture The texture that will be used as output when rendering
73    * @param[in] mipmapLevel The mipmap of the texture to be attached
74    * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
75    */
76   void AttachColorTexture( Context& context, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int layer );
77
78   /**
79    * @brief Bind the framebuffer
80    * @param[in] context The GL context
81    */
82   void Bind( Context& context );
83
84   /**
85    * @brief Get the width of the FrameBuffer
86    * @return The width of the framebuffer
87    */
88   unsigned int GetWidth() const;
89
90   /**
91    * @brief Get the height of the FrameBuffer
92    * @return The height of the framebuffer
93    */
94   unsigned int GetHeight() const;
95
96 private:
97
98   GLuint mId;
99   GLuint mDepthBuffer;
100   GLuint mStencilBuffer;
101   unsigned int mWidth;
102   unsigned int mHeight;
103 };
104
105
106 } // namespace Render
107
108 } // namespace Internal
109
110 } // namespace Dali
111
112
113 #endif // DALI_INTERNAL_RENDER_FRAME_BUFFER_H