Evas: Remove rectangle free's (no, it's not a leak) ;)

Add missing Asyn Push code (tho it's disabled anyway). 
Use shmget like xlib did and create with 0777 permissions.
Add a Sync call if try_shm == 2.
Add checks for frame_queuing & low libext version safety.




SVN revision: 61895
This commit is contained in:
Christopher Michael 2011-07-29 14:41:18 +00:00
parent c49d6b9916
commit b3469dd413
3 changed files with 69 additions and 37 deletions

View File

@ -234,7 +234,7 @@ evas_software_xcb_can_do_shm(xcb_connection_t *conn, xcb_screen_t *screen)
xcbob =
evas_software_xcb_output_buffer_new(conn, visual, screen->root_depth,
1, 1, EINA_TRUE, NULL);
16, 16, 2, NULL); // 1, 1 EINA_TRUE
if (!xcbob)
cached_result = 0;
else
@ -247,7 +247,7 @@ evas_software_xcb_can_do_shm(xcb_connection_t *conn, xcb_screen_t *screen)
}
Xcb_Output_Buffer *
evas_software_xcb_output_buffer_new(xcb_connection_t *conn, xcb_visualtype_t *vis, int depth, int w, int h, Eina_Bool try_shm, unsigned char *data)
evas_software_xcb_output_buffer_new(xcb_connection_t *conn, xcb_visualtype_t *vis, int depth, int w, int h, int try_shm, unsigned char *data)
{
Xcb_Output_Buffer *xcbob = NULL;
@ -262,7 +262,7 @@ evas_software_xcb_output_buffer_new(xcb_connection_t *conn, xcb_visualtype_t *vi
xcbob->h = h;
xcbob->data = data;
if (try_shm)
if (try_shm > 0)
{
xcbob->shm_info = malloc(sizeof(xcb_shm_segment_info_t));
if (xcbob->shm_info)
@ -273,8 +273,9 @@ evas_software_xcb_output_buffer_new(xcb_connection_t *conn, xcb_visualtype_t *vi
depth, NULL, ~0, NULL);
if (xcbob->xim)
{
/* was 0666 */
xcbob->shm_info->shmid =
shmget(IPC_PRIVATE, xcbob->xim->size, (IPC_CREAT | 0666));
shmget(IPC_PRIVATE, xcbob->xim->size, (IPC_CREAT | 0777));
if (xcbob->shm_info->shmid == (uint32_t)-1)
{
xcb_image_destroy(xcbob->xim);
@ -286,15 +287,29 @@ evas_software_xcb_output_buffer_new(xcb_connection_t *conn, xcb_visualtype_t *vi
shmat(xcbob->shm_info->shmid, 0, 0);
if (xcbob->shm_info->shmaddr != ((void *)-1))
{
/* Sync only needed for testing */
if (try_shm == 2) _xcbob_sync(conn);
xcbob->xim->data = xcbob->shm_info->shmaddr;
#if defined(EVAS_FRAME_QUEING) && defined(LIBXEXT_VERSION_LOW)
if (evas_common_frameq_enabled())
xcb_grab_server(conn);
#endif
xcb_shm_attach(conn, xcbob->shm_info->shmseg,
xcbob->shm_info->shmid, 0);
#if defined(EVAS_FRAME_QUEING) && defined(LIBXEXT_VERSION_LOW)
if (evas_common_frameq_enabled())
xcb_ungrab_server(conn);
#endif
if (try_shm == 2) _xcbob_sync(conn);
xcbob->bpl = xcbob->xim->stride;
xcbob->psize = (xcbob->bpl * xcbob->h);
return xcbob;
}
else
{
shmdt(xcbob->shm_info->shmaddr);
shmctl(xcbob->shm_info->shmid, IPC_RMID, 0);
xcb_image_destroy(xcbob->xim);
free(xcbob->shm_info);
@ -315,30 +330,31 @@ evas_software_xcb_output_buffer_new(xcb_connection_t *conn, xcb_visualtype_t *vi
return NULL;
}
}
else
if (try_shm > 1) return NULL;
/* no shm */
xcbob->xim =
_xcbob_create_native(conn, w, h, XCB_IMAGE_FORMAT_Z_PIXMAP,
depth, NULL, ~0, NULL);
if (!xcbob->xim)
{
/* no shm */
xcbob->xim =
_xcbob_create_native(conn, w, h, XCB_IMAGE_FORMAT_Z_PIXMAP,
depth, NULL, ~0, NULL);
if (!xcbob->xim)
free(xcbob);
return NULL;
}
if (!xcbob->xim->data)
{
xcbob->xim->data = malloc(xcbob->xim->size);
if (!xcbob->xim->data)
{
xcb_image_destroy(xcbob->xim);
free(xcbob);
return NULL;
}
if (!xcbob->xim->data)
{
xcbob->xim->data = malloc(xcbob->xim->size);
if (!xcbob->xim->data)
{
xcb_image_destroy(xcbob->xim);
free(xcbob);
return NULL;
}
}
xcbob->bpl = xcbob->xim->stride;
xcbob->psize = xcbob->xim->size;
}
xcbob->bpl = xcbob->xim->stride;
xcbob->psize = xcbob->xim->size;
return xcbob;
}

View File

@ -19,7 +19,7 @@ void evas_software_xcb_write_mask_line_rev(Outbuf *buf, Xcb_Output_Buffer *xcbob
void evas_software_xcb_write_mask_line_vert(Outbuf *buf, Xcb_Output_Buffer *xcbob, DATA32 *src, int h, int y, int w);
void evas_software_xcb_write_mask_line_vert_rev(Outbuf *buf, Xcb_Output_Buffer *xcbob, DATA32 *src, int h, int y, int w);
Eina_Bool evas_software_xcb_can_do_shm(xcb_connection_t *conn, xcb_screen_t *screen);
Xcb_Output_Buffer *evas_software_xcb_output_buffer_new(xcb_connection_t *conn, xcb_visualtype_t *vis, int depth, int w, int h, Eina_Bool try_shm, unsigned char *data);
Xcb_Output_Buffer *evas_software_xcb_output_buffer_new(xcb_connection_t *conn, xcb_visualtype_t *vis, int depth, int w, int h, int try_shm, unsigned char *data);
void evas_software_xcb_output_buffer_free(Xcb_Output_Buffer *xcbob, Eina_Bool sync);
void evas_software_xcb_output_buffer_paste(Xcb_Output_Buffer *xcbob, xcb_drawable_t drawable, xcb_gcontext_t gc, int x, int y, Eina_Bool sync);
DATA8 *evas_software_xcb_output_buffer_data(Xcb_Output_Buffer *xcbob, int *bpl_ret);

View File

@ -24,7 +24,7 @@ static void _xcbob_sync(xcb_connection_t *conn);
static Eina_List *_shmpool = NULL;
static int _shmsize = 0;
static int _shmlimit = (10 * 1024 * 1024);
static int _shmcountlimit = 32;
static const unsigned int _shmcountlimit = 32;
#ifdef EVAS_FRAME_QUEUING
static LK(lock_shmpool);
@ -180,6 +180,7 @@ evas_software_xcb_outbuf_setup(int w, int h, int rot, Outbuf_Depth depth, xcb_co
else
pm = PAL_MODE_MONO;
}
/* FIXME: Only allocate once per display & colormap */
buf->priv.pal =
evas_software_xcb_color_allocate(conn, cmap, vis, pm);
if (!buf->priv.pal)
@ -276,7 +277,6 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
_xcbob_sync(buf->priv.x11.xcb.conn);
buf->priv.synced = EINA_TRUE;
}
eina_rectangle_free(rect);
return buf->priv.onebuf;
}
obr->x = 0;
@ -300,7 +300,6 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
NULL);
if (!obr->xcbob)
{
eina_rectangle_free(rect);
free(obr);
return NULL;
}
@ -312,7 +311,6 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
if (!im)
{
evas_software_xcb_output_buffer_free(obr->xcbob, EINA_FALSE);
eina_rectangle_free(rect);
free(obr);
return NULL;
}
@ -334,7 +332,6 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
(RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
if (!im)
{
eina_rectangle_free(rect);
free(obr);
return NULL;
}
@ -359,7 +356,6 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
if (!obr->xcbob)
{
evas_cache_image_drop(&im->cache_entry);
eina_rectangle_free(rect);
free(obr);
return NULL;
}
@ -372,7 +368,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
NULL);
}
}
/* FIXME: */
/* FIXME: We should be able to remove this memset. */
if ((alpha) && (im->image.data))
{
/* FIXME: Faster memset */
@ -466,7 +462,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
bw, bh, use_shm, NULL);
}
}
/* FIXME: */
/* FIXME: We should be able to remove this memset. */
if (((buf->priv.x11.xcb.mask) || (buf->priv.destination_alpha)) &&
(im->image.data))
{
@ -506,6 +502,10 @@ evas_software_xcb_outbuf_flush(Outbuf *buf)
{
Eina_Rectangle *rect, xr = { 0, 0, 0, 0 };
rect = buf->priv.onebuf_regions->data;
buf->priv.onebuf_regions =
eina_list_remove_list(buf->priv.onebuf_regions,
buf->priv.onebuf_regions);
if (buf->rot == 0)
{
xr.x = rect->x;
@ -534,10 +534,6 @@ evas_software_xcb_outbuf_flush(Outbuf *buf)
xr.w = rect->h;
xr.h = rect->w;
}
rect = buf->priv.onebuf_regions->data;
buf->priv.onebuf_regions =
eina_list_remove_list(buf->priv.onebuf_regions,
buf->priv.onebuf_regions);
pixman_region_union_rect(&tmpr, &tmpr, xr.x, xr.y, xr.w, xr.h);
if (buf->priv.debug)
evas_software_xcb_outbuf_debug_show(buf, buf->priv.x11.xcb.win,
@ -612,7 +608,9 @@ evas_software_xcb_outbuf_flush(Outbuf *buf)
xcb_flush(buf->priv.x11.xcb.conn);
#else
/* FIXME: Async Push Disabled */
_xcbob_sync(buf->priv.x11.xcb.conn);
while (buf->priv.pending_writes)
{
im = eina_list_data_get(buf->priv.pending_writes);
@ -779,7 +777,18 @@ evas_software_xcb_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, in
}
#if 1
#else
/* FIXME: Add async push code */
/* Async Push */
if (!((buf->priv.onebuf) && (buf->priv.onebuf_regions)))
{
if (buf->priv.debug)
evas_software_xcb_outbuf_debug_show(buf, buf->priv.x11.xcb.win,
obr->x, obr->y, obr->w, obr->h);
if (obr->xcbob)
evas_software_xcb_output_buffer_paste(obr->xcbob,
buf->priv.x11.xcb.win,
buf->priv.x11.xcb.gc,
obr->x, obr->y, 0);
}
#endif
if (obr->mask)
{
@ -813,7 +822,14 @@ evas_software_xcb_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, in
}
#if 1
#else
/* FIXME: Add Async Push */
/* Async Push */
if (!((buf->priv.onebuf) && (buf->priv.onebuf_regions)))
{
evas_software_xcb_output_buffer_paste(obr->xcbob,
buf->priv.x11.xcb.mask,
buf->priv.x11.xcb.gcm,
obr->x, obr->y, 0);
}
#endif
}
#if 1