summaryrefslogtreecommitdiffstats
path: root/examples/wayland/qwindow-compositor
diff options
context:
space:
mode:
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;