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