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 * Sets the refresh sync mode.
111 virtual bool SetRefreshSync( SyncMode mode );
114 * Performs an OpenGL swap buffers command
116 virtual void SwapBuffers();
119 * Performs an OpenGL copy buffers command
121 virtual void CopyBuffers();
124 * Performs an EGL wait GL command
126 virtual void WaitGL();
129 * Choose config of egl
130 * @param isWindowType whether the config for window or pixmap
131 * @param colorDepth Bit per pixel value (ex. 32 or 24)
133 void ChooseConfig( bool isWindowType, ColorDepth depth );
136 * Create an OpenGL surface using a window
137 * @param window The window to create the surface on
138 * @param colorDepth Bit per pixel value (ex. 32 or 24)
139 * @return true on success, false on failure
141 void CreateSurfaceWindow( EGLNativeWindowType window, ColorDepth depth );
144 * Create the OpenGL surface using a pixmap
145 * @param pixmap The pixmap to create the surface on
146 * @param colorDepth Bit per pixel value (ex. 32 or 24)
147 * @return true on success, false on failure
149 void CreateSurfacePixmap( EGLNativePixmapType pixmap, ColorDepth depth );
152 * Replaces the render surface
153 * @param[in] window, the window to create the new surface on
154 * @param[in] display, the display
155 * @return true if the context was lost due to a change in display
156 * between old surface and new surface
158 bool ReplaceSurfaceWindow( EGLNativeWindowType window, EGLNativeDisplayType display );
161 * Replaces the render surface
162 * @param[in] pixmap, the pixmap to create the new surface on
163 * @param[in] display, the display
164 * @return true if the context was lost due to a change in x-display
165 * between old surface and new surface
167 bool ReplaceSurfacePixmap( EGLNativePixmapType pixmap, EGLNativeDisplayType display );
170 * returns the display with which this object was initialized
171 * @return the EGL Display.
173 EGLDisplay GetDisplay() const;
176 * Returns the EGL context
177 * @return the EGL context.
179 EGLContext GetContext() const;
183 Vector<EGLint> mContextAttribs;
185 EGLNativeDisplayType mEglNativeDisplay;
186 EGLNativeWindowType mEglNativeWindow;
187 EGLNativePixmapType mEglNativePixmap;
189 EGLDisplay mEglDisplay;
190 EGLConfig mEglConfig;
191 EGLContext mEglContext;
192 EGLSurface mEglSurface;
194 bool mGlesInitialized;
197 bool mContextCurrent;
199 ColorDepth mColorDepth;
202 } // namespace Adaptor
204 } // namespace Internal
208 #endif // __DALI_INTERNAL_EGL_IMPLEMENTATION_H__