Revert "[Tizen] Revert "Support screen rotation""
[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) 2017 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 class ThreadSynchronizationInterface;
35
36 namespace Integration
37 {
38
39 class GlAbstraction;
40
41 } // namespace Integration
42
43 /**
44  * @brief The position and size of the render surface.
45  */
46 typedef Dali::Rect<int> PositionSize;
47
48 /**
49  * @brief Interface for a render surface onto which Dali draws.
50  *
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.
54  *
55  * Dali::Application will automatically create a render surface using a window.
56  *
57  * The implementation of the factory method below should choose an appropriate
58  * implementation of RenderSurface for the given platform
59  */
60
61 class RenderSurface
62 {
63 public:
64
65   enum Type
66   {
67     ECORE_RENDER_SURFACE,
68     WAYLAND_RENDER_SURFACE,
69     NATIVE_RENDER_SURFACE
70   };
71
72   /**
73    * @brief Constructor
74    * Inlined as this is a pure abstract interface
75    */
76   RenderSurface() {}
77
78   /**
79    * @brief Virtual Destructor.
80    * Inlined as this is a pure abstract interface
81    */
82   virtual ~RenderSurface() {}
83
84   /**
85    * @brief Return the size and position of the surface.
86    * @return The position and size
87    */
88   virtual PositionSize GetPositionSize() const = 0;
89
90   /**
91    * Initialize EGL, RenderSurface should create egl display and initialize
92    * @param egl implementation to use for the creation
93    */
94   virtual void InitializeEgl( EglInterface& egl ) = 0;
95
96   /**
97    * @brief Creates EGL Surface
98    * @param egl implementation to use for the creation
99    */
100   virtual void CreateEglSurface( EglInterface& egl ) = 0;
101
102   /**
103    * @brief Destroys EGL Surface
104    * @param egl implementation to use for the destruction
105    */
106   virtual void DestroyEglSurface( EglInterface& egl ) = 0;
107
108   /**
109    * @brief Replace the EGL Surface
110    * @param egl implementation to use for the creation
111    * @return true if context was lost
112    */
113   virtual bool ReplaceEGLSurface( EglInterface& egl ) = 0;
114
115   /**
116    * @brief Resizes the underlying surface. Only available for x window
117    */
118   virtual void MoveResize( Dali::PositionSize positionSize ) = 0;
119
120   /**
121    * @brief Set the stereoscopic 3D view mode
122    * @param[in] viewMode The new view mode
123    */
124   virtual void SetViewMode( ViewMode viewMode ) = 0;
125
126   /**
127    * @brief Called when Render thread has started
128    */
129   virtual void StartRender() = 0;
130
131   /**
132    * @brief Invoked by render thread before Core::Render
133    * If the operation fails, then Core::Render should not be called until there is
134    * a surface to render onto.
135    * @param[in] egl The Egl interface
136    * @param[in] glAbstraction OpenGLES abstraction interface
137    * @param[in] resizingSurface True if the surface is being resized
138    * @return True if the operation is successful, False if the operation failed
139    */
140   virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface ) = 0;
141
142   /**
143    * @brief Invoked by render thread after Core::Render
144    * @param[in] egl The Egl interface
145    * @param[in] glAbstraction OpenGLES abstraction interface
146    * @param[in] displayConnection display connection
147    * @param[in] replacingSurface True if the surface is being replaced.
148    * @param[in] resizingSurface True if the surface is being resized.
149    */
150   virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface ) = 0;
151
152   /**
153    * @brief Invoked by render thread when the thread should be stop
154    */
155   virtual void StopRender() = 0;
156
157   /**
158    * @brief Invoked by Event Thread when the compositor lock should be released and rendering should resume.
159    */
160   virtual void ReleaseLock() = 0;
161
162   /**
163    * @brief Sets the ThreadSynchronizationInterface
164    *
165    * @param threadSynchronization The thread-synchronization implementation.
166    */
167   virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) = 0;
168
169   virtual RenderSurface::Type GetSurfaceType() = 0;
170
171 private:
172
173   /**
174    * @brief Undefined copy constructor. RenderSurface cannot be copied
175    */
176   RenderSurface( const RenderSurface& rhs );
177
178   /**
179    * @brief Undefined assignment operator. RenderSurface cannot be copied
180    */
181   RenderSurface& operator=( const RenderSurface& rhs );
182 };
183
184 } // namespace Dali
185
186 #endif // __DALI_RENDER_SURFACE_H__