Revert "[Tizen] Revert "Support multiple window rendering""
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / ubuntu-x11 / pixmap-render-surface-ecore-x.h
1 #ifndef DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H
2 #define DALI_ECORE_X_PIXMAP_RENDER_SURFACE_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 // INTERNAL INCLUDES
22 #include <dali/integration-api/egl-interface.h>
23 #include <dali/internal/graphics/gles/egl-implementation.h>
24 #include <dali/internal/window-system/common/pixmap-render-surface.h>
25 #include <dali/internal/window-system/ubuntu-x11/ecore-x-types.h>
26 #include <dali/public-api/dali-adaptor-common.h>
27 #include <dali/internal/graphics/common/graphics-interface.h>
28
29 // EXTERNAL INCLUDES
30 #include <dali/devel-api/threading/conditional-wait.h>
31 #include <Ecore_X.h>
32
33
34 namespace Dali
35 {
36 namespace Internal
37 {
38 namespace Adaptor
39 {
40
41 /**
42  * Ecore X11 Pixmap implementation of render surface.
43  */
44 class PixmapRenderSurfaceEcoreX : public PixmapRenderSurface
45 {
46 public:
47
48   /**
49     * Uses an X11 surface to render to.
50     * @param [in] positionSize the position and size of the surface
51     * @param [in] surface can be a X-window or X-pixmap (type must be unsigned int).
52     * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
53     */
54   PixmapRenderSurfaceEcoreX( Dali::PositionSize positionSize, Any surface, bool isTransparent = false );
55
56   /**
57    * @brief Destructor
58    */
59   virtual ~PixmapRenderSurfaceEcoreX();
60
61 public: // from WindowRenderSurface
62
63   /**
64    * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::GetSurface()
65    */
66   virtual Any GetSurface() override;
67
68   /**
69    * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::SetRenderNotification()
70    */
71   virtual void SetRenderNotification( TriggerEventInterface* renderNotification ) 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 ) override;
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 private: // from PixmapRenderSurface
146
147   /**
148    * @copydoc Dali::Integration::RenderSurface::ReleaseLock()
149    */
150   virtual void ReleaseLock() override;
151
152   /**
153    * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
154    */
155   virtual void Initialize( Any surface ) override;
156
157   /**
158    * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
159    */
160   virtual void CreateRenderable() override;
161
162   /**
163    * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
164    */
165   virtual void UseExistingRenderable( unsigned int surfaceId ) override;
166
167 private:
168
169   /**
170    * Get the surface id if the surface parameter is not empty
171    * @param surface Any containing a surface id, or can be empty
172    * @return surface id, or zero if surface is empty
173    */
174   unsigned int GetSurfaceId( Any surface ) const;
175
176 private: // Data
177
178   static const int BUFFER_COUNT = 2;
179   GraphicsInterface*              mGraphics;               ///< Graphics interface
180   Dali::DisplayConnection*        mDisplayConnection;      ///< Display connection
181   PositionSize                    mPosition;               ///< Position
182   TriggerEventInterface*          mRenderNotification;     ///< Render notification trigger
183   ColorDepth                      mColorDepth;             ///< Color depth of surface (32 bit or 24 bit)
184   bool                            mOwnSurface;             ///< Whether we own the surface (responsible for deleting it)
185
186   int                             mProduceBufferIndex;
187   int                             mConsumeBufferIndex;
188   XPixmap                         mX11Pixmaps[BUFFER_COUNT];  ///< X-Pixmap
189   EGLSurface                      mEglSurfaces[BUFFER_COUNT];
190   ThreadSynchronizationInterface* mThreadSynchronization;     ///< A pointer to the thread-synchronization
191   ConditionalWait                 mPixmapCondition;           ///< condition to share pixmap
192 };
193
194 } // namespace Adaptor
195
196 } // namespace internal
197
198 } // namespace Dali
199
200 #endif // DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H