diff options
author | Olivier Fourdan <ofourdan@redhat.com> | 2019-12-17 17:07:58 +0100 |
---|---|---|
committer | Olivier Fourdan <ofourdan@redhat.com> | 2019-12-20 16:19:01 +0100 |
commit | d780bdc2fdaeb94b873a9b6dd05a3ab636840ce7 (patch) | |
tree | 0a6caaf70a66ed4303813c457fda3ad2579f9f64 /hw/xwayland | |
parent | 89e32d00f6e03fcdab267bfd9f0b0c5c2747d380 (diff) |
xwayland: Separate Xwayland pixmap code
Move Xwayland generic pixmap code to a separate source file and header.
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Diffstat (limited to 'hw/xwayland')
-rw-r--r-- | hw/xwayland/Makefile.am | 2 | ||||
-rw-r--r-- | hw/xwayland/meson.build | 2 | ||||
-rw-r--r-- | hw/xwayland/xwayland-glamor-eglstream.c | 1 | ||||
-rw-r--r-- | hw/xwayland/xwayland-glamor-gbm.c | 1 | ||||
-rw-r--r-- | hw/xwayland/xwayland-pixmap.c | 123 | ||||
-rw-r--r-- | hw/xwayland/xwayland-pixmap.h | 47 | ||||
-rw-r--r-- | hw/xwayland/xwayland-present.c | 1 | ||||
-rw-r--r-- | hw/xwayland/xwayland-shm.c | 3 | ||||
-rw-r--r-- | hw/xwayland/xwayland-window-buffers.c | 1 | ||||
-rw-r--r-- | hw/xwayland/xwayland.c | 79 | ||||
-rw-r--r-- | hw/xwayland/xwayland.h | 9 |
11 files changed, 184 insertions, 85 deletions
diff --git a/hw/xwayland/Makefile.am b/hw/xwayland/Makefile.am index 4abc4692a..f20973797 100644 --- a/hw/xwayland/Makefile.am +++ b/hw/xwayland/Makefile.am @@ -14,6 +14,8 @@ Xwayland_SOURCES = \ xwayland-input.c \ xwayland-cursor.c \ xwayland-glamor.h \ + xwayland-pixmap.c \ + xwayland-pixmap.h \ xwayland-shm.c \ xwayland-shm.h \ xwayland-types.h \ diff --git a/hw/xwayland/meson.build b/hw/xwayland/meson.build index 178f9166e..6cf502289 100644 --- a/hw/xwayland/meson.build +++ b/hw/xwayland/meson.build @@ -3,6 +3,8 @@ srcs = [ 'xwayland-input.c', 'xwayland-cursor.c', 'xwayland-glamor.h', + 'xwayland-pixmap.c', + 'xwayland-pixmap.h', 'xwayland-shm.c', 'xwayland-shm.h', 'xwayland-types.h', diff --git a/hw/xwayland/xwayland-glamor-eglstream.c b/hw/xwayland/xwayland-glamor-eglstream.c index b9d3bc45d..e052df29c 100644 --- a/hw/xwayland/xwayland-glamor-eglstream.c +++ b/hw/xwayland/xwayland-glamor-eglstream.c @@ -42,6 +42,7 @@ #include "xwayland.h" #include "xwayland-glamor.h" +#include "xwayland-pixmap.h" #include "wayland-eglstream-client-protocol.h" #include "wayland-eglstream-controller-client-protocol.h" diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c index e4718da52..6ed097fc2 100644 --- a/hw/xwayland/xwayland-glamor-gbm.c +++ b/hw/xwayland/xwayland-glamor-gbm.c @@ -48,6 +48,7 @@ #include "xwayland.h" #include "xwayland-glamor.h" +#include "xwayland-pixmap.h" #include "linux-dmabuf-unstable-v1-client-protocol.h" diff --git a/hw/xwayland/xwayland-pixmap.c b/hw/xwayland/xwayland-pixmap.c new file mode 100644 index 000000000..fef6fa4cf --- /dev/null +++ b/hw/xwayland/xwayland-pixmap.c @@ -0,0 +1,123 @@ +/* + * Copyright © 2014 Intel Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of the + * copyright holders not be used in advertising or publicity + * pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#include <xwayland-config.h> + +#include <X11/X.h> + +#include "os.h" +#include "privates.h" +#include "dix.h" +#include "fb.h" +#include "pixmapstr.h" + +#include "xwayland-types.h" +#include "xwayland-pixmap.h" +#include "xwayland-window-buffers.h" + +static DevPrivateKeyRec xwl_pixmap_private_key; +static DevPrivateKeyRec xwl_pixmap_cb_private_key; + +struct xwl_pixmap_buffer_release_callback { + xwl_pixmap_cb callback; + void *data; +}; + +void +xwl_pixmap_set_private(PixmapPtr pixmap, struct xwl_pixmap *xwl_pixmap) +{ + dixSetPrivate(&pixmap->devPrivates, &xwl_pixmap_private_key, xwl_pixmap); +} + +struct xwl_pixmap * +xwl_pixmap_get(PixmapPtr pixmap) +{ + return dixLookupPrivate(&pixmap->devPrivates, &xwl_pixmap_private_key); +} + +Bool +xwl_pixmap_set_buffer_release_cb(PixmapPtr pixmap, + xwl_pixmap_cb func, void *data) +{ + struct xwl_pixmap_buffer_release_callback *xwl_pixmap_buffer_release_callback; + + xwl_pixmap_buffer_release_callback = dixLookupPrivate(&pixmap->devPrivates, + &xwl_pixmap_cb_private_key); + + if (xwl_pixmap_buffer_release_callback == NULL) { + xwl_pixmap_buffer_release_callback = + calloc(1, sizeof (struct xwl_pixmap_buffer_release_callback)); + + if (xwl_pixmap_buffer_release_callback == NULL) { + ErrorF("Failed to allocate pixmap callback data\n"); + return FALSE; + } + dixSetPrivate(&pixmap->devPrivates, &xwl_pixmap_cb_private_key, + xwl_pixmap_buffer_release_callback); + } + + xwl_pixmap_buffer_release_callback->callback = func; + xwl_pixmap_buffer_release_callback->data = data; + + return TRUE; +} + +void +xwl_pixmap_del_buffer_release_cb(PixmapPtr pixmap) +{ + struct xwl_pixmap_buffer_release_callback *xwl_pixmap_buffer_release_callback; + + xwl_pixmap_buffer_release_callback = dixLookupPrivate(&pixmap->devPrivates, + &xwl_pixmap_cb_private_key); + if (xwl_pixmap_buffer_release_callback) { + dixSetPrivate(&pixmap->devPrivates, &xwl_pixmap_cb_private_key, NULL); + free(xwl_pixmap_buffer_release_callback); + } +} + +void +xwl_pixmap_buffer_release_cb(void *data, struct wl_buffer *wl_buffer) +{ + PixmapPtr pixmap = data; + struct xwl_pixmap_buffer_release_callback *xwl_pixmap_buffer_release_callback; + + xwl_pixmap_buffer_release_callback = dixLookupPrivate(&pixmap->devPrivates, + &xwl_pixmap_cb_private_key); + if (xwl_pixmap_buffer_release_callback) + (*xwl_pixmap_buffer_release_callback->callback) + (pixmap, xwl_pixmap_buffer_release_callback->data); +} + +Bool +xwl_pixmap_init(void) +{ + if (!dixRegisterPrivateKey(&xwl_pixmap_private_key, PRIVATE_PIXMAP, 0)) + return FALSE; + + if (!dixRegisterPrivateKey(&xwl_pixmap_cb_private_key, PRIVATE_PIXMAP, 0)) + return FALSE; + + return TRUE; +} diff --git a/hw/xwayland/xwayland-pixmap.h b/hw/xwayland/xwayland-pixmap.h new file mode 100644 index 000000000..9b926b507 --- /dev/null +++ b/hw/xwayland/xwayland-pixmap.h @@ -0,0 +1,47 @@ +/* + * Copyright © 2014 Intel Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of the + * copyright holders not be used in advertising or publicity + * pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifndef XWAYLAND_PIXMAP_H +#define XWAYLAND_PIXMAP_H + +#include <xwayland-config.h> +#include <wayland-client.h> + +#include "pixmapstr.h" + +/* This is an opaque structure implemented in the different backends */ +struct xwl_pixmap; + +typedef void (*xwl_pixmap_cb) (PixmapPtr pixmap, void *data); + +void xwl_pixmap_set_private(PixmapPtr pixmap, struct xwl_pixmap *xwl_pixmap); +struct xwl_pixmap *xwl_pixmap_get(PixmapPtr pixmap); +Bool xwl_pixmap_set_buffer_release_cb(PixmapPtr pixmap, + xwl_pixmap_cb func, void *data); +void xwl_pixmap_del_buffer_release_cb(PixmapPtr pixmap); +void xwl_pixmap_buffer_release_cb(void *data, struct wl_buffer *wl_buffer); +Bool xwl_pixmap_init(void); + +#endif /* XWAYLAND_PIXMAP_H */ diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c index 1397b4ba4..c766ce19b 100644 --- a/hw/xwayland/xwayland-present.c +++ b/hw/xwayland/xwayland-present.c @@ -32,6 +32,7 @@ #include "xwayland.h" #include "xwayland-window.h" +#include "xwayland-pixmap.h" #include "glamor.h" /* diff --git a/hw/xwayland/xwayland-shm.c b/hw/xwayland/xwayland-shm.c index 586874b90..995bf64f8 100644 --- a/hw/xwayland/xwayland-shm.c +++ b/hw/xwayland/xwayland-shm.c @@ -26,6 +26,8 @@ #include <xwayland-config.h> +#include "os.h" + #include <sys/mman.h> #include <sys/types.h> #include <unistd.h> @@ -39,6 +41,7 @@ #include "pixmapstr.h" #include "xwayland.h" +#include "xwayland-pixmap.h" #include "xwayland-shm.h" struct xwl_pixmap { diff --git a/hw/xwayland/xwayland-window-buffers.c b/hw/xwayland/xwayland-window-buffers.c index 43c887a82..6d0eac96e 100644 --- a/hw/xwayland/xwayland-window-buffers.c +++ b/hw/xwayland/xwayland-window-buffers.c @@ -29,6 +29,7 @@ #include "gcstruct.h" #include "xwayland-window.h" +#include "xwayland-pixmap.h" #include "xwayland-window-buffers.h" #define BUFFER_TIMEOUT 1 * 1000 /* ms */ diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c index b8f6b4c16..5476e3c7d 100644 --- a/hw/xwayland/xwayland.c +++ b/hw/xwayland/xwayland.c @@ -38,9 +38,10 @@ #include "xwayland.h" #include "xwayland-glamor.h" +#include "xwayland-pixmap.h" #include "xwayland-shm.h" -#include "xwayland-window.h" #include "xwayland-window-buffers.h" +#include "xwayland-window.h" #ifdef XF86VIDMODE #include <X11/extensions/xf86vmproto.h> @@ -171,8 +172,6 @@ ddxProcessArgument(int argc, char *argv[], int i) static DevPrivateKeyRec xwl_client_private_key; static DevPrivateKeyRec xwl_screen_private_key; -static DevPrivateKeyRec xwl_pixmap_private_key; -static DevPrivateKeyRec xwl_pixmap_cb_private_key; struct xwl_client * xwl_client_get(ClientPtr client) @@ -242,64 +241,6 @@ xwl_property_callback(CallbackListPtr *pcbl, void *closure, xwl_window_update_property(xwl_window, rec); } -struct xwl_pixmap_buffer_release_cb { - xwl_pixmap_cb callback; - void *data; -}; - -Bool -xwl_pixmap_set_buffer_release_cb(PixmapPtr pixmap, - xwl_pixmap_cb func, void *data) -{ - struct xwl_pixmap_buffer_release_cb *xwl_pixmap_buffer_release_cb; - - xwl_pixmap_buffer_release_cb = dixLookupPrivate(&pixmap->devPrivates, - &xwl_pixmap_cb_private_key); - - if (xwl_pixmap_buffer_release_cb == NULL) { - xwl_pixmap_buffer_release_cb = - calloc(1, sizeof (struct xwl_pixmap_buffer_release_cb)); - - if (xwl_pixmap_buffer_release_cb == NULL) { - ErrorF("Failed to allocate pixmap callback data\n"); - return FALSE; - } - dixSetPrivate(&pixmap->devPrivates, &xwl_pixmap_cb_private_key, - xwl_pixmap_buffer_release_cb); - } - - xwl_pixmap_buffer_release_cb->callback = func; - xwl_pixmap_buffer_release_cb->data = data; - - return TRUE; -} - -void -xwl_pixmap_del_buffer_release_cb(PixmapPtr pixmap) -{ - struct xwl_pixmap_buffer_release_cb *xwl_pixmap_buffer_release_cb; - - xwl_pixmap_buffer_release_cb = dixLookupPrivate(&pixmap->devPrivates, - &xwl_pixmap_cb_private_key); - if (xwl_pixmap_buffer_release_cb) { - dixSetPrivate(&pixmap->devPrivates, &xwl_pixmap_cb_private_key, NULL); - free(xwl_pixmap_buffer_release_cb); - } -} - -void -xwl_pixmap_buffer_release_cb(void *data, struct wl_buffer *wl_buffer) -{ - PixmapPtr pixmap = data; - struct xwl_pixmap_buffer_release_cb *xwl_pixmap_buffer_release_cb; - - xwl_pixmap_buffer_release_cb = dixLookupPrivate(&pixmap->devPrivates, - &xwl_pixmap_cb_private_key); - if (xwl_pixmap_buffer_release_cb) - (*xwl_pixmap_buffer_release_cb->callback) - (pixmap, xwl_pixmap_buffer_release_cb->data); -} - static Bool xwl_close_screen(ScreenPtr screen) { @@ -423,18 +364,6 @@ xwl_cursor_confined_to(DeviceIntPtr device, } void -xwl_pixmap_set_private(PixmapPtr pixmap, struct xwl_pixmap *xwl_pixmap) -{ - dixSetPrivate(&pixmap->devPrivates, &xwl_pixmap_private_key, xwl_pixmap); -} - -struct xwl_pixmap * -xwl_pixmap_get(PixmapPtr pixmap) -{ - return dixLookupPrivate(&pixmap->devPrivates, &xwl_pixmap_private_key); -} - -void xwl_screen_check_resolution_change_emulation(struct xwl_screen *xwl_screen) { struct xwl_window *xwl_window; @@ -679,9 +608,7 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv) if (!dixRegisterPrivateKey(&xwl_screen_private_key, PRIVATE_SCREEN, 0)) return FALSE; - if (!dixRegisterPrivateKey(&xwl_pixmap_private_key, PRIVATE_PIXMAP, 0)) - return FALSE; - if (!dixRegisterPrivateKey(&xwl_pixmap_cb_private_key, PRIVATE_PIXMAP, 0)) + if (!xwl_pixmap_init()) return FALSE; if (!xwl_window_init()) return FALSE; diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h index 5b802c0fd..60cb1b622 100644 --- a/hw/xwayland/xwayland.h +++ b/hw/xwayland/xwayland.h @@ -59,8 +59,6 @@ struct xwl_format { uint64_t *modifiers; }; -typedef void (*xwl_pixmap_cb) (PixmapPtr pixmap, void *data); - struct xwl_screen { int width; int height; @@ -386,13 +384,6 @@ void xwl_output_set_window_randr_emu_props(struct xwl_screen *xwl_screen, RRModePtr xwayland_cvt(int HDisplay, int VDisplay, float VRefresh, Bool Reduced, Bool Interlaced); -void xwl_pixmap_set_private(PixmapPtr pixmap, struct xwl_pixmap *xwl_pixmap); -struct xwl_pixmap *xwl_pixmap_get(PixmapPtr pixmap); -Bool xwl_pixmap_set_buffer_release_cb(PixmapPtr pixmap, - xwl_pixmap_cb func, void *data); -void xwl_pixmap_del_buffer_release_cb(PixmapPtr pixmap); -void xwl_pixmap_buffer_release_cb(void *data, struct wl_buffer *wl_buffer); - #ifdef XWL_HAS_GLAMOR #ifdef GLAMOR_HAS_GBM |