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