diff options
author | Paul Olav Tvete <paul.tvete@gmail.com> | 2016-09-07 17:10:49 +0200 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@qt.io> | 2016-10-01 15:42:54 +0000 |
commit | 844204b2b04d0f3477d069db326f0e70129c71e2 (patch) | |
tree | c7134c0b7991192131c82fb14455cfbdfc4d9a14 /examples/wayland/minimal-cpp | |
parent | 2cfefb35b755e1489aff1a3c427d781e8b887223 (diff) |
Refactor buffer handling
We cannot support bindToTexture() functions. On some
platforms the texture is provided by the driver. Therefore,
the HW integration must always provide a texture.
This has the added bonus of unifying the two separate code paths
that were introduced when EGLStream support was added.
Add a separate buffer manager that owns all buffers.
Don't destroy buffer objects on release. The client will probably
attach them again later. Also, release shm buffers immediately
after uploading to texture (needs to be documented that image()
will not work afterwards).
Make the old SurfaceBuffer class into an abstract base class,
so we can store state in the buffer class instead of having
to map from the wl_resource in each buffer integration. Move
the shared memory buffer handling into a separate subclass.
Change-Id: I81e471d13c92913d31ea1efe487f93fa908b5e0c
Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
Reviewed-by: Louai Al-Khanji <louai.al-khanji@qt.io>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Diffstat (limited to 'examples/wayland/minimal-cpp')
-rw-r--r-- | examples/wayland/minimal-cpp/compositor.cpp | 14 | ||||
-rw-r--r-- | examples/wayland/minimal-cpp/compositor.h | 5 | ||||
-rw-r--r-- | examples/wayland/minimal-cpp/window.cpp | 6 |
3 files changed, 11 insertions, 14 deletions
diff --git a/examples/wayland/minimal-cpp/compositor.cpp b/examples/wayland/minimal-cpp/compositor.cpp index ea685923b..5e46895c4 100644 --- a/examples/wayland/minimal-cpp/compositor.cpp +++ b/examples/wayland/minimal-cpp/compositor.cpp @@ -44,17 +44,9 @@ #include <QtWaylandCompositor/qwaylandoutput.h> #include <QOpenGLFunctions> -GLuint View::getTexture() { - if (advance()) { - QOpenGLFunctions *functions = QOpenGLContext::currentContext()->functions(); - if (m_texture) - functions->glDeleteTextures(1, &m_texture); - - functions->glGenTextures(1, &m_texture); - functions->glBindTexture(GL_TEXTURE_2D, m_texture); - functions->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - currentBuffer().bindToTexture(); - } +QOpenGLTexture *View::getTexture() { + if (advance()) + m_texture = currentBuffer().toOpenGLTexture(); return m_texture; } diff --git a/examples/wayland/minimal-cpp/compositor.h b/examples/wayland/minimal-cpp/compositor.h index fe379082c..e44a8eb52 100644 --- a/examples/wayland/minimal-cpp/compositor.h +++ b/examples/wayland/minimal-cpp/compositor.h @@ -48,17 +48,18 @@ QT_BEGIN_NAMESPACE class Window; +class QOpenGLTexture; class View : public QWaylandView { Q_OBJECT public: View() : m_texture(0) {} - GLuint getTexture(); + QOpenGLTexture *getTexture(); bool isCursor() const; private: friend class Compositor; - GLuint m_texture; + QOpenGLTexture *m_texture; }; class Compositor : public QWaylandCompositor diff --git a/examples/wayland/minimal-cpp/window.cpp b/examples/wayland/minimal-cpp/window.cpp index 2d529cce5..6ae89be4f 100644 --- a/examples/wayland/minimal-cpp/window.cpp +++ b/examples/wayland/minimal-cpp/window.cpp @@ -44,6 +44,7 @@ #include <QPainter> #include <QMatrix4x4> #include <QOpenGLFunctions> +#include <QOpenGLTexture> Window::Window() : m_compositor(0) @@ -83,7 +84,10 @@ void Window::paintGL() Q_FOREACH (View *view, m_compositor->views()) { if (view->isCursor()) continue; - GLuint textureId = view->getTexture(); + auto texture = view->getTexture(); + if (!texture) + continue; + GLuint textureId = texture->textureId(); QWaylandSurface *surface = view->surface(); if (surface && surface->hasContent()) { QSize s = surface->size(); |