From f452b4a47b3bebf883e84df804e8d54830ccfe83 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 2 Dec 2014 14:47:45 -0500 Subject: [PATCH 1/3] glx: Dynamically compute attribute slot in GetDrawableAttributes No functional change. Reviewed-by: Eric Anholt Signed-off-by: Adam Jackson --- glx/glxcmds.c | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index e836af8d5..4de86439e 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1918,42 +1918,43 @@ DoGetDrawableAttributes(__GLXclientState * cl, XID drawId) xGLXGetDrawableAttributesReply reply; __GLXdrawable *pGlxDraw; CARD32 attributes[14]; - int numAttribs = 0, error; + int num = 0, error; if (!validGlxDrawable(client, drawId, GLX_DRAWABLE_ANY, DixGetAttrAccess, &pGlxDraw, &error)) return error; - attributes[0] = GLX_TEXTURE_TARGET_EXT; - attributes[1] = pGlxDraw->target == GL_TEXTURE_2D ? GLX_TEXTURE_2D_EXT : + attributes[2*num] = GLX_TEXTURE_TARGET_EXT; + attributes[2*num+1] = pGlxDraw->target == GL_TEXTURE_2D ? + GLX_TEXTURE_2D_EXT : GLX_TEXTURE_RECTANGLE_EXT; - numAttribs++; - attributes[2] = GLX_Y_INVERTED_EXT; - attributes[3] = GL_FALSE; - numAttribs++; - attributes[4] = GLX_EVENT_MASK; - attributes[5] = pGlxDraw->eventMask; - numAttribs++; - attributes[6] = GLX_WIDTH; - attributes[7] = pGlxDraw->pDraw->width; - numAttribs++; - attributes[8] = GLX_HEIGHT; - attributes[9] = pGlxDraw->pDraw->height; - numAttribs++; - attributes[10] = GLX_FBCONFIG_ID; - attributes[11] = pGlxDraw->config->fbconfigID; - numAttribs++; + num++; + attributes[2*num] = GLX_Y_INVERTED_EXT; + attributes[2*num+1] = GL_FALSE; + num++; + attributes[2*num] = GLX_EVENT_MASK; + attributes[2*num+1] = pGlxDraw->eventMask; + num++; + attributes[2*num] = GLX_WIDTH; + attributes[2*num+1] = pGlxDraw->pDraw->width; + num++; + attributes[2*num] = GLX_HEIGHT; + attributes[2*num+1] = pGlxDraw->pDraw->height; + num++; + attributes[2*num] = GLX_FBCONFIG_ID; + attributes[2*num+1] = pGlxDraw->config->fbconfigID; + num++; if (pGlxDraw->type == GLX_DRAWABLE_PBUFFER) { - attributes[12] = GLX_PRESERVED_CONTENTS; - attributes[13] = GL_TRUE; - numAttribs++; + attributes[2*num] = GLX_PRESERVED_CONTENTS; + attributes[2*num+1] = GL_TRUE; + num++; } reply = (xGLXGetDrawableAttributesReply) { .type = X_Reply, .sequenceNumber = client->sequence, - .length = numAttribs << 1, - .numAttribs = numAttribs + .length = num << 1, + .numAttribs = num }; if (client->swapped) { From cadd70c809232c9a6601fb8baab665a7ab10045d Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 2 Dec 2014 14:52:35 -0500 Subject: [PATCH 2/3] glx: Add hack for GLX-1.2-style naked windows to GetDrawableAttributes Some people like to call this on bare Window XIDs and expect reasonable results. I sure wish they wouldn't, but since they do, if we're given a window without any glx decoration just fill in as much as we can. This means you won't actually get an answer for GLX_FBCONFIG_ID and friends, but there's not much to be done about that, and it matches what NVIDIA's driver seems to do. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=54080 Reviewed-by: Eric Anholt Signed-off-by: Adam Jackson --- glx/glxcmds.c | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 4de86439e..f5f2babb8 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1916,38 +1916,48 @@ DoGetDrawableAttributes(__GLXclientState * cl, XID drawId) { ClientPtr client = cl->client; xGLXGetDrawableAttributesReply reply; - __GLXdrawable *pGlxDraw; + __GLXdrawable *pGlxDraw = NULL; + DrawablePtr pDraw; CARD32 attributes[14]; int num = 0, error; if (!validGlxDrawable(client, drawId, GLX_DRAWABLE_ANY, - DixGetAttrAccess, &pGlxDraw, &error)) - return error; + DixGetAttrAccess, &pGlxDraw, &error)) { + /* hack for GLX 1.2 naked windows */ + int err = dixLookupWindow((WindowPtr *)&pDraw, drawId, client, + DixGetAttrAccess); + if (err != Success) + return error; + } + if (pGlxDraw) + pDraw = pGlxDraw->pDraw; - attributes[2*num] = GLX_TEXTURE_TARGET_EXT; - attributes[2*num+1] = pGlxDraw->target == GL_TEXTURE_2D ? - GLX_TEXTURE_2D_EXT : - GLX_TEXTURE_RECTANGLE_EXT; - num++; attributes[2*num] = GLX_Y_INVERTED_EXT; attributes[2*num+1] = GL_FALSE; num++; - attributes[2*num] = GLX_EVENT_MASK; - attributes[2*num+1] = pGlxDraw->eventMask; - num++; attributes[2*num] = GLX_WIDTH; - attributes[2*num+1] = pGlxDraw->pDraw->width; + attributes[2*num+1] = pDraw->width; num++; attributes[2*num] = GLX_HEIGHT; - attributes[2*num+1] = pGlxDraw->pDraw->height; + attributes[2*num+1] = pDraw->height; num++; - attributes[2*num] = GLX_FBCONFIG_ID; - attributes[2*num+1] = pGlxDraw->config->fbconfigID; - num++; - if (pGlxDraw->type == GLX_DRAWABLE_PBUFFER) { - attributes[2*num] = GLX_PRESERVED_CONTENTS; - attributes[2*num+1] = GL_TRUE; + if (pGlxDraw) { + attributes[2*num] = GLX_TEXTURE_TARGET_EXT; + attributes[2*num+1] = pGlxDraw->target == GL_TEXTURE_2D ? + GLX_TEXTURE_2D_EXT : + GLX_TEXTURE_RECTANGLE_EXT; num++; + attributes[2*num] = GLX_EVENT_MASK; + attributes[2*num+1] = pGlxDraw->eventMask; + num++; + attributes[2*num] = GLX_FBCONFIG_ID; + attributes[2*num+1] = pGlxDraw->config->fbconfigID; + num++; + if (pGlxDraw->type == GLX_DRAWABLE_PBUFFER) { + attributes[2*num] = GLX_PRESERVED_CONTENTS; + attributes[2*num+1] = GL_TRUE; + num++; + } } reply = (xGLXGetDrawableAttributesReply) { From e774663fa5209ff469d920821934bb1f5964a72f Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Wed, 3 Dec 2014 11:30:29 -0500 Subject: [PATCH 3/3] ephyr: Implement per-screen colormaps Xephyr's pseudocolor emulation added in: commit 81a3b6fe27567b4f91033ece69996aa6bf8d01a3 Author: Matthew Allum Date: Mon Nov 8 22:39:47 2004 +0000 Add support to Xephyr for lower depths than hosts only tracks one global colormap for the whole (Xephyr) display. Move this to per-screen state so each screen's colormap can be correct. [ajax: rebased to 1.17, cleaned up commit message] Reviewed-by: Adam Jackson Reviewed-by: Eric Anholt Signed-off-by: Michele Baldessari --- hw/kdrive/ephyr/ephyr.c | 2 +- hw/kdrive/ephyr/ephyr.h | 1 + hw/kdrive/ephyr/hostx.c | 11 ++++++----- hw/kdrive/ephyr/hostx.h | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index 93a48a9cd..907bbebae 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -1292,7 +1292,7 @@ ephyrPutColors(ScreenPtr pScreen, int n, xColorItem * pdefs) if (p > max) max = p; - hostx_set_cmap_entry(p, + hostx_set_cmap_entry(pScreen, p, pdefs->red >> 8, pdefs->green >> 8, pdefs->blue >> 8); pdefs++; diff --git a/hw/kdrive/ephyr/ephyr.h b/hw/kdrive/ephyr/ephyr.h index 2395a7f7e..18bfe11ff 100644 --- a/hw/kdrive/ephyr/ephyr.h +++ b/hw/kdrive/ephyr/ephyr.h @@ -83,6 +83,7 @@ typedef struct _ephyrScrPriv { KdScreenInfo *screen; int mynum; /* Screen number */ + unsigned long cmap[256]; /** * Per-screen Xlib-using state for glamor (private to diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 8d6d5e83b..f64861b50 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -82,8 +82,6 @@ struct EphyrHostXVars { KdScreenInfo **screens; long damage_debug_msec; - - unsigned long cmap[256]; }; /* memset ( missing> ) instead of below */ @@ -751,9 +749,12 @@ hostx_calculate_color_shift(unsigned long mask) } void -hostx_set_cmap_entry(unsigned char idx, +hostx_set_cmap_entry(ScreenPtr pScreen, unsigned char idx, unsigned char r, unsigned char g, unsigned char b) { + KdScreenPriv(pScreen); + KdScreenInfo *screen = pScreenPriv->screen; + EphyrScrPriv *scrpriv = screen->driver; /* need to calculate the shifts for RGB because server could be BGR. */ /* XXX Not sure if this is correct for 8 on 16, but this works for 8 on 24.*/ static int rshift, bshift, gshift = 0; @@ -765,7 +766,7 @@ hostx_set_cmap_entry(unsigned char idx, gshift = hostx_calculate_color_shift(HostX.visual->green_mask); bshift = hostx_calculate_color_shift(HostX.visual->blue_mask); } - HostX.cmap[idx] = ((r << rshift) & HostX.visual->red_mask) | + scrpriv->cmap[idx] = ((r << rshift) & HostX.visual->red_mask) | ((g << gshift) & HostX.visual->green_mask) | ((b << bshift) & HostX.visual->blue_mask); } @@ -1017,7 +1018,7 @@ hostx_paint_rect(KdScreenInfo *screen, unsigned char pixel = *(unsigned char *) (scrpriv->fb_data + idx); xcb_image_put_pixel(scrpriv->ximg, x, y, - HostX.cmap[pixel]); + scrpriv->cmap[pixel]); break; } default: diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h index 87acd5a50..93aaa509c 100644 --- a/hw/kdrive/ephyr/hostx.h +++ b/hw/kdrive/ephyr/hostx.h @@ -141,7 +141,7 @@ hostx_get_visual_masks(KdScreenInfo *screen, CARD32 *rmsk, CARD32 *gmsk, CARD32 *bmsk); void -hostx_set_cmap_entry(unsigned char idx, +hostx_set_cmap_entry(ScreenPtr pScreen, unsigned char idx, unsigned char r, unsigned char g, unsigned char b); void *hostx_screen_init(KdScreenInfo *screen,