5d26d162bfa34d22355a6a9cbb5aaa33ab039b29
[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   void PostRender();
133
134 private:
135
136   // Undefined
137   RenderHelper( const RenderHelper& RenderHelper );
138
139   // Undefined
140   RenderHelper& operator=( const RenderHelper& RenderHelper );
141
142 private: // Data
143
144   Integration::GlAbstraction&   mGLES;                   ///< GL abstraction reference
145   EglFactoryInterface*          mEglFactory;             ///< Factory class to create EGL implementation
146   EglInterface*                 mEGL;                    ///< Interface to EGL implementation
147   RenderSurface*                mSurface;                ///< Current surface
148   Dali::DisplayConnection*      mDisplayConnection;      ///< Display connection
149   bool                          mSurfaceReplaced;        ///< True when new surface has been initialized.
150   bool                          mSurfaceResized;         ///< True when the surface is resized.
151 };
152
153 } // namespace Adaptor
154
155 } // namespace Internal
156
157 } // namespace Dali
158
159 #endif // __DALI_INTERNAL_RENDER_HELPER_H__