Simplified ThreadController
[platform/core/uifw/dali-adaptor.git] / adaptors / devel-api / adaptor-framework / render-surface.h
1 #ifndef __DALI_RENDER_SURFACE_H__
2 #define __DALI_RENDER_SURFACE_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/math/rect.h>
23 #include <dali/public-api/object/any.h>
24 #include <dali/public-api/common/dali-common.h>
25 #include <dali/public-api/common/view-mode.h>
26
27 // INTERNAL INCLUDES
28
29 namespace Dali
30 {
31
32 class EglInterface;
33 class DisplayConnection;
34
35 namespace Integration
36 {
37
38 class GlAbstraction;
39
40 } // namespace Integration
41
42 /**
43  * @brief The position and size of the render surface.
44  */
45 typedef Dali::Rect<int> PositionSize;
46
47 /**
48  * @brief Interface for a render surface onto which Dali draws.
49  *
50  * Dali::Adaptor requires a render surface to draw on to. This is
51  * usually a window in the native windowing system, or some other
52  * mapped pixel buffer.
53  *
54  * Dali::Application will automatically create a render surface using a window.
55  *
56  * The implementation of the factory method below should choose an appropriate
57  * implementation of RenderSurface for the given platform
58  */
59
60 class RenderSurface
61 {
62 public:
63
64   /**
65    * @brief Constructor
66    * Inlined as this is a pure abstract interface
67    */
68   RenderSurface() {}
69
70   /**
71    * @brief Virtual Destructor.
72    * Inlined as this is a pure abstract interface
73    */
74   virtual ~RenderSurface() {}
75
76   /**
77    * @brief Return the size and position of the surface.
78    * @return The position and size
79    */
80   virtual PositionSize GetPositionSize() const = 0;
81
82   /**
83    * Initialize EGL, RenderSurface should create egl display and initialize
84    * @param egl implementation to use for the creation
85    */
86   virtual void InitializeEgl( EglInterface& egl ) = 0;
87
88   /**
89    * @brief Creates EGL Surface
90    * @param egl implementation to use for the creation
91    */
92   virtual void CreateEglSurface( EglInterface& egl ) = 0;
93
94   /**
95    * @brief Destroys EGL Surface
96    * @param egl implementation to use for the destruction
97    */
98   virtual void DestroyEglSurface( EglInterface& egl ) = 0;
99
100   /**
101    * @brief Replace the EGL Surface
102    * @param egl implementation to use for the creation
103    * @return true if context was lost
104    */
105   virtual bool ReplaceEGLSurface( EglInterface& egl ) = 0;
106
107   /**
108    * @brief Resizes the underlying surface. Only available for x window
109    */
110   virtual void MoveResize( Dali::PositionSize positionSize ) = 0;
111
112   /**
113    * @brief Set the stereoscopic 3D view mode
114    * @param[in] viewMode The new view mode
115    */
116   virtual void SetViewMode( ViewMode viewMode ) = 0;
117
118   /**
119    * @brief Called when Render thread has started
120    */
121   virtual void StartRender() = 0;
122
123   /**
124    * @brief Invoked by render thread before Core::Render
125    * If the operation fails, then Core::Render should not be called until there is
126    * a surface to render onto.
127    * @param[in] egl The Egl interface
128    * @param[in] glAbstraction OpenGLES abstraction interface
129    * @return True if the operation is successful, False if the operation failed
130    */
131   virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction ) = 0;
132
133   /**
134    * @brief Invoked by render thread after Core::Render
135    * @param[in] egl The Egl interface
136    * @param[in] glAbstraction OpenGLES abstraction interface
137    * @param[in] displayConnection display connection
138    * @param[in] replacingSurface True if the surface is being replaced.
139    */
140   virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface ) = 0;
141
142   /**
143    * @brief Invoked by render thread when the thread should be stop
144    */
145   virtual void StopRender() = 0;
146
147   /**
148    * @brief Invoked by Event Thread when the compositor lock should be released and rendering should resume.
149    */
150   virtual void ReleaseLock() = 0;
151
152 private:
153
154   /**
155    * @brief Undefined copy constructor. RenderSurface cannot be copied
156    */
157   RenderSurface( const RenderSurface& rhs );
158
159   /**
160    * @brief Undefined assignment operator. RenderSurface cannot be copied
161    */
162   RenderSurface& operator=( const RenderSurface& rhs );
163 };
164
165 } // namespace Dali
166
167 #endif // __DALI_RENDER_SURFACE_H__