QEglFSContext::QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share,
EGLDisplay display, EGLenum eglApi)
- : QEGLPlatformContext(format, share, display, eglApi)
+ : QEGLPlatformContext(hooks->surfaceFormatFor(format), share, display, eglApi)
{
}
bool QEglFSContext::makeCurrent(QPlatformSurface *surface)
{
- // create the native window surface. this makes sure that
- // we create surfaces only for painted widgets (unlike QDesktopWidget)
- (static_cast<QEglFSWindow *>(surface))->create();
return QEGLPlatformContext::makeCurrent(surface);
}
virtual QSize screenSize() const;
virtual int screenDepth() const;
virtual QImage::Format screenFormat() const;
- virtual QSurfaceFormat defaultSurfaceFormat() const;
+ virtual QSurfaceFormat surfaceFormatFor(const QSurfaceFormat &inputFormat) const;
virtual EGLNativeWindowType createNativeWindow(const QSize &size);
virtual void destroyNativeWindow(EGLNativeWindowType window);
virtual bool hasCapability(QPlatformIntegration::Capability cap) const;
return screenDepth() == 16 ? QImage::Format_RGB16 : QImage::Format_RGB32;
}
-QSurfaceFormat QEglFSHooks::defaultSurfaceFormat() const
+QSurfaceFormat QEglFSHooks::surfaceFormatFor(const QSurfaceFormat &inputFormat) const
{
- QSurfaceFormat format;
- if (screenDepth() == 16) {
- format.setDepthBufferSize(16);
- format.setRedBufferSize(5);
- format.setGreenBufferSize(6);
- format.setBlueBufferSize(5);
- } else {
- format.setDepthBufferSize(24);
- format.setStencilBufferSize(8);
- format.setRedBufferSize(8);
- format.setGreenBufferSize(8);
- format.setBlueBufferSize(8);
- }
-
- static int samples = qgetenv("QT_QPA_EGLFS_MULTISAMPLE").toInt();
- format.setSamples(samples);
-
- return format;
+ return inputFormat;
}
EGLNativeWindowType QEglFSHooks::createNativeWindow(const QSize &size)
#endif
setWindowState(Qt::WindowFullScreen);
+
+ create();
}
QEglFSWindow::~QEglFSWindow()
void QEglFSWindow::create()
{
- if (m_window) {
- return;
- }
+ Q_ASSERT(!m_window);
EGLDisplay display = (static_cast<QEglFSScreen *>(window()->screen()->handle()))->display();
- QSurfaceFormat platformFormat = hooks->defaultSurfaceFormat();
+ QSurfaceFormat platformFormat = hooks->surfaceFormatFor(window()->requestedFormat());
EGLConfig config = q_configFromGLFormat(display, platformFormat);
+ m_format = q_glFormatFromConfig(display, config);
m_window = hooks->createNativeWindow(hooks->screenSize());
m_surface = eglCreateWindowSurface(display, config, m_window, NULL);
if (m_surface == EGL_NO_SURFACE) {
- qWarning("Could not create the egl surface: error = 0x%x\n", eglGetError());
eglTerminate(display);
- qFatal("EGL error");
+ qFatal("EGL Error : Could not create the egl surface: error = 0x%x\n", eglGetError());
}
}
QSurfaceFormat QEglFSWindow::format() const
{
- return hooks->defaultSurfaceFormat();
+ return m_format;
}
QT_END_NAMESPACE
WId m_winid;
EGLSurface m_surface;
EGLNativeWindowType m_window;
+ QSurfaceFormat m_format;
};
QT_END_NAMESPACE
#endif // QEGLFSWINDOW_H