Graphics and Vulkan integration within Adaptor
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / common / render-helper.h
1 #ifndef DALI_INTERNAL_RENDER_HELPER_H
2 #define DALI_INTERNAL_RENDER_HELPER_H
3
4 /*
5  * Copyright (c) 2017 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/egl-interface.h>
23 #include <dali/integration-api/render-surface.h>
24
25 namespace Dali
26 {
27
28 class RenderSurface;
29 class DisplayConnection;
30
31 namespace Integration
32 {
33 class GlAbstraction;
34 namespace Graphics
35 {
36 class Graphics;
37 }
38 }
39
40 namespace Internal
41 {
42 namespace Adaptor
43 {
44
45 class AdaptorInternalServices;
46 class EglFactoryInterface;
47
48 /**
49  * Helper class for EGL, surface, pre & post rendering
50  */
51 class RenderHelper
52 {
53 public:
54
55   /**
56    * Create a RenderHelper.
57    * @param[in] adaptorInterfaces base adaptor interface
58    */
59   RenderHelper( AdaptorInternalServices& adaptorInterfaces );
60
61   /**
62    * Non-virtual Destructor
63    */
64   ~RenderHelper();
65
66   /////////////////////////////////////////////////////////////////////////////////////////////////
67   // Called on the Event Thread
68   /////////////////////////////////////////////////////////////////////////////////////////////////
69
70   /**
71    * Sets up all render related objects to start rendering.
72    */
73   void Start();
74
75   /**
76    * Sets up all render related objects to stop rendering.
77    */
78   void Stop();
79
80   /////////////////////////////////////////////////////////////////////////////////////////////////
81   // Called on the Rendering Thread
82   /////////////////////////////////////////////////////////////////////////////////////////////////
83
84   /**
85    * Consumes any pending events to avoid memory leaks
86    *
87    * @note Called from rendering thread
88    */
89   void ConsumeEvents();
90
91   /**
92    * Initializes EGL.
93    *
94    * @note Called from rendering thread
95    */
96   void InitializeEgl();
97
98   /**
99    * Replaces the rendering surface
100    *
101    * Used for replacing pixmaps due to resizing
102    * @param newSurface to use
103    *
104    * @note Called from render thread
105    */
106   void ReplaceSurface( RenderSurface* newSurface );
107
108   /**
109    * Resize the rendering surface.
110    *
111    * @note Called from render thread
112    */
113   void ResizeSurface();
114
115   /**
116    * Shuts down EGL.
117    *
118    * @note Called from render thread
119    */
120   void ShutdownEgl();
121
122   /**
123    * Called before core renders the scene
124    *
125    * @return true if successful and Core::Render should be called.
126    *
127    * @note Called from render thread
128    */
129   bool PreRender();
130
131   /**
132    * Called after core has rendered the scene
133    *
134    * @note Called from render thread
135    *
136    * @param[in] renderToFbo Whether to render to a Frame Buffer Object.
137    */
138   void PostRender( bool renderToFbo );
139
140 private:
141
142   // Undefined
143   RenderHelper( const RenderHelper& RenderHelper );
144
145   // Undefined
146   RenderHelper& operator=( const RenderHelper& RenderHelper );
147
148 private: // Data
149
150   Integration::GlAbstraction&       mGLES;                   ///< GL abstraction reference
151   EglFactoryInterface*              mEglFactory;             ///< Factory class to create EGL implementation
152   EglInterface*                     mEGL;                    ///< Interface to EGL implementation
153   RenderSurface*                    mSurface;                ///< Current surface
154   Dali::DisplayConnection*          mDisplayConnection;      ///< Display connection
155   Integration::Graphics::Graphics&  mGraphics;
156   bool                              mSurfaceReplaced;        ///< True when new surface has been initialized.
157   bool                              mSurfaceResized;         ///< True when the surface is resized.
158 };
159
160 } // namespace Adaptor
161
162 } // namespace Internal
163
164 } // namespace Dali
165
166 #endif // DALI_INTERNAL_RENDER_HELPER_H