WindowRenderSurface and EventHandler refactoring
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / native-render-surface-ecore-wl.h
1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_NATIVE_SURFACE_ECORE_WL_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_NATIVE_SURFACE_ECORE_WL_H
3
4 /*
5  * Copyright (c) 2018 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 <tbm_surface_queue.h>
24 #include <dali/devel-api/threading/conditional-wait.h>
25
26 // INTERNAL INCLUDES
27 #include <dali/public-api/dali-adaptor-common.h>
28 #include <dali/integration-api/native-render-surface.h>
29
30 namespace Dali
31 {
32
33 /**
34  * Ecore Wayland Native implementation of render surface.
35  */
36 class NativeRenderSurfaceEcoreWl : public Dali::NativeRenderSurface
37 {
38 public:
39
40   /**
41     * Uses an Wayland surface to render to.
42     * @param [in] positionSize the position and size of the surface
43     * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
44     */
45   NativeRenderSurfaceEcoreWl( Dali::PositionSize positionSize, bool isTransparent = false );
46
47   /**
48    * @brief Destructor
49    */
50   virtual ~NativeRenderSurfaceEcoreWl();
51
52 public: // from WindowRenderSurface
53
54   /**
55    * @copydoc Dali::NativeRenderSurface::GetSurface()
56    */
57   virtual Any GetDrawable() override;
58
59   /**
60    * @copydoc Dali::NativeRenderSurface::SetRenderNotification()
61    */
62   virtual void SetRenderNotification( TriggerEventInterface* renderNotification ) override;
63
64   /**
65    * @copydoc Dali::NativeRenderSurface::WaitUntilSurfaceReplaced()
66    */
67   virtual void WaitUntilSurfaceReplaced() override;
68
69 public: // from Dali::RenderSurface
70
71   /**
72    * @copydoc Dali::RenderSurface::GetPositionSize()
73    */
74   virtual PositionSize GetPositionSize() const override;
75
76   /**
77    * @copydoc Dali::RenderSurface::GetDpi()
78    */
79   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
80
81   /**
82    * @copydoc Dali::RenderSurface::InitializeEgl()
83    */
84   virtual void InitializeEgl( EglInterface& egl ) override;
85
86   /**
87    * @copydoc Dali::RenderSurface::CreateEglSurface()
88    */
89   virtual void CreateEglSurface( EglInterface& egl ) override;
90
91   /**
92    * @copydoc Dali::RenderSurface::DestroyEglSurface()
93    */
94   virtual void DestroyEglSurface( EglInterface& egl ) override;
95
96   /**
97    * @copydoc Dali::RenderSurface::ReplaceEGLSurface()
98    */
99   virtual bool ReplaceEGLSurface( EglInterface& egl ) override;
100
101   /**
102    * @copydoc Dali::RenderSurface::MoveResize()
103    */
104   virtual void MoveResize( Dali::PositionSize positionSize) override;
105
106   /**
107    * @copydoc Dali::RenderSurface::SetViewMode()
108    */
109   virtual void SetViewMode( ViewMode viewMode ) override;
110
111   /**
112    * @copydoc Dali::RenderSurface::StartRender()
113    */
114   virtual void StartRender() override;
115
116   /**
117    * @copydoc Dali::RenderSurface::PreRender()
118    */
119   virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface ) override;
120
121   /**
122    * @copydoc Dali::RenderSurface::PostRender()
123    */
124   virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface ) override;
125
126   /**
127    * @copydoc Dali::RenderSurface::StopRender()
128    */
129   virtual void StopRender() override;
130
131   /**
132    * @copydoc Dali::RenderSurface::SetThreadSynchronization
133    */
134   virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization )override;
135
136   /**
137    * @copydoc Dali::RenderSurface::GetSurfaceType()
138    */
139   virtual RenderSurface::Type GetSurfaceType() override;
140
141 private:
142
143   /**
144    * @copydoc Dali::RenderSurface::ReleaseLock()
145    */
146   virtual void ReleaseLock() override;
147
148   /**
149    * @copydoc Dali::NativeRenderSurface::CreateNativeRenderable()
150    */
151   virtual void CreateNativeRenderable() override;
152
153   /**
154    * @copydoc Dali::NativeRenderSurface::ReleaseDrawable()
155    */
156   virtual void ReleaseDrawable() override;
157
158 private: // Data
159
160   PositionSize                    mPosition;
161   TriggerEventInterface*          mRenderNotification;
162   ColorDepth                      mColorDepth;
163   tbm_format                      mTbmFormat;
164   bool                            mOwnSurface;
165   bool                            mDrawableCompleted;
166
167   tbm_surface_queue_h             mTbmQueue;
168   tbm_surface_h                   mConsumeSurface;
169   ThreadSynchronizationInterface* mThreadSynchronization;     ///< A pointer to the thread-synchronization
170   ConditionalWait                 mTbmSurfaceCondition;
171
172 };
173
174 } // namespace Dali
175
176 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_NATIVE_SURFACE_ECORE_WL_H