Update wayland_sha1 and implement buffer_pool interface
authorJørgen Lind <jorgen.lind@nokia.com>
Fri, 6 Apr 2012 11:35:43 +0000 (13:35 +0200)
committerJørgen Lind <jorgen.lind@nokia.com>
Tue, 10 Apr 2012 16:54:33 +0000 (18:54 +0200)
Change-Id: I0628a7655a6deb061a5d0b6c6304c89d8655cf11
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
28 files changed:
src/compositor/wayland_wrapper/wayland_wrapper.pri
src/compositor/wayland_wrapper/wlcompositor.cpp
src/compositor/wayland_wrapper/wlcompositor.h
src/compositor/wayland_wrapper/wlinputdevice.cpp
src/compositor/wayland_wrapper/wlshmbuffer.cpp [deleted file]
src/compositor/wayland_wrapper/wlshmbuffer.h [deleted file]
src/compositor/wayland_wrapper/wlsurface.cpp
src/compositor/wayland_wrapper/wlsurface.h
src/compositor/wayland_wrapper/wlsurfacebuffer.cpp
src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglinclude.h
src/plugins/platforms/wayland/qwaylandbuffer.h
src/plugins/platforms/wayland/qwaylandcursor.cpp
src/plugins/platforms/wayland/qwaylandextendedsurface.cpp
src/plugins/platforms/wayland/qwaylandextendedsurface.h
src/plugins/platforms/wayland/qwaylandinputdevice.cpp
src/plugins/platforms/wayland/qwaylandinputdevice.h
src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp
src/plugins/platforms/wayland/qwaylandshmbackingstore.h
src/plugins/platforms/wayland/qwaylandsubsurface.h
tests/auto/client/client.pro
tests/auto/client/mockcompositor.cpp
tests/auto/client/mockshm.cpp [deleted file]
tests/auto/client/mockshm.h [deleted file]
tests/auto/client/mocksurface.cpp
tests/auto/client/tst_client.cpp
tests/auto/compositor/mockclient.cpp
tests/auto/compositor/mockclient.h
wayland_sha1.txt

index f15fc9e..96b02f4 100644 (file)
@@ -10,7 +10,6 @@ HEADERS += \
     $$PWD/wlcompositor.h \
     $$PWD/wldisplay.h \
     $$PWD/wloutput.h \
-    $$PWD/wlshmbuffer.h \
     $$PWD/wlsurface.h \
     $$PWD/wlshellsurface.h \
     $$PWD/wlinputdevice.h \
@@ -31,7 +30,6 @@ SOURCES += \
     $$PWD/wlcompositor.cpp \
     $$PWD/wldisplay.cpp \
     $$PWD/wloutput.cpp \
-    $$PWD/wlshmbuffer.cpp \
     $$PWD/wlsurface.cpp \
     $$PWD/wlshellsurface.cpp \
     $$PWD/wlinputdevice.cpp \
index 5b5c107..9388ab9 100644 (file)
@@ -42,7 +42,6 @@
 
 #include "waylandinput.h"
 #include "wldisplay.h"
-#include "wlshmbuffer.h"
 #include "wlsurface.h"
 #include "waylandcompositor.h"
 #include "wldatadevicemanager.h"
@@ -120,7 +119,6 @@ Compositor::Compositor(WaylandCompositor *qt_compositor)
     : m_display(new Display)
     , m_default_input_device(0)
     , m_pageFlipper(0)
-    , m_shm(m_display)
     , m_current_frame(0)
     , m_last_queued_buf(-1)
     , m_qt_compositor(qt_compositor)
@@ -153,6 +151,8 @@ Compositor::Compositor(WaylandCompositor *qt_compositor)
     m_shell = new Shell();
     wl_display_add_global(m_display->handle(), &wl_shell_interface, m_shell, Shell::bind_func);
 
+    wl_display_init_shm(m_display->handle());
+
     m_outputExtension = new OutputExtensionGlobal(this);
     m_surfaceExtension = new SurfaceExtensionGlobal(this);
     m_qtkeyExtension = new QtKeyExtensionGlobal(this);
index 1d3e358..9f0a531 100644 (file)
 #include "waylandexport.h"
 
 #include <QtCore/QSet>
