94 #if defined(QT_OPENGL_ES_2) |
94 #if defined(QT_OPENGL_ES_2) |
95 EGL_CONTEXT_CLIENT_VERSION, 2, |
95 EGL_CONTEXT_CLIENT_VERSION, 2, |
96 #endif |
96 #endif |
97 EGL_NONE |
97 EGL_NONE |
98 }; |
98 }; |
99 qPixmapARGBSharedEglContext = eglCreateContext(QEglContext::defaultDisplay(0), |
99 qPixmapARGBSharedEglContext = eglCreateContext(QEglContext::display(), |
100 argbConfig, 0, contextAttribs); |
100 argbConfig, 0, contextAttribs); |
101 |
101 |
102 if (argbConfig == rgbConfig) { |
102 if (argbConfig == rgbConfig) { |
103 // If the configs are the same, we can re-use the same context. |
103 // If the configs are the same, we can re-use the same context. |
104 qPixmapRGBSharedEglContext = qPixmapARGBSharedEglContext; |
104 qPixmapRGBSharedEglContext = qPixmapARGBSharedEglContext; |
105 } else { |
105 } else { |
106 qPixmapRGBSharedEglContext = eglCreateContext(QEglContext::defaultDisplay(0), |
106 qPixmapRGBSharedEglContext = eglCreateContext(QEglContext::display(), |
107 rgbConfig, 0, contextAttribs); |
107 rgbConfig, 0, contextAttribs); |
108 } |
108 } |
109 |
109 |
110 argbPixmapData = new QX11PixmapData(QPixmapData::PixmapType); |
110 argbPixmapData = new QX11PixmapData(QPixmapData::PixmapType); |
111 argbPixmapData->resize(100, 100); |
111 argbPixmapData->resize(100, 100); |
112 argbPixmapData->fill(Qt::transparent); // Force ARGB |
112 argbPixmapData->fill(Qt::transparent); // Force ARGB |
113 |
113 |
114 if (!qt_createEGLSurfaceForPixmap(argbPixmapData, false)) |
114 if (!qt_createEGLSurfaceForPixmap(argbPixmapData, false)) |
115 break; |
115 break; |
116 |
116 |
117 haveX11Pixmaps = eglMakeCurrent(QEglContext::defaultDisplay(0), |
117 haveX11Pixmaps = eglMakeCurrent(QEglContext::display(), |
118 (EGLSurface)argbPixmapData->gl_surface, |
118 (EGLSurface)argbPixmapData->gl_surface, |
119 (EGLSurface)argbPixmapData->gl_surface, |
119 (EGLSurface)argbPixmapData->gl_surface, |
120 qPixmapARGBSharedEglContext); |
120 qPixmapARGBSharedEglContext); |
121 if (!haveX11Pixmaps) { |
121 if (!haveX11Pixmaps) { |
122 EGLint err = eglGetError(); |
122 EGLint err = eglGetError(); |
132 |
132 |
133 // Try to actually create an EGL pixmap surface |
133 // Try to actually create an EGL pixmap surface |
134 if (!qt_createEGLSurfaceForPixmap(rgbPixmapData, false)) |
134 if (!qt_createEGLSurfaceForPixmap(rgbPixmapData, false)) |
135 break; |
135 break; |
136 |
136 |
137 haveX11Pixmaps = eglMakeCurrent(QEglContext::defaultDisplay(0), |
137 haveX11Pixmaps = eglMakeCurrent(QEglContext::display(), |
138 (EGLSurface)rgbPixmapData->gl_surface, |
138 (EGLSurface)rgbPixmapData->gl_surface, |
139 (EGLSurface)rgbPixmapData->gl_surface, |
139 (EGLSurface)rgbPixmapData->gl_surface, |
140 qPixmapRGBSharedEglContext); |
140 qPixmapRGBSharedEglContext); |
141 if (!haveX11Pixmaps) { |
141 if (!haveX11Pixmaps) { |
142 EGLint err = eglGetError(); |
142 EGLint err = eglGetError(); |
145 } |
145 } |
146 } |
146 } |
147 } while (0); |
147 } while (0); |
148 |
148 |
149 if (qPixmapARGBSharedEglContext || qPixmapRGBSharedEglContext) { |
149 if (qPixmapARGBSharedEglContext || qPixmapRGBSharedEglContext) { |
150 eglMakeCurrent(QEglContext::defaultDisplay(0), |
150 eglMakeCurrent(QEglContext::display(), |
151 EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
151 EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
152 } |
152 } |
153 |
153 |
154 if (argbPixmapData) { |
154 if (argbPixmapData) { |
155 if (argbPixmapData->gl_surface) |
155 if (argbPixmapData->gl_surface) |
165 } |
165 } |
166 |
166 |
167 if (!haveX11Pixmaps) { |
167 if (!haveX11Pixmaps) { |
168 // Clean up the context(s) if we can't use X11GL pixmaps |
168 // Clean up the context(s) if we can't use X11GL pixmaps |
169 if (qPixmapARGBSharedEglContext != EGL_NO_CONTEXT) |
169 if (qPixmapARGBSharedEglContext != EGL_NO_CONTEXT) |
170 eglDestroyContext(QEglContext::defaultDisplay(0), qPixmapARGBSharedEglContext); |
170 eglDestroyContext(QEglContext::display(), qPixmapARGBSharedEglContext); |
171 |
171 |
172 if (qPixmapRGBSharedEglContext != qPixmapARGBSharedEglContext && |
172 if (qPixmapRGBSharedEglContext != qPixmapARGBSharedEglContext && |
173 qPixmapRGBSharedEglContext != EGL_NO_CONTEXT) |
173 qPixmapRGBSharedEglContext != EGL_NO_CONTEXT) |
174 { |
174 { |
175 eglDestroyContext(QEglContext::defaultDisplay(0), qPixmapRGBSharedEglContext); |
175 eglDestroyContext(QEglContext::display(), qPixmapRGBSharedEglContext); |
176 } |
176 } |
177 qPixmapRGBSharedEglContext = EGL_NO_CONTEXT; |
177 qPixmapRGBSharedEglContext = EGL_NO_CONTEXT; |
178 qPixmapARGBSharedEglContext = EGL_NO_CONTEXT; |
178 qPixmapARGBSharedEglContext = EGL_NO_CONTEXT; |
179 } |
179 } |
180 |
180 |
210 // We need to create the context before beginPaint - do it here: |
210 // We need to create the context before beginPaint - do it here: |
211 if (!ctx) { |
211 if (!ctx) { |
212 ctx = new QGLContext(glFormat()); |
212 ctx = new QGLContext(glFormat()); |
213 if (ctx->d_func()->eglContext == 0) |
213 if (ctx->d_func()->eglContext == 0) |
214 ctx->d_func()->eglContext = new QEglContext(); |
214 ctx->d_func()->eglContext = new QEglContext(); |
215 ctx->d_func()->eglContext->openDisplay(0); // ;-) |
|
216 ctx->d_func()->eglContext->setApi(QEgl::OpenGL); |
215 ctx->d_func()->eglContext->setApi(QEgl::OpenGL); |
217 ctx->d_func()->eglContext->setContext(hasAlphaChannel() ? qPixmapARGBSharedEglContext |
216 ctx->d_func()->eglContext->setContext(hasAlphaChannel() ? qPixmapARGBSharedEglContext |
218 : qPixmapRGBSharedEglContext); |
217 : qPixmapRGBSharedEglContext); |
219 } |
218 } |
220 |
219 |