equal
deleted
inserted
replaced
188 |
188 |
189 // Get the display and initialize it. |
189 // Get the display and initialize it. |
190 if (d->eglContext == 0) { |
190 if (d->eglContext == 0) { |
191 d->eglContext = new QEglContext(); |
191 d->eglContext = new QEglContext(); |
192 d->eglContext->setApi(QEgl::OpenGL); |
192 d->eglContext->setApi(QEgl::OpenGL); |
193 if (!d->eglContext->openDisplay(device())) { |
|
194 delete d->eglContext; |
|
195 d->eglContext = 0; |
|
196 return false; |
|
197 } |
|
198 |
193 |
199 // Construct the configuration we need for this surface. |
194 // Construct the configuration we need for this surface. |
200 QEglProperties configProps; |
195 QEglProperties configProps; |
201 qt_egl_set_format(configProps, devType, d->glFormat); |
196 qt_egl_set_format(configProps, devType, d->glFormat); |
202 qt_egl_add_platform_config(configProps, device()); |
197 qt_egl_add_platform_config(configProps, device()); |
612 configAttribs.setValue(EGL_SAMPLE_BUFFERS, 1); |
607 configAttribs.setValue(EGL_SAMPLE_BUFFERS, 1); |
613 } |
608 } |
614 |
609 |
615 EGLint configCount = 0; |
610 EGLint configCount = 0; |
616 do { |
611 do { |
617 eglChooseConfig(QEglContext::defaultDisplay(0), configAttribs.properties(), targetConfig, 1, &configCount); |
612 eglChooseConfig(QEglContext::display(), configAttribs.properties(), targetConfig, 1, &configCount); |
618 if (configCount > 0) { |
613 if (configCount > 0) { |
619 // Got one |
614 // Got one |
620 qDebug() << "Found an" << (hasAlpha ? "ARGB" : "RGB") << (readOnly ? "readonly" : "target" ) |
615 qDebug() << "Found an" << (hasAlpha ? "ARGB" : "RGB") << (readOnly ? "readonly" : "target" ) |
621 << "config (" << int(*targetConfig) << ") to create a pixmap surface:"; |
616 << "config (" << int(*targetConfig) << ") to create a pixmap surface:"; |
622 |
617 |
651 pixmapAttribs.setValue(EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA); |
646 pixmapAttribs.setValue(EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA); |
652 else |
647 else |
653 pixmapAttribs.setValue(EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB); |
648 pixmapAttribs.setValue(EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB); |
654 |
649 |
655 EGLSurface pixmapSurface; |
650 EGLSurface pixmapSurface; |
656 pixmapSurface = eglCreatePixmapSurface(QEglContext::defaultDisplay(0), |
651 pixmapSurface = eglCreatePixmapSurface(QEglContext::display(), |
657 pixmapConfig, |
652 pixmapConfig, |
658 (EGLNativePixmapType) pixmapData->handle(), |
653 (EGLNativePixmapType) pixmapData->handle(), |
659 pixmapAttribs.properties()); |
654 pixmapAttribs.properties()); |
660 // qDebug("qt_createEGLSurfaceForPixmap() created surface 0x%x for pixmap 0x%x", |
655 // qDebug("qt_createEGLSurfaceForPixmap() created surface 0x%x for pixmap 0x%x", |
661 // pixmapSurface, pixmapData->handle()); |
656 // pixmapSurface, pixmapData->handle()); |
760 { |
755 { |
761 Q_ASSERT(pmd->classId() == QPixmapData::X11Class); |
756 Q_ASSERT(pmd->classId() == QPixmapData::X11Class); |
762 QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd); |
757 QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd); |
763 if (pixmapData->gl_surface) { |
758 if (pixmapData->gl_surface) { |
764 EGLBoolean success; |
759 EGLBoolean success; |
765 success = eglDestroySurface(QEglContext::defaultDisplay(0), (EGLSurface)pixmapData->gl_surface); |
760 success = eglDestroySurface(QEglContext::display(), (EGLSurface)pixmapData->gl_surface); |
766 if (success == EGL_FALSE) { |
761 if (success == EGL_FALSE) { |
767 qWarning() << "destroyGlSurfaceForPixmap() - Error deleting surface: " |
762 qWarning() << "destroyGlSurfaceForPixmap() - Error deleting surface: " |
768 << QEglContext::errorString(eglGetError()); |
763 << QEglContext::errorString(eglGetError()); |
769 } |
764 } |
770 pixmapData->gl_surface = 0; |
765 pixmapData->gl_surface = 0; |
775 { |
770 { |
776 Q_ASSERT(pmd->classId() == QPixmapData::X11Class); |
771 Q_ASSERT(pmd->classId() == QPixmapData::X11Class); |
777 QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd); |
772 QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd); |
778 if (pixmapData->gl_surface) { |
773 if (pixmapData->gl_surface) { |
779 EGLBoolean success; |
774 EGLBoolean success; |
780 success = eglReleaseTexImage(QEglContext::defaultDisplay(0), |
775 success = eglReleaseTexImage(QEglContext::display(), |
781 (EGLSurface)pixmapData->gl_surface, |
776 (EGLSurface)pixmapData->gl_surface, |
782 EGL_BACK_BUFFER); |
777 EGL_BACK_BUFFER); |
783 if (success == EGL_FALSE) { |
778 if (success == EGL_FALSE) { |
784 qWarning() << "unbindPixmapFromTexture() - Unable to release bound texture: " |
779 qWarning() << "unbindPixmapFromTexture() - Unable to release bound texture: " |
785 << QEglContext::errorString(eglGetError()); |
780 << QEglContext::errorString(eglGetError()); |