[Tizen] Revert "Support multiple window rendering"
[platform/core/uifw/dali-core.git] / dali / internal / event / rendering / frame-buffer-impl.h
1 #ifndef DALI_INTERNAL_FRAME_BUFFER_H
2 #define DALI_INTERNAL_FRAME_BUFFER_H
3
4 /*
5  * Copyright (c) 2018 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/common/dali-common.h> // DALI_ASSERT_ALWAYS
23 #include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
24 #include <dali/public-api/object/base-object.h>
25 #include <dali/public-api/rendering/frame-buffer.h>
26 #include <dali/internal/event/common/event-thread-services.h>
27 #include <dali/internal/event/rendering/texture-impl.h>
28
29 namespace Dali
30 {
31 namespace Internal
32 {
33 namespace Render
34 {
35 class FrameBuffer;
36 }
37
38 class FrameBuffer;
39 typedef IntrusivePtr<FrameBuffer> FrameBufferPtr;
40
41 class FrameBuffer : public BaseObject
42 {
43 public:
44
45   using Mask = Dali::FrameBuffer::Attachment::Mask;
46
47   /**
48    * @brief Create a new FrameBuffer
49    *
50    * @param[in] width       The width of the FrameBuffer
51    * @param[in] height      The height of the FrameBuffer
52    * @param[in] attachments The attachments comprising the format of the FrameBuffer (bit-mask)
53    * @return A smart-pointer to the newly allocated Texture.
54    */
55   static FrameBufferPtr New( uint32_t width, uint32_t height, Mask attachments );
56
57   /**
58    * @brief Get the FrameBuffer render object
59    *
60    * @return the FrameBuffer render object
61    */
62   Render::FrameBuffer* GetRenderObject() const;
63
64   /**
65    * @copydoc Dali::FrameBuffer::AttachColorTexture()
66    */
67   void AttachColorTexture( TexturePtr texture, uint32_t mipmapLevel, uint32_t layer );
68
69   /**
70    * @copydoc Dali::FrameBuffer::GetColorTexture()
71    */
72   Texture* GetColorTexture();
73
74 private: // implementation
75
76   /**
77    * Constructor
78    * @param[in] width       The width of the FrameBuffer
79    * @param[in] height      The height of the FrameBuffer
80    * @param[in] attachments The attachments comprising the format of the FrameBuffer (bit-mask)
81    */
82   FrameBuffer( uint32_t width, uint32_t height, Mask attachments );
83
84   /**
85    * Second stage initialization of the Texture
86    */
87   void Initialize();
88
89 protected:
90
91   /**
92    * A reference counted object may only be deleted by calling Unreference()
93    */
94   virtual ~FrameBuffer();
95
96 private: // unimplemented methods
97
98   FrameBuffer() = delete;
99   FrameBuffer( const FrameBuffer& ) = delete;
100   FrameBuffer& operator=( const FrameBuffer& ) = delete;
101
102 private: // data
103
104   Internal::EventThreadServices& mEventThreadServices; ///< Used to send messages to the render thread via update thread
105   Internal::Render::FrameBuffer* mRenderObject;        ///< The Render::Texture associated to this texture
106
107   TexturePtr mColor;
108   uint32_t mWidth;
109   uint32_t mHeight;
110   Mask mAttachments;                           ///< Bit-mask of type FrameBuffer::Attachment::Mask
111
112 };
113
114 } // namespace Internal
115
116 // Helpers for public-api forwarding methods
117 inline Internal::FrameBuffer& GetImplementation(Dali::FrameBuffer& handle)
118 {
119   DALI_ASSERT_ALWAYS(handle && "FrameBuffer handle is empty");
120
121   BaseObject& object = handle.GetBaseObject();
122
123   return static_cast<Internal::FrameBuffer&>(object);
124 }
125
126 inline const Internal::FrameBuffer& GetImplementation(const Dali::FrameBuffer& handle)
127 {
128   DALI_ASSERT_ALWAYS(handle && "FrameBuffer handle is empty");
129
130   const BaseObject& object = handle.GetBaseObject();
131
132   return static_cast<const Internal::FrameBuffer&>(object);
133 }
134
135 } // namespace Dali
136
137 #endif // DALI_INTERNAL_FRAME_BUFFER_H