summaryrefslogtreecommitdiffstats
path: root/examples/wayland/qwindow-compositor
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@pelagicore.com>2016-03-02 11:27:46 +0100
committerDominik Holland <dominik.holland@pelagicore.com>2016-05-18 15:08:53 +0000
commitc7832b0a1d4e5e095e56315c43145bb8964f7030 (patch)
tree30e63aa55221255e9d759be7cdaae924e6e0798e /examples/wayland/qwindow-compositor
parent959d9d604da402e768ce329d43510d2b03756d89 (diff)
Fixed eglStream compositing
When creating the eglStream from the fd we also need to create the texture and call stream_consumer_gltexture. Otherwise the wayland client can't create the wayland client surface. Fixed the qwindow-compositor example to use the texture associated to the QWaylandBufferRef when compositing a EXTERNAL_OES target. QML compositing only works when QSG_RENDER_LOOP is set to basic as we need to generate a texture from the gui thread. As the texture is created by the bufferintegration it might end up in a different gl context than the quick item using it. The texture is also deleted together with the buffer, which prevents the use of the texture afterwards. Both problems need to be fixed in follow up commits. Task-number: QTBUG-50850 Change-Id: Ifec67bbe9e4b2a680c871dc4aced37b71b7b6f80 Reviewed-by: Louai Al-Khanji <louai.al-khanji@qt.io> Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Diffstat (limited to 'examples/wayland/qwindow-compositor')
-rw-r--r--examples/wayland/qwindow-compositor/compositorwindow.cpp10
-rw-r--r--examples/wayland/qwindow-compositor/windowcompositor.cpp33
-rw-r--r--examples/wayland/qwindow-compositor/windowcompositor.h3
3 files changed, 36 insertions, 10 deletions
diff --git a/examples/wayland/qwindow-compositor/compositorwindow.cpp b/examples/wayland/qwindow-compositor/compositorwindow.cpp
index 7e10a1739..537a3d08a 100644
--- a/examples/wayland/qwindow-compositor/compositorwindow.cpp
+++ b/examples/wayland/qwindow-compositor/compositorwindow.cpp
@@ -116,10 +116,18 @@ void CompositorWindow::paintGL()
functions->glEnable(GL_BLEND);
functions->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ GLenum currentTarget = GL_TEXTURE_2D;
Q_FOREACH (WindowCompositorView *view, m_compositor->views()) {
if (view->isCursor())
continue;
- GLuint textureId = view->getTexture();
+ GLenum target;
+ GLuint textureId = view->getTexture(&target);
+ if (!textureId || !target)
+ continue;
+ if (target != currentTarget) {
+ currentTarget = target;
+ m_textureBlitter.bind(currentTarget);
+ }
QWaylandSurface *surface = view->surface();
if (surface && surface->isMapped()) {
QSize s = surface->size();
diff --git a/examples/wayland/qwindow-compositor/windowcompositor.cpp b/examples/wayland/qwindow-compositor/windowcompositor.cpp
index bd39908e5..ecbbc5041 100644
--- a/examples/wayland/qwindow-compositor/windowcompositor.cpp
+++ b/examples/wayland/qwindow-compositor/windowcompositor.cpp
@@ -50,25 +50,42 @@
#include <QtWaylandCompositor/qwaylanddrag.h>
#include <QDebug>
+#include <QOpenGLContext>
+
+#ifndef GL_TEXTURE_EXTERNAL_OES
+#define GL_TEXTURE_EXTERNAL_OES 0x8D65
+#endif
WindowCompositorView::WindowCompositorView()
- : m_texture(0)
+ : m_textureTarget(GL_TEXTURE_2D)
+ , m_texture(0)
, m_wlShellSurface(nullptr)
, m_xdgSurface(nullptr)
, m_xdgPopup(nullptr)
, m_parentView(nullptr)
{}
-GLuint WindowCompositorView::getTexture() {
+GLuint WindowCompositorView::getTexture(GLenum *target)
+{
+ QWaylandBufferRef buf = currentBuffer();
+ m_texture = buf.textureForPlane(0);
+
+ if (buf.bufferFormatEgl() == QWaylandBufferRef::BufferFormatEgl_EXTERNAL_OES)
+ m_textureTarget = GL_TEXTURE_EXTERNAL_OES;
+
if (advance()) {
- if (m_texture)
- glDeleteTextures(1, &m_texture);
+ if (!m_texture)
+ glGenTextures(1, &m_texture);
- glGenTextures(1, &m_texture);
- glBindTexture(GL_TEXTURE_2D, m_texture);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- currentBuffer().bindToTexture();
+ glBindTexture(m_textureTarget, m_texture);
+ buf.bindToTexture();
}
+
+ buf.updateTexture();
+
+ if (target)
+ *target = m_textureTarget;
+
return m_texture;
}
diff --git a/examples/wayland/qwindow-compositor/windowcompositor.h b/examples/wayland/qwindow-compositor/windowcompositor.h
index 5290d7c85..80a7bebe4 100644
--- a/examples/wayland/qwindow-compositor/windowcompositor.h
+++ b/examples/wayland/qwindow-compositor/windowcompositor.h
@@ -59,7 +59,7 @@ class WindowCompositorView : public QWaylandView
Q_OBJECT
public:
WindowCompositorView();
- GLuint getTexture();
+ GLuint getTexture(GLenum *target = 0);
QPointF position() const { return m_position; }
void setPosition(const QPointF &pos) { m_position = pos; }
bool isCursor() const;
@@ -72,6 +72,7 @@ public:
private:
friend class WindowCompositor;
+ GLenum m_textureTarget;
GLuint m_texture;
QPointF m_position;
QWaylandWlShellSurface *m_wlShellSurface;