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