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 Return the orientation of the surface.
91 * @return The orientation
93 virtual int GetOrientation() const = 0;
96 * @brief InitializeGraphics the platform specific graphics surface interfaces
98 virtual void InitializeGraphics() = 0;
101 * @brief Creates the Surface
103 virtual void CreateSurface() = 0;
106 * @brief Destroys the Surface
108 virtual void DestroySurface() = 0;
111 * @brief Replace the Surface
112 * @return true if context was lost
114 virtual bool ReplaceGraphicsSurface() = 0;
117 * @brief Resizes the underlying surface.
118 * @param[in] The dimensions of the new position
120 virtual void MoveResize( Dali::PositionSize positionSize ) = 0;
123 * @brief Called when Render thread has started
125 virtual void StartRender() = 0;
128 * @brief Invoked by render thread before Core::Render
129 * If the operation fails, then Core::Render should not be called until there is
130 * a surface to render onto.
131 * @param[in] resizingSurface True if the surface is being resized
132 * @return True if the operation is successful, False if the operation failed
134 virtual bool PreRender( bool resizingSurface ) = 0;
137 * @brief Invoked by render thread after Core::Render
138 * @param[in] renderToFbo True if render to FBO.
139 * @param[in] replacingSurface True if the surface is being replaced.
140 * @param[in] resizingSurface True if the surface is being resized.
142 virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface ) = 0;
144 * @brief Invoked by render thread when the thread should be stop
146 virtual void StopRender() = 0;
149 * @brief Invoked by Event Thread when the compositor lock should be released and rendering should resume.
151 virtual void ReleaseLock() = 0;
154 * @brief Sets the ThreadSynchronizationInterface
156 * @param threadSynchronization The thread-synchronization implementation.
158 virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) = 0;
161 * @brief Gets the surface type
163 virtual Dali::Integration::RenderSurface::Type GetSurfaceType() = 0;
166 * @brief Makes the graphics context current
168 virtual void MakeContextCurrent() = 0;
171 * @brief Get whether the depth buffer is required
172 * @return TRUE if the depth buffer is required
174 virtual Integration::DepthBufferAvailable GetDepthBufferRequired() = 0;
177 * @brief Get whether the stencil buffer is required
178 * @return TRUE if the stencil buffer is required
180 virtual Integration::StencilBufferAvailable GetStencilBufferRequired() = 0;
183 * @brief Sets currentframe damaged rects
184 * @param[in] Sets currentframe damaged rects
185 * @param[out] return merged rect
187 virtual void SetDamagedRect( const Dali::DamagedRect& damagedRect, Dali::DamagedRect& mergedRectArray ) = 0;
190 * @brief Gets buffer age
192 virtual int32_t GetBufferAge() = 0;
196 void SetAdaptor( Dali::Internal::Adaptor::AdaptorInternalServices& adaptor )
201 void SetGraphicsInterface( Dali::Internal::Adaptor::GraphicsInterface& graphics )
203 mGraphics = &graphics;
206 void SetDisplayConnection( Dali::DisplayConnection& displayConnection )
208 mDisplayConnection = &displayConnection;
214 * @brief Undefined copy constructor. RenderSurface cannot be copied
216 RenderSurfaceInterface( const RenderSurfaceInterface& rhs );
219 * @brief Undefined assignment operator. RenderSurface cannot be copied
221 RenderSurfaceInterface& operator=( const RenderSurfaceInterface& rhs );
225 Dali::Internal::Adaptor::AdaptorInternalServices* mAdaptor;
226 Dali::Internal::Adaptor::GraphicsInterface* mGraphics;
227 Dali::DisplayConnection* mDisplayConnection;
231 Integration::DepthBufferAvailable mDepthBufferRequired; ///< Whether the depth buffer is required
232 Integration::StencilBufferAvailable mStencilBufferRequired; ///< Whether the stencil buffer is required
234 Vector4 mBackgroundColor; ///< The background color of the surface
239 #endif // DALI_RENDER_SURFACE_INTERFACE_H