diff options
Diffstat (limited to 'src/compositor/wayland_wrapper')
-rw-r--r-- | src/compositor/wayland_wrapper/wayland_wrapper.pri | 2 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/wlcompositor.cpp | 4 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/wlcompositor.h | 5 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/wlinputdevice.cpp | 17 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/wlshmbuffer.cpp | 133 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/wlshmbuffer.h | 93 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/wlsurface.cpp | 11 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/wlsurface.h | 1 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/wlsurfacebuffer.cpp | 2 |
9 files changed, 23 insertions, 245 deletions
diff --git a/src/compositor/wayland_wrapper/wayland_wrapper.pri b/src/compositor/wayland_wrapper/wayland_wrapper.pri index f15fc9ed..96b02f4c 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 5b5c1078..9388ab9e 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 1d3e358e..9f0a531d 100644 --- a/src/compositor/wayland_wrapper/wlcompositor.h +++ b/src/compositor/wayland_wrapper/wlcompositor.h @@ -44,10 +44,10 @@ #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; diff --git a/src/compositor/wayland_wrapper/wlinputdevice.cpp b/src/compositor/wayland_wrapper/wlinputdevice.cpp index 2e0f4b88..adbff667 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<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 index 984397c0..00000000 --- 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 <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 index 8cb2293e..00000000 --- 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 <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 diff --git a/src/compositor/wayland_wrapper/wlsurface.cpp b/src/compositor/wayland_wrapper/wlsurface.cpp index 1b1926e9..e280ba05 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<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(); } diff --git a/src/compositor/wayland_wrapper/wlsurface.h b/src/compositor/wayland_wrapper/wlsurface.h index 0d917cbd..294a467d 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 7d3fe9a2..aff962a7 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) |