1 #ifndef DALI_RENDER_SURFACE_INTERFACE_H
2 #define DALI_RENDER_SURFACE_INTERFACE_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.
22 #include <dali/integration-api/render-surface.h>
23 #include <dali/integration-api/core-enumerations.h>
24 #include <dali/public-api/math/vector4.h>
29 class DisplayConnection;
30 class ThreadSynchronizationInterface;
36 class AdaptorInternalServices;
37 class GraphicsInterface;
42 * @brief Interface for a render surface onto which Dali draws.
44 * Dali::Adaptor requires a render surface to draw on to. This is
45 * usually a window in the native windowing system, or some other
46 * mapped pixel buffer.
48 * Dali::Application will automatically create a render surface using a window.
50 * The implementation of the factory method below should choose an appropriate
51 * implementation of RenderSurface for the given platform
54 class RenderSurfaceInterface : public Dali::Integration::RenderSurface
60 * Inlined as this is a pure abstract interface
62 RenderSurfaceInterface()
63 : mAdaptor( nullptr ),
65 mDisplayConnection( nullptr ),
66 mDepthBufferRequired( Integration::DepthBufferAvailable::FALSE ),
67 mStencilBufferRequired( Integration::StencilBufferAvailable::FALSE )
71 * @brief Virtual Destructor.
72 * Inlined as this is a pure abstract interface
74 virtual ~RenderSurfaceInterface() {}
77 * @brief Return the size and position of the surface.
78 * @return The position and size
80 virtual Dali::PositionSize GetPositionSize() const = 0;
84 * @param[out] dpiHorizontal set to the horizontal dpi
85 * @param[out] dpiVertical set to the vertical dpi
87 virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) = 0;
90 * @brief InitializeGraphics the platform specific graphics surface interfaces
92 virtual void InitializeGraphics() = 0;
95 * @brief Creates the Surface
97 virtual void CreateSurface() = 0;
100 * @brief Destroys the Surface
102 virtual void DestroySurface() = 0;
105 * @brief Replace the Surface
106 * @return true if context was lost
108 virtual bool ReplaceGraphicsSurface() = 0;
111 * @brief Resizes the underlying surface.
112 * @param[in] The dimensions of the new position
114 virtual void MoveResize( Dali::PositionSize positionSize ) = 0;
117 * @brief Called when Render thread has started
119 virtual void StartRender() = 0;
122 * @brief Invoked by render thread before Core::Render
123 * If the operation fails, then Core::Render should not be called until there is
124 * a surface to render onto.
125 * @param[in] resizingSurface True if the surface is being resized
126 * @return True if the operation is successful, False if the operation failed
128 virtual bool PreRender( bool resizingSurface ) = 0;
131 * @brief Invoked by render thread after Core::Render
132 * @param[in] renderToFbo True if render to FBO.
133 * @param[in] replacingSurface True if the surface is being replaced.
134 * @param[in] resizingSurface True if the surface is being resized.
136 virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface ) = 0;
138 * @brief Invoked by render thread when the thread should be stop
140 virtual void StopRender() = 0;
143 * @brief Invoked by Event Thread when the compositor lock should be released and rendering should resume.
145 virtual void ReleaseLock() = 0;
148 * @brief Sets the ThreadSynchronizationInterface
150 * @param threadSynchronization The thread-synchronization implementation.
152 virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) = 0;
155 * @brief Gets the surface type
157 virtual Dali::Integration::RenderSurface::Type GetSurfaceType() = 0;
160 * @brief Makes the graphics context current
162 virtual void MakeContextCurrent() = 0;
165 * @brief Get whether the depth buffer is required
166 * @return TRUE if the depth buffer is required
168 virtual Integration::DepthBufferAvailable GetDepthBufferRequired() = 0;
171 * @brief Get whether the stencil buffer is required
172 * @return TRUE if the stencil buffer is required
174 virtual Integration::StencilBufferAvailable GetStencilBufferRequired() = 0;
178 void SetAdaptor( Dali::Internal::Adaptor::AdaptorInternalServices& adaptor )
183 void SetGraphicsInterface( Dali::Internal::Adaptor::GraphicsInterface& graphics )
185 mGraphics = &graphics;
188 void SetDisplayConnection( Dali::DisplayConnection& displayConnection )
190 mDisplayConnection = &displayConnection;
196 * @brief Undefined copy constructor. RenderSurface cannot be copied
198 RenderSurfaceInterface( const RenderSurfaceInterface& rhs );
201 * @brief Undefined assignment operator. RenderSurface cannot be copied
203 RenderSurfaceInterface& operator=( const RenderSurfaceInterface& rhs );
207 Dali::Internal::Adaptor::AdaptorInternalServices* mAdaptor;
208 Dali::Internal::Adaptor::GraphicsInterface* mGraphics;
209 Dali::DisplayConnection* mDisplayConnection;
213 Integration::DepthBufferAvailable mDepthBufferRequired; ///< Whether the depth buffer is required
214 Integration::StencilBufferAvailable mStencilBufferRequired; ///< Whether the stencil buffer is required
216 Vector4 mBackgroundColor; ///< The background color of the surface
221 #endif // DALI_RENDER_SURFACE_INTERFACE_H