From d321eec79f3af2c359a1577e172ea1f7329e2dc2 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 5 Feb 2017 10:56:29 +0100 Subject: Added XShmImage support in X11 rendering backend. --- plugingui/nativewindow_x11.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'plugingui/nativewindow_x11.h') diff --git a/plugingui/nativewindow_x11.h b/plugingui/nativewindow_x11.h index db6ec76..f36be51 100644 --- a/plugingui/nativewindow_x11.h +++ b/plugingui/nativewindow_x11.h @@ -27,13 +27,18 @@ #pragma once #include +#include #include "nativewindow.h" -namespace GUI { +namespace GUI +{ class Window; -class NativeWindowX11 : public NativeWindow { + +class NativeWindowX11 + : public NativeWindow +{ public: NativeWindowX11(void* native_window, Window& window); ~NativeWindowX11(); @@ -54,11 +59,22 @@ public: private: std::shared_ptr translateXMessage(XEvent& xevent, bool peek = false); - XImage* createImageFromBuffer(unsigned char* buf, int width, int height); + + //! Allocate new shared memory buffer for the pixel buffer. + //! Frees the existing buffer if there is one. + void allocateShmImage(std::size_t width, std::size_t height); + + //! Deallocate image and shm resources. + void deallocateShmImage(); + + //! Copy data from the pixel buffer into the shared memory + void updateImageFromBuffer(); + + XShmSegmentInfo shm_info; + XImage* image{nullptr}; ::Window xwindow{0}; GC gc{0}; - XImage* buffer{nullptr}; Window& window; @@ -66,6 +82,8 @@ private: Display* display{nullptr}; int screen{0}; + int depth{0}; + Visual* visual{nullptr}; Atom wmDeleteMessage{0}; }; -- cgit v1.2.3