Revert "[Tizen] Implement partial update"
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-render-surface.h
1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_RENDER_SURFACE_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_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/internal/graphics/common/graphics-interface.h>
23
24 #ifdef DALI_ADAPTOR_COMPILATION
25 #include <dali/integration-api/egl-interface.h>
26 #include <dali/integration-api/render-surface-interface.h>
27 #else
28 #include <dali/integration-api/adaptors/egl-interface.h>
29 #include <dali/integration-api/adaptors/render-surface-interface.h>
30 #endif
31
32 // EXTERNAL INCLUDES
33 #include <dali/public-api/signals/connection-tracker.h>
34 #include <dali/public-api/signals/dali-signal.h>
35
36 namespace Dali
37 {
38
39 class TriggerEventInterface;
40
41 namespace Internal
42 {
43 namespace Adaptor
44 {
45
46 class WindowBase;
47 class AdaptorInternalServices;
48
49 /**
50  * Window interface of render surface.
51  */
52 class WindowRenderSurface : public Dali::RenderSurfaceInterface, public ConnectionTracker
53 {
54 public:
55
56   typedef Signal< void ( ) > OutputSignalType;
57
58   /**
59     * Uses an window surface to render to.
60     * @param [in] positionSize the position and size of the surface
61     * @param [in] surface can be a window or pixmap.
62     * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
63     */
64   WindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false );
65
66   /**
67    * @brief Destructor
68    */
69   virtual ~WindowRenderSurface();
70
71 public: // API
72
73   /**
74    * @brief Get the native window handle
75    * @return The native window handle
76    */
77   Any GetNativeWindow();
78
79   /**
80    * @brief Get the native window id
81    * @return The native window id
82    */
83   int GetNativeWindowId();
84
85   /**
86    * @brief Map window
87    */
88   void Map();
89
90   /**
91    * @brief Sets the render notification trigger to call when render thread is completed a frame
92    * @param renderNotification to use
93    */
94   void SetRenderNotification( TriggerEventInterface* renderNotification );
95
96   /**
97    * @brief Sets whether the surface is transparent or not.
98    * @param[in] transparent Whether the surface is transparent
99    */
100   void SetTransparency( bool transparent );
101
102   /**
103    * Request surface rotation
104    * @param[in] angle A new angle of the surface
105    * @param[in] width A new width of the surface
106    * @param[in] height A new height of the surface
107    */
108   void RequestRotation( int angle, int width, int height );
109
110   /**
111    * @brief Gets the window base object
112    * @return The window base object
113    */
114   WindowBase* GetWindowBase();
115
116   /**
117    * @brief This signal is emitted when the output is transformed.
118    */
119   OutputSignalType& OutputTransformedSignal();
120
121 public: // from Dali::Integration::RenderSurface
122
123   /**
124    * @copydoc Dali::Integration::RenderSurface::GetPositionSize()
125    */
126   virtual PositionSize GetPositionSize() const override;
127
128   /**
129    */
130   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
131
132   /**
133    * @brief Return the orientation of the surface.
134    * @return The orientation
135    */
136   virtual int GetOrientation() const override;
137
138   /**
139    * @copydoc Dali::Integration::RenderSurface::InitializeGraphics()
140    */
141   virtual void InitializeGraphics() override;
142
143   /**
144    * @copydoc Dali::Integration::RenderSurface::CreateSurface()
145    */
146   virtual void CreateSurface() override;
147
148   /**
149    * @copydoc Dali::Integration::RenderSurface::DestroySurface()
150    */
151   virtual void DestroySurface() override;
152
153   /**
154    * @copydoc Dali::Integration::RenderSurface::ReplaceGraphicsSurface()
155    */
156   virtual bool ReplaceGraphicsSurface() override;
157
158   /**
159    * @copydoc Dali::Integration::RenderSurface::MoveResize()
160    */
161   virtual void MoveResize( Dali::PositionSize positionSize) override;
162
163   /**
164    * @copydoc Dali::Integration::RenderSurface::StartRender()
165    */
166   virtual void StartRender() override;
167
168   /**
169    * @copydoc Dali::Integration::RenderSurface::PreRender()
170    */
171   virtual bool PreRender( bool resizingSurface ) override;
172
173   /**
174    * @copydoc Dali::Integration::RenderSurface::PostRender()
175    */
176   virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface );
177
178   /**
179    * @copydoc Dali::Integration::RenderSurface::StopRender()
180    */
181   virtual void StopRender() override;
182
183   /**
184    * @copydoc Dali::Integration::RenderSurface::SetThreadSynchronization
185    */
186   virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) override;
187
188   /**
189    * @copydoc Dali::Integration::RenderSurface::ReleaseLock()
190    */
191   virtual void ReleaseLock() override;
192
193   /**
194    * @copydoc Dali::Integration::RenderSurface::GetSurfaceType()
195    */
196   virtual Integration::RenderSurface::Type GetSurfaceType() override;
197
198   /**
199    * @copydoc Dali::Integration::RenderSurface::MakeContextCurrent()
200    */
201   virtual void MakeContextCurrent() override;
202
203   /**
204    * @copydoc Dali::Integration::RenderSurface::GetDepthBufferRequired()
205    */
206   virtual Integration::DepthBufferAvailable GetDepthBufferRequired() override;
207
208   /**
209    * @copydoc Dali::Integration::RenderSurface::GetStencilBufferRequired()
210    */
211   virtual Integration::StencilBufferAvailable GetStencilBufferRequired() override;
212
213 private:
214
215   /**
216    * @brief Second stage construction
217    */
218   void Initialize( Any surface );
219
220   /**
221    * Notify output is transformed.
222    */
223   void OutputTransformed();
224
225   /**
226    * @brief Used as the callback for the rotation-trigger.
227    */
228   void ProcessRotationRequest();
229
230 protected:
231
232   // Undefined
233   WindowRenderSurface(const WindowRenderSurface&) = delete;
234
235   // Undefined
236   WindowRenderSurface& operator=(const WindowRenderSurface& rhs) = delete;
237
238 private: // Data
239
240   EglInterface*                   mEGL;
241   Dali::DisplayConnection*        mDisplayConnection;
242   PositionSize                    mPositionSize;       ///< Position
243   std::unique_ptr< WindowBase >   mWindowBase;
244   ThreadSynchronizationInterface* mThreadSynchronization;
245   TriggerEventInterface*          mRenderNotification; ///< Render notification trigger
246   TriggerEventInterface*          mRotationTrigger;
247   GraphicsInterface*              mGraphics;           ///< Graphics interface
248   EGLSurface                      mEGLSurface;
249   EGLContext                      mEGLContext;
250   ColorDepth                      mColorDepth;         ///< Color depth of surface (32 bit or 24 bit)
251   OutputSignalType                mOutputTransformedSignal;
252   int                             mRotationAngle;
253   int                             mScreenRotationAngle;
254   bool                            mOwnSurface;         ///< Whether we own the surface (responsible for deleting it)
255   bool                            mRotationSupported;
256   bool                            mRotationFinished;
257   bool                            mScreenRotationFinished;
258   bool                            mResizeFinished;
259
260   uint32_t                        mDpiHorizontal;
261   uint32_t                        mDpiVertical;
262
263 }; // class WindowRenderSurface
264
265 } // namespace Adaptor
266
267 } // namespace internal
268
269 } // namespace Dali
270
271 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_RENDER_SURFACE_H