EGLConfig QEglFSIntegration::chooseConfig(EGLDisplay display, const QSurfaceFormat &format) { class Chooser : public QEglConfigChooser { public: Chooser(EGLDisplay display) : QEglConfigChooser(display) { } bool filterConfig(EGLConfig config) const Q_DECL_OVERRIDE { return qt_egl_device_integration()->filterConfig(display(), config) && QEglConfigChooser::filterConfig(config); } };
bool QEglFSIntegration::hasCapability(QPlatformIntegration::Capability cap) const { // We assume that devices will have more and not less capabilities if (qt_egl_device_integration()->hasCapability(cap)) return true; switch (cap) { case ThreadedPixmaps: return true; case OpenGL: return true; case ThreadedOpenGL: return true; case WindowManagement: return false; case RasterGLSurface: return true; default: return QPlatformIntegration::hasCapability(cap); } }
QEGLPlatformContext *QEglFSIntegration::createContext(const QSurfaceFormat &format, QPlatformOpenGLContext *shareContext, EGLDisplay display, QVariant *nativeHandle) const { QEglFSContext *ctx; QSurfaceFormat adjustedFormat = qt_egl_device_integration()->surfaceFormatFor(format); if (!nativeHandle || nativeHandle->isNull()) { EGLConfig config = QEglFSIntegration::chooseConfig(display, adjustedFormat); ctx = new QEglFSContext(adjustedFormat, shareContext, display, &config, QVariant()); } else { ctx = new QEglFSContext(adjustedFormat, shareContext, display, 0, *nativeHandle); } *nativeHandle = QVariant::fromValue<QEGLNativeContext>(QEGLNativeContext(ctx->eglContext(), display)); return ctx; }
QPlatformOpenGLContext *QEglFSIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const { EGLDisplay dpy = context->screen() ? static_cast<QEglFSScreen *>(context->screen()->handle())->display() : display(); QPlatformOpenGLContext *share = context->shareHandle(); QVariant nativeHandle = context->nativeHandle(); QEglFSContext *ctx; QSurfaceFormat adjustedFormat = qt_egl_device_integration()->surfaceFormatFor(context->format()); if (nativeHandle.isNull()) { EGLConfig config = QEglFSIntegration::chooseConfig(dpy, adjustedFormat); ctx = new QEglFSContext(adjustedFormat, share, dpy, &config, QVariant()); } else { ctx = new QEglFSContext(adjustedFormat, share, dpy, 0, nativeHandle); } nativeHandle = QVariant::fromValue<QEGLNativeContext>(QEGLNativeContext(ctx->eglContext(), dpy)); context->setNativeHandle(nativeHandle); return ctx; }
void *QEglFSIntegration::nativeResourceForIntegration(const QByteArray &resource) { void *result = 0; switch (resourceType(resource)) { case EglDisplay: result = display(); break; case NativeDisplay: result = reinterpret_cast<void*>(nativeDisplay()); break; case WaylandDisplay: result = qt_egl_device_integration()->wlDisplay(); break; default: break; } return result; }
EGLNativeDisplayType QEglFSIntegration::nativeDisplay() const { return qt_egl_device_integration()->platformDisplay(); }
void QEglFSIntegration::destroy() { qt_egl_device_integration()->screenDestroy(); QEGLPlatformIntegration::destroy(); qt_egl_device_integration()->platformDestroy(); }