This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 7a70f93fbae16a2ff97c983e8c32968efabdaa0a (commit) from de060ec35891593790612d5492f50c29c63b6248 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/7a70f93fbae16a2ff97c983e8c32968efabda...
commit 7a70f93fbae16a2ff97c983e8c32968efabdaa0a Author: Cyril Hrubis metan@ucw.cz Date: Fri May 3 15:31:29 2013 +0200
backends: X11: Fix XImage pixel matching.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c index 0ef7512..79b65c6 100644 --- a/libs/backends/GP_X11.c +++ b/libs/backends/GP_X11.c @@ -264,30 +264,12 @@ static int x11_resize_ack(struct GP_Backend *self) return ret; }
-static void match_pixel_type(struct x11_win *win, - enum GP_PixelType *pixel_type, int *depth) -{ - /* - * Eh, the XImage supports either 8, 16 or 32 bit pixels - * - * Do best effor on selecting appropriate pixel type - */ - for (*depth = 8; *depth <= 32; *depth<<=1) { - *pixel_type = GP_PixelRGBMatch(win->vis->red_mask, - win->vis->green_mask, - win->vis->blue_mask, - 0x0, *depth); - - if (*pixel_type != GP_PIXEL_UNKNOWN) - break; - } -} - #ifdef HAVE_X_SHM
static int create_shm_ximage(GP_Backend *self, GP_Size w, GP_Size h) { struct x11_win *win = GP_BACKEND_PRIV(self); + enum GP_PixelType pixel_type;
if (XShmQueryExtension(win->dpy) == False) { GP_DEBUG(1, "MIT SHM Extension not supported, " @@ -298,18 +280,6 @@ static int create_shm_ximage(GP_Backend *self, GP_Size w, GP_Size h) if (self->context == NULL) GP_DEBUG(1, "Using MIT SHM Extension");
- enum GP_PixelType pixel_type; - int depth; - - if (self->context == NULL) - match_pixel_type(win, &pixel_type, &depth); - else - pixel_type = self->context->pixel_type; - - if (pixel_type == GP_PIXEL_UNKNOWN) { - GP_DEBUG(1, "Unknown pixel type"); - return 1; - }
win->img = XShmCreateImage(win->dpy, win->vis, win->scr_depth, ZPixmap, NULL, &win->shminfo, w, h); @@ -321,6 +291,16 @@ static int create_shm_ximage(GP_Backend *self, GP_Size w, GP_Size h) size_t size = win->img->bytes_per_line * win->img->height;
+ pixel_type = GP_PixelRGBMatch(win->img->red_mask, + win->img->green_mask, + win->img->blue_mask, + 0x0, win->img->bits_per_pixel); + + if (pixel_type == GP_PIXEL_UNKNOWN) { + GP_DEBUG(1, "Unknown pixel type"); + goto err0; + } + win->shminfo.shmid = shmget(IPC_PRIVATE, size, 0600);
if (win->shminfo.shmid == -1) { @@ -430,25 +410,46 @@ static int create_ximage(GP_Backend *self, GP_Size w, GP_Size h) enum GP_PixelType pixel_type; int depth;
- match_pixel_type(win, &pixel_type, &depth); - - if (pixel_type == GP_PIXEL_UNKNOWN) { - GP_DEBUG(1, "Unknown pixel type"); - return 1; + /* Get depth similiar to the default visual depth */ + switch (win->scr_depth) { + case 32: + case 24: + depth = 32; + case 16: + depth = 16; + case 8: + depth = 8; + default: + /* TODO: better default */ + depth = 32; }
- self->context = GP_ContextAlloc(w, h, pixel_type); - - if (self->context == NULL) - return 1; + GP_DEBUG(1, "Screen depth %i, using XImage depth %i", + win->scr_depth, depth);
win->img = XCreateImage(win->dpy, win->vis, win->scr_depth, ZPixmap, 0, NULL, w, h, depth, 0);
if (win->img == NULL) { GP_DEBUG(1, "Failed to create XImage"); - GP_ContextFree(self->context); - return 1; + goto err0; + } + + pixel_type = GP_PixelRGBMatch(win->img->red_mask, + win->img->green_mask, + win->img->blue_mask, + 0x0, win->img->bits_per_pixel); + + if (pixel_type == GP_PIXEL_UNKNOWN) { + GP_DEBUG(1, "Unknown pixel type"); + goto err1; + } + + self->context = GP_ContextAlloc(w, h, pixel_type); + + if (self->context == NULL) { + GP_DEBUG(1, "Malloc failed :("); + goto err1; }
win->shm_flag = 0; @@ -456,6 +457,10 @@ static int create_ximage(GP_Backend *self, GP_Size w, GP_Size h) win->img->data = (char*)self->context->pixels; return 0; +err1: + XDestroyImage(win->img); +err0: + return 1; }
static void destroy_ximage(GP_Backend *self)
-----------------------------------------------------------------------
Summary of changes: libs/backends/GP_X11.c | 89 +++++++++++++++++++++++++---------------------- 1 files changed, 47 insertions(+), 42 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.