QNX: Destroy window buffers when resized

QNX version of screen doesn't reallocate window buffers dynamically.
The buffers have to be destroyed and recreated when a window is resized.
As the overhead is minimal this will be done on BlackBerry, as well.

Change-Id: I488942879822c64a6ab1871ebf5d6da9aec144d6
Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
This commit is contained in:
Bernd Weimer 2014-04-04 17:42:05 +02:00 committed by The Qt Project
parent 118494aeda
commit c6720d8721
3 changed files with 31 additions and 37 deletions

View File

@ -81,15 +81,14 @@ QQnxEglWindow::~QQnxEglWindow()
void QQnxEglWindow::createEGLSurface()
{
// Fetch the surface size from the window and update
// the window's buffers before we create the EGL surface
const QSize surfaceSize = requestedBufferSize();
if (!surfaceSize.isValid()) {
if (!m_requestedBufferSize.isValid()) {
qWarning("QQNX: Trying to create 0 size EGL surface. "
"Please set a valid window size before calling QOpenGLContext::makeCurrent()");
return;
}
setBufferSize(surfaceSize);
// update the window's buffers before we create the EGL surface
setBufferSize(m_requestedBufferSize);
const EGLint eglSurfaceAttrs[] =
{
@ -99,9 +98,10 @@ void QQnxEglWindow::createEGLSurface()
qEglWindowDebug() << "Creating EGL surface" << platformOpenGLContext()->getEglDisplay()
<< platformOpenGLContext()->getEglConfig();
// Create EGL surface
m_eglSurface = eglCreateWindowSurface(platformOpenGLContext()->getEglDisplay()
, platformOpenGLContext()->getEglConfig(),
m_eglSurface = eglCreateWindowSurface(platformOpenGLContext()->getEglDisplay(),
platformOpenGLContext()->getEglConfig(),
(EGLNativeWindowType) nativeHandle(), eglSurfaceAttrs);
if (m_eglSurface == EGL_NO_SURFACE) {
const EGLenum error = QQnxGLContext::checkEGLError("eglCreateWindowSurface");
@ -171,11 +171,6 @@ void QQnxEglWindow::setGeometry(const QRect &rect)
QQnxWindow::setGeometry(newGeometry);
}
QSize QQnxEglWindow::requestedBufferSize() const
{
return m_requestedBufferSize;
}
void QQnxEglWindow::setPlatformOpenGLContext(QQnxGLContext *platformOpenGLContext)
{
// This function does not take ownership of the platform gl context.

View File

@ -65,9 +65,6 @@ public:
void setGeometry(const QRect &rect);
// Called by QQnxGLContext::createSurface()
QSize requestedBufferSize() const;
protected:
int pixelFormat() const;
void resetBuffers();

View File

@ -353,37 +353,39 @@ void QQnxWindow::setBufferSize(const QSize &size)
{
qWindowDebug() << Q_FUNC_INFO << "window =" << window() << "size =" << size;
// Set window buffer size
// libscreen fails when creating empty buffers
const QSize nonEmptySize = size.isEmpty() ? QSize(1, 1) : size;
int format = pixelFormat();
if (nonEmptySize == m_bufferSize || format == -1)
return;
Q_SCREEN_CRITICALERROR(
screen_set_window_property_iv(m_window, SCREEN_PROPERTY_FORMAT, &format),
"Failed to set window format");
if (m_bufferSize.isValid()) {
// destroy buffers first, if resized
Q_SCREEN_CRITICALERROR(screen_destroy_window_buffers(m_window),
"Failed to destroy window buffers");
}
int val[2] = { nonEmptySize.width(), nonEmptySize.height() };
Q_SCREEN_CHECKERROR(screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, val),
"Failed to set window buffer size");
// Create window buffers if they do not exist
if (m_bufferSize.isEmpty()) {
val[0] = pixelFormat();
if (val[0] == -1) // The platform GL context was not set yet on the window, so we can't procede
return;
Q_SCREEN_CRITICALERROR(screen_create_window_buffers(m_window, MAX_BUFFER_COUNT),
"Failed to create window buffers");
Q_SCREEN_CRITICALERROR(
screen_set_window_property_iv(m_window, SCREEN_PROPERTY_FORMAT, val),
"Failed to set window format");
// check if there are any buffers available
int bufferCount = 0;
Q_SCREEN_CRITICALERROR(
screen_get_window_property_iv(m_window, SCREEN_PROPERTY_RENDER_BUFFER_COUNT, &bufferCount),
"Failed to query render buffer count");
Q_SCREEN_CRITICALERROR(screen_create_window_buffers(m_window, MAX_BUFFER_COUNT),
"Failed to create window buffers");
// check if there are any buffers available
int bufferCount = 0;
Q_SCREEN_CRITICALERROR(
screen_get_window_property_iv(m_window, SCREEN_PROPERTY_RENDER_BUFFER_COUNT, &bufferCount),
"Failed to query render buffer count");
if (bufferCount != MAX_BUFFER_COUNT) {
qFatal("QQnxWindow: invalid buffer count. Expected = %d, got = %d. You might experience problems.",
MAX_BUFFER_COUNT, bufferCount);
}
if (bufferCount != MAX_BUFFER_COUNT) {
qFatal("QQnxWindow: invalid buffer count. Expected = %d, got = %d.",
MAX_BUFFER_COUNT, bufferCount);
}
// Set the transparency. According to QNX technical support, setting the window