DALi Version 1.0.30
[platform/core/uifw/dali-adaptor.git] / adaptors / 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 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 <render-surface.h>
23 #include <dali/public-api/common/dali-common.h>
24 #include <dali/public-api/common/view-mode.h>
25 #include <base/interfaces/egl-interface.h>
26
27 namespace Dali
28 {
29
30 namespace Integration
31 {
32
33 class GlAbstraction;
34
35 } // namespace Integration
36
37 namespace Internal
38 {
39
40 namespace Adaptor
41 {
42
43 class EglInterface;
44
45 /**
46  * This is the internal RenderSurface API
47  */
48 class RenderSurface : public Dali::RenderSurface
49 {
50 public:
51
52   /**
53    * Constructor
54    */
55   RenderSurface();
56
57   /**
58    * Destructor
59    */
60   virtual ~RenderSurface();
61
62 public: // API
63
64   /**
65    * Initialize EGL, RenderSurface should create egl display and initialize
66    * @param egl implementation to use for the creation
67    */
68   virtual void InitializeEgl( EglInterface& egl ) = 0;
69
70   /**
71    * Creates EGL Surface
72    * @param egl implementation to use for the creation
73    */
74   virtual void CreateEglSurface( EglInterface& egl ) = 0;
75
76   /**
77    * Destroys EGL Surface
78    * @param egl implementation to use for the destruction
79    */
80   virtual void DestroyEglSurface( EglInterface& egl ) = 0;
81
82   /**
83    * Replace the EGL Surface
84    * @param egl implementation to use for the creation
85    * @return true if context was lost
86    */
87   virtual bool ReplaceEGLSurface( EglInterface& egl ) = 0;
88
89   /**
90    * Resizes the underlying surface.
91    * Only available for x window
92    */
93   virtual void MoveResize( Dali::PositionSize positionSize ) = 0;
94
95   /**
96    * Get DPI
97    * @param dpiHorizontal set to the horizontal dpi
98    * @param dpiVertical set to the vertical dpi
99    */
100   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) const = 0;
101
102   /**
103    * Call to map the surface (only works if surface is a window)
104    */
105   virtual void Map() = 0;
106
107   /**
108    * Transfers the ownership of a display
109    * @param newSurface to transfer
110    */
111   virtual void TransferDisplayOwner( Internal::Adaptor::RenderSurface& newSurface ) = 0;
112
113   /**
114    *  Consumes any possible events on the queue so that there is no leaking between frames
115    */
116   virtual void ConsumeEvents() = 0;
117
118   /**
119    * Set the stereoscopic 3D view mode
120    * @param[in] viewMode The new view mode
121    */
122   virtual void SetViewMode( ViewMode viewMode ) = 0;
123
124   /**
125    * Called when Render thread has started
126    */
127   virtual void StartRender() = 0;
128
129   /**
130    * Invoked by render thread before Core::Render
131    * If the operation fails, then Core::Render should not be called until there is
132    * a surface to render onto.
133    * @param[in] egl The Egl interface
134    * @param[in] glAbstraction OpenGLES abstraction interface
135    * @return True if the operation is successful, False if the operation failed
136    */
137   virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction ) = 0;
138
139   /**
140    * Invoked by render thread after Core::Render
141    * @param[in] egl The Egl interface
142    * @param[in] glAbstraction OpenGLES abstraction interface
143    * @param[in] deltaTime Time (in microseconds) since PostRender was last called.
144    * @param[in] replacingSurface True if the surface is being replaced.
145    */
146   virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int deltaTime, bool replacingSurface ) = 0;
147
148   /**
149    * Invoked by render thread when the thread should be stop
150    */
151   virtual void StopRender() = 0;
152
153   /**
154    * Invoked by Event Thread when the compositor lock should be released and rendering should resume.
155    */
156   virtual void ReleaseLock() = 0;
157 };
158
159 } // namespace Adaptor
160
161 } // namespace internal
162
163 } // namespace Dali
164
165 #endif // __DALI_INTERNAL_RENDER_SURFACE_H__