11e01e1c333c7b7ca9dab17660c50035fd258118
[platform/core/uifw/dali-adaptor.git] / adaptors / integration-api / wayland / native-render-surface.h
1 #ifndef __DALI_NATIVE_RENDER_SURFACE_H__
2 #define __DALI_NATIVE_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 <tbm_surface.h>
23 #include <dali/public-api/common/dali-common.h>
24
25 // INTERNAL INCLUDES
26 #ifdef DALI_ADAPTOR_COMPILATION
27 #include <render-surface.h>
28 #include <egl-interface.h>
29 #else
30 #include <dali/devel-api/adaptor-framework/render-surface.h>
31 #include <dali/integration-api/adaptors/egl-interface.h>
32 #endif
33
34 namespace Dali
35 {
36
37 class TriggerEventInterface;
38
39 /**
40  * Ecore X11 implementation of render surface.
41  */
42 class DALI_IMPORT_API NativeRenderSurface : public Dali::RenderSurface
43 {
44 public:
45
46   /**
47     * Uses an Wayland surface to render to.
48     * @param [in] positionSize the position and size of the surface
49     * @param [in] name optional name of surface passed in
50     * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
51     */
52   NativeRenderSurface( Dali::PositionSize positionSize,
53                              const std::string& name,
54                              bool isTransparent = false );
55
56   /**
57    * @copydoc Dali::RenderSurface::~RenderSurface
58    */
59   virtual ~NativeRenderSurface();
60
61 public: // API
62
63   /**
64    * @brief Sets the render notification trigger to call when render thread is completed a frame
65    *
66    * @param renderNotification to use
67    */
68   void SetRenderNotification( TriggerEventInterface* renderNotification );
69
70   /**
71    * @brief Gets the tbm surface for offscreen rendering
72    */
73   virtual tbm_surface_h GetDrawable();
74
75   /**
76    * @brief Gets the surface
77    *
78    * @return TBM surface
79    */
80   virtual Any GetSurface();
81
82   /**
83    * @brief Waits until surface is replaced
84    * After tbm surface is acquired in PostRender, this function is finished.
85    */
86   void WaitUntilSurfaceReplaced();
87
88 public: // from Dali::RenderSurface
89
90   /**
91    * @copydoc Dali::RenderSurface::GetPositionSize()
92    */
93   virtual PositionSize GetPositionSize() const;
94
95   /**
96    * @copydoc Dali::RenderSurface::InitializeEgl()
97    */
98   virtual void InitializeEgl( EglInterface& egl );
99
100   /**
101    * @copydoc Dali::RenderSurface::CreateEglSurface()
102    */
103   virtual void CreateEglSurface( EglInterface& egl );
104
105   /**
106    * @copydoc Dali::RenderSurface::DestroyEglSurface()
107    */
108   virtual void DestroyEglSurface( EglInterface& egl );
109
110   /**
111    * @copydoc Dali::RenderSurface::ReplaceEGLSurface()
112    */
113   virtual bool ReplaceEGLSurface( EglInterface& egl );
114
115   /**
116    * @copydoc Dali::RenderSurface::MoveResize()
117    */
118   virtual void MoveResize( Dali::PositionSize positionSize);
119
120   /**
121    * @copydoc Dali::RenderSurface::SetViewMode()
122    */
123   void SetViewMode( ViewMode viewMode );
124
125   /**
126    * @copydoc Dali::RenderSurface::StartRender()
127    */
128   virtual void StartRender();
129
130   /**
131    * @copydoc Dali::RenderSurface::PreRender()
132    */
133   virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface );
134
135   /**
136    * @copydoc Dali::RenderSurface::PostRender()
137    */
138   virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface );
139
140   /**
141    * @copydoc Dali::RenderSurface::StopRender()
142    */
143   virtual void StopRender();
144
145   /**
146    * @copydoc Dali::RenderSurface::SetThreadSynchronization
147    */
148   virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization );
149
150   /**
151    * @copydoc Dali::RenderSurface::GetSurfaceType()
152    */
153   virtual RenderSurface::Type GetSurfaceType();
154
155 private:
156
157   /**
158    * Release any locks.
159    */
160   void ReleaseLock();
161
162   /**
163    * Create tbm surface
164    */
165   virtual void CreateNativeRenderable();
166
167   /**
168    * Release tbm surface
169    */
170   void ReleaseDrawable();
171
172 private: // Data
173
174   struct Impl;
175
176   Impl* mImpl;
177
178 };
179
180 } // namespace Dali
181
182 #endif // __DALI_NATIVE_RENDER_SURFACE_H__