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 <dali/public-api/common/dali-vector.h>
27 #include <adaptors/integration-api/egl-interface.h>
38 * EglImplementation class provides an EGL implementation.
40 class EglImplementation : public EglInterface
45 * @param environmentOptions To check the envirionment options
47 EglImplementation( unsigned int multiSamplingLevel );
52 virtual ~EglImplementation();
57 * (Called from ECoreX::RenderSurface, not RenderThread, so not in i/f, hence, not virtual)
59 * @param display The display
60 * @param isOwnSurface whether the surface is own or not
61 * @return true on success, false on failure
63 bool InitializeGles( EGLNativeDisplayType display, bool isOwnSurface = true );
66 * Create the OpenGL context.
67 * @return true if successful
69 virtual bool CreateContext();
72 * Destroy the OpenGL context.
74 void DestroyContext();
77 * Destroy the OpenGL surface.
79 void DestroySurface();
82 * Make the OpenGL context current
84 virtual void MakeContextCurrent();
87 * clear the OpenGL context
89 void MakeContextNull();
92 * @brief Make the OpenGL surface current
94 * @param pixmap The pixmap to replace the current surface
95 * @param eglSurface The eglSurface to replace the current OpenGL surface.
97 void MakeCurrent( EGLNativePixmapType pixmap, EGLSurface eglSurface );
102 virtual void TerminateGles();
105 * Checks if GL is initialised
106 * @return true if it is
108 bool IsGlesInitialized() const;
111 * Performs an OpenGL swap buffers command
113 virtual void SwapBuffers();
116 * Performs an OpenGL copy buffers command
118 virtual void CopyBuffers();
121 * Performs an EGL wait GL command
123 virtual void WaitGL();
126 * Choose config of egl
127 * @param isWindowType whether the config for window or pixmap
128 * @param colorDepth Bit per pixel value (ex. 32 or 24)
130 void ChooseConfig( bool isWindowType, ColorDepth depth );
133 * Create an OpenGL surface using a window
134 * @param window The window to create the surface on
135 * @param colorDepth Bit per pixel value (ex. 32 or 24)
136 * @return true on success, false on failure
138 void CreateSurfaceWindow( EGLNativeWindowType window, ColorDepth depth );
141 * Create the OpenGL surface using a pixmap
142 * @param pixmap The pixmap to create the surface on
143 * @param colorDepth Bit per pixel value (ex. 32 or 24)
144 * @return Handle to an off-screen EGL pixmap surface (the requester has an ownership of this egl surface)
146 EGLSurface CreateSurfacePixmap( EGLNativePixmapType pixmap, ColorDepth depth );
149 * Replaces the render surface
150 * @param[in] window, the window to create the new surface on
151 * @return true if the context was lost due to a change in display
152 * between old surface and new surface
154 bool ReplaceSurfaceWindow( EGLNativeWindowType window );
157 * Replaces the render surface
158 * @param[in] pixmap, the pixmap to replace the new surface on
159 * @param[out] eglSurface, the eglSurface is created using a pixmap.
160 * @return true if the context was lost due to a change in x-display
161 * between old surface and new surface
163 bool ReplaceSurfacePixmap( EGLNativePixmapType pixmap, EGLSurface& eglSurface );
166 * returns the display with which this object was initialized
167 * @return the EGL Display.
169 EGLDisplay GetDisplay() const;
172 * Returns the EGL context
173 * @return the EGL context.
175 EGLContext GetContext() const;
179 Vector<EGLint> mContextAttribs;
181 EGLNativeDisplayType mEglNativeDisplay;
183 EGLNativeWindowType mEglNativeWindow;
185 EGLNativePixmapType mCurrentEglNativePixmap;
187 EGLDisplay mEglDisplay;
188 EGLConfig mEglConfig;
189 EGLContext mEglContext;
190 EGLSurface mCurrentEglSurface;
192 bool mGlesInitialized;
194 bool mContextCurrent;
196 ColorDepth mColorDepth;
198 unsigned int mMultiSamplingLevel;
201 } // namespace Adaptor
203 } // namespace Internal
207 #endif // __DALI_INTERNAL_EGL_IMPLEMENTATION_H__