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