PixmapSurface changes to double buffered pixmap.
[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) 2015 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    * Shuts down EGL.
106    *
107    * @note Called from render thread
108    */
109   void ShutdownEgl();
110
111   /**
112    * Called before core renders the scene
113    *
114    * @return true if successful and Core::Render should be called.
115    *
116    * @note Called from render thread
117    */
118   bool PreRender();
119
120   /**
121    * Called after core has rendered the scene
122    *
123    * @note Called from render thread
124    */
125   void PostRender();
126
127 private:
128
129   // Undefined
130   RenderHelper( const RenderHelper& RenderHelper );
131
132   // Undefined
133   RenderHelper& operator=( const RenderHelper& RenderHelper );
134
135 private: // Data
136
137   Integration::GlAbstraction&   mGLES;                   ///< GL abstraction reference
138   EglFactoryInterface*          mEglFactory;             ///< Factory class to create EGL implementation
139   EglInterface*                 mEGL;                    ///< Interface to EGL implementation
140   RenderSurface*                mSurface;                ///< Current surface
141   Dali::DisplayConnection*      mDisplayConnection;      ///< Display connection
142   bool                          mSurfaceReplaced;        ///< True when new surface has been initialized.
143 };
144
145 } // namespace Adaptor
146
147 } // namespace Internal
148
149 } // namespace Dali
150
151 #endif // __DALI_INTERNAL_RENDER_HELPER_H__