1 #ifndef DALI_INTERNAL_RENDER_SURFACE_FRAME_BUFFER_H
2 #define DALI_INTERNAL_RENDER_SURFACE_FRAME_BUFFER_H
5 * Copyright (c) 2019 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.
21 #include <dali/internal/update/manager/update-manager.h>
22 #include <dali/internal/render/renderers/render-frame-buffer.h>
23 #include <dali/integration-api/render-surface.h>
36 class SurfaceFrameBuffer : public FrameBuffer
42 * @param[in] surface The render surface
44 SurfaceFrameBuffer( Integration::RenderSurface* surface );
49 virtual ~SurfaceFrameBuffer();
52 * @copydoc Dali::Internal::Renderer::FrameBuffer::Initialize()
54 void Initialize( Context& context ) override;
57 * @copydoc Dali::Internal::Renderer::FrameBuffer::Destroy()
59 void Destroy( Context& context ) override;
62 * @copydoc Dali::Internal::Renderer::FrameBuffer::GlContextDestroyed()
64 void GlContextDestroyed() override;
67 * @copydoc Dali::Internal::Renderer::FrameBuffer::Bind()
69 void Bind( Context& context ) override;
72 * @copydoc Dali::Internal::Renderer::FrameBuffer::GetWidth()
74 uint32_t GetWidth() const override;
77 * @copydoc Dali::Internal::Renderer::FrameBuffer::GetHeight()
79 uint32_t GetHeight() const override;
82 * @copydoc Dali::Internal::Renderer::FrameBuffer::IsSurfaceBacked()
84 bool IsSurfaceBacked() override { return true; };
87 * @brief Sets the frame buffer size.
88 * @param[in] width The width size
89 * @param[in] height The height size
91 void SetSize( uint32_t width, uint32_t height );
94 * @brief Sets the background color.
95 * @param[in] color The new background color
97 void SetBackgroundColor( const Vector4& color );
102 * Called after this frame buffer is rendered in the render manager
107 * Gets the context holding the GL state of rendering for the surface
108 * @return the context
110 Context* GetContext();
113 * @brief Gets whether the depth buffer is required
114 * @return TRUE if the depth buffer is required
116 Integration::DepthBufferAvailable GetDepthBufferRequired();
119 * @brief Gets whether the stencil buffer is required
120 * @return TRUE if the stencil buffer is required
122 Integration::StencilBufferAvailable GetStencilBufferRequired();
125 * @brief Gets the background color of the surface.
126 * @return The background color
128 Vector4 GetBackgroundColor();
132 Integration::RenderSurface* mSurface; ///< The render surface
133 Context* mContext; ///< The context holding the GL state of rendering for the surface backed frame buffer
137 Vector4 mBackgroundColor;
141 // Messages for FrameBuffer
142 inline void SetFrameBufferSizeMessage( SceneGraph::UpdateManager& updateManager, SurfaceFrameBuffer* surfaceFrameBuffer, uint32_t width, uint32_t height )
144 typedef MessageValue2< SurfaceFrameBuffer, uint32_t, uint32_t > LocalType;
146 // Reserve some memory inside the message queue
147 uint32_t* slot = updateManager.ReserveMessageSlot( sizeof( LocalType ) );
149 // Construct message in the message queue memory; note that delete should not be called on the return value
150 new (slot) LocalType( surfaceFrameBuffer, &SurfaceFrameBuffer::SetSize, width, height );
153 inline void SetFrameBufferBackgroundColorMessage( SceneGraph::UpdateManager& updateManager, SurfaceFrameBuffer* surfaceFrameBuffer, const Vector4& color )
155 typedef MessageValue1< SurfaceFrameBuffer, Vector4 > LocalType;
157 // Reserve some memory inside the message queue
158 uint32_t* slot = updateManager.ReserveMessageSlot( sizeof( LocalType ) );
160 // Construct message in the message queue memory; note that delete should not be called on the return value
161 new (slot) LocalType( surfaceFrameBuffer, &SurfaceFrameBuffer::SetBackgroundColor, color );
164 } // namespace Render
166 } // namespace Internal
171 #endif // DALI_INTERNAL_RENDER_SURFACE_FRAME_BUFFER_H