+#include <QtGui/QWindow>
 
 #include "wloutput.h"
 #include "wldisplay.h"
-#include "wlshmbuffer.h"
 
 #include <wayland-server.h>
 
@@ -162,9 +162,6 @@ private:
     //This one should be part of the outputs
     QPlatformScreenPageFlipper *m_pageFlipper;
 
-    /* shm/*/
-    ShmHandler m_shm;
-
     DataDeviceManager *m_data_device_manager;
 
     QList<Surface *> m_surfaces;
index 2e0f4b8..adbff66 100644 (file)
@@ -40,7 +40,6 @@
 
 #include "wlinputdevice.h"
 
-#include "wlshmbuffer.h"
 #include "wlcompositor.h"
 #include "wldatadevice.h"
 #include "wlsurface.h"
@@ -52,7 +51,7 @@
 
 namespace Wayland {
 
-static ShmBuffer *currentCursor;
+static QImage *currentCursor;
 
 InputDevice::InputDevice(WaylandInputDevice *handle, Compositor *compositor)
     : m_handle(handle)
@@ -346,10 +345,16 @@ void InputDevice::input_device_attach(struct wl_client *client,
 
     InputDevice *inputDevice = wayland_cast<InputDevice>(device_base);
     if (wl_buffer_is_shm(buffer)) {
-        ShmBuffer *shmBuffer = static_cast<ShmBuffer *>(buffer->user_data);
-        if (shmBuffer) {
-            inputDevice->m_compositor->waylandCompositor()->changeCursor(shmBuffer->image(), x, y);
-            currentCursor = shmBuffer;
+        int stride = wl_shm_buffer_get_stride(buffer);
+        uint format = wl_shm_buffer_get_format(buffer);
+        (void) format;
+        void *data = wl_shm_buffer_get_data(buffer);
+        const uchar *char_data = static_cast<const uchar *>(data);
+        if (char_data) {
+            QImage *img = new QImage(char_data, buffer->width, buffer->height, stride, QImage::Format_ARGB32_Premultiplied);
+            inputDevice->m_compositor->waylandCompositor()->changeCursor(*img, x, y);
+            delete currentCursor;
+            currentCursor = img;
         }
     }
 }
diff --git a/src/compositor/wayland_wrapper/wlshmbuffer.cpp b/src/compositor/wayland_wrapper/wlshmbuffer.cpp
deleted file mode 100644 (file)
index 984397c..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the Qt Compositor.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "wlshmbuffer.h"
-
-#include "wldisplay.h"
-#include "wlcompositor.h"
-
-#include <QtCore/QDebug>
-
-#include <sys/mman.h>
-
-namespace Wayland {
-
-ShmBuffer::ShmBuffer(struct wl_buffer *buffer)
-    : m_buffer(buffer)
-{
-    m_buffer->user_data = this;
-    m_data = wl_shm_buffer_get_data(m_buffer);
-    m_stride = wl_shm_buffer_get_stride(m_buffer);
-
-    damage();
-}
-
-ShmBuffer::~ShmBuffer()
-{
-}
-
-QImage ShmBuffer::image() const
-{
-    return m_image;
-}
-
-QSize ShmBuffer::size() const
-{
-    return QSize(m_buffer->width, m_buffer->height);
-}
-
-void ShmBuffer::damage()
-{
-    QImage::Format imageFormat = QImage::Format_Invalid;
-
-    imageFormat = QImage::Format_ARGB32_Premultiplied;
-
-    m_image = QImage(static_cast<uchar *>(m_data),m_buffer->width, m_buffer->height,m_stride,imageFormat);
-
-}
-
-static ShmHandler *handlerInstance;
-
-ShmHandler::ShmHandler(Display *display)
-    : m_display(display)
-{
-    handlerInstance = this;
-    m_shm = wl_shm_init(m_display->handle(),&shm_callbacks);
-}
-
-ShmHandler::~ShmHandler()
-{
-    wl_shm_finish(m_shm);
-}
-
-struct wl_shm_callbacks ShmHandler::shm_callbacks = {
-    buffer_created_callback,
-    buffer_damaged_callback,
-    buffer_destroyed_callback
-};
-
-void ShmHandler::buffer_created_callback(struct wl_buffer *buffer)
-{
-    ShmBuffer *newBuffer = new ShmBuffer(buffer);
-    Q_UNUSED(newBuffer);
-}
-
-void ShmHandler::buffer_damaged_callback(struct wl_buffer *buffer,
-                      int32_t x, int32_t y,
-                      int32_t width, int32_t height)
-{
-    Q_UNUSED(buffer);
-    Q_UNUSED(x);
-    Q_UNUSED(y);
-    Q_UNUSED(width);
-    Q_UNUSED(height);
-    //damage has the responsibillity to update the QImage
-    //for now we just recrate the entire QImage as we need a new
-    //hash key for texture uploads
-    static_cast<ShmBuffer *>(buffer->user_data)->damage();
-}
-
-void ShmHandler::buffer_destroyed_callback(struct wl_buffer *buffer)
-{
-    ShmBuffer *shmbuf = static_cast<ShmBuffer *>(buffer->user_data);
-    delete shmbuf;
-}
-
-}
diff --git a/src/compositor/wayland_wrapper/wlshmbuffer.h b/src/compositor/wayland_wrapper/wlshmbuffer.h
deleted file mode 100644 (file)
index 8cb2293..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the Qt Compositor.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef WL_SHMBUFFER_H
-#define WL_SHMBUFFER_H
-
-#include "waylandobject.h"
-
-#include <QtCore/QRect>
-#include <QtGui/QImage>
-
-
-namespace Wayland {
-
-class Surface;
-class Display;
-
-class ShmBuffer
-{
-public:
-    ShmBuffer(struct wl_buffer *buffer);
-    ~ShmBuffer();
-
-    QImage image() const;
-    QSize size() const;
-
-    void damage();
-
-private:
-    struct wl_buffer *m_buffer;
-    int m_stride;
-    void *m_data;
-    QImage m_image;
-};
-
-class ShmHandler
-{
-public:
-    ShmHandler(Display *display);
-    ~ShmHandler();
-
-private:
-    Display *m_display;
-    struct wl_shm *m_shm;
-
-    static struct wl_shm_callbacks shm_callbacks;
-    static void buffer_created_callback(struct wl_buffer *buffer);
-    static void buffer_damaged_callback(struct wl_buffer *buffer,
-                          int32_t x, int32_t y,
-                          int32_t width, int32_t height);
-    static void buffer_destroyed_callback(struct wl_buffer *buffer);
-};
-
-}
-
-#endif //WL_SHMBUFFER_H
index 1b1926e..e280ba0 100644 (file)
@@ -44,7 +44,6 @@
 #include "waylandsurfaceitem.h"
 
 #include "wlcompositor.h"
-#include "wlshmbuffer.h"
 #include "wlinputdevice.h"
 #include "wlextendedsurface.h"
 #include "wlregion.h"
@@ -187,8 +186,14 @@ QImage Surface::image() const
 {
     SurfaceBuffer *surfacebuffer = currentSurfaceBuffer();
     if (surfacebuffer && !surfacebuffer->isDestroyed() && type() == WaylandSurface::Shm) {
-        ShmBuffer *shmBuffer = static_cast<ShmBuffer *>(surfacebuffer->waylandBufferHandle()->user_data);
-        return shmBuffer->image();
+        struct wl_buffer *buffer = surfacebuffer->waylandBufferHandle();
+        int stride = wl_shm_buffer_get_stride(buffer);
+        uint format = wl_shm_buffer_get_format(buffer);
+        (void) format;
+        void *data = wl_shm_buffer_get_data(buffer);
+        const uchar *char_data = static_cast<const uchar *>(data);
+        QImage img(char_data, buffer->width, buffer->height, stride, QImage::Format_ARGB32_Premultiplied);
+        return img;
     }
     return QImage();
 }
index 0d917cb..294a467 100644 (file)
@@ -43,7 +43,6 @@
 
 #include "waylandexport.h"
 
-#include "wlshmbuffer.h"
 #include "wlsurfacebuffer.h"
 #include "waylandsurface.h"
 
index 7d3fe9a..aff962a 100644 (file)
@@ -171,7 +171,7 @@ void SurfaceBuffer::handleDisplayed()
 
 void *SurfaceBuffer::handle() const
 {
-    return m_buffer->user_data;
+    return m_buffer;
 }
 
 void SurfaceBuffer::destroy_listener_callback(wl_listener *listener, wl_resource *resource, uint32_t time)
index e63e384..125c3b0 100644 (file)
@@ -54,18 +54,9 @@ public:
     virtual ~QWaylandBuffer() { }
     wl_buffer *buffer() {return mBuffer;}
     virtual QSize size() const = 0;
-    inline void damage(const QRect &rect = QRect());
 
 protected:
     struct wl_buffer *mBuffer;
 };
 
-void QWaylandBuffer::damage(const QRect &rect)
-{
-    if (rect.isValid())
-        wl_buffer_damage(mBuffer,rect.x(),rect.y(),rect.width(),rect.height());
-    else
-        wl_buffer_damage(mBuffer,0,0,size().width(),size().height());
-}
-
 #endif // QWAYLANDBUFFER_H
index e8e7ef1..560ec4e 100644 (file)
@@ -180,7 +180,6 @@ void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window)
                                             QImage::Format_ARGB32);
         }
         reader.read(mBuffer->image());
