summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Barnes <jbarnes@virtuousgeek.org>2010-06-17 19:02:41 -0700
committerJesse Barnes <jbarnes@virtuousgeek.org>2010-06-17 19:02:41 -0700
commit744d2a603f1fd58270b5b0bd07208611c91ce9da (patch)
tree7fc533929ae990327a8259c7e2d31fac504ff22d
parente5fda342bac55a61969d2b6b1fde246dcd2c21a1 (diff)
Wayland: draw something at swapbuffers time
Could really make a specific "present buffer" call for Wayland, but overloading swapBuffers works too. Attach the image at that time and present it.
-rw-r--r--src/opengl/qgl_egl.cpp24
-rw-r--r--src/opengl/qgl_p.h4
-rw-r--r--src/opengl/qgl_waylandegl.cpp12
3 files changed, 32 insertions, 8 deletions
diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp
index 34fa46d60a..ffe3ba0db6 100644
--- a/src/opengl/qgl_egl.cpp
+++ b/src/opengl/qgl_egl.cpp
@@ -247,15 +247,31 @@ void QGLContext::swapBuffers() const
#ifndef Q_WS_WAYLAND
d->eglContext->swapBuffers(d->eglSurfaceForDevice());
#else
+ QWidget *widget;
struct wl_visual *visual;
+ struct wl_surface *surf;
EGLint name, stride;
- QEgl::eglExportDRMImageMESA(qWayland->egl_display, d->eglImage, &name, NULL,
- &stride);
+ if (!device())
+ return;
+
+ int devType = device()->devType();
+
+ if (devType != QInternal::Widget)
+ return;
+
+ widget = static_cast<QWidget*>(device());
+ surf = widget->winId();
+
+ if (d->eglImage == EGL_NO_IMAGE_KHR)
+ qFatal("bad image at swap time\n");
visual = (struct wl_visual *)wl_display_get_premultiplied_argb_visual(qWayland->wl_display);
- wl_surface_attach(d->wl_surface, name, 100, 100, stride, visual);
- wl_surface_map(d->wl_surface, 0, 0, 100, 100);
+ if (!visual)
+ qWarning("bad wayland visual\n");
+ wl_surface_attach(surf, d->drmName, 100, 100, d->drmStride, visual);
+ wl_surface_map(surf, 0, 0, 100, 100);
wl_compositor_commit(qWayland->compositor, 10);
+ wl_display_iterate(qWayland->wl_display, WL_DISPLAY_WRITABLE);
qWarning("swap buffers\n");
#endif
}
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index df67d65b5c..3b809e4754 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -354,7 +354,9 @@ public:
* needs
*/
EGLImageKHR eglImage;
- struct wl_surface *wl_surface;
+ EGLint drmName;
+ EGLint drmHandle;
+ EGLint drmStride;
#else
EGLSurface eglSurface;
#endif
diff --git a/src/opengl/qgl_waylandegl.cpp b/src/opengl/qgl_waylandegl.cpp
index 97e9e26bfd..bfa9bfcdfe 100644
--- a/src/opengl/qgl_waylandegl.cpp
+++ b/src/opengl/qgl_waylandegl.cpp
@@ -152,6 +152,7 @@ bool QGLFormat::hasOpenGLOverlays()
// Chooses the EGL config and creates the EGL context
bool QGLContext::chooseContext(const QGLContext* shareContext)
{
+ EGLint name, stride, handle;
Q_D(QGLContext);
if (!device())
@@ -226,9 +227,14 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
d->eglImage = QEgl::createImage(device(), d->eglContext->config());
if (!d->eglImage)
qWarning("failed to create EGL image: 0x%08x\n", eglGetError());
- d->wl_surface = wl_compositor_create_surface(qWayland->compositor);
- if (!d->wl_surface)
- qWarning("failed to create wayland surface\n");
+ if (!QEgl::eglExportDRMImageMESA(qWayland->egl_display, d->eglImage,
+ &name, &handle, &stride)) {
+ qWarning("failed to export EGL image: 0x%08x\n", eglGetError());
+ d->eglImage = EGL_NO_IMAGE_KHR;
+ }
+ d->drmName = name;
+ d->drmHandle = handle;
+ d->drmStride = stride;
setWindowCreated(true);
}