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