bef71c0227322f06e5bae3c2cbc1aab1e8854d48
[platform/core/uifw/dali-adaptor.git] / adaptors / tizen / internal / common / render-surface-impl.h
1 #ifndef __DALI_INTERNAL_RENDER_SURFACE_H__
2 #define __DALI_INTERNAL_RENDER_SURFACE_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // EXTERNAL INCLUDES
21 #include <dali/public-api/adaptor-framework/common/render-surface.h>
22 #include <dali/public-api/common/dali-common.h>
23 #include <dali/public-api/common/view-mode.h>
24
25 namespace Dali
26 {
27
28 namespace Integration
29 {
30
31 class GlAbstraction;
32
33 } // namespace Integration
34
35 namespace Internal
36 {
37
38 namespace Adaptor
39 {
40
41 class EglInterface;
42
43 /**
44  * This is the internal RenderSurface API
45  */
46 class DALI_IMPORT_API RenderSurface : public Dali::RenderSurface
47 {
48 public:
49
50   enum SyncMode
51   {
52     SYNC_MODE_NONE,               ///< Do not wait for RenderSync
53     SYNC_MODE_WAIT                ///< Wait for RenderSync
54   };
55
56 public:
57
58   /**
59    * Constructor
60    */
61   RenderSurface();
62
63   /**
64    * Destructor
65    */
66   virtual ~RenderSurface();
67
68 public: // API
69
70   /**
71    * Initialize EGL, RenderSurface should create egl display and initialize
72    * @param egl implementation to use for the creation
73    */
74   virtual void InitializeEgl( EglInterface& egl ) = 0;
75
76   /**
77    * Creates EGL Surface
78    * @param egl implementation to use for the creation
79    */
80   virtual void CreateEglSurface( EglInterface& egl ) = 0;
81
82   /**
83    * Destroyes EGL Surface
84    * @param egl implementation to use for the destruction
85    */
86   virtual void DestroyEglSurface( EglInterface& egl ) = 0;
87
88   /**
89    * Replace the EGL Surface
90    * @param egl implementation to use for the creation
91    * @return true if context was lost
92    */
93   virtual bool ReplaceEGLSurface( EglInterface& egl ) = 0;
94
95   /**
96    * Resizes the underlying surface.
97    * Only available for x window
98    */
99   virtual void MoveResize( Dali::PositionSize positionSize ) = 0;
100
101   /**
102    * Get DPI
103    * @param dpiHorizontal set to the horizontal dpi
104    * @param dpiVertical set to the vertical dpi
105    */
106   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) const = 0;
107
108   /**
109    * Call to map the surface (only works if surface is a window)
110    */
111   virtual void Map() = 0;
112
113   /**
114    * Transfers the ownership of a display
115    * @param newSurface to transfer
116    */
117   virtual void TransferDisplayOwner( Internal::Adaptor::RenderSurface& newSurface ) = 0;
118
119   /**
120    *  Consumes any possible events on the queue so that there is no leaking between frames
121    */
122   virtual void ConsumeEvents() = 0;
123
124   /**
125    * Set the stereoscopic 3D view mode
126    * @param[in] viewMode The new view mode
127    */
128   virtual void SetViewMode( ViewMode viewMode ) = 0;
129
130   /**
131    * Called after offscreen is posted to onscreen
132    */
133   virtual void RenderSync() = 0;
134
135   /**
136    * Invoked by render thread before Core::Render
137    * @param[in] egl The Egl interface
138    * @param[in] glAbstraction OpenGLES abstraction interface
139    * @return True if the operation is successful
140    */
141   virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction ) = 0;
142
143   /**
144    * Invoked by render thread after Core::Render
145    * @param[in] egl The Egl interface
146    * @param[in] glAbstraction OpenGLES abstraction interface
147    * @param[in] deltaTime Time (in microseconds) since PostRender was last called.
148    * @param[in] syncMode Wait for render sync flag.
149    *                     RenderSync will be skipped if this or SetSyncMode() is set to SYNC_MODE_NONE.
150    */
151   virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int deltaTime, SyncMode syncMode ) = 0;
152
153   /**
154    * Invoked by render thread when the thread should be stop
155    */
156   virtual void StopRender() = 0;
157
158   /**
159    * Set whether the surface should wait for RenderSync notifications
160    * @param[in] syncMode Wait for render sync flag. A member of SyncMode
161    */
162   virtual void SetSyncMode( SyncMode syncMode ) = 0;
163 };
164
165 } // namespace Adaptor
166
167 } // namespace internal
168
169 } // namespace Dali
170
171 #endif // __DALI_INTERNAL_RENDER_SURFACE_H__