[Tizen] Add screen and client rotation itself function
[platform/core/uifw/dali-adaptor.git] / dali / integration-api / adaptor-framework / render-surface-interface.h
1 #ifndef DALI_RENDER_SURFACE_INTERFACE_H
2 #define DALI_RENDER_SURFACE_INTERFACE_H
3
4 /*
5  * Copyright (c) 2019 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/integration-api/render-surface.h>
23 #include <dali/integration-api/core-enumerations.h>
24 #include <dali/public-api/math/vector4.h>
25
26 namespace Dali
27 {
28
29 class DisplayConnection;
30 class ThreadSynchronizationInterface;
31
32 namespace Internal
33 {
34 namespace Adaptor
35 {
36 class AdaptorInternalServices;
37 class GraphicsInterface;
38 }
39 }
40
41 /**
42  * @brief Interface for a render surface onto which Dali draws.
43  *
44  * Dali::Adaptor requires a render surface to draw on to. This is
45  * usually a window in the native windowing system, or some other
46  * mapped pixel buffer.
47  *
48  * Dali::Application will automatically create a render surface using a window.
49  *
50  * The implementation of the factory method below should choose an appropriate
51  * implementation of RenderSurface for the given platform
52  */
53
54 class RenderSurfaceInterface : public Dali::Integration::RenderSurface
55 {
56 public:
57
58   /**
59    * @brief Constructor
60    * Inlined as this is a pure abstract interface
61    */
62   RenderSurfaceInterface()
63   : mAdaptor( nullptr ),
64     mGraphics( nullptr ),
65     mDisplayConnection( nullptr ),
66     mDepthBufferRequired( Integration::DepthBufferAvailable::FALSE ),
67     mStencilBufferRequired( Integration::StencilBufferAvailable::FALSE )
68   {}
69
70   /**
71    * @brief Virtual Destructor.
72    * Inlined as this is a pure abstract interface
73    */
74   virtual ~RenderSurfaceInterface() {}
75
76   /**
77    * @brief Return the size and position of the surface.
78    * @return The position and size
79    */
80   virtual Dali::PositionSize GetPositionSize() const = 0;
81
82   /**
83    * @brief Get DPI
84    * @param[out] dpiHorizontal set to the horizontal dpi
85    * @param[out] dpiVertical set to the vertical dpi
86    */
87   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) = 0;
88
89   /**
90    * @brief Return the orientation of the surface.
91    * @return The orientation
92    */
93   virtual int GetOrientation() const = 0;
94
95   /**
96    * @brief InitializeGraphics the platform specific graphics surface interfaces
97    */
98   virtual void InitializeGraphics() = 0;
99
100   /**
101    * @brief Creates the Surface
102    */
103   virtual void CreateSurface() = 0;
104
105   /**
106    * @brief Destroys the Surface
107    */
108   virtual void DestroySurface() = 0;
109
110   /**
111    * @brief Replace the Surface
112    * @return true if context was lost
113    */
114   virtual bool ReplaceGraphicsSurface() = 0;
115
116   /**
117    * @brief Resizes the underlying surface.
118    * @param[in] The dimensions of the new position
119    */
120   virtual void MoveResize( Dali::PositionSize positionSize ) = 0;
121
122   /**
123    * @brief Called when Render thread has started
124    */
125   virtual void StartRender() = 0;
126
127   /**
128    * @brief Invoked by render thread before Core::Render
129    * If the operation fails, then Core::Render should not be called until there is
130    * a surface to render onto.
131    * @param[in] resizingSurface True if the surface is being resized
132    * @return True if the operation is successful, False if the operation failed
133    */
134   virtual bool PreRender( bool resizingSurface ) = 0;
135
136   /**
137    * @brief Invoked by render thread after Core::Render
138    * @param[in] renderToFbo True if render to FBO.
139    * @param[in] replacingSurface True if the surface is being replaced.
140    * @param[in] resizingSurface True if the surface is being resized.
141    */
142   virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface ) = 0;
143   /**
144    * @brief Invoked by render thread when the thread should be stop
145    */
146   virtual void StopRender() = 0;
147
148   /**
149    * @brief Invoked by Event Thread when the compositor lock should be released and rendering should resume.
150    */
151   virtual void ReleaseLock() = 0;
152
153   /**
154    * @brief Sets the ThreadSynchronizationInterface
155    *
156    * @param threadSynchronization The thread-synchronization implementation.
157    */
158   virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) = 0;
159
160   /**
161    * @brief Gets the surface type
162    */
163   virtual Dali::Integration::RenderSurface::Type GetSurfaceType() = 0;
164
165   /**
166    * @brief Makes the graphics context current
167    */
168   virtual void MakeContextCurrent() = 0;
169
170   /**
171    * @brief Get whether the depth buffer is required
172    * @return TRUE if the depth buffer is required
173    */
174   virtual Integration::DepthBufferAvailable GetDepthBufferRequired() = 0;
175
176   /**
177    * @brief Get whether the stencil buffer is required
178    * @return TRUE if the stencil buffer is required
179    */
180   virtual Integration::StencilBufferAvailable GetStencilBufferRequired() = 0;
181
182 public:
183
184   void SetAdaptor( Dali::Internal::Adaptor::AdaptorInternalServices& adaptor )
185   {
186     mAdaptor = &adaptor;
187   }
188
189   void SetGraphicsInterface( Dali::Internal::Adaptor::GraphicsInterface& graphics )
190   {
191     mGraphics = &graphics;
192   }
193
194   void SetDisplayConnection( Dali::DisplayConnection& displayConnection )
195   {
196     mDisplayConnection = &displayConnection;
197   }
198
199 private:
200
201   /**
202    * @brief Undefined copy constructor. RenderSurface cannot be copied
203    */
204   RenderSurfaceInterface( const RenderSurfaceInterface& rhs );
205
206   /**
207    * @brief Undefined assignment operator. RenderSurface cannot be copied
208    */
209   RenderSurfaceInterface& operator=( const RenderSurfaceInterface& rhs );
210
211 protected:
212
213   Dali::Internal::Adaptor::AdaptorInternalServices* mAdaptor;
214   Dali::Internal::Adaptor::GraphicsInterface* mGraphics;
215   Dali::DisplayConnection* mDisplayConnection;
216
217 private:
218
219   Integration::DepthBufferAvailable mDepthBufferRequired;       ///< Whether the depth buffer is required
220   Integration::StencilBufferAvailable mStencilBufferRequired;   ///< Whether the stencil buffer is required
221
222   Vector4 mBackgroundColor;                                     ///< The background color of the surface
223 };
224
225 } // namespace Dali
226
227 #endif // DALI_RENDER_SURFACE_INTERFACE_H