diff options
author | Giulio Camuffo <giulio.camuffo@jollamobile.com> | 2014-04-05 18:56:00 +0300 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-07 09:37:24 +0200 |
commit | 439a084cd359acfafa284961b5f08d6b2891c6c6 (patch) | |
tree | aa9f0aae1e3661bc457bd7a0c886683afd130454 /src/hardwareintegration | |
parent | bda292c1ee61475a1bb93f01e7ab6dc22b9f08f2 (diff) |
Deal with 0x0 sized egl windows
wl_egl_windows must have both the width and height > 0 to be valid
Change-Id: I444f3732d9df3eabf12bbd966ac62093866b6926
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'src/hardwareintegration')
-rw-r--r-- | src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp | 55 | ||||
-rw-r--r-- | src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h | 4 |
2 files changed, 32 insertions, 27 deletions
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp index 30f649263..5d2866ea3 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp +++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp @@ -65,9 +65,6 @@ QWaylandEglWindow::QWaylandEglWindow(QWindow *window) , m_format(q_glFormatFromConfig(m_clientBufferIntegration->eglDisplay(), m_eglConfig)) { setGeometry(window->geometry()); - - EGLNativeWindowType eglw = (EGLNativeWindowType) m_waylandEglWindow; - m_eglSurface = eglCreateWindowSurface(m_clientBufferIntegration->eglDisplay(), m_eglConfig, eglw, 0); } QWaylandEglWindow::~QWaylandEglWindow() @@ -95,17 +92,38 @@ void QWaylandEglWindow::setGeometry(const QRect &rect) QMargins margins = frameMargins(); QSize sizeWithMargins = rect.size() + QSize(margins.left() + margins.right(), margins.top() + margins.bottom()); - if (m_waylandEglWindow) { - int current_width, current_height; - wl_egl_window_get_attached_size(m_waylandEglWindow,¤t_width,¤t_height); - if (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) { - wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y()); - mOffset = QPoint(); - - m_resize = true; + // wl_egl_windows must have both width and height > 0 + // mesa's egl returns NULL if we try to create a, invalid wl_egl_window, however not all EGL + // implementations may do that, so check the size ourself. Besides, we must deal with resizing + // a valid window to 0x0, which would make it invalid. Hence, destroy it. + if (sizeWithMargins.isEmpty()) { + if (m_eglSurface) { + eglDestroySurface(m_clientBufferIntegration->eglDisplay(), m_eglSurface); + m_eglSurface = 0; + } + if (m_waylandEglWindow) { + wl_egl_window_destroy(m_waylandEglWindow); + m_waylandEglWindow = 0; } + mOffset = QPoint(); } else { - m_waylandEglWindow = wl_egl_window_create(object(), sizeWithMargins.width(), sizeWithMargins.height()); + if (m_waylandEglWindow) { + int current_width, current_height; + wl_egl_window_get_attached_size(m_waylandEglWindow,¤t_width,¤t_height); + if (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) { + wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y()); + mOffset = QPoint(); + + m_resize = true; + } + } else { + m_waylandEglWindow = wl_egl_window_create(object(), sizeWithMargins.width(), sizeWithMargins.height()); + } + + if (!m_eglSurface) { + EGLNativeWindowType eglw = (EGLNativeWindowType) m_waylandEglWindow; + m_eglSurface = eglCreateWindowSurface(m_clientBufferIntegration->eglDisplay(), m_eglConfig, eglw, 0); + } } } @@ -123,19 +141,6 @@ QSurfaceFormat QWaylandEglWindow::format() const EGLSurface QWaylandEglWindow::eglSurface() const { - if (!m_waylandEglWindow) { - QWaylandEglWindow *self = const_cast<QWaylandEglWindow *>(this); - self->createDecoration(); - QMargins margins = frameMargins(); - QSize sizeWithMargins = geometry().size() + QSize(margins.left() + margins.right(), margins.top() + margins.bottom()); - m_waylandEglWindow = wl_egl_window_create(self->object(), sizeWithMargins.width(), sizeWithMargins.height()); - } - - if (!m_eglSurface) { - EGLNativeWindowType window = (EGLNativeWindowType) m_waylandEglWindow; - m_eglSurface = eglCreateWindowSurface(m_clientBufferIntegration->eglDisplay(), m_eglConfig, window, 0); - } - return m_eglSurface; } diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h index d6708a342..c2c4dfa4c 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h +++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h @@ -71,11 +71,11 @@ public: private: QWaylandEglClientBufferIntegration *m_clientBufferIntegration; - mutable struct wl_egl_window *m_waylandEglWindow; + struct wl_egl_window *m_waylandEglWindow; const QWaylandWindow *m_parentWindow; - mutable EGLSurface m_eglSurface; + EGLSurface m_eglSurface; EGLConfig m_eglConfig; mutable QOpenGLFramebufferObject *m_contentFBO; mutable bool m_resize; |