1 #ifndef DALI_INTERNAL_FRAME_BUFFER_H
2 #define DALI_INTERNAL_FRAME_BUFFER_H
5 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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/devel-api/rendering/frame-buffer-devel.h>
27 #include <dali/internal/event/common/event-thread-services.h>
28 #include <dali/internal/event/rendering/texture-impl.h>
46 typedef IntrusivePtr<FrameBuffer> FrameBufferPtr;
48 class FrameBuffer : public BaseObject
52 using Mask = Dali::FrameBuffer::Attachment::Mask;
55 * @brief Create a new FrameBuffer
57 * @param[in] width The width of the FrameBuffer
58 * @param[in] height The height of the FrameBuffer
59 * @param[in] attachments The attachments comprising the format of the FrameBuffer (bit-mask)
60 * @return A smart-pointer to the newly allocated Texture.
62 static FrameBufferPtr New( uint32_t width, uint32_t height, Mask attachments );
65 * @brief Create a new FrameBuffer
67 * @param[in] renderSurface The render surface
68 * @param[in] attachments The attachments comprising the format of the FrameBuffer (bit-mask)
69 * @return A smart-pointer to the newly allocated Texture.
71 static FrameBufferPtr New( Dali::Integration::RenderSurface& renderSurface, Mask attachments );
74 * A reference counted object may only be deleted by calling Unreference()
76 virtual ~FrameBuffer();
79 * @brief Get the FrameBuffer render object
81 * @return the FrameBuffer render object
83 Render::FrameBuffer* GetRenderObject() const;
86 * @copydoc Dali::FrameBuffer::AttachColorTexture()
88 void AttachColorTexture( TexturePtr texture, uint32_t mipmapLevel, uint32_t layer );
91 * @copydoc Dali::FrameBuffer::GetColorTexture()
93 Texture* GetColorTexture(uint8_t index) const;
96 * @brief Sets the frame buffer size.
97 * @param[in] width The width size
98 * @param[in] height The height size
100 void SetSize( uint32_t width, uint32_t height );
103 * @brief Mark the render surface as invalid
105 * The render surface is maked as invalid when it is deleted.
107 * @note Only for FrameBuffer backed by a render surface.
108 * @return True if the FrameBuffer is backed by a render surface
110 void MarkSurfaceAsInvalid();
113 * @brief Sets whether to enable partial update.
114 * @param[in] value whether partial update or not
116 void SetPartialUpdateEnabled( bool value );
118 private: // implementation
122 * @param[in] width The width of the FrameBuffer
123 * @param[in] height The height of the FrameBuffer
124 * @param[in] attachments The attachments comprising the format of the FrameBuffer (bit-mask)
126 FrameBuffer( uint32_t width, uint32_t height, Mask attachments );
129 * Second stage initialization of the Texture
131 void Initialize( Integration::RenderSurface* renderSurface = nullptr );
135 private: // unimplemented methods
137 FrameBuffer() = delete;
138 FrameBuffer( const FrameBuffer& ) = delete;
139 FrameBuffer& operator=( const FrameBuffer& ) = delete;
143 Internal::EventThreadServices& mEventThreadServices; ///< Used to send messages to the render thread via update thread
144 Internal::Render::FrameBuffer* mRenderObject; ///< The Render::Texture associated to this texture
146 TexturePtr mColor[ Dali::DevelFrameBuffer::MAX_COLOR_ATTACHMENTS ];
149 Mask mAttachments; ///< Bit-mask of type FrameBuffer::Attachment::Mask
150 uint8_t mColorAttachmentCount;
152 bool mIsSurfaceBacked:1;
156 } // namespace Internal
158 // Helpers for public-api forwarding methods
159 inline Internal::FrameBuffer& GetImplementation(Dali::FrameBuffer& handle)
161 DALI_ASSERT_ALWAYS(handle && "FrameBuffer handle is empty");
163 BaseObject& object = handle.GetBaseObject();
165 return static_cast<Internal::FrameBuffer&>(object);
168 inline const Internal::FrameBuffer& GetImplementation(const Dali::FrameBuffer& handle)
170 DALI_ASSERT_ALWAYS(handle && "FrameBuffer handle is empty");
172 const BaseObject& object = handle.GetBaseObject();
174 return static_cast<const Internal::FrameBuffer&>(object);
179 #endif // DALI_INTERNAL_FRAME_BUFFER_H