1 #ifndef __DALI_INTERNAL_EGL_IMPLEMENTATION_H__
2 #define __DALI_INTERNAL_EGL_IMPLEMENTATION_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #include <EGL/eglext.h>
24 #include <boost/any.hpp>
25 #include <dali/public-api/common/dali-vector.h>
28 #include <base/interfaces/egl-interface.h>
44 * EglImplementation class provides an EGL implementation.
46 class EglImplementation : public EglInterface
57 virtual ~EglImplementation();
62 * (Called from ECoreX::RenderSurface, not RenderThread, so not in i/f, hence, not virtual)
64 * @param display The display
65 * @param isOwnSurface whether the surface is own or not
66 * @return true on success, false on failure
68 bool InitializeGles( EGLNativeDisplayType display, bool isOwnSurface = true );
71 * Create the OpenGL context.
72 * @return true if successful
74 virtual bool CreateContext();
77 * Destroy the OpenGL context.
79 void DestroyContext();
82 * Destroy the OpenGL surface.
84 void DestroySurface();
87 * Make the OpenGL context current
89 virtual void MakeContextCurrent();
92 * clear the OpenGL context
94 void MakeContextNull();
99 virtual void TerminateGles();
102 * Checks if GL is initialised
103 * @return true if it is
105 bool IsGlesInitialized() const;
108 * Performs an OpenGL swap buffers command
110 virtual void SwapBuffers();
113 * Performs an OpenGL copy buffers command
115 virtual void CopyBuffers();
118 * Performs an EGL wait GL command
120 virtual void WaitGL();
123 * Choose config of egl
124 * @param isWindowType whether the config for window or pixmap
125 * @param colorDepth Bit per pixel value (ex. 32 or 24)
127 void ChooseConfig( bool isWindowType, ColorDepth depth );
130 * Create an OpenGL surface using a window
131 * @param window The window to create the surface on
132 * @param colorDepth Bit per pixel value (ex. 32 or 24)
133 * @return true on success, false on failure
135 void CreateSurfaceWindow( EGLNativeWindowType window, ColorDepth depth );
138 * Create the OpenGL surface using a pixmap
139 * @param pixmap The pixmap to create the surface on
140 * @param colorDepth Bit per pixel value (ex. 32 or 24)
141 * @return true on success, false on failure
143 void CreateSurfacePixmap( EGLNativePixmapType pixmap, ColorDepth depth );
146 * Replaces the render surface
147 * @param[in] window, the window to create the new surface on
148 * @param[in] display, the display
149 * @return true if the context was lost due to a change in display
150 * between old surface and new surface
152 bool ReplaceSurfaceWindow( EGLNativeWindowType window, EGLNativeDisplayType display );
155 * Replaces the render surface
156 * @param[in] pixmap, the pixmap to create the new surface on
157 * @param[in] display, the display
158 * @return true if the context was lost due to a change in x-display
159 * between old surface and new surface
161 bool ReplaceSurfacePixmap( EGLNativePixmapType pixmap, EGLNativeDisplayType display );
164 * returns the display with which this object was initialized
165 * @return the EGL Display.
167 EGLDisplay GetDisplay() const;
170 * Returns the EGL context
171 * @return the EGL context.
173 EGLContext GetContext() const;
177 Vector<EGLint> mContextAttribs;
179 EGLNativeDisplayType mEglNativeDisplay;
180 EGLNativeWindowType mEglNativeWindow;
181 EGLNativePixmapType mEglNativePixmap;
183 EGLDisplay mEglDisplay;
184 EGLConfig mEglConfig;
185 EGLContext mEglContext;
186 EGLSurface mEglSurface;
188 bool mGlesInitialized;
190 bool mContextCurrent;
192 ColorDepth mColorDepth;
195 } // namespace Adaptor
197 } // namespace Internal
201 #endif // __DALI_INTERNAL_EGL_IMPLEMENTATION_H__