-        mBuffer->damage();
         mDisplay->setCursor(mBuffer, p->hotspot_x, p->hotspot_y);
     }
 }
index 1e565f4..09ab8f7 100644 (file)
@@ -86,7 +86,7 @@ void QWaylandExtendedSurface::updateGenericProperty(const QString &name, const Q
     QDataStream ds(&byteValue, QIODevice::WriteOnly);
     ds << value;
 
-    wl_array data;
+    struct wl_array data;
     data.size = byteValue.size();
     data.data = (void*)byteValue.constData();
     data.alloc = 0;
index 9d4534b..a231208 100644 (file)
 #ifndef QWAYLANDEXTENDEDSURFACE_H
 #define QWAYLANDEXTENDEDSURFACE_H
 
-#include <wayland-client.h>
-
 #include <QtCore/QString>
 #include <QtCore/QVariant>
 
+#include <wayland-client.h>
+
 class QWaylandDisplay;
 class QWaylandWindow;
 class QWaylandExtendedSurface;
index c5b5eee..ac5ac8b 100644 (file)
@@ -197,6 +197,18 @@ void QWaylandInputDevice::inputHandleButton(void *data,
                                             inputDevice->mButtons);
 }
 
+void QWaylandInputDevice::inputHandleAxis(void *data,
+                                          struct wl_input_device *wl_input_device,
+                                          uint32_t time,
+                                          uint32_t axis,
+                                          int32_t value)
+{
+    Q_UNUSED(data);
+    Q_UNUSED(wl_input_device);
+    Q_UNUSED(time);
+    Q_UNUSED(axis);
+    Q_UNUSED(value);
+}
 #ifndef QT_NO_WAYLAND_XKB
 static Qt::KeyboardModifiers translateModifiers(int s)
 {
@@ -559,6 +571,7 @@ void QWaylandInputDevice::inputHandleTouchCancel(void *data, struct wl_input_dev
 const struct wl_input_device_listener QWaylandInputDevice::inputDeviceListener = {
     QWaylandInputDevice::inputHandleMotion,
     QWaylandInputDevice::inputHandleButton,
+    QWaylandInputDevice::inputHandleAxis,
     QWaylandInputDevice::inputHandleKey,
     QWaylandInputDevice::inputHandlePointerEnter,
     QWaylandInputDevice::inputHandlePointerLeave,
index 8275862..9d512a6 100644 (file)
@@ -91,6 +91,11 @@ private:
     static void inputHandleButton(void *data,
                                  struct wl_input_device *input_device,
                                  uint32_t time, uint32_t button, uint32_t state);
+    static void inputHandleAxis(void *data,
+                                struct wl_input_device *wl_input_device,
+                                uint32_t time,
+                                uint32_t axis,
+                                int32_t value);
     static void inputHandleKey(void *data,
                               struct wl_input_device *input_device,
                               uint32_t time, uint32_t key, uint32_t state);
index 7efa725..6aafd1c 100644 (file)
@@ -79,7 +79,8 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
     }
 
     mImage = QImage(data, size.width(), size.height(), stride, format);
-    mBuffer = wl_shm_create_buffer(display->shm(),fd, size.width(), size.height(),
+    mShmPool = wl_shm_create_pool(display->shm(), fd, alloc);
+    mBuffer = wl_shm_pool_create_buffer(mShmPool,0, size.width(), size.height(),
                                        stride, WL_SHM_FORMAT_ARGB8888);
     close(fd);
 }
@@ -88,6 +89,7 @@ QWaylandShmBuffer::~QWaylandShmBuffer(void)
 {
     munmap((void *) mImage.constBits(), mImage.byteCount());
     wl_buffer_destroy(mBuffer);
+    wl_shm_pool_destroy(mShmPool);
 }
 
 QWaylandShmBackingStore::QWaylandShmBackingStore(QWindow *window)
@@ -122,7 +124,6 @@ void QWaylandShmBackingStore::flush(QWindow *window, const QRegion &region, cons
     QVector<QRect> rects = region.rects();
     for (int i = 0; i < rects.size(); i++) {
         const QRect rect = rects.at(i);
-        wl_buffer_damage(mBuffer->buffer(),rect.x(),rect.y(),rect.width(),rect.height());
         waylandWindow->damage(rect);
     }
 }
index dc895cc..e194077 100644 (file)
@@ -60,6 +60,7 @@ public:
     QImage *image() { return &mImage; }
 private:
     QImage mImage;
+    struct wl_shm_pool *mShmPool;
 };
 
 class QWaylandShmBackingStore : public QPlatformBackingStore
index 6bd7794..2b8b039 100644 (file)
@@ -46,6 +46,7 @@ class QWaylandDisplay;
 class QWaylandWindow;
 class QWaylandSubSurface;
 
+#include <string.h>
 #include <wayland-client.h>
 
 class QWaylandSubSurfaceExtension
index 6bfe82b..9a7e2c8 100644 (file)
@@ -33,9 +33,7 @@ SOURCES += tst_client.cpp \
            mockcompositor.cpp \
            mockinput.cpp \
            mockshell.cpp \
-           mockshm.cpp \
            mocksurface.cpp \
            mockoutput.cpp
 HEADERS += mockcompositor.h \
-           mockshm.h \
            mocksurface.h
index c751bcc..119adc0 100644 (file)
@@ -204,7 +204,7 @@ Compositor::Compositor()
     wl_display_add_global(m_display, &wl_output_interface, this, bindOutput);
     wl_display_add_global(m_display, &wl_shell_interface, this, bindShell);
 
-    initShm();
+    wl_display_init_shm(m_display);
 
     m_loop = wl_display_get_event_loop(m_display);
     m_fd = wl_event_loop_get_fd(m_loop);
@@ -212,7 +212,6 @@ Compositor::Compositor()
 
 Compositor::~Compositor()
 {
-    wl_shm_finish(m_shm);
     wl_display_destroy(m_display);
 }
 
diff --git a/tests/auto/client/mockshm.cpp b/tests/auto/client/mockshm.cpp
deleted file mode 100644 (file)
index 5c0ba38..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "mockcompositor.h"
-#include "mockshm.h"
-
-namespace Impl {
-
-ShmBuffer::ShmBuffer(wl_buffer *buffer)
-    : m_buffer(buffer)
-{
-    refresh();
-}
-
-void ShmBuffer::refresh()
-{
-    m_image = QImage(static_cast<uint8_t *>(wl_shm_buffer_get_data(m_buffer)),
-                     m_buffer->width, m_buffer->height,
-                     wl_shm_buffer_get_stride(m_buffer),
-                     QImage::Format_ARGB32_Premultiplied);
-}
-
-QImage ShmBuffer::image() const
-{
-    return m_image;
-}
-
-static void shm_buffer_created(wl_buffer *buffer)
-{
-    buffer->user_data = new ShmBuffer(buffer);
-}
-
-static void shm_buffer_damaged(wl_buffer *buffer,
-                               int32_t x, int32_t y,
-                               int32_t width, int32_t height)
-{
-    Q_UNUSED(QRect(x, y, width, height));
-    static_cast<ShmBuffer *>(buffer->user_data)->refresh();
-}
-
-static void shm_buffer_destroyed(wl_buffer *buffer)
-{
-    delete static_cast<ShmBuffer *>(buffer->user_data);
-}
-
-void Compositor::initShm()
-{
-    static struct wl_shm_callbacks shmCallbacks = {
-        shm_buffer_created,
-        shm_buffer_damaged,
-        shm_buffer_destroyed
-    };
-
-    m_shm = wl_shm_init(m_display, &shmCallbacks);
-}
-
-}
-
diff --git a/tests/auto/client/mockshm.h b/tests/auto/client/mockshm.h
deleted file mode 100644 (file)
index 96c7712..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qglobal.h>
-#include <wayland-server.h>
-
-#include <QImage>
-
-namespace Impl {
-
-class ShmBuffer
-{
-public:
-    ShmBuffer(wl_buffer *buffer);
-
-    void refresh();
-    QImage image() const;
-
-private:
-    wl_buffer *m_buffer;
-    QImage m_image;
-};
-
-}
index 68c18ba..f149822 100644 (file)
@@ -41,7 +41,6 @@
 
 #include "mocksurface.h"
 #include "mockcompositor.h"
-#include "mockshm.h"
 
 namespace Impl {
 
@@ -87,8 +86,15 @@ void surface_damage(wl_client *client, wl_resource *surfaceResource,
     if (!buffer)
         return;
 
-    if (wl_buffer_is_shm(buffer))
-        surface->m_mockSurface->image = static_cast<ShmBuffer *>(buffer->user_data)->image();
+    if (wl_buffer_is_shm(buffer)) {
+        int stride = wl_shm_buffer_get_stride(buffer);
+        uint format = wl_shm_buffer_get_format(buffer);
+        (void) format;
+        void *data = wl_shm_buffer_get_data(buffer);
+        const uchar *char_data = static_cast<const uchar *>(data);
+        QImage img(char_data, buffer->width, buffer->height, stride, QImage::Format_ARGB32_Premultiplied);
+        surface->m_mockSurface->image = img;
+    }
 
     wl_resource *frameCallback;
     wl_list_for_each(frameCallback, &surface->m_frameCallbackList, link) {
index b6d434f..5b59419 100644 (file)
@@ -230,8 +230,8 @@ void tst_WaylandClient::backingStore()
 
     backingStore.flush(rect);
 
-    QTRY_COMPARE(surface->image.size(), rect.size());
-    QTRY_COMPARE(surface->image.pixel(0, 0), color.rgba());
+    QTRY_COMPARE(surface->image.size(), window.frameGeometry().size());
+    QTRY_COMPARE(surface->image.pixel(window.frameMargins().left(), window.frameMargins().top()), color.rgba());
 
     window.hide();
 
index 5dabfcd..4b04164 100644 (file)
@@ -167,7 +167,8 @@ ShmBuffer::ShmBuffer(const QSize &size, wl_shm *shm)
     }
 
     image = QImage(static_cast<uchar *>(data), size.width(), size.height(), stride, QImage::Format_ARGB32_Premultiplied);
-    handle = wl_shm_create_buffer(shm,fd, size.width(), size.height(),
+    shm_pool = wl_shm_create_pool(shm,fd,alloc);
+    handle = wl_shm_pool_create_buffer(shm_pool,0, size.width(), size.height(),
                                    stride, WL_SHM_FORMAT_ARGB8888);
     close(fd);
 }
@@ -176,5 +177,6 @@ ShmBuffer::~ShmBuffer()
 {
     munmap(image.bits(), image.byteCount());
     wl_buffer_destroy(handle);
+    wl_shm_pool_destroy(shm_pool);
 }
 
index 2f2f665..e6be12f 100644 (file)
@@ -39,6 +39,7 @@
 **
 ****************************************************************************/
 
+#include "string.h"
 #include "wayland-client.h"
 
 #include <QObject>
@@ -51,7 +52,8 @@ public:
     ShmBuffer(const QSize &size, wl_shm *shm);
     ~ShmBuffer();
 
-    wl_buffer *handle;
+    struct wl_buffer *handle;
+    struct wl_shm_pool *shm_pool;
     QImage image;
 };
 
index 27aea15..099b2fb 100644 (file)
@@ -1,3 +1,3 @@
 This version of Qt-Compositor is checked against the following sha1 from the
 Wayland repository:
-bb4b05bc8d0df6dc119a20bdaad30a0849a028be
+aa777e5b10e17d12c4bb6440f7c659d2a12191f5