summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorBernd Weimer <bweimer@blackberry.com>2014-04-04 17:42:05 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-08 09:50:08 +0200
commitc6720d87218915f2557d9698218a22c1d46b4950 (patch)
tree7325bfb38d03456124477c0058ac790382b70b23 /src/plugins/platforms
parent118494aeda916a63dd94474442f9dbf7b2ad7ff5 (diff)
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>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/qnx/qqnxeglwindow.cpp19
-rw-r--r--src/plugins/platforms/qnx/qqnxeglwindow.h3
-rw-r--r--src/plugins/platforms/qnx/qqnxwindow.cpp46
3 files changed, 31 insertions, 37 deletions
diff --git a/src/plugins/platforms/qnx/qqnxeglwindow.cpp b/src/plugins/platforms/qnx/qqnxeglwindow.cpp
index f1f9f5469c..9d40d166af 100644
--- a/src/plugins/platforms/qnx/qqnxeglwindow.cpp
+++ b/src/plugins/platforms/qnx/qqnxeglwindow.cpp
@@ -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.
diff --git a/src/plugins/platforms/qnx/qqnxeglwindow.h b/src/plugins/platforms/qnx/qqnxeglwindow.h
index a6a223c58e..cd98f9369d 100644
--- a/src/plugins/platforms/qnx/qqnxeglwindow.h
+++ b/src/plugins/platforms/qnx/qqnxeglwindow.h
@@ -65,9 +65,6 @@ public:
void setGeometry(const QRect &rect);
- // Called by QQnxGLContext::createSurface()
- QSize requestedBufferSize() const;
-
protected:
int pixelFormat() const;
void resetBuffers();
diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp
index 42318729b1..2e0febff20 100644
--- a/src/plugins/platforms/qnx/qqnxwindow.cpp
+++ b/src/plugins/platforms/qnx/qqnxwindow.cpp
@@ -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_set_window_property_iv(m_window, SCREEN_PROPERTY_FORMAT, val),
- "Failed to set window format");
+ Q_SCREEN_CRITICALERROR(screen_create_window_buffers(m_window, MAX_BUFFER_COUNT),
+ "Failed to create window buffers");
- 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");
- // 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