1 /******************************************************************** 2 Copyright 2014 Martin Gräßlin <mgraesslin@kde.org> 3 Copyright © 2020 Roman Gilg <subdiff@gmail.com> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) version 3, or any 9 later version accepted by the membership of KDE e.V. (or its 10 successor approved by the membership of KDE e.V.), which shall 11 act as a proxy defined in Section 6 of version 3 of the license. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with this library. If not, see <http://www.gnu.org/licenses/>. 20 *********************************************************************/ 21 #include "buffer.h" 22 23 #include <wayland-server.h> 24 25 namespace Wrapland::Server 26 { 27 namespace Wayland 28 { 29 class Display; 30 } 31 32 struct DestroyWrapper { 33 Buffer* buffer; 34 struct wl_listener listener; 35 }; 36 37 class ShmImage::Private 38 { 39 public: 40 Private(Buffer* buffer, ShmImage::Format format); 41 ~Private(); 42 43 QImage createQImage(); 44 45 ShmImage::Format format{ShmImage::Format::invalid}; 46 int32_t stride; 47 int32_t bpp; 48 49 uchar* data; 50 51 Buffer* buffer; 52 Wayland::Display* display; 53 54 private: 55 static void imageBufferCleanupHandler(void* info); 56 QImage image; 57 }; 58 59 class Buffer::Private 60 { 61 public: 62 Private(Buffer* q, wl_resource* wlResource, Surface* surface, Wayland::Display* display); 63 ~Private(); 64 65 wl_resource* resource; 66 wl_shm_buffer* shmBuffer; 67 LinuxDmabufBufferV1* dmabufBuffer{nullptr}; 68 69 Surface* surface; 70 int refCount{0}; 71 QSize size; 72 bool alpha{false}; 73 bool committed{false}; 74 75 Wayland::Display* display; 76 77 private: 78 static void destroyListenerCallback(wl_listener* listener, void* data); 79 80 Buffer* q_ptr; 81 DestroyWrapper destroyWrapper; 82 }; 83 84 } 85