115 QGLScreen *glScreen = glScreenForDevice(0); |
115 QGLScreen *glScreen = glScreenForDevice(0); |
116 if (glScreen) |
116 if (glScreen) |
117 return (glScreen->options() & QGLScreen::Overlays); |
117 return (glScreen->options() & QGLScreen::Overlays); |
118 else |
118 else |
119 return false; |
119 return false; |
120 } |
|
121 |
|
122 void qt_egl_add_platform_config(QEglProperties& props, QPaintDevice *device) |
|
123 { |
|
124 // Find the QGLScreen for this paint device. |
|
125 QGLScreen *glScreen = glScreenForDevice(device); |
|
126 if (!glScreen) { |
|
127 qWarning("QGLContext::chooseContext(): The screen is not a QGLScreen"); |
|
128 return; |
|
129 } |
|
130 int devType = device->devType(); |
|
131 if (devType == QInternal::Image) |
|
132 props.setPixelFormat(static_cast<QImage *>(device)->format()); |
|
133 else |
|
134 props.setPixelFormat(glScreen->pixelFormat()); |
|
135 } |
120 } |
136 |
121 |
137 static EGLSurface qt_egl_create_surface |
122 static EGLSurface qt_egl_create_surface |
138 (QEglContext *context, QPaintDevice *device, |
123 (QEglContext *context, QPaintDevice *device, |
139 const QEglProperties *properties = 0) |
124 const QEglProperties *properties = 0) |
195 return false; |
180 return false; |
196 } |
181 } |
197 |
182 |
198 // Get the display and initialize it. |
183 // Get the display and initialize it. |
199 d->eglContext = new QEglContext(); |
184 d->eglContext = new QEglContext(); |
|
185 d->ownsEglContext = true; |
200 d->eglContext->setApi(QEgl::OpenGL); |
186 d->eglContext->setApi(QEgl::OpenGL); |
201 |
187 |
202 // Construct the configuration we need for this surface. |
188 // Construct the configuration we need for this surface. |
203 QEglProperties configProps; |
189 QEglProperties configProps; |
204 qt_egl_add_platform_config(configProps, device()); |
190 qt_eglproperties_set_glformat(configProps, d->glFormat); |
205 qt_egl_set_format(configProps, devType, d->glFormat); |
191 configProps.setDeviceType(devType); |
|
192 configProps.setPaintDeviceFormat(device()); |
206 configProps.setRenderableType(QEgl::OpenGL); |
193 configProps.setRenderableType(QEgl::OpenGL); |
207 |
194 |
208 // Search for a matching configuration, reducing the complexity |
195 // Search for a matching configuration, reducing the complexity |
209 // each time until we get something that matches. |
196 // each time until we get something that matches. |
210 if (!d->eglContext->chooseConfig(configProps)) { |
197 if (!d->eglContext->chooseConfig(configProps)) { |
212 d->eglContext = 0; |
199 d->eglContext = 0; |
213 return false; |
200 return false; |
214 } |
201 } |
215 |
202 |
216 // Inform the higher layers about the actual format properties. |
203 // Inform the higher layers about the actual format properties. |
217 qt_egl_update_format(*(d->eglContext), d->glFormat); |
204 qt_glformat_from_eglconfig(d->glFormat, d->eglContext->config()); |
218 |
205 |
219 // Create a new context for the configuration. |
206 // Create a new context for the configuration. |
220 if (!d->eglContext->createContext |
207 if (!d->eglContext->createContext |
221 (shareContext ? shareContext->d_func()->eglContext : 0)) { |
208 (shareContext ? shareContext->d_func()->eglContext : 0)) { |
222 delete d->eglContext; |
209 delete d->eglContext; |