eglfs: Make QEglFSWindow respect the window format
Prior to this change, eglfs code used to override the window format with it's own format. With this change, eglfs will respect the window format. This is useful when the application requires a surface with alpha (for example, so that the video layer below is visible) QEglFSHooks::surfaceFormatFor() allows the hook author to override the context and window surface format. Change-Id: I97f03a8b0871dfebfca73004fa0188b33d0d0367 Reviewed-by: Johannes Zellner <johannes.zellner@nokia.com> Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
This commit is contained in:
parent
ed776e3670
commit
f2d04d9b8c
@ -50,15 +50,12 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
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;
|
||||
|
@ -72,26 +72,9 @@ QImage::Format QEglFSHooks::screenFormat() 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)
|
||||
|
@ -61,6 +61,8 @@ QEglFSWindow::QEglFSWindow(QWindow *w)
|
||||
#endif
|
||||
|
||||
setWindowState(Qt::WindowFullScreen);
|
||||
|
||||
create();
|
||||
}
|
||||
|
||||
QEglFSWindow::~QEglFSWindow()
|
||||
@ -70,19 +72,17 @@ 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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ WId QEglFSWindow::winId() const
|
||||
|
||||
QSurfaceFormat QEglFSWindow::format() const
|
||||
{
|
||||
return hooks->defaultSurfaceFormat();
|
||||
return m_format;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -69,6 +69,7 @@ private:
|
||||
WId m_winid;
|
||||
EGLSurface m_surface;
|
||||
EGLNativeWindowType m_window;
|
||||
QSurfaceFormat m_format;
|
||||
};
|
||||
QT_END_NAMESPACE
|
||||
#endif // QEGLFSWINDOW_H
|
||||
|
Loading…
Reference in New Issue
Block a user