|
|
d64d53 |
From c6da90b55546748d3f4a2f536f94751da3abcd77 Mon Sep 17 00:00:00 2001
|
|
|
70130e |
From: Daniel Stone <daniel@fooishbar.org>
|
|
|
70130e |
Date: Fri, 16 Aug 2013 13:51:08 +0100
|
|
|
d64d53 |
Subject: [PATCH 19/38] XWayland: Support 16bpp X surfaces in DRM/SHM
|
|
|
70130e |
|
|
|
70130e |
Properly look at the window's visual to determine which format we should
|
|
|
70130e |
use for allocation.
|
|
|
70130e |
|
|
|
70130e |
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|
|
|
70130e |
---
|
|
|
70130e |
hw/xfree86/xwayland/xwayland-drm.c | 12 ++++++++++--
|
|
|
70130e |
hw/xfree86/xwayland/xwayland.c | 38 +++++++++++++++++++++++++++++++-------
|
|
|
70130e |
2 files changed, 41 insertions(+), 9 deletions(-)
|
|
|
70130e |
|
|
|
70130e |
diff --git a/hw/xfree86/xwayland/xwayland-drm.c b/hw/xfree86/xwayland/xwayland-drm.c
|
|
|
70130e |
index 6e4c778..5250857 100644
|
|
|
70130e |
--- a/hw/xfree86/xwayland/xwayland-drm.c
|
|
|
70130e |
+++ b/hw/xfree86/xwayland/xwayland-drm.c
|
|
|
70130e |
@@ -225,10 +225,18 @@ xwl_create_window_buffer_drm(struct xwl_window *xwl_window,
|
|
|
70130e |
if (screen->visuals[i].vid == visual)
|
|
|
70130e |
break;
|
|
|
70130e |
|
|
|
70130e |
- if (screen->visuals[i].nplanes == 32)
|
|
|
70130e |
+ switch (screen->visuals[i].nplanes) {
|
|
|
70130e |
+ case 32:
|
|
|
70130e |
format = WL_DRM_FORMAT_ARGB8888;
|
|
|
70130e |
- else
|
|
|
70130e |
+ break;
|
|
|
70130e |
+ case 24:
|
|
|
70130e |
+ default:
|
|
|
70130e |
format = WL_DRM_FORMAT_XRGB8888;
|
|
|
70130e |
+ break;
|
|
|
70130e |
+ case 16:
|
|
|
70130e |
+ format = WL_DRM_FORMAT_RGB565;
|
|
|
70130e |
+ break;
|
|
|
70130e |
+ }
|
|
|
70130e |
|
|
|
70130e |
xwl_window->buffer =
|
|
|
70130e |
wl_drm_create_buffer(xwl_window->xwl_screen->drm,
|
|
|
70130e |
diff --git a/hw/xfree86/xwayland/xwayland.c b/hw/xfree86/xwayland/xwayland.c
|
|
|
70130e |
index 6a515f5..36f7cbf 100644
|
|
|
70130e |
--- a/hw/xfree86/xwayland/xwayland.c
|
|
|
70130e |
+++ b/hw/xfree86/xwayland/xwayland.c
|
|
|
70130e |
@@ -277,19 +277,43 @@ xwl_create_window_buffer_shm(struct xwl_window *xwl_window,
|
|
|
70130e |
PixmapPtr pixmap, int fd)
|
|
|
70130e |
{
|
|
|
70130e |
struct wl_shm_pool *pool;
|
|
|
70130e |
- int size, stride;
|
|
|
70130e |
+ WindowPtr window = xwl_window->window;
|
|
|
70130e |
+ ScreenPtr screen = window->drawable.pScreen;
|
|
|
70130e |
+ VisualID visual = wVisual(window);
|
|
|
70130e |
+ uint32_t format;
|
|
|
70130e |
+ int size, stride, bpp, i;
|
|
|
70130e |
+
|
|
|
70130e |
+ for (i = 0; i < screen->numVisuals; i++)
|
|
|
70130e |
+ if (screen->visuals[i].vid == visual)
|
|
|
70130e |
+ break;
|
|
|
70130e |
+
|
|
|
70130e |
+ switch (screen->visuals[i].nplanes) {
|
|
|
70130e |
+ case 32:
|
|
|
70130e |
+ format = WL_SHM_FORMAT_ARGB8888;
|
|
|
70130e |
+ bpp = 4;
|
|
|
70130e |
+ break;
|
|
|
70130e |
+ case 24:
|
|
|
70130e |
+ default:
|
|
|
70130e |
+ format = WL_SHM_FORMAT_XRGB8888;
|
|
|
70130e |
+ bpp = 4;
|
|
|
70130e |
+ break;
|
|
|
70130e |
+#ifdef WL_SHM_FORMAT_RGB565
|
|
|
70130e |
+ case 16:
|
|
|
70130e |
+ /* XXX: Check run-time protocol version too */
|
|
|
70130e |
+ format = WL_SHM_FORMAT_RGB565;
|
|
|
70130e |
+ bpp = 2;
|
|
|
70130e |
+ break;
|
|
|
70130e |
+#endif
|
|
|
70130e |
+ }
|
|
|
70130e |
|
|
|
70130e |
- stride = pixmap->drawable.width * 4;
|
|
|
70130e |
+ stride = pixmap->drawable.width * bpp;
|
|
|
70130e |
+ size = stride * pixmap->drawable.height;
|
|
|
70130e |
|
|
|
70130e |
- size = pixmap->drawable.width * pixmap->drawable.height * 4;
|
|
|
70130e |
pool = wl_shm_create_pool(xwl_window->xwl_screen->shm, fd, size);
|
|
|
70130e |
xwl_window->buffer = wl_shm_pool_create_buffer(pool, 0,
|
|
|
70130e |
pixmap->drawable.width,
|
|
|
70130e |
pixmap->drawable.height,
|
|
|
70130e |
- stride,
|
|
|
70130e |
- pixmap->drawable.depth == 32 ?
|
|
|
70130e |
- WL_SHM_FORMAT_ARGB8888 :
|
|
|
70130e |
- WL_SHM_FORMAT_XRGB8888);
|
|
|
70130e |
+ stride, format);
|
|
|
70130e |
wl_shm_pool_destroy(pool);
|
|
|
70130e |
|
|
|
70130e |
return xwl_window->buffer ? Success : BadDrawable;
|
|
|
70130e |
--
|
|
|
d64d53 |
1.8.4.2
|
|
|
70130e |
|