1 #ifndef __DALI_RENDER_SURFACE_H__
2 #define __DALI_RENDER_SURFACE_H__
5 * Copyright (c) 2018 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/math/rect.h>
23 #include <dali/public-api/object/any.h>
24 #include <dali/public-api/common/view-mode.h>
27 #include <dali/public-api/dali-adaptor-common.h>
33 class DisplayConnection;
34 class ThreadSynchronizationInterface;
41 } // namespace Integration
44 * @brief The position and size of the render surface.
46 typedef Dali::Rect<int> PositionSize;
49 * @brief Interface for a render surface onto which Dali draws.
51 * Dali::Adaptor requires a render surface to draw on to. This is
52 * usually a window in the native windowing system, or some other
53 * mapped pixel buffer.
55 * Dali::Application will automatically create a render surface using a window.
57 * The implementation of the factory method below should choose an appropriate
58 * implementation of RenderSurface for the given platform
67 WINDOW_RENDER_SURFACE,
68 PIXMAP_RENDER_SURFACE,
74 * Inlined as this is a pure abstract interface
79 * @brief Virtual Destructor.
80 * Inlined as this is a pure abstract interface
82 virtual ~RenderSurface() {}
85 * @brief Return the size and position of the surface.
86 * @return The position and size
88 virtual PositionSize GetPositionSize() const = 0;
92 * @param[out] dpiHorizontal set to the horizontal dpi
93 * @param[out] dpiVertical set to the vertical dpi
95 virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) = 0;
98 * Initialize EGL, RenderSurface should create egl display and initialize
99 * @param egl implementation to use for the creation
101 virtual void InitializeEgl( EglInterface& egl ) = 0;
104 * @brief Creates EGL Surface
105 * @param egl implementation to use for the creation
107 virtual void CreateEglSurface( EglInterface& egl ) = 0;
110 * @brief Destroys EGL Surface
111 * @param egl implementation to use for the destruction
113 virtual void DestroyEglSurface( EglInterface& egl ) = 0;
116 * @brief Replace the EGL Surface
117 * @param egl implementation to use for the creation
118 * @return true if context was lost
120 virtual bool ReplaceEGLSurface( EglInterface& egl ) = 0;
123 * @brief Resizes the underlying surface.
125 virtual void MoveResize( Dali::PositionSize positionSize ) = 0;
128 * @brief Set the stereoscopic 3D view mode
129 * @param[in] viewMode The new view mode
131 virtual void SetViewMode( ViewMode viewMode ) = 0;
134 * @brief Called when Render thread has started
136 virtual void StartRender() = 0;
139 * @brief Invoked by render thread before Core::Render
140 * If the operation fails, then Core::Render should not be called until there is
141 * a surface to render onto.
142 * @param[in] egl The Egl interface
143 * @param[in] glAbstraction OpenGLES abstraction interface
144 * @param[in] resizingSurface True if the surface is being resized
145 * @return True if the operation is successful, False if the operation failed
147 virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface ) = 0;
150 * @brief Invoked by render thread after Core::Render
151 * @param[in] egl The Egl interface
152 * @param[in] glAbstraction OpenGLES abstraction interface
153 * @param[in] displayConnection display connection
154 * @param[in] replacingSurface True if the surface is being replaced.
155 * @param[in] resizingSurface True if the surface is being resized.
157 virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface ) = 0;
160 * @brief Invoked by render thread when the thread should be stop
162 virtual void StopRender() = 0;
165 * @brief Invoked by Event Thread when the compositor lock should be released and rendering should resume.
167 virtual void ReleaseLock() = 0;
170 * @brief Sets the ThreadSynchronizationInterface
172 * @param threadSynchronization The thread-synchronization implementation.
174 virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) = 0;
177 * @brief Gets the surface type
179 virtual RenderSurface::Type GetSurfaceType() = 0;
184 * @brief Undefined copy constructor. RenderSurface cannot be copied
186 RenderSurface( const RenderSurface& rhs );
189 * @brief Undefined assignment operator. RenderSurface cannot be copied
191 RenderSurface& operator=( const RenderSurface& rhs );
196 #endif // __DALI_RENDER_SURFACE_H__