Revert "[Tizen] Implement partial update"
[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) 2019 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 <dali/internal/system/linux/dali-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    * @brief Return the orientation of the surface.
87    * @return The orientation
88    */
89   virtual int GetOrientation() const override;
90
91   /**
92    * @copydoc Dali::Integration::RenderSurface::InitializeGraphics()
93    */
94   virtual void InitializeGraphics() override;
95
96   /**
97    * @copydoc Dali::Integration::RenderSurface::CreateSurface()
98    */
99   virtual void CreateSurface() override;
100
101   /**
102    * @copydoc Dali::Integration::RenderSurface::DestroySurface()
103    */
104   virtual void DestroySurface() override;
105
106   /**
107    * @copydoc Dali::Integration::RenderSurface::ReplaceGraphicsSurface()
108    */
109   virtual bool ReplaceGraphicsSurface() override;
110
111   /**
112    * @copydoc Dali::Integration::RenderSurface::MoveResize()
113    */
114   virtual void MoveResize( Dali::PositionSize positionSize) override {}
115
116   /**
117    * @copydoc Dali::Integration::RenderSurface::StartRender()
118    */
119   virtual void StartRender() override;
120
121   /**
122    * @copydoc Dali::Integration::RenderSurface::PreRender()
123    */
124   virtual bool PreRender( bool resizingSurface ) override;
125
126   /**
127    * @copydoc Dali::Integration::RenderSurface::PostRender()
128    */
129   virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface ) override;
130
131   /**
132    * @copydoc Dali::Integration::RenderSurface::StopRender()
133    */
134   virtual void StopRender() override;
135
136   /**
137    * @copydoc Dali::Integration::RenderSurface::SetThreadSynchronization
138    */
139   virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) override;
140
141   /**
142    * @copydoc Dali::Integration::RenderSurface::GetSurfaceType()
143    */
144   virtual Integration::RenderSurface::Type GetSurfaceType() override;
145
146   /**
147    * @copydoc Dali::Integration::RenderSurface::MakeContextCurrent()
148    */
149   virtual void MakeContextCurrent() override;
150
151 private: // from PixmapRenderSurface
152
153   /**
154    * @copydoc Dali::Integration::RenderSurface::ReleaseLock()
155    */
156   virtual void ReleaseLock() override;
157
158   /**
159    * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
160    */
161   virtual void Initialize( Any surface ) override;
162
163   /**
164    * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
165    */
166   virtual void CreateRenderable() override;
167
168   /**
169    * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
170    */
171   virtual void UseExistingRenderable( unsigned int surfaceId ) override;
172
173 private:
174
175   /**
176    * Get the surface id if the surface parameter is not empty
177    * @param surface Any containing a surface id, or can be empty
178    * @return surface id, or zero if surface is empty
179    */
180   unsigned int GetSurfaceId( Any surface ) const;
181
182 private: // Data
183
184   static const int BUFFER_COUNT = 2;
185   GraphicsInterface*              mGraphics;               ///< Graphics interface
186   Dali::DisplayConnection*        mDisplayConnection;      ///< Display connection
187   PositionSize                    mPosition;               ///< Position
188   TriggerEventInterface*          mRenderNotification;     ///< Render notification trigger
189   ColorDepth                      mColorDepth;             ///< Color depth of surface (32 bit or 24 bit)
190   bool                            mOwnSurface;             ///< Whether we own the surface (responsible for deleting it)
191
192   int                             mProduceBufferIndex;
193   int                             mConsumeBufferIndex;
194   XPixmap                         mX11Pixmaps[BUFFER_COUNT];  ///< X-Pixmap
195   EGLSurface                      mEglSurfaces[BUFFER_COUNT];
196   ThreadSynchronizationInterface* mThreadSynchronization;     ///< A pointer to the thread-synchronization
197   ConditionalWait                 mPixmapCondition;           ///< condition to share pixmap
198 };
199
200 } // namespace Adaptor
201
202 } // namespace internal
203
204 } // namespace Dali
205
206 #endif // DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H