summaryrefslogtreecommitdiffstats
path: root/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@gmail.com>2016-09-07 17:10:49 +0200
committerPaul Olav Tvete <paul.tvete@qt.io>2016-10-01 15:42:54 +0000
commit844204b2b04d0f3477d069db326f0e70129c71e2 (patch)
treec7134c0b7991192131c82fb14455cfbdfc4d9a14 /src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp
parent2cfefb35b755e1489aff1a3c427d781e8b887223 (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 'src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp')
-rw-r--r--src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp58
1 files changed, 44 insertions, 14 deletions
diff --git a/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp b/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp
index 6f70d2bbf..0b11c2630 100644
--- a/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp
+++ b/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp
@@ -41,6 +41,7 @@
#include <qpa/qplatformnativeinterface.h>
#include <qpa/qplatformintegration.h>
#include <QtGui/QOpenGLContext>
+#include <QtGui/QOpenGLTexture>
#include "xcompositebuffer.h"
#include "xcompositehandler.h"
@@ -109,14 +110,31 @@ void XCompositeGLXClientBufferIntegration::initializeHardware(struct ::wl_displa
delete glContext;
}
-void XCompositeGLXClientBufferIntegration::bindTextureToBuffer(struct ::wl_resource *buffer)
+QtWayland::ClientBuffer *XCompositeGLXClientBufferIntegration::createBufferFor(wl_resource *buffer)
{
- XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(buffer);
- Pixmap pixmap = XCompositeNameWindowPixmap(mDisplay, compositorBuffer->window());
+ if (wl_shm_buffer_get(buffer))
+ return nullptr;
+ return new XCompositeGLXClientBuffer(this, buffer);
+}
+
+XCompositeGLXClientBuffer::XCompositeGLXClientBuffer(XCompositeGLXClientBufferIntegration *integration, wl_resource *bufferResource)
+ : QtWayland::ClientBuffer(bufferResource)
+ , m_texture(nullptr)
+ , m_integration(integration)
+ , m_glxPixmap(0)
+{
+}
+
+
+QOpenGLTexture *XCompositeGLXClientBuffer::toOpenGlTexture(int plane)
+{
+ Q_UNUSED(plane);
+ XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(m_buffer);
+ Pixmap pixmap = XCompositeNameWindowPixmap(m_integration->xDisplay(), compositorBuffer->window());
QVector<int> glxConfigSpec = qglx_buildSpec();
int numberOfConfigs;
- GLXFBConfig *configs = glXChooseFBConfig(mDisplay,mScreen,glxConfigSpec.constData(),&numberOfConfigs);
+ GLXFBConfig *configs = glXChooseFBConfig(m_integration->xDisplay(),m_integration->xScreen(),glxConfigSpec.constData(),&numberOfConfigs);
QVector<int> attribList;
attribList.append(GLX_TEXTURE_FORMAT_EXT);
@@ -124,28 +142,40 @@ void XCompositeGLXClientBufferIntegration::bindTextureToBuffer(struct ::wl_resou
attribList.append(GLX_TEXTURE_TARGET_EXT);
attribList.append(GLX_TEXTURE_2D_EXT);
attribList.append(0);
- GLXPixmap glxPixmap = glXCreatePixmap(mDisplay,*configs,pixmap,attribList.constData());
+
+ if (!m_glxPixmap)
+ m_glxPixmap = glXCreatePixmap(m_integration->xDisplay(), *configs, pixmap, attribList.constData());
uint inverted = 0;
- glXQueryDrawable(mDisplay, glxPixmap, GLX_Y_INVERTED_EXT,&inverted);
+ glXQueryDrawable(m_integration->xDisplay(), m_glxPixmap, GLX_Y_INVERTED_EXT,&inverted);
compositorBuffer->setOrigin(inverted ? QWaylandSurface::OriginBottomLeft : QWaylandSurface::OriginTopLeft);
XFree(configs);
+ auto tex = m_texture;
+ if (!m_texture) {
+ tex = new QOpenGLTexture(QOpenGLTexture::Target2D);
+ tex->create();
+ m_texture = tex;
+ }
+ tex->bind();
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ m_integration->m_glxBindTexImageEXT(m_integration->xDisplay(),m_glxPixmap,GLX_FRONT_EXT, 0);
- m_glxBindTexImageEXT(mDisplay,glxPixmap,GLX_FRONT_EXT, 0);
- //Do we need to change the api so that we do bind and release in the painevent?
- //The specification states that when deleting the texture the color buffer is deleted
-// m_glxReleaseTexImageEXT(mDisplay,glxPixmap,GLX_FRONT_EXT);
+ // TODO: release in the destructor?
+ // m_glxReleaseTexImageEXT(mDisplay,glxPixmap,GLX_FRONT_EXT);
+ return tex;
}
-QWaylandSurface::Origin XCompositeGLXClientBufferIntegration::origin(struct ::wl_resource *buffer) const
+
+QWaylandSurface::Origin XCompositeGLXClientBuffer::origin() const
{
- return XCompositeBuffer::fromResource(buffer)->origin();
+ XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(m_buffer);
+ return compositorBuffer->origin();
}
-QSize XCompositeGLXClientBufferIntegration::bufferSize(struct ::wl_resource *buffer) const
+QSize XCompositeGLXClientBuffer::size() const
{
- XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(buffer);
+ XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(m_buffer);
return compositorBuffer->size();
}