1 #ifndef DALI_INTERNAL_EGL_IMPLEMENTATION_H
2 #define DALI_INTERNAL_EGL_IMPLEMENTATION_H
5 * Copyright (c) 2017 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>
25 #include <dali/integration-api/core-enumerations.h>
28 #include <dali/integration-api/egl-interface.h>
39 * EglImplementation class provides an EGL implementation.
41 class EglImplementation : public EglInterface
47 * @param[in] multiSamplingLevel The Multi-sampling level required
48 * @param[in] depthBufferRequired Whether the depth buffer is required
49 * @param[in] stencilBufferRequired Whether the stencil buffer is required
51 EglImplementation( int multiSamplingLevel,
52 Integration::DepthBufferAvailable depthBufferRequired,
53 Integration::StencilBufferAvailable stencilBufferRequired );
58 virtual ~EglImplementation();
63 * (Called from ECoreX::RenderSurface, not RenderThread, so not in i/f, hence, not virtual)
65 * @param display The display
66 * @param isOwnSurface whether the surface is own or not
67 * @return true on success, false on failure
69 bool InitializeGles( EGLNativeDisplayType display, bool isOwnSurface = true );
72 * Create the OpenGL context.
73 * @return true if successful
75 virtual bool CreateContext();
78 * Destroy the OpenGL context.
80 void DestroyContext();
83 * Destroy the OpenGL surface.
85 void DestroySurface();
88 * Make the OpenGL context current
90 virtual void MakeContextCurrent();
93 * clear the OpenGL context
95 void MakeContextNull();
98 * @brief Make the OpenGL surface current
100 * @param pixmap The pixmap to replace the current surface
101 * @param eglSurface The eglSurface to replace the current OpenGL surface.
103 void MakeCurrent( EGLNativePixmapType pixmap, EGLSurface eglSurface );
108 virtual void TerminateGles();
111 * Checks if GL is initialised
112 * @return true if it is
114 bool IsGlesInitialized() const;
117 * Performs an OpenGL swap buffers command
119 virtual void SwapBuffers();
122 * Performs an OpenGL copy buffers command
124 virtual void CopyBuffers();
127 * Performs an EGL wait GL command
129 virtual void WaitGL();
132 * Choose config of egl
133 * @param isWindowType whether the config for window or pixmap
134 * @param colorDepth Bit per pixel value (ex. 32 or 24)
136 void ChooseConfig( bool isWindowType, ColorDepth depth );
139 * Create an OpenGL surface using a window
140 * @param window The window to create the surface on
141 * @param colorDepth Bit per pixel value (ex. 32 or 24)
142 * @return true on success, false on failure
144 void CreateSurfaceWindow( EGLNativeWindowType window, ColorDepth depth );
147 * Create the OpenGL surface using a pixmap
148 * @param pixmap The pixmap to create the surface on
149 * @param colorDepth Bit per pixel value (ex. 32 or 24)
150 * @return Handle to an off-screen EGL pixmap surface (the requester has an ownership of this egl surface)
152 EGLSurface CreateSurfacePixmap( EGLNativePixmapType pixmap, ColorDepth depth );
155 * Replaces the render surface
156 * @param[in] window, the window to create the new surface on
157 * @return true if the context was lost due to a change in display
158 * between old surface and new surface
160 bool ReplaceSurfaceWindow( EGLNativeWindowType window );
163 * Replaces the render surface
164 * @param[in] pixmap, the pixmap to replace the new surface on
165 * @param[out] eglSurface, the eglSurface is created using a pixmap.
166 * @return true if the context was lost due to a change in x-display
167 * between old surface and new surface
169 bool ReplaceSurfacePixmap( EGLNativePixmapType pixmap, EGLSurface& eglSurface );
172 * returns the display with which this object was initialized
173 * @return the EGL Display.
175 EGLDisplay GetDisplay() const;
178 * Returns the EGL context
179 * @return the EGL context.
181 EGLContext GetContext() const;
185 Vector<EGLint> mContextAttribs;
187 EGLNativeDisplayType mEglNativeDisplay;
189 EGLNativeWindowType mEglNativeWindow;
191 EGLNativePixmapType mCurrentEglNativePixmap;
193 EGLDisplay mEglDisplay;
194 EGLConfig mEglConfig;
195 EGLContext mEglContext;
196 EGLSurface mCurrentEglSurface;
198 int mMultiSamplingLevel;
200 ColorDepth mColorDepth;
202 bool mGlesInitialized;
204 bool mContextCurrent;
206 bool mDepthBufferRequired;
207 bool mStencilBufferRequired;
210 } // namespace Adaptor
212 } // namespace Internal
216 #endif // DALI_INTERNAL_EGL_IMPLEMENTATION_H