Revert "[Tizen] Add screen and client rotation itself function"
[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) 2020 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 <dali/devel-api/threading/conditional-wait.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/dali-adaptor-common.h>
26 #include <dali/integration-api/adaptor-framework/egl-interface.h>
27 #include <dali/internal/graphics/common/graphics-interface.h>
28 #include <dali/internal/graphics/gles/egl-implementation.h>
29 #include <dali/internal/system/linux/dali-ecore-x.h>
30 #include <dali/internal/window-system/common/pixmap-render-surface.h>
31 #include <dali/internal/window-system/ubuntu-x11/ecore-x-types.h>
32
33 namespace Dali
34 {
35 namespace Internal
36 {
37 namespace Adaptor
38 {
39
40 /**
41  * Ecore X11 Pixmap implementation of render surface.
42  */
43 class PixmapRenderSurfaceEcoreX : public PixmapRenderSurface
44 {
45 public:
46
47   /**
48     * Uses an X11 surface to render to.
49     * @param [in] positionSize the position and size of the surface
50     * @param [in] surface can be a X-window or X-pixmap (type must be unsigned int).
51     * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
52     */
53   PixmapRenderSurfaceEcoreX( Dali::PositionSize positionSize, Any surface, bool isTransparent = false );
54
55   /**
56    * @brief Destructor
57    */
58   virtual ~PixmapRenderSurfaceEcoreX();
59
60 public: // from WindowRenderSurface
61
62   /**
63    * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::GetSurface()
64    */
65   virtual Any GetSurface() override;
66
67   /**
68    * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::SetRenderNotification()
69    */
70   virtual void SetRenderNotification( TriggerEventInterface* renderNotification ) override;
71
72 public: // from Dali::RenderSurfaceInterface
73
74   /**
75    * @copydoc Dali::RenderSurfaceInterface::GetPositionSize()
76    */
77   virtual PositionSize GetPositionSize() const override;
78
79   /**
80    * @copydoc Dali::RenderSurfaceInterface::GetDpi()
81    */
82   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
83
84   /**
85    * @copydoc Dali::RenderSurfaceInterface::InitializeGraphics()
86    */
87   virtual void InitializeGraphics() override;
88
89   /**
90    * @copydoc Dali::RenderSurfaceInterface::CreateSurface()
91    */
92   virtual void CreateSurface() override;
93
94   /**
95    * @copydoc Dali::RenderSurfaceInterface::DestroySurface()
96    */
97   virtual void DestroySurface() override;
98
99   /**
100    * @copydoc Dali::RenderSurfaceInterface::ReplaceGraphicsSurface()
101    */
102   virtual bool ReplaceGraphicsSurface() override;
103
104   /**
105    * @copydoc Dali::RenderSurfaceInterface::MoveResize()
106    */
107   virtual void MoveResize( Dali::PositionSize positionSize) override {}
108
109   /**
110    * @copydoc Dali::RenderSurfaceInterface::StartRender()
111    */
112   virtual void StartRender() override;
113
114   /**
115    * @copydoc Dali::RenderSurfaceInterface::PreRender()
116    */
117   virtual bool PreRender( bool resizingSurface ) override;
118
119   /**
120    * @copydoc Dali::RenderSurfaceInterface::PostRender()
121    */
122   virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface ) override;
123
124   /**
125    * @copydoc Dali::RenderSurfaceInterface::StopRender()
126    */
127   virtual void StopRender() override;
128
129   /**
130    * @copydoc Dali::RenderSurfaceInterface::SetThreadSynchronization
131    */
132   virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) override;
133
134   /**
135    * @copydoc Dali::RenderSurfaceInterface::GetSurfaceType()
136    */
137   virtual Dali::RenderSurfaceInterface::Type GetSurfaceType() override;
138
139   /**
140    * @copydoc Dali::RenderSurfaceInterface::MakeContextCurrent()
141    */
142   virtual void MakeContextCurrent() override;
143
144 private: // from PixmapRenderSurface
145
146   /**
147    * @copydoc Dali::RenderSurfaceInterface::ReleaseLock()
148    */
149   virtual void ReleaseLock() override;
150
151   /**
152    * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
153    */
154   virtual void Initialize( Any surface ) override;
155
156   /**
157    * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
158    */
159   virtual void CreateRenderable() override;
160
161   /**
162    * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
163    */
164   virtual void UseExistingRenderable( unsigned int surfaceId ) override;
165
166 private:
167
168   /**
169    * Get the surface id if the surface parameter is not empty
170    * @param surface Any containing a surface id, or can be empty
171    * @return surface id, or zero if surface is empty
172    */
173   unsigned int GetSurfaceId( Any surface ) const;
174
175 private: // Data
176
177   static const int BUFFER_COUNT = 2;
178   GraphicsInterface*              mGraphics;               ///< Graphics interface
179   Dali::DisplayConnection*        mDisplayConnection;      ///< Display connection
180   PositionSize                    mPosition;               ///< Position
181   TriggerEventInterface*          mRenderNotification;     ///< Render notification trigger
182   ColorDepth                      mColorDepth;             ///< Color depth of surface (32 bit or 24 bit)
183   bool                            mOwnSurface;             ///< Whether we own the surface (responsible for deleting it)
184
185   int                             mProduceBufferIndex;
186   int                             mConsumeBufferIndex;
187   XPixmap                         mX11Pixmaps[BUFFER_COUNT];  ///< X-Pixmap
188   EGLSurface                      mEglSurfaces[BUFFER_COUNT];
189   ThreadSynchronizationInterface* mThreadSynchronization;     ///< A pointer to the thread-synchronization
190   ConditionalWait                 mPixmapCondition;           ///< condition to share pixmap
191 };
192
193 } // namespace Adaptor
194
195 } // namespace internal
196
197 } // namespace Dali
198
199 #endif // DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H