1 #ifndef DALI_INTERNAL_FRAME_BUFFER_H
2 #define DALI_INTERNAL_FRAME_BUFFER_H
5 * Copyright (c) 2021 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/devel-api/rendering/frame-buffer-devel.h>
23 #include <dali/internal/event/common/event-thread-services.h>
24 #include <dali/internal/event/rendering/texture-impl.h>
25 #include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
26 #include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
27 #include <dali/public-api/object/base-object.h>
28 #include <dali/public-api/rendering/frame-buffer.h>
32 using Mask = Dali::FrameBuffer::Attachment::Mask;
42 using FrameBufferPtr = IntrusivePtr<FrameBuffer>;
44 class FrameBuffer : public BaseObject
47 using Mask = Dali::FrameBuffer::Attachment::Mask;
50 * @brief Create a new FrameBuffer
52 * @param[in] width The width of the FrameBuffer
53 * @param[in] height The height of the FrameBuffer
54 * @param[in] attachments The attachments comprising the format of the FrameBuffer (bit-mask)
55 * @return A smart-pointer to the newly allocated Texture.
57 static FrameBufferPtr New(uint32_t width, uint32_t height, Mask attachments);
60 * A reference counted object may only be deleted by calling Unreference()
62 ~FrameBuffer() override;
65 * @brief Get the FrameBuffer render object
67 * @return the FrameBuffer render object
69 Render::FrameBuffer* GetRenderObject() const;
72 * @copydoc Dali::FrameBuffer::AttachColorTexture()
74 void AttachColorTexture(TexturePtr texture, uint32_t mipmapLevel, uint32_t layer);
77 * @copydoc Dali::DevelFrameBuffer::AttachDepthTexture()
79 void AttachDepthTexture(TexturePtr texture, uint32_t mipmapLevel);
82 * @copydoc Dali::DevelFrameBuffer::AttachDepthStencilTexture()
84 void AttachDepthStencilTexture(TexturePtr texture, uint32_t mipmapLevel);
87 * @copydoc Dali::FrameBuffer::GetColorTexture()
89 Texture* GetColorTexture(uint8_t index) const;
92 * @copydoc Dali::DevelFrameBuffer::GetDepthTexture()
94 Texture* GetDepthTexture() const;
97 * @copydoc Dali::DevelFrameBuffer::GetDepthStencilTexture()
99 Texture* GetDepthStencilTexture() const;
102 * @brief Sets the frame buffer size.
103 * @param[in] width The width size
104 * @param[in] height The height size
106 void SetSize(uint32_t width, uint32_t height);
108 private: // implementation
111 * @param[in] width The width of the FrameBuffer
112 * @param[in] height The height of the FrameBuffer
113 * @param[in] attachments The attachments comprising the format of the FrameBuffer (bit-mask)
115 FrameBuffer(uint32_t width, uint32_t height, Mask attachments);
118 * Second stage initialization of the Texture
123 private: // unimplemented methods
124 FrameBuffer() = delete;
125 FrameBuffer(const FrameBuffer&) = delete;
126 FrameBuffer& operator=(const FrameBuffer&) = delete;
129 Internal::EventThreadServices& mEventThreadServices; ///< Used to send messages to the render thread via update thread
130 Internal::Render::FrameBuffer* mRenderObject; ///< The Render::Texture associated to this texture
132 TexturePtr mColor[Dali::DevelFrameBuffer::MAX_COLOR_ATTACHMENTS];
137 Mask mAttachments; ///< Bit-mask of type FrameBuffer::Attachment::Mask
138 uint8_t mColorAttachmentCount;
141 } // namespace Internal
143 // Helpers for public-api forwarding methods
144 inline Internal::FrameBuffer& GetImplementation(Dali::FrameBuffer& handle)
146 DALI_ASSERT_ALWAYS(handle && "FrameBuffer handle is empty");
148 BaseObject& object = handle.GetBaseObject();
150 return static_cast<Internal::FrameBuffer&>(object);
153 inline const Internal::FrameBuffer& GetImplementation(const Dali::FrameBuffer& handle)
155 DALI_ASSERT_ALWAYS(handle && "FrameBuffer handle is empty");
157 const BaseObject& object = handle.GetBaseObject();
159 return static_cast<const Internal::FrameBuffer&>(object);
164 #endif // DALI_INTERNAL_FRAME_BUFFER_H