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