Revert "[Tizen] Revert "Support multiple window rendering""
[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 #include <dali/internal/graphics/common/graphics-interface.h>
30
31 namespace Dali
32 {
33
34 class DisplayConnection;
35 class EglInterface;
36
37 /**
38  * Ecore Wayland Native implementation of render surface.
39  */
40 class NativeRenderSurfaceEcoreWl : public Dali::NativeRenderSurface
41 {
42 public:
43
44   /**
45     * Uses an Wayland surface to render to.
46     * @param [in] positionSize the position and size of the surface
47     * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
48     */
49   NativeRenderSurfaceEcoreWl( Dali::PositionSize positionSize, bool isTransparent = false );
50
51   /**
52    * @brief Destructor
53    */
54   virtual ~NativeRenderSurfaceEcoreWl();
55
56 public: // from WindowRenderSurface
57
58   /**
59    * @copydoc Dali::NativeRenderSurface::GetSurface()
60    */
61   virtual Any GetDrawable() override;
62
63   /**
64    * @copydoc Dali::NativeRenderSurface::SetRenderNotification()
65    */
66   virtual void SetRenderNotification( TriggerEventInterface* renderNotification ) override;
67
68   /**
69    * @copydoc Dali::NativeRenderSurface::WaitUntilSurfaceReplaced()
70    */
71   virtual void WaitUntilSurfaceReplaced() override;
72
73 public: // from Dali::Integration::RenderSurface
74
75   /**
76    * @copydoc Dali::Integration::RenderSurface::GetPositionSize()
77    */
78   virtual PositionSize GetPositionSize() const override;
79
80   /**
81    * @copydoc Dali::Integration::RenderSurface::GetDpi()
82    */
83   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
84
85   /**
86    * @copydoc Dali::Integration::RenderSurface::InitializeGraphics()
87    */
88   virtual void InitializeGraphics() override;
89
90   /**
91    * @copydoc Dali::Integration::RenderSurface::CreateSurface()
92    */
93   virtual void CreateSurface() override;
94
95   /**
96    * @copydoc Dali::Integration::RenderSurface::DestroySurface()
97    */
98   virtual void DestroySurface() override;
99
100   /**
101    * @copydoc Dali::Integration::RenderSurface::ReplaceGraphicsSurface()
102    */
103   virtual bool ReplaceGraphicsSurface() override;
104
105   /**
106    * @copydoc Dali::Integration::RenderSurface::MoveResize()
107    */
108   virtual void MoveResize( Dali::PositionSize positionSize) override;
109
110   /**
111    * @copydoc Dali::Integration::RenderSurface::StartRender()
112    */
113   virtual void StartRender() override;
114
115   /**
116    * @copydoc Dali::Integration::RenderSurface::PreRender()
117    */
118   virtual bool PreRender( bool resizingSurface ) override;
119
120   /**
121    * @copydoc Dali::Integration::RenderSurface::PostRender()
122    */
123   virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface );
124
125   /**
126    * @copydoc Dali::Integration::RenderSurface::StopRender()
127    */
128   virtual void StopRender() override;
129
130   /**
131    * @copydoc Dali::Integration::RenderSurface::SetThreadSynchronization
132    */
133   virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization )override;
134
135   /**
136    * @copydoc Dali::Integration::RenderSurface::GetSurfaceType()
137    */
138   virtual Integration::RenderSurface::Type GetSurfaceType() override;
139
140   /**
141    * @copydoc Dali::Integration::RenderSurface::MakeContextCurrent()
142    */
143   virtual void MakeContextCurrent() override;
144
145   /**
146    * @copydoc Dali::Integration::RenderSurface::GetDepthBufferRequired()
147    */
148   virtual Integration::DepthBufferAvailable GetDepthBufferRequired() override;
149
150   /**
151    * @copydoc Dali::Integration::RenderSurface::GetStencilBufferRequired()
152    */
153   virtual Integration::StencilBufferAvailable GetStencilBufferRequired() override;
154
155 private:
156
157   /**
158    * @copydoc Dali::Integration::RenderSurface::ReleaseLock()
159    */
160   virtual void ReleaseLock() override;
161
162   /**
163    * @copydoc Dali::NativeRenderSurface::CreateNativeRenderable()
164    */
165   virtual void CreateNativeRenderable() override;
166
167   /**
168    * @copydoc Dali::NativeRenderSurface::ReleaseDrawable()
169    */
170   virtual void ReleaseDrawable() override;
171
172 private: // Data
173
174   PositionSize                           mPosition;
175   TriggerEventInterface*                 mRenderNotification;
176   Internal::Adaptor::GraphicsInterface*  mGraphics;                  ///< The graphics interface
177   EglInterface*                          mEGL;
178   EGLSurface                             mEGLSurface;
179   EGLContext                             mEGLContext;
180   ColorDepth                             mColorDepth;
181   tbm_format                             mTbmFormat;
182   bool                                   mOwnSurface;
183   bool                                   mDrawableCompleted;
184
185   tbm_surface_queue_h                    mTbmQueue;
186   tbm_surface_h                          mConsumeSurface;
187   ThreadSynchronizationInterface*        mThreadSynchronization;     ///< A pointer to the thread-synchronization
188   ConditionalWait                        mTbmSurfaceCondition;
189
190 };
191
192 } // namespace Dali
193
194 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_NATIVE_SURFACE_ECORE_WL_H