From ea9c39e2f7b3c91fcf29b5400e41abd527ce5227 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Tue, 25 Aug 2009 16:21:09 +0000 Subject: [PATCH] masks should be correctly rotated in the xcb engine, now remove a few unused parameters and unused variables SVN revision: 41975 --- .../engines/software_x11/evas_engine.c | 4 +- .../engines/software_x11/evas_xcb_buffer.c | 176 ++++++++++++++++++ .../engines/software_x11/evas_xcb_buffer.h | 17 ++ .../engines/software_x11/evas_xcb_outbuf.c | 129 +++++++++---- .../engines/software_x11/evas_xlib_outbuf.c | 2 +- 5 files changed, 293 insertions(+), 35 deletions(-) diff --git a/legacy/evas/src/modules/engines/software_x11/evas_engine.c b/legacy/evas/src/modules/engines/software_x11/evas_engine.c index 79832f75b5..2559d39337 100644 --- a/legacy/evas/src/modules/engines/software_x11/evas_engine.c +++ b/legacy/evas/src/modules/engines/software_x11/evas_engine.c @@ -628,7 +628,7 @@ eng_output_idle_flush(void *data) } static Eina_Bool -eng_canvas_alpha_get(void *data, void *context) +eng_canvas_alpha_get(void *data, void *context __UNUSED__) { Render_Engine *re; @@ -667,7 +667,7 @@ module_open(Evas_Module *em) } static void -module_close(Evas_Module *em) +module_close(Evas_Module *em __UNUSED__) { } diff --git a/legacy/evas/src/modules/engines/software_x11/evas_xcb_buffer.c b/legacy/evas/src/modules/engines/software_x11/evas_xcb_buffer.c index f852479f8d..b091d14610 100644 --- a/legacy/evas/src/modules/engines/software_x11/evas_xcb_buffer.c +++ b/legacy/evas/src/modules/engines/software_x11/evas_xcb_buffer.c @@ -62,6 +62,182 @@ evas_software_xcb_x_write_mask_line(Outbuf *buf, } } +void +evas_software_xcb_x_write_mask_line_rev(Outbuf *buf, + Xcb_Output_Buffer *xcbob, + DATA32 *src, + int w, + int y) +{ + int x; + DATA32 *src_ptr; + DATA8 *dst_ptr; + int bpl = 0; + + src_ptr = src + w - 1; + dst_ptr = evas_software_xcb_x_output_buffer_data(xcbob, &bpl); + dst_ptr = dst_ptr + (bpl * y); + w -= 7; + if (buf->priv.x11.xcb.bit_swap) + { + for (x = 0; x < w; x += 8) + { + *dst_ptr = + ((A_VAL(&(src_ptr[ 0])) >> 7) << 7) | + ((A_VAL(&(src_ptr[-1])) >> 7) << 6) | + ((A_VAL(&(src_ptr[-2])) >> 7) << 5) | + ((A_VAL(&(src_ptr[-3])) >> 7) << 4) | + ((A_VAL(&(src_ptr[-4])) >> 7) << 3) | + ((A_VAL(&(src_ptr[-5])) >> 7) << 2) | + ((A_VAL(&(src_ptr[-6])) >> 7) << 1) | + ((A_VAL(&(src_ptr[-7])) >> 7) << 0); + src_ptr -= 8; + dst_ptr++; + } + } + else + { + for (x = 0; x < w; x += 8) + { + *dst_ptr = + ((A_VAL(&(src_ptr[ 0])) >> 7) << 0) | + ((A_VAL(&(src_ptr[-1])) >> 7) << 1) | + ((A_VAL(&(src_ptr[-2])) >> 7) << 2) | + ((A_VAL(&(src_ptr[-3])) >> 7) << 3) | + ((A_VAL(&(src_ptr[-4])) >> 7) << 4) | + ((A_VAL(&(src_ptr[-5])) >> 7) << 5) | + ((A_VAL(&(src_ptr[-6])) >> 7) << 6) | + ((A_VAL(&(src_ptr[-7])) >> 7) << 7); + src_ptr -= 8; + dst_ptr++; + } + } + w += 7; + for (; x < w; x ++) + { + xcb_image_put_pixel(xcbob->image, x, y, A_VAL(src_ptr) >> 7); + src_ptr--; + } +} + +void +evas_software_xcb_x_write_mask_line_vert(Outbuf *buf, + Xcb_Output_Buffer *xcbob, + DATA32 *src, + int h, + int ym, + int w) +{ + int y; + DATA32 *src_ptr; + DATA8 *dst_ptr; + int bpl = 0; + + src_ptr = src; + dst_ptr = evas_software_xcb_x_output_buffer_data(xcbob, &bpl); + dst_ptr = dst_ptr + (bpl * ym); + h -= 7; + if (buf->priv.x11.xcb.bit_swap) + { + for (y = 0; y < h; y += 8) + { + *dst_ptr = + ((A_VAL(&(src_ptr[0 * w])) >> 7) << 7) | + ((A_VAL(&(src_ptr[1 * w])) >> 7) << 6) | + ((A_VAL(&(src_ptr[2 * w])) >> 7) << 5) | + ((A_VAL(&(src_ptr[3 * w])) >> 7) << 4) | + ((A_VAL(&(src_ptr[4 * w])) >> 7) << 3) | + ((A_VAL(&(src_ptr[5 * w])) >> 7) << 2) | + ((A_VAL(&(src_ptr[6 * w])) >> 7) << 1) | + ((A_VAL(&(src_ptr[7 * w])) >> 7) << 0); + src_ptr += 8 * w; + dst_ptr++; + } + } + else + { + for (y = 0; y < h; y += 8) + { + *dst_ptr = + ((A_VAL(&(src_ptr[0 * w])) >> 7) << 0) | + ((A_VAL(&(src_ptr[1 * w])) >> 7) << 1) | + ((A_VAL(&(src_ptr[2 * w])) >> 7) << 2) | + ((A_VAL(&(src_ptr[3 * w])) >> 7) << 3) | + ((A_VAL(&(src_ptr[4 * w])) >> 7) << 4) | + ((A_VAL(&(src_ptr[5 * w])) >> 7) << 5) | + ((A_VAL(&(src_ptr[6 * w])) >> 7) << 6) | + ((A_VAL(&(src_ptr[7 * w])) >> 7) << 7); + src_ptr += 8 * w; + dst_ptr++; + } + } + h += 7; + for (; y < h; y ++) + { + xcb_image_put_pixel(xcbob->image, y, ym, A_VAL(src_ptr) >> 7); + src_ptr += w; + } +} + +void +evas_software_xcb_x_write_mask_line_vert_rev(Outbuf *buf, + Xcb_Output_Buffer *xcbob, + DATA32 *src, + int h, + int ym, + int w) +{ + int y; + DATA32 *src_ptr; + DATA8 *dst_ptr; + int bpl = 0; + + src_ptr = src + ((h - 1) * w); + dst_ptr = evas_software_xcb_x_output_buffer_data(xcbob, &bpl); + dst_ptr = dst_ptr + (bpl * ym); + h -= 7; + if (buf->priv.x11.xcb.bit_swap) + { + for (y = 0; y < h; y += 8) + { + *dst_ptr = + ((A_VAL(&(src_ptr[ 0 * w])) >> 7) << 7) | + ((A_VAL(&(src_ptr[-1 * w])) >> 7) << 6) | + ((A_VAL(&(src_ptr[-2 * w])) >> 7) << 5) | + ((A_VAL(&(src_ptr[-3 * w])) >> 7) << 4) | + ((A_VAL(&(src_ptr[-4 * w])) >> 7) << 3) | + ((A_VAL(&(src_ptr[-5 * w])) >> 7) << 2) | + ((A_VAL(&(src_ptr[-6 * w])) >> 7) << 1) | + ((A_VAL(&(src_ptr[-7 * w])) >> 7) << 0); + src_ptr -= 8 * w; + dst_ptr++; + } + } + else + { + for (y = 0; y < h; y += 8) + { + *dst_ptr = + ((A_VAL(&(src_ptr[ 0 * w])) >> 7) << 0) | + ((A_VAL(&(src_ptr[-1 * w])) >> 7) << 1) | + ((A_VAL(&(src_ptr[-2 * w])) >> 7) << 2) | + ((A_VAL(&(src_ptr[-3 * w])) >> 7) << 3) | + ((A_VAL(&(src_ptr[-4 * w])) >> 7) << 4) | + ((A_VAL(&(src_ptr[-5 * w])) >> 7) << 5) | + ((A_VAL(&(src_ptr[-6 * w])) >> 7) << 6) | + ((A_VAL(&(src_ptr[-7 * w])) >> 7) << 7); + src_ptr -= 8 * w; + dst_ptr++; + } + } + h += 7; + for (; y < h; y ++) + { + xcb_image_put_pixel(xcbob->image, y, ym, A_VAL(src_ptr) >> 7); + src_ptr -= w; + } +} + int evas_software_xcb_x_can_do_shm(xcb_connection_t *c, xcb_screen_t *screen) diff --git a/legacy/evas/src/modules/engines/software_x11/evas_xcb_buffer.h b/legacy/evas/src/modules/engines/software_x11/evas_xcb_buffer.h index f68d1dbcfa..f9582c86c7 100644 --- a/legacy/evas/src/modules/engines/software_x11/evas_xcb_buffer.h +++ b/legacy/evas/src/modules/engines/software_x11/evas_xcb_buffer.h @@ -24,6 +24,23 @@ void evas_software_xcb_x_write_mask_line (Outbuf DATA32 *src, int w, int y); +void evas_software_xcb_x_write_mask_line_rev (Outbuf *buf, + Xcb_Output_Buffer *xcbob, + DATA32 *src, + int w, + int y); +void evas_software_xcb_x_write_mask_line_vert (Outbuf *buf, + Xcb_Output_Buffer *xcbob, + DATA32 *src, + int h, + int ym, + int w); +void evas_software_xcb_x_write_mask_line_vert_rev(Outbuf *buf, + Xcb_Output_Buffer *xcbob, + DATA32 *src, + int h, + int ym, + int w); int evas_software_xcb_x_can_do_shm (xcb_connection_t *c, xcb_screen_t *screen); Xcb_Output_Buffer *evas_software_xcb_x_output_buffer_new (xcb_connection_t *c, diff --git a/legacy/evas/src/modules/engines/software_x11/evas_xcb_outbuf.c b/legacy/evas/src/modules/engines/software_x11/evas_xcb_outbuf.c index ad70b39698..3b0dba9448 100644 --- a/legacy/evas/src/modules/engines/software_x11/evas_xcb_outbuf.c +++ b/legacy/evas/src/modules/engines/software_x11/evas_xcb_outbuf.c @@ -32,7 +32,7 @@ static Xcb_Output_Buffer * _find_xcbob(xcb_connection_t *conn, int depth, int w, int h, int shm, void *data) { Eina_List *l; - Eina_List *xl; + Eina_List *xl = NULL; Xcb_Output_Buffer *xcbob = NULL; Xcb_Output_Buffer *xcbob2; int fitness = 0x7fffffff; @@ -458,23 +458,36 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, evas_cache_image_surface_alloc(&im->cache_entry, buf->w, buf->h); im->extended_info = obr; if ((buf->rot == 0) || (buf->rot == 180)) - obr->xcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x11.xcb.conn, - buf->priv.x11.xcb.depth, - buf->w, buf->h, - use_shm, - NULL); + { + obr->xcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x11.xcb.conn, + buf->priv.x11.xcb.depth, + buf->w, buf->h, + use_shm, + NULL); + if (buf->priv.x11.xcb.mask) + obr->mxcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x11.xcb.conn, + buf->priv.x11.xcb.depth, + buf->w, buf->h, + use_shm, + NULL); + } else if ((buf->rot == 90) || (buf->rot == 270)) - obr->xcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x11.xcb.conn, - buf->priv.x11.xcb.depth, - buf->h, buf->w, - use_shm, - NULL); - if (buf->priv.x11.xcb.mask) - obr->mxcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x11.xcb.conn, - 1, buf->w, buf->h, - use_shm, - NULL); + { + obr->xcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x11.xcb.conn, + buf->priv.x11.xcb.depth, + buf->h, buf->w, + use_shm, + NULL); + if (buf->priv.x11.xcb.mask) + obr->mxcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x11.xcb.conn, + buf->priv.x11.xcb.depth, + buf->h, buf->w, + use_shm, + NULL); + } } + /* FIXME: We should be able to remove this memset, but somewhere in the process + we copy too much to the destination surface and some area are not cleaned before copy. */ if (alpha) /* FIXME: faster memset! */ memset(im->image.data, 0, w * h * sizeof(DATA32)); @@ -520,7 +533,8 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, im->extended_info = obr; if (buf->priv.x11.xcb.mask) obr->mxcbob = _find_xcbob(buf->priv.x11.xcb.conn, - 1, w, h, + buf->priv.x11.xcb.depth, + w, h, use_shm, NULL); /* obr->mxcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x11.xcb.conn, */ @@ -537,11 +551,19 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, evas_cache_image_surface_alloc(&im->cache_entry, w, h); im->extended_info = obr; if ((buf->rot == 0) || (buf->rot == 180)) - obr->xcbob = _find_xcbob(buf->priv.x11.xcb.conn, - buf->priv.x11.xcb.depth, - w, h, - use_shm, - NULL); + { + obr->xcbob = _find_xcbob(buf->priv.x11.xcb.conn, + buf->priv.x11.xcb.depth, + w, h, + use_shm, + NULL); + if (buf->priv.x11.xcb.mask) + obr->mxcbob = _find_xcbob(buf->priv.x11.xcb.conn, + buf->priv.x11.xcb.depth, + w, h, + use_shm, + NULL); + } /* obr->xcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x11.xcb.conn, */ /* buf->priv.x11.xcb.depth, */ /* w, */ @@ -549,22 +571,32 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, /* use_shm, */ /* NULL); */ else if ((buf->rot == 90) || (buf->rot == 270)) - obr->xcbob = _find_xcbob(buf->priv.x11.xcb.conn, - buf->priv.x11.xcb.depth, - h, w, - use_shm, - NULL); + { + obr->xcbob = _find_xcbob(buf->priv.x11.xcb.conn, + buf->priv.x11.xcb.depth, + h, w, + use_shm, + NULL); + if (buf->priv.x11.xcb.mask) + obr->mxcbob = _find_xcbob(buf->priv.x11.xcb.conn, + buf->priv.x11.xcb.depth, + h, w, + use_shm, + NULL); + } /* obr->xcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x11.xcb.conn, */ /* buf->priv.x11.xcb.depth, */ /* h, */ /* w, */ /* use_shm, */ /* NULL); */ +/* if (buf->priv.x11.xcb.mask) obr->mxcbob = _find_xcbob(buf->priv.x11.xcb.conn, 1, w, h, use_shm, NULL); +*/ /* obr->mxcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x11.xcb.conn, */ /* 1, */ /* w, */ @@ -572,6 +604,8 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, /* use_shm, */ /* NULL); */ } + /* FIXME: We should be able to remove this memset, but somewhere in the process + we copy too much to the destination surface and some area are not cleaned before copy. */ if ((buf->priv.x11.xcb.mask) || (buf->priv.destination_alpha)) /* FIXME: faster memset! */ memset(im->image.data, 0, w * h * sizeof(DATA32)); @@ -874,11 +908,42 @@ evas_software_xcb_outbuf_push_updated_region(Outbuf *buf, #endif if (obr->mxcbob) { - for (yy = 0; yy < obr->h; yy++) - evas_software_xcb_x_write_mask_line(buf, obr->mxcbob, - src_data + (yy * obr->w), - obr->w, - yy); + if (buf->rot == 0) + { + for (yy = 0; yy < obr->h; yy++) + evas_software_xcb_x_write_mask_line(buf, obr->mxcbob, + src_data + (yy * obr->w), + obr->w, + yy); + } + else if (buf->rot == 90) + { + for (yy = 0; yy < obr->h; yy++) + evas_software_xcb_x_write_mask_line_vert(buf, obr->mxcbob, + src_data + yy, + h, // h + obr->h - yy - 1, // ym + w); // w + } + else if (buf->rot == 180) + { + for (yy = 0; yy < obr->h; yy++) + { + evas_software_xcb_x_write_mask_line_rev(buf, obr->mxcbob, + src_data + (yy * obr->w), + obr->w, + obr->h - yy - 1); + } + } + else if (buf->rot == 270) + { + for (yy = 0; yy < obr->h; yy++) + evas_software_xcb_x_write_mask_line_vert_rev(buf, obr->mxcbob, + src_data + yy, + h, // h + yy, // ym + w); // w + } #if 1 #else /* XX async push */ diff --git a/legacy/evas/src/modules/engines/software_x11/evas_xlib_outbuf.c b/legacy/evas/src/modules/engines/software_x11/evas_xlib_outbuf.c index 6e4201e843..6e1ac92e56 100644 --- a/legacy/evas/src/modules/engines/software_x11/evas_xlib_outbuf.c +++ b/legacy/evas/src/modules/engines/software_x11/evas_xlib_outbuf.c @@ -761,7 +761,7 @@ evas_software_xlib_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, i Outbuf_Region *obr; DATA32 *src_data; void *data; - int bpl = 0, xx, yy; + int bpl = 0, yy; obr = update->extended_info; if (buf->priv.pal)