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