From a72e662b4e5c45988bbe06d587e167901b5606da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 6 Apr 2012 13:35:43 +0200 Subject: Update wayland_sha1 and implement buffer_pool interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0628a7655a6deb061a5d0b6c6304c89d8655cf11 Reviewed-by: Samuel Rødal --- src/compositor/wayland_wrapper/wayland_wrapper.pri | 2 - src/compositor/wayland_wrapper/wlcompositor.cpp | 4 +- src/compositor/wayland_wrapper/wlcompositor.h | 5 +- src/compositor/wayland_wrapper/wlinputdevice.cpp | 17 ++- src/compositor/wayland_wrapper/wlshmbuffer.cpp | 133 --------------------- src/compositor/wayland_wrapper/wlshmbuffer.h | 93 -------------- src/compositor/wayland_wrapper/wlsurface.cpp | 11 +- src/compositor/wayland_wrapper/wlsurface.h | 1 - src/compositor/wayland_wrapper/wlsurfacebuffer.cpp | 2 +- .../wayland_egl/qwaylandeglinclude.h | 1 + src/plugins/platforms/wayland/qwaylandbuffer.h | 9 -- src/plugins/platforms/wayland/qwaylandcursor.cpp | 1 - .../platforms/wayland/qwaylandextendedsurface.cpp | 2 +- .../platforms/wayland/qwaylandextendedsurface.h | 4 +- .../platforms/wayland/qwaylandinputdevice.cpp | 13 ++ .../platforms/wayland/qwaylandinputdevice.h | 5 + .../platforms/wayland/qwaylandshmbackingstore.cpp | 5 +- .../platforms/wayland/qwaylandshmbackingstore.h | 1 + src/plugins/platforms/wayland/qwaylandsubsurface.h | 1 + tests/auto/client/client.pro | 2 - tests/auto/client/mockcompositor.cpp | 3 +- tests/auto/client/mockshm.cpp | 96 --------------- tests/auto/client/mockshm.h | 62 ---------- tests/auto/client/mocksurface.cpp | 12 +- tests/auto/client/tst_client.cpp | 4 +- tests/auto/compositor/mockclient.cpp | 4 +- tests/auto/compositor/mockclient.h | 4 +- wayland_sha1.txt | 2 +- 28 files changed, 69 insertions(+), 430 deletions(-) delete mode 100644 src/compositor/wayland_wrapper/wlshmbuffer.cpp delete mode 100644 src/compositor/wayland_wrapper/wlshmbuffer.h delete mode 100644 tests/auto/client/mockshm.cpp delete mode 100644 tests/auto/client/mockshm.h diff --git a/src/compositor/wayland_wrapper/wayland_wrapper.pri b/src/compositor/wayland_wrapper/wayland_wrapper.pri index f15fc9ed8..96b02f4ce 100644 --- a/src/compositor/wayland_wrapper/wayland_wrapper.pri +++ b/src/compositor/wayland_wrapper/wayland_wrapper.pri @@ -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 \ diff --git a/src/compositor/wayland_wrapper/wlcompositor.cpp b/src/compositor/wayland_wrapper/wlcompositor.cpp index 5b5c10787..9388ab9e6 100644 --- a/src/compositor/wayland_wrapper/wlcompositor.cpp +++ b/src/compositor/wayland_wrapper/wlcompositor.cpp @@ -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); diff --git a/src/compositor/wayland_wrapper/wlcompositor.h b/src/compositor/wayland_wrapper/wlcompositor.h index 1d3e358ef..9f0a531d0 100644 --- a/src/compositor/wayland_wrapper/wlcompositor.h +++ b/src/compositor/wayland_wrapper/wlcompositor.h @@ -44,10 +44,10 @@ #include "waylandexport.h" #include +#include #include "wloutput.h" #include "wldisplay.h" -#include "wlshmbuffer.h" #include @@ -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 m_surfaces; diff --git a/src/compositor/wayland_wrapper/wlinputdevice.cpp b/src/compositor/wayland_wrapper/wlinputdevice.cpp index 2e0f4b883..adbff6679 100644 --- a/src/compositor/wayland_wrapper/wlinputdevice.cpp +++ b/src/compositor/wayland_wrapper/wlinputdevice.cpp @@ -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(device_base); if (wl_buffer_is_shm(buffer)) { - ShmBuffer *shmBuffer = static_cast(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(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 index 984397c03..000000000 --- a/src/compositor/wayland_wrapper/wlshmbuffer.cpp +++ /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 - -#include - -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(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(buffer->user_data)->damage(); -} - -void ShmHandler::buffer_destroyed_callback(struct wl_buffer *buffer) -{ - ShmBuffer *shmbuf = static_cast(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 index 8cb2293e4..000000000 --- a/src/compositor/wayland_wrapper/wlshmbuffer.h +++ /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 -#include - - -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 diff --git a/src/compositor/wayland_wrapper/wlsurface.cpp b/src/compositor/wayland_wrapper/wlsurface.cpp index 1b1926e98..e280ba05a 100644 --- a/src/compositor/wayland_wrapper/wlsurface.cpp +++ b/src/compositor/wayland_wrapper/wlsurface.cpp @@ -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(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(data); + QImage img(char_data, buffer->width, buffer->height, stride, QImage::Format_ARGB32_Premultiplied); + return img; } return QImage(); } diff --git a/src/compositor/wayland_wrapper/wlsurface.h b/src/compositor/wayland_wrapper/wlsurface.h index 0d917cbd8..294a467d2 100644 --- a/src/compositor/wayland_wrapper/wlsurface.h +++ b/src/compositor/wayland_wrapper/wlsurface.h @@ -43,7 +43,6 @@ #include "waylandexport.h" -#include "wlshmbuffer.h" #include "wlsurfacebuffer.h" #include "waylandsurface.h" diff --git a/src/compositor/wayland_wrapper/wlsurfacebuffer.cpp b/src/compositor/wayland_wrapper/wlsurfacebuffer.cpp index 7d3fe9a29..aff962a7b 100644 --- a/src/compositor/wayland_wrapper/wlsurfacebuffer.cpp +++ b/src/compositor/wayland_wrapper/wlsurfacebuffer.cpp @@ -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) diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglinclude.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglinclude.h index 416ffea40..b4cb0edf3 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglinclude.h +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglinclude.h @@ -42,6 +42,7 @@ #ifndef QWAYLANDEGLINCLUDE_H #define QWAYLANDEGLINCLUDE_H +#include #include #include diff --git a/src/plugins/platforms/wayland/qwaylandbuffer.h b/src/plugins/platforms/wayland/qwaylandbuffer.h index e63e3849c..125c3b0a6 100644 --- a/src/plugins/platforms/wayland/qwaylandbuffer.h +++ b/src/plugins/platforms/wayland/qwaylandbuffer.h @@ -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 diff --git a/src/plugins/platforms/wayland/qwaylandcursor.cpp b/src/plugins/platforms/wayland/qwaylandcursor.cpp index e8e7ef1e7..560ec4ef4 100644 --- a/src/plugins/platforms/wayland/qwaylandcursor.cpp +++ b/src/plugins/platforms/wayland/qwaylandcursor.cpp @@ -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); } } diff --git a/src/plugins/platforms/wayland/qwaylandextendedsurface.cpp b/src/plugins/platforms/wayland/qwaylandextendedsurface.cpp index 1e565f4dc..09ab8f73b 100644 --- a/src/plugins/platforms/wayland/qwaylandextendedsurface.cpp +++ b/src/plugins/platforms/wayland/qwaylandextendedsurface.cpp @@ -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; diff --git a/src/plugins/platforms/wayland/qwaylandextendedsurface.h b/src/plugins/platforms/wayland/qwaylandextendedsurface.h index 9d4534b81..a23120843 100644 --- a/src/plugins/platforms/wayland/qwaylandextendedsurface.h +++ b/src/plugins/platforms/wayland/qwaylandextendedsurface.h @@ -42,11 +42,11 @@ #ifndef QWAYLANDEXTENDEDSURFACE_H #define QWAYLANDEXTENDEDSURFACE_H -#include - #include #include +#include + class QWaylandDisplay; class QWaylandWindow; class QWaylandExtendedSurface; diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index c5b5eee86..ac5ac8b17 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -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, diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.h b/src/plugins/platforms/wayland/qwaylandinputdevice.h index 827586257..9d512a69a 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.h +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.h @@ -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); diff --git a/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp b/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp index 7efa72545..6aafd1c98 100644 --- a/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp @@ -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 ®ion, cons QVector 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); } } diff --git a/src/plugins/platforms/wayland/qwaylandshmbackingstore.h b/src/plugins/platforms/wayland/qwaylandshmbackingstore.h index dc895cc96..e1940776c 100644 --- a/src/plugins/platforms/wayland/qwaylandshmbackingstore.h +++ b/src/plugins/platforms/wayland/qwaylandshmbackingstore.h @@ -60,6 +60,7 @@ public: QImage *image() { return &mImage; } private: QImage mImage; + struct wl_shm_pool *mShmPool; }; class QWaylandShmBackingStore : public QPlatformBackingStore diff --git a/src/plugins/platforms/wayland/qwaylandsubsurface.h b/src/plugins/platforms/wayland/qwaylandsubsurface.h index 6bd7794c1..2b8b039e4 100644 --- a/src/plugins/platforms/wayland/qwaylandsubsurface.h +++ b/src/plugins/platforms/wayland/qwaylandsubsurface.h @@ -46,6 +46,7 @@ class QWaylandDisplay; class QWaylandWindow; class QWaylandSubSurface; +#include #include class QWaylandSubSurfaceExtension diff --git a/tests/auto/client/client.pro b/tests/auto/client/client.pro index 6bfe82b78..9a7e2c8c2 100644 --- a/tests/auto/client/client.pro +++ b/tests/auto/client/client.pro @@ -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 diff --git a/tests/auto/client/mockcompositor.cpp b/tests/auto/client/mockcompositor.cpp index c751bccb2..119adc054 100644 --- a/tests/auto/client/mockcompositor.cpp +++ b/tests/auto/client/mockcompositor.cpp @@ -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 index 5c0ba38a3..000000000 --- a/tests/auto/client/mockshm.cpp +++ /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(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(buffer->user_data)->refresh(); -} - -static void shm_buffer_destroyed(wl_buffer *buffer) -{ - delete static_cast(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 index 96c77129f..000000000 --- a/tests/auto/client/mockshm.h +++ /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 -#include - -#include - -namespace Impl { - -class ShmBuffer -{ -public: - ShmBuffer(wl_buffer *buffer); - - void refresh(); - QImage image() const; - -private: - wl_buffer *m_buffer; - QImage m_image; -}; - -} diff --git a/tests/auto/client/mocksurface.cpp b/tests/auto/client/mocksurface.cpp index 68c18bac6..f149822f6 100644 --- a/tests/auto/client/mocksurface.cpp +++ b/tests/auto/client/mocksurface.cpp @@ -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(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(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) { diff --git a/tests/auto/client/tst_client.cpp b/tests/auto/client/tst_client.cpp index b6d434f8a..5b594198e 100644 --- a/tests/auto/client/tst_client.cpp +++ b/tests/auto/client/tst_client.cpp @@ -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(); diff --git a/tests/auto/compositor/mockclient.cpp b/tests/auto/compositor/mockclient.cpp index 5dabfcd57..4b04164b6 100644 --- a/tests/auto/compositor/mockclient.cpp +++ b/tests/auto/compositor/mockclient.cpp @@ -167,7 +167,8 @@ ShmBuffer::ShmBuffer(const QSize &size, wl_shm *shm) } image = QImage(static_cast(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); } diff --git a/tests/auto/compositor/mockclient.h b/tests/auto/compositor/mockclient.h index 2f2f665cd..e6be12fe7 100644 --- a/tests/auto/compositor/mockclient.h +++ b/tests/auto/compositor/mockclient.h @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include "string.h" #include "wayland-client.h" #include @@ -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; }; diff --git a/wayland_sha1.txt b/wayland_sha1.txt index 27aea1534..099b2fb3d 100644 --- a/wayland_sha1.txt +++ b/wayland_sha1.txt @@ -1,3 +1,3 @@ This version of Qt-Compositor is checked against the following sha1 from the Wayland repository: -bb4b05bc8d0df6dc119a20bdaad30a0849a028be +aa777e5b10e17d12c4bb6440f7c659d2a12191f5 -- cgit v1.2.3