diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2011-03-31 16:26:20 +0200 |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2011-03-31 16:26:20 +0200 |
commit | ba975816b987204d95d10d11738f5fb43e0bd468 (patch) | |
tree | 736d016cd58d42eb274d158c5e5321f751e09e5f | |
parent | 847ec74aab7960c0d25c51e855800ade8d6f224d (diff) |
XPixmap over the wirexpixmaps
21 files changed, 833 insertions, 138 deletions
diff --git a/examples/qwidget-compositor/qt-compositor.pro b/examples/qwidget-compositor/qt-compositor.pro index 952a88e..5394e7f 100644 --- a/examples/qwidget-compositor/qt-compositor.pro +++ b/examples/qwidget-compositor/qt-compositor.pro @@ -5,9 +5,10 @@ INCLUDEPATH += . # comment out the following CONFIG lines to disable DRM CONFIG += wayland_gl +CONFIG += xpixmap_glx +CONFIG += xpixmap_egl #CONFIG += mesa_egl #CONFIG += dri2_xcb -CONFIG += xpixmap_egl # comment out the following to not use pkg-config in the pri files CONFIG += use_pkgconfig diff --git a/src/qt-compositor/hardware_integration/dri2_xcb/dri2xcbbuffer.cpp b/src/qt-compositor/hardware_integration/dri2_xcb/dri2xcbbuffer.cpp index eb516d1..e1e2a27 100644 --- a/src/qt-compositor/hardware_integration/dri2_xcb/dri2xcbbuffer.cpp +++ b/src/qt-compositor/hardware_integration/dri2_xcb/dri2xcbbuffer.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** This file is part of QtCompositor** +** +** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation qt-info@nokia.com +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** +** Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** +** Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** +** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +****************************************************************************/ + #include "dri2xcbbuffer.h" #include "waylandobject.h" diff --git a/src/qt-compositor/hardware_integration/dri2_xcb/dri2xcbbuffer.h b/src/qt-compositor/hardware_integration/dri2_xcb/dri2xcbbuffer.h index 81fa067..5daf89d 100644 --- a/src/qt-compositor/hardware_integration/dri2_xcb/dri2xcbbuffer.h +++ b/src/qt-compositor/hardware_integration/dri2_xcb/dri2xcbbuffer.h @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** This file is part of QtCompositor** +** +** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation qt-info@nokia.com +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** +** Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** +** Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** +** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +****************************************************************************/ + #ifndef DRI2XCBBUFFER_H #define DRI2XCBBUFFER_H diff --git a/src/qt-compositor/hardware_integration/dri2_xcb/dri2xcbhwintegration.cpp b/src/qt-compositor/hardware_integration/dri2_xcb/dri2xcbhwintegration.cpp index 6e6bb53..93ccaea 100644 --- a/src/qt-compositor/hardware_integration/dri2_xcb/dri2xcbhwintegration.cpp +++ b/src/qt-compositor/hardware_integration/dri2_xcb/dri2xcbhwintegration.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** This file is part of QtCompositor** +** +** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation qt-info@nokia.com +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** +** Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** +** Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** +** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +****************************************************************************/ + #include "dri2xcbhwintegration.h" #include "dri2xcbbuffer.h" diff --git a/src/qt-compositor/hardware_integration/dri2_xcb/dri2xcbhwintegration.h b/src/qt-compositor/hardware_integration/dri2_xcb/dri2xcbhwintegration.h index e54debd..84c9582 100644 --- a/src/qt-compositor/hardware_integration/dri2_xcb/dri2xcbhwintegration.h +++ b/src/qt-compositor/hardware_integration/dri2_xcb/dri2xcbhwintegration.h @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** This file is part of QtCompositor** +** +** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation qt-info@nokia.com +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** +** Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** +** Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** +** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +****************************************************************************/ + #ifndef DRI2XCBHWINTEGRATION_H #define DRI2XCBHWINTEGRATION_H diff --git a/src/qt-compositor/hardware_integration/hardware_integration.pri b/src/qt-compositor/hardware_integration/hardware_integration.pri index 3e75bce..e92fc93 100644 --- a/src/qt-compositor/hardware_integration/hardware_integration.pri +++ b/src/qt-compositor/hardware_integration/hardware_integration.pri @@ -5,17 +5,26 @@ SOURCES += \ $$PWD/graphicshardwareintegration.cpp wayland_gl { - mesa_egl { - include ($$PWD/mesa_egl/mesa_egl.pri) - DEFINES += QT_COMPOSITOR_MESA_EGL - } + contains(QT_CONFIG, opengles2) { + xpixmap_egl { + include ($$PWD/xpixmap_egl/xpixmap_egl.pri) + } - dri2_xcb { - include ($$PWD/dri2_xcb/dri2_xcb.pri) - DEFINES += QT_COMPOSITOR_DRI2_XCB - } + mesa_egl { + include ($$PWD/mesa_egl/mesa_egl.pri) + DEFINES += QT_COMPOSITOR_MESA_EGL + } + + dri2_xcb { + include ($$PWD/dri2_xcb/dri2_xcb.pri) + DEFINES += QT_COMPOSITOR_DRI2_XCB + } - xpixmap_egl { - include ($$PWD/xpixmap_egl/xpixmap_egl.pri) + } else { + xpixmap_glx { + include ($$PWD/xpixmap_glx/xpixmap_glx.pri) + } } + + } diff --git a/src/qt-compositor/hardware_integration/xpixmap_egl/xpixmap_egl.pri b/src/qt-compositor/hardware_integration/xpixmap_egl/xpixmap_egl.pri index f885fe4..27f9d30 100644 --- a/src/qt-compositor/hardware_integration/xpixmap_egl/xpixmap_egl.pri +++ b/src/qt-compositor/hardware_integration/xpixmap_egl/xpixmap_egl.pri @@ -1,11 +1,9 @@ include ($$PWD/../xpixmap_share/xpixmap_share.pri) HEADERS += \ - $$PWD/xpixmapeglintegration.h \ - $$PWD/xpixmapbuffer.h + $$PWD/xpixmapeglintegration.h SOURCES += \ - $$PWD/xpixmapeglintegration.cpp \ - $$PWD/xpixmapbuffer.cpp + $$PWD/xpixmapeglintegration.cpp LIBS += -lEGL diff --git a/src/qt-compositor/hardware_integration/xpixmap_egl/xpixmapbuffer.cpp b/src/qt-compositor/hardware_integration/xpixmap_egl/xpixmapbuffer.cpp deleted file mode 100644 index f59c86a..0000000 --- a/src/qt-compositor/hardware_integration/xpixmap_egl/xpixmapbuffer.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "xpixmapbuffer.h" - -void destroy_buffer(struct wl_resource *resource, struct wl_client *client) -{ - -} - -XPixmapBuffer::XPixmapBuffer(Pixmap pixmap, const QSize &size, - wl_visual *visual, Wayland::Compositor *compositor) - : m_pixmap(pixmap) -{ - base()->height = size.height(); - base()->width = size.width(); - base()->compositor = compositor->base(); - base()->visual = visual; - - //These are set to 0 in super constructor, but do it here as well - //to make a point out of that this surface is a gl surface - base()->attach = 0; - base()->damage = 0; - - base()->resource.destroy = destroy_buffer; -} - -XPixmapBuffer::~XPixmapBuffer() -{ - -} - -Pixmap XPixmapBuffer::pixmap() const -{ - return m_pixmap; -} - -void xPixmapBufferDestroy(struct wl_client *client, struct wl_buffer *buffer) -{ - Q_UNUSED(client); - delete Wayland::wayland_cast<XPixmapBuffer *>(buffer); -} diff --git a/src/qt-compositor/hardware_integration/xpixmap_egl/xpixmapbuffer.h b/src/qt-compositor/hardware_integration/xpixmap_egl/xpixmapbuffer.h deleted file mode 100644 index 96aeba4..0000000 --- a/src/qt-compositor/hardware_integration/xpixmap_egl/xpixmapbuffer.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef XPIXMAPBUFFER_H -#define XPIXMAPBUFFER_H - -#include "waylandobject.h" -#include "wayland_wrapper/wlcompositor.h" - -#include <QtCore/QSize> - -#include <X11/Xlib.h> - -class XPixmapBuffer : public Wayland::Object<struct wl_buffer> -{ -public: - XPixmapBuffer(Pixmap pixmap, const QSize &size, - wl_visual *visual, Wayland::Compositor *compositor); - - ~XPixmapBuffer(); - - Pixmap pixmap() const; -private: - Pixmap m_pixmap; -}; - -void xPixmapBufferDestroy(struct wl_client *client, struct wl_buffer *buffer); - -const static struct wl_buffer_interface xpixmap_buffer_interface = { - xPixmapBufferDestroy -}; - - -#endif // XPIXMAPBUFFER_H diff --git a/src/qt-compositor/hardware_integration/xpixmap_egl/xpixmapeglintegration.cpp b/src/qt-compositor/hardware_integration/xpixmap_egl/xpixmapeglintegration.cpp index a2eccea..3859449 100644 --- a/src/qt-compositor/hardware_integration/xpixmap_egl/xpixmapeglintegration.cpp +++ b/src/qt-compositor/hardware_integration/xpixmap_egl/xpixmapeglintegration.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** This file is part of QtCompositor** +** +** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation qt-info@nokia.com +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** +** Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** +** Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** +** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +****************************************************************************/ + #include "xpixmapeglintegration.h" #include <QDebug> @@ -244,49 +284,6 @@ EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformW return 0; } -class XPixmapHandler : public Wayland::Object<struct wl_object> -{ -public: - XPixmapHandler(Wayland::Compositor *compositor, QWidget *topLevelWidget) - :m_compositor(compositor) - { - } - - ~XPixmapHandler() - { - qDebug() << "xpixmapHandler destroyed"; - } - - void createBuffer(wl_client *client, uint32_t id, uint32_t xpixmap_id, const QSize &size, wl_visual *visual) - { - - qDebug() << "creating buffer for id" << xpixmap_id << "and size" << size; - Pixmap pixmap = (Pixmap)xpixmap_id; - XPixmapBuffer *pixmapBuffer = new XPixmapBuffer(pixmap,size,visual,m_compositor); - Wayland::addClientResource(client,&pixmapBuffer->base()->resource,id,&wl_buffer_interface,&xpixmap_buffer_interface,0); - } - -private: - Wayland::Compositor *m_compositor; -}; - -void create_buffer(struct wl_client *client, - struct wl_xpixmap *xpixmap, - uint32_t id, - uint32_t xpixmap_id, - int width, - int height, - struct wl_visual *visual) -{ - XPixmapHandler *xpixmapHandler = reinterpret_cast<XPixmapHandler *>(xpixmap); - xpixmapHandler->createBuffer(client,id,xpixmap_id,QSize(width,height),visual); -} - -const static struct wl_xpixmap_interface xpixmap_interface = { - create_buffer -}; - - XPixmapEglIntegration::XPixmapEglIntegration(WaylandCompositor *compositor) : GraphicsHardwareIntegration(compositor) { @@ -304,6 +301,7 @@ void XPixmapEglIntegration::initializeHardware(Wayland::Display *waylandDisplay) QPlatformNativeInterface *nativeInterface = QApplicationPrivate::platformIntegration()->nativeInterface(); m_egl_display = static_cast<EGLDisplay>(nativeInterface->nativeResourceForWidget("EglDisplay",m_compositor->topLevelWidget())); m_egl_context = static_cast<EGLContext>(nativeInterface->nativeResourceForWidget("EglContext",m_compositor->topLevelWidget())); + m_xpixmap_handler = new XPixmapHandler(m_compositor->handle(),m_compositor->topLevelWidget()); waylandDisplay->addGlobalObject(m_xpixmap_handler->base(), &wl_xpixmap_interface, &xpixmap_interface,0); } @@ -312,7 +310,6 @@ GLuint XPixmapEglIntegration::createTextureFromBuffer(wl_buffer *buffer) { XPixmapBuffer *xPixmapBuffer = Wayland::wayland_cast<XPixmapBuffer *>(buffer); - EGLConfig config = q_configFromQPlatformWindowFormat(m_egl_display,m_compositor->topLevelWidget()->platformWindowFormat(),true,EGL_PIXMAP_BIT); QVector<EGLint> attribList; diff --git a/src/qt-compositor/hardware_integration/xpixmap_egl/xpixmapeglintegration.h b/src/qt-compositor/hardware_integration/xpixmap_egl/xpixmapeglintegration.h index 0b71412..1fd7fb5 100644 --- a/src/qt-compositor/hardware_integration/xpixmap_egl/xpixmapeglintegration.h +++ b/src/qt-compositor/hardware_integration/xpixmap_egl/xpixmapeglintegration.h @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** This file is part of QtCompositor** +** +** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation qt-info@nokia.com +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** +** Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** +** Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** +** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +****************************************************************************/ + #ifndef XPIXMAPEGLINTEGRATION_H #define XPIXMAPEGLINTEGRATION_H diff --git a/src/qt-compositor/hardware_integration/xpixmap_glx/xpixmap_glx.pri b/src/qt-compositor/hardware_integration/xpixmap_glx/xpixmap_glx.pri new file mode 100644 index 0000000..def2030 --- /dev/null +++ b/src/qt-compositor/hardware_integration/xpixmap_glx/xpixmap_glx.pri @@ -0,0 +1,7 @@ +include ($$PWD/../xpixmap_share/xpixmap_share.pri) + +HEADERS += \ + ../../src/qt-compositor/hardware_integration/xpixmap_glx/xpixmapglxintegration.h + +SOURCES += \ + ../../src/qt-compositor/hardware_integration/xpixmap_glx/xpixmapglxintegration.cpp diff --git a/src/qt-compositor/hardware_integration/xpixmap_glx/xpixmapglxintegration.cpp b/src/qt-compositor/hardware_integration/xpixmap_glx/xpixmapglxintegration.cpp new file mode 100644 index 0000000..1045150 --- /dev/null +++ b/src/qt-compositor/hardware_integration/xpixmap_glx/xpixmapglxintegration.cpp @@ -0,0 +1,164 @@ +/**************************************************************************** +** +** This file is part of QtCompositor** +** +** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation qt-info@nokia.com +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** +** Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** +** Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** +** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +****************************************************************************/ + +#include "xpixmapglxintegration.h" + +#include "xpixmapbuffer.h" +#include <QtGui/QPlatformGLContext> + +#define GLX_GLXEXT_PROTOTYPES +#include <GL/glx.h> +#include <GL/glxext.h> + +QVector<int> qglx_buildSpec(const QPlatformWindowFormat &format) +{ + QVector<int> spec(48); + int i = 0; + + spec[i++] = GLX_LEVEL; + spec[i++] = 0; + spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = GLX_PIXMAP_BIT; + spec[i++] = GLX_BIND_TO_TEXTURE_TARGETS_EXT; spec[i++] = GLX_TEXTURE_2D_BIT_EXT; + spec[i++] = GLX_BIND_TO_TEXTURE_RGBA_EXT; spec[i++] = TRUE; + + //don't know if we need the color configuration? + spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT; + spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize(); + spec[i++] = GLX_GREEN_SIZE; spec[i++] = (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize(); + spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize(); + if (format.alpha()) { + spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize(); + } + + spec[i++] = 0; + return spec; +} + +bool checkConfig(Display *display, GLXFBConfig config) +{ + int value; + glXGetFBConfigAttrib (display, config, GLX_DRAWABLE_TYPE, &value); + if (!(value & GLX_PIXMAP_BIT)) + return false; + + glXGetFBConfigAttrib (display, config, + GLX_BIND_TO_TEXTURE_TARGETS_EXT, + &value); + if (!(value & GLX_TEXTURE_2D_BIT_EXT)) + return false; + + glXGetFBConfigAttrib (display, config, + GLX_BIND_TO_TEXTURE_RGBA_EXT, + &value); + if (value == FALSE) + { + glXGetFBConfigAttrib (display, config, + GLX_BIND_TO_TEXTURE_RGB_EXT, + &value); + if (value == FALSE) + return false; + } + return true; +} + +GraphicsHardwareIntegration *GraphicsHardwareIntegration::createGraphicsHardwareIntegration(WaylandCompositor *compositor) +{ + return new XPixmapGLXIntegration(compositor); +} + + +XPixmapGLXIntegration::XPixmapGLXIntegration(WaylandCompositor *compositor) + : GraphicsHardwareIntegration(compositor) +{ +} + +void XPixmapGLXIntegration::initializeHardware(Wayland::Display *waylandDisplay) +{ + QPlatformNativeInterface *nativeInterface = QApplicationPrivate::platformIntegration()->nativeInterface(); + m_display = static_cast<Display *>(nativeInterface->nativeResourceForWidget("Display",m_compositor->topLevelWidget())); + m_screen_number = XDefaultScreen(m_display); + + m_xpixmap_handler = new XPixmapHandler(m_compositor->handle(),m_compositor->topLevelWidget()); + waylandDisplay->addGlobalObject(m_xpixmap_handler->base(), &wl_xpixmap_interface, &xpixmap_interface,0); + QPlatformGLContext *glContext =m_compositor->topLevelWidget()->platformWindow()->glContext(); + m_glxBindTexImageEXT = reinterpret_cast<PFNGLXBINDTEXIMAGEEXTPROC>(glContext->getProcAddress("glXBindTexImageEXT")); + if (!m_glxBindTexImageEXT) { + qDebug() << "Did not find glxBindTexImageExt, everything will FAIL!"; + } + m_glxReleaseTexImageEXT = reinterpret_cast<PFNGLXRELEASETEXIMAGEEXTPROC>(glContext->getProcAddress("glXReleaseTexImageEXT")); + if (!m_glxReleaseTexImageEXT) { + qDebug() << "Did not find glxReleaseTexImageExt"; + } +} + +GLuint XPixmapGLXIntegration::createTextureFromBuffer(wl_buffer *buffer) +{ + XSync(m_display,False); + XPixmapBuffer *xPixmapBuffer = Wayland::wayland_cast<XPixmapBuffer *>(buffer); + + QVector<int> glxConfigSpec = qglx_buildSpec(m_compositor->topLevelWidget()->platformWindowFormat()); + int numberOfConfigs; + GLXFBConfig *configs = glXChooseFBConfig(m_display,m_screen_number,glxConfigSpec.constData(),&numberOfConfigs); + + if (!checkConfig(m_display, *configs)) { + qDebug() << "GLXFBConfig is no good!"; + return 0; + } else { + qDebug() << "Config is good, creating pixmap for" << xPixmapBuffer->pixmap(); + } + + QVector<int> attribList; + attribList.append(GLX_TEXTURE_FORMAT_EXT); + attribList.append(GLX_TEXTURE_FORMAT_RGBA_EXT); + attribList.append(GLX_TEXTURE_TARGET_EXT); + attribList.append(GLX_TEXTURE_2D_EXT); + attribList.append(0); + GLXPixmap glxPixmap = glXCreatePixmap(m_display,*configs,xPixmapBuffer->pixmap(),attribList.constData()); + XFree(configs); + + GLuint textureId; + glGenTextures(1,&textureId); + glBindTexture(GL_TEXTURE_2D, textureId); + m_glxBindTexImageEXT(m_display,glxPixmap,GLX_BACK_EXT, 0); + //Do we need to change the api so that we do bind and release in the painevent? + //We delete the texture is it enough +// m_glxReleaseTexImageEXT(m_display,glxPixmap,GLX_BACK_EXT); + return textureId; +} diff --git a/src/qt-compositor/hardware_integration/xpixmap_glx/xpixmapglxintegration.h b/src/qt-compositor/hardware_integration/xpixmap_glx/xpixmapglxintegration.h new file mode 100644 index 0000000..68b0117 --- /dev/null +++ b/src/qt-compositor/hardware_integration/xpixmap_glx/xpixmapglxintegration.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** This file is part of QtCompositor** +** +** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation qt-info@nokia.com +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** +** Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** +** Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** +** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +****************************************************************************/ + +#ifndef XPIXMAPGLXINTEGRATION_H +#define XPIXMAPGLXINTEGRATION_H + +#include "hardware_integration/graphicshardwareintegration.h" + +#include "xpixmaphandler.h" +#include <QtGui/private/qapplication_p.h> +#include <QtGui/QPlatformNativeInterface> +#include <QtCore/QDebug> + +#include <GL/glx.h> +#include <GL/glxext.h> + +#include <X11/Xlib.h> +class XPixmapHandler; +class XPixmapGLXIntegration : public GraphicsHardwareIntegration +{ +public: + XPixmapGLXIntegration(WaylandCompositor *compositor); + + void initializeHardware(Wayland::Display *waylandDisplay); + + /** Bind the Wayland buffer to the textureId. The correct context is the current context, + so there is no need to do makeCurrent in this function. + **/ + GLuint createTextureFromBuffer(struct wl_buffer *buffer); + +private: + XPixmapHandler *m_xpixmap_handler; + + Display *m_display; + int m_screen_number; + + PFNGLXBINDTEXIMAGEEXTPROC m_glxBindTexImageEXT; + PFNGLXRELEASETEXIMAGEEXTPROC m_glxReleaseTexImageEXT; + +}; + +#endif // XPIXMAPGLXINTEGRATION_H diff --git a/src/qt-compositor/hardware_integration/xpixmap_share/xpixmap_share.pri b/src/qt-compositor/hardware_integration/xpixmap_share/xpixmap_share.pri index d7a5178..b186992 100644 --- a/src/qt-compositor/hardware_integration/xpixmap_share/xpixmap_share.pri +++ b/src/qt-compositor/hardware_integration/xpixmap_share/xpixmap_share.pri @@ -1,5 +1,11 @@ INCLUDEPATH += $$PWD -HEADERS += $$PWD/wayland-xpixmap-server-protocol.h +HEADERS += \ + $$PWD/wayland-xpixmap-server-protocol.h \ + $$PWD/xpixmapbuffer.h \ + ../../src/qt-compositor/hardware_integration/xpixmap_share/xpixmaphandler.h -SOURCES += $$PWD/wayland-xpixmap-protocol.c +SOURCES += \ + $$PWD/wayland-xpixmap-protocol.c \ + $$PWD/xpixmapbuffer.cpp \ + ../../src/qt-compositor/hardware_integration/xpixmap_share/xpixmaphandler.cpp diff --git a/src/qt-compositor/hardware_integration/xpixmap_share/xpixmapbuffer.cpp b/src/qt-compositor/hardware_integration/xpixmap_share/xpixmapbuffer.cpp new file mode 100644 index 0000000..2d3a27f --- /dev/null +++ b/src/qt-compositor/hardware_integration/xpixmap_share/xpixmapbuffer.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** This file is part of QtCompositor** +** +** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation qt-info@nokia.com +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** +** Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** +** Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** +** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +****************************************************************************/ + +#include "xpixmapbuffer.h" + +void destroy_buffer(struct wl_resource *resource, struct wl_client *client) +{ + +} + +XPixmapBuffer::XPixmapBuffer(Pixmap pixmap, const QSize &size, + wl_visual *visual, Wayland::Compositor *compositor) + : m_pixmap(pixmap) + , m_glxpixmap(0) +{ + base()->height = size.height(); + base()->width = size.width(); + base()->compositor = compositor->base(); + base()->visual = visual; + + //These are set to 0 in super constructor, but do it here as well + //to make a point out of that this surface is a gl surface + base()->attach = 0; + base()->damage = 0; +} + +XPixmapBuffer::~XPixmapBuffer() +{ + +} + +Pixmap XPixmapBuffer::pixmap() const +{ + return m_pixmap; +} + +void xPixmapBufferDestroy(struct wl_client *client, struct wl_buffer *buffer) +{ + Q_UNUSED(client); + delete Wayland::wayland_cast<XPixmapBuffer *>(buffer); +} diff --git a/src/qt-compositor/hardware_integration/xpixmap_share/xpixmapbuffer.h b/src/qt-compositor/hardware_integration/xpixmap_share/xpixmapbuffer.h new file mode 100644 index 0000000..c9574bb --- /dev/null +++ b/src/qt-compositor/hardware_integration/xpixmap_share/xpixmapbuffer.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** This file is part of QtCompositor** +** +** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation qt-info@nokia.com +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** +** Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** +** Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** +** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +****************************************************************************/ + +#ifndef XPIXMAPBUFFER_H +#define XPIXMAPBUFFER_H + +#include "waylandobject.h" +#include "wayland_wrapper/wlcompositor.h" + +#include <QtCore/QSize> + +#include <X11/Xlib.h> +#include <GL/glx.h> + +class XPixmapBuffer : public Wayland::Object<struct wl_buffer> +{ +public: + XPixmapBuffer(Pixmap pixmap, const QSize &size, + wl_visual *visual, Wayland::Compositor *compositor); + + ~XPixmapBuffer(); + + Pixmap pixmap() const; + GLXPixmap m_glxpixmap; +private: + Pixmap m_pixmap; +}; + +void xPixmapBufferDestroy(struct wl_client *client, struct wl_buffer *buffer); + +const static struct wl_buffer_interface xpixmap_buffer_interface = { + xPixmapBufferDestroy +}; + + +#endif // XPIXMAPBUFFER_H diff --git a/src/qt-compositor/hardware_integration/xpixmap_share/xpixmaphandler.cpp b/src/qt-compositor/hardware_integration/xpixmap_share/xpixmaphandler.cpp new file mode 100644 index 0000000..3c620c5 --- /dev/null +++ b/src/qt-compositor/hardware_integration/xpixmap_share/xpixmaphandler.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** This file is part of QtCompositor** +** +** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation qt-info@nokia.com +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** +** Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** +** Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** +** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +****************************************************************************/ + +#include "xpixmaphandler.h" + +#include <QtGui/QWidget> +#include "wayland_wrapper/wlcompositor.h" + +#include <QtCore/QDebug> + +#include "xpixmapbuffer.h" +#include <X11/Xlib.h> + +XPixmapHandler::XPixmapHandler(Wayland::Compositor *compositor, QWidget *topLevelWidget) + :m_compositor(compositor) +{ +} + +XPixmapHandler::~XPixmapHandler() +{ + qDebug() << "xpixmapHandler destroyed"; +} + +void create_buffer(struct wl_client *client, + struct wl_xpixmap *xpixmap, + uint32_t id, + uint32_t xpixmap_id, + int width, + int height, + struct wl_visual *visual) +{ + XPixmapHandler *xpixmapHandler = reinterpret_cast<XPixmapHandler *>(xpixmap); + xpixmapHandler->createBuffer(client,id,xpixmap_id,QSize(width,height),visual); +} + +void XPixmapHandler::createBuffer(wl_client *client, uint32_t id, uint32_t xpixmap_id, const QSize &size, wl_visual *visual) +{ + + qDebug() << "creating buffer for id" << xpixmap_id << "and size" << size; + Pixmap pixmap = (Pixmap)xpixmap_id; + XPixmapBuffer *pixmapBuffer = new XPixmapBuffer(pixmap,size,visual,m_compositor); + Wayland::addClientResource(client,&pixmapBuffer->base()->resource,id,&wl_buffer_interface,&xpixmap_buffer_interface,0); +} diff --git a/src/qt-compositor/hardware_integration/xpixmap_share/xpixmaphandler.h b/src/qt-compositor/hardware_integration/xpixmap_share/xpixmaphandler.h new file mode 100644 index 0000000..ad9c24f --- /dev/null +++ b/src/qt-compositor/hardware_integration/xpixmap_share/xpixmaphandler.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** This file is part of QtCompositor** +** +** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation qt-info@nokia.com +** +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** +** Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** +** Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** +** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +****************************************************************************/ + +#ifndef XPIXMAPHANDLER_H +#define XPIXMAPHANDLER_H + +#include "wayland-xpixmap-server-protocol.h" + +#include "waylandobject.h" +#include <QtCore/QSize> + +namespace Wayland { +class Compositor; +} +class QWidget; + +class XPixmapHandler : public Wayland::Object<struct wl_object> +{ +public: + XPixmapHandler(Wayland::Compositor *compositor, QWidget *topLevelWidget); + + ~XPixmapHandler(); + + void createBuffer(wl_client *client, uint32_t id, uint32_t xpixmap_id, const QSize &size, wl_visual *visual); +private: + Wayland::Compositor *m_compositor; +}; + +void create_buffer(struct wl_client *client, + struct wl_xpixmap *xpixmap, + uint32_t id, + uint32_t xpixmap_id, + int width, + int height, + struct wl_visual *visual); + +const static struct wl_xpixmap_interface xpixmap_interface = { + create_buffer +}; + +#endif // XPIXMAPHANDLER_H diff --git a/src/qt-compositor/qt-compositor.pri b/src/qt-compositor/qt-compositor.pri index c29b7b0..a11593e 100644 --- a/src/qt-compositor/qt-compositor.pri +++ b/src/qt-compositor/qt-compositor.pri @@ -14,12 +14,7 @@ wayland_gl { system(echo "Qt-Compositor configured with openGL") QT += opengl DEFINES += QT_COMPOSITOR_WAYLAND_GL - use_pkgconfig { - QMAKE_CXXFLAGS += $$system(pkg-config --cflags glesv2) - #for some reason this is not included in the cflags line - INCLUDEPATH += $$system(pkg-config --variable=includedir glesv2) - LIBS += $$system(pkg-config --libs glesv2) - } + } else { system(echo "Qt-Compositor configured as raster only compositor") } diff --git a/src/qt-compositor/wayland_wrapper/wlsurface.cpp b/src/qt-compositor/wayland_wrapper/wlsurface.cpp index 51e835f..13f2230 100644 --- a/src/qt-compositor/wayland_wrapper/wlsurface.cpp +++ b/src/qt-compositor/wayland_wrapper/wlsurface.cpp @@ -111,7 +111,7 @@ void surface_map_toplevel(struct wl_client *client, struct wl_surface *surface) { Q_UNUSED(client); - printf("surface_map_toplevel: %p, %p", client, surface); + printf("surface_map_toplevel: %p, %p\n", client, surface); wayland_cast<Surface *>(surface)->mapTopLevel(); } |