summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-07-26 13:18:22 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-07-26 13:33:06 +0900
commit789926c82df084400c9a89ceebc1e5165e6101b7 (patch)
tree4e36dbe330021f9996107f8efe6960e430ff522a
parent00934c870e8da48d1d0caca1f85ff152779484de (diff)
evas and ecore_x shm segment management - fix over allocation and perms
so our sysv shm segments were both over-permissive (nothing bad really, just other users could read and write to/from our pixel data destined for the screen... they could do this to x11 directly anyway so no real issue), but be more restrictive and use 0600 as xserver runs as root so can read/write anyway and we only want our own uid access. but even more - fix our shm segment flushing to not keep lots of segments floating about like a bad smell when we don't need them. we had a cache but it wasnt flushed when it should be since async rendering turned up. this fixes that and we're back to agressively flushing them out when idle. @fix
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_image.c4
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_image.c4
-rw-r--r--src/modules/evas/engines/software_x11/evas_engine.h1
-rw-r--r--src/modules/evas/engines/software_x11/evas_xcb_buffer.c2
-rw-r--r--src/modules/evas/engines/software_x11/evas_xcb_outbuf.c64
-rw-r--r--src/modules/evas/engines/software_x11/evas_xlib_buffer.c2
-rw-r--r--src/modules/evas/engines/software_x11/evas_xlib_outbuf.c73
-rw-r--r--src/modules/evas/engines/software_x11/evas_xlib_swapper.c2
8 files changed, 121 insertions, 31 deletions
diff --git a/src/lib/ecore_x/xcb/ecore_xcb_image.c b/src/lib/ecore_x/xcb/ecore_xcb_image.c
index 67a1470ffd..b6ac6ff4b0 100644
--- a/src/lib/ecore_x/xcb/ecore_xcb_image.c
+++ b/src/lib/ecore_x/xcb/ecore_xcb_image.c
@@ -621,7 +621,7 @@ _ecore_xcb_image_shm_check(void)
621 } 621 }
622 622
623 shminfo.shmid = 623 shminfo.shmid =
624 shmget(IPC_PRIVATE, img->stride * img->height, (IPC_CREAT | 0666)); 624 shmget(IPC_PRIVATE, img->stride * img->height, (IPC_CREAT | 0600));
625 if (shminfo.shmid == (uint32_t)-1) 625 if (shminfo.shmid == (uint32_t)-1)
626 { 626 {
627 xcb_image_destroy(img); 627 xcb_image_destroy(img);
@@ -675,7 +675,7 @@ _ecore_xcb_image_shm_create(Ecore_X_Image *im)
675 im->depth, NULL, ~0, NULL); 675 im->depth, NULL, ~0, NULL);
676 if (!im->xim) return; 676 if (!im->xim) return;
677 677
678 im->shminfo.shmid = shmget(IPC_PRIVATE, im->xim->size, (IPC_CREAT | 0666)); 678 im->shminfo.shmid = shmget(IPC_PRIVATE, im->xim->size, (IPC_CREAT | 0600));
679 if (im->shminfo.shmid == (uint32_t)-1) 679 if (im->shminfo.shmid == (uint32_t)-1)
680 { 680 {
681 xcb_image_destroy(im->xim); 681 xcb_image_destroy(im->xim);
diff --git a/src/lib/ecore_x/xlib/ecore_x_image.c b/src/lib/ecore_x/xlib/ecore_x_image.c
index 6dfe931d04..35ee976971 100644
--- a/src/lib/ecore_x/xlib/ecore_x_image.c
+++ b/src/lib/ecore_x/xlib/ecore_x_image.c
@@ -120,7 +120,7 @@ _ecore_x_image_shm_check(void)
120 } 120 }
121 121
122 shminfo.shmid = shmget(IPC_PRIVATE, xim->bytes_per_line * xim->height, 122 shminfo.shmid = shmget(IPC_PRIVATE, xim->bytes_per_line * xim->height,
123 IPC_CREAT | 0666); 123 IPC_CREAT | 0600);
124 if (shminfo.shmid == -1) 124 if (shminfo.shmid == -1)
125 { 125 {
126 ERR("%s", strerror(errno)); 126 ERR("%s", strerror(errno));
@@ -246,7 +246,7 @@ _ecore_x_image_shm_create(Ecore_X_Image *im)
246 246
247 im->shminfo.shmid = shmget(IPC_PRIVATE, 247 im->shminfo.shmid = shmget(IPC_PRIVATE,
248 im->xim->bytes_per_line * im->xim->height, 248 im->xim->bytes_per_line * im->xim->height,
249 IPC_CREAT | 0666); 249 IPC_CREAT | 0600);
250 if (im->shminfo.shmid == -1) 250 if (im->shminfo.shmid == -1)
251 { 251 {
252 ERR("shmget failed: %s", strerror(errno)); 252 ERR("shmget failed: %s", strerror(errno));
diff --git a/src/modules/evas/engines/software_x11/evas_engine.h b/src/modules/evas/engines/software_x11/evas_engine.h
index c29f62deea..895e320621 100644
--- a/src/modules/evas/engines/software_x11/evas_engine.h
+++ b/src/modules/evas/engines/software_x11/evas_engine.h
@@ -106,6 +106,7 @@ struct _Outbuf
106 106
107 /* a list of previous frame pending regions to write to the target */ 107 /* a list of previous frame pending regions to write to the target */
108 Eina_List *prev_pending_writes; 108 Eina_List *prev_pending_writes;
109 Eina_Spinlock lock;
109 110
110 unsigned char mask_dither : 1; 111 unsigned char mask_dither : 1;
111 unsigned char destination_alpha : 1; 112 unsigned char destination_alpha : 1;
diff --git a/src/modules/evas/engines/software_x11/evas_xcb_buffer.c b/src/modules/evas/engines/software_x11/evas_xcb_buffer.c
index 38d4584e50..ff90a6898c 100644
--- a/src/modules/evas/engines/software_x11/evas_xcb_buffer.c
+++ b/src/modules/evas/engines/software_x11/evas_xcb_buffer.c
@@ -282,7 +282,7 @@ evas_software_xcb_output_buffer_new(xcb_connection_t *conn, xcb_visualtype_t *vi
282 xcbob->shm_info->shmid = 282 xcbob->shm_info->shmid =
283 shmget(IPC_PRIVATE, 283 shmget(IPC_PRIVATE,
284 xcbob->xim->stride * xcbob->xim->height, 284 xcbob->xim->stride * xcbob->xim->height,
285 (IPC_CREAT | 0777)); 285 (IPC_CREAT | 0600));
286 if (xcbob->shm_info->shmid == (uint32_t)-1) 286 if (xcbob->shm_info->shmid == (uint32_t)-1)
287 { 287 {
288 xcb_image_destroy(xcbob->xim); 288 xcb_image_destroy(xcbob->xim);
diff --git a/src/modules/evas/engines/software_x11/evas_xcb_outbuf.c b/src/modules/evas/engines/software_x11/evas_xcb_outbuf.c
index 632d13cd64..cee38e9d5a 100644
--- a/src/modules/evas/engines/software_x11/evas_xcb_outbuf.c
+++ b/src/modules/evas/engines/software_x11/evas_xcb_outbuf.c
@@ -46,6 +46,7 @@ evas_software_xcb_outbuf_init(void)
46void 46void
47evas_software_xcb_outbuf_free(Outbuf *buf) 47evas_software_xcb_outbuf_free(Outbuf *buf)
48{ 48{
49 eina_spinlock_take(&(buf->priv.lock));
49 while (buf->priv.pending_writes) 50 while (buf->priv.pending_writes)
50 { 51 {
51 RGBA_Image *im = NULL; 52 RGBA_Image *im = NULL;
@@ -67,6 +68,7 @@ evas_software_xcb_outbuf_free(Outbuf *buf)
67 if (obr->mask) _unfind_xcbob(obr->mask, EINA_FALSE); 68 if (obr->mask) _unfind_xcbob(obr->mask, EINA_FALSE);
68 free(obr); 69 free(obr);
69 } 70 }
71 eina_spinlock_release(&(buf->priv.lock));
70 72
71 evas_software_xcb_outbuf_idle_flush(buf); 73 evas_software_xcb_outbuf_idle_flush(buf);
72 evas_software_xcb_outbuf_flush(buf, NULL, MODE_FULL); 74 evas_software_xcb_outbuf_flush(buf, NULL, MODE_FULL);
@@ -82,10 +84,9 @@ evas_software_xcb_outbuf_free(Outbuf *buf)
82 buf->priv.pal); 84 buf->priv.pal);
83 85
84 eina_array_flush(&buf->priv.onebuf_regions); 86 eina_array_flush(&buf->priv.onebuf_regions);
85 87 eina_spinlock_free(&(buf->priv.lock));
86 free(buf); 88 free(buf);
87 _clear_xcbob(EINA_FALSE); 89 _clear_xcbob(EINA_TRUE);
88 eina_spinlock_free(&shmpool_lock);
89} 90}
90 91
91Outbuf * 92Outbuf *
@@ -260,6 +261,7 @@ evas_software_xcb_outbuf_setup(int w, int h, int rot, Outbuf_Depth depth, xcb_co
260 261
261 evas_software_xcb_outbuf_drawable_set(buf, draw); 262 evas_software_xcb_outbuf_drawable_set(buf, draw);
262 evas_software_xcb_outbuf_mask_set(buf, mask); 263 evas_software_xcb_outbuf_mask_set(buf, mask);
264 eina_spinlock_new(&(buf->priv.lock));
263 265
264 return buf; 266 return buf;
265} 267}
@@ -273,6 +275,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
273 Eina_Bool alpha = EINA_FALSE; 275 Eina_Bool alpha = EINA_FALSE;
274 int bpl = 0; 276 int bpl = 0;
275 277
278 eina_spinlock_take(&(buf->priv.lock));
276 if ((buf->onebuf) && (buf->priv.x11.xcb.shm)) 279 if ((buf->onebuf) && (buf->priv.x11.xcb.shm))
277 { 280 {
278 Eina_Rectangle *rect; 281 Eina_Rectangle *rect;
@@ -280,11 +283,15 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
280 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, buf->w, buf->h); 283 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, buf->w, buf->h);
281 284
282 if (!(obr = calloc(1, sizeof(Outbuf_Region)))) 285 if (!(obr = calloc(1, sizeof(Outbuf_Region))))
283 return NULL; 286 {
287 eina_spinlock_release(&(buf->priv.lock));
288 return NULL;
289 }
284 290
285 if (!(rect = eina_rectangle_new(x, y, w, h))) 291 if (!(rect = eina_rectangle_new(x, y, w, h)))
286 { 292 {
287 free(obr); 293 free(obr);
294 eina_spinlock_release(&(buf->priv.lock));
288 return NULL; 295 return NULL;
289 } 296 }
290 297
@@ -301,6 +308,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
301 buf->priv.synced = EINA_TRUE; 308 buf->priv.synced = EINA_TRUE;
302 } 309 }
303 free(obr); 310 free(obr);
311 eina_spinlock_release(&(buf->priv.lock));
304 return buf->priv.onebuf; 312 return buf->priv.onebuf;
305 } 313 }
306 obr->x = 0; 314 obr->x = 0;
@@ -330,6 +338,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
330 if (!obr->xcbob) 338 if (!obr->xcbob)
331 { 339 {
332 free(obr); 340 free(obr);
341 eina_spinlock_release(&(buf->priv.lock));
333 return NULL; 342 return NULL;
334 } 343 }
335#ifdef EVAS_CSERVE2 344#ifdef EVAS_CSERVE2
@@ -355,6 +364,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
355 { 364 {
356 evas_software_xcb_output_buffer_free(obr->xcbob, EINA_FALSE); 365 evas_software_xcb_output_buffer_free(obr->xcbob, EINA_FALSE);
357 free(obr); 366 free(obr);
367 eina_spinlock_release(&(buf->priv.lock));
358 return NULL; 368 return NULL;
359 } 369 }
360 im->extended_info = obr; 370 im->extended_info = obr;
@@ -387,6 +397,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
387 if (!im) 397 if (!im)
388 { 398 {
389 free(obr); 399 free(obr);
400 eina_spinlock_release(&(buf->priv.lock));
390 return NULL; 401 return NULL;
391 } 402 }
392 im->cache_entry.flags.alpha |= (alpha ? 1 : 0); 403 im->cache_entry.flags.alpha |= (alpha ? 1 : 0);
@@ -423,6 +434,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
423 evas_cache_image_drop(&im->cache_entry); 434 evas_cache_image_drop(&im->cache_entry);
424 435
425 free(obr); 436 free(obr);
437 eina_spinlock_release(&(buf->priv.lock));
426 return NULL; 438 return NULL;
427 } 439 }
428 if (buf->priv.x11.xcb.mask) 440 if (buf->priv.x11.xcb.mask)
@@ -441,11 +453,15 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
441// memset(im->image.data, 0, (w * h * sizeof(DATA32))); 453// memset(im->image.data, 0, (w * h * sizeof(DATA32)));
442 } 454 }
443 buf->priv.onebuf = im; 455 buf->priv.onebuf = im;
456 eina_spinlock_release(&(buf->priv.lock));
444 return im; 457 return im;
445 } 458 }
446 459
447 if (!(obr = calloc(1, sizeof(Outbuf_Region)))) 460 if (!(obr = calloc(1, sizeof(Outbuf_Region))))
448 return NULL; 461 {
462 eina_spinlock_release(&(buf->priv.lock));
463 return NULL;
464 }
449 465
450 obr->x = x; 466 obr->x = x;
451 obr->y = y; 467 obr->y = y;
@@ -470,6 +486,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
470 if (!obr->xcbob) 486 if (!obr->xcbob)
471 { 487 {
472 free(obr); 488 free(obr);
489 eina_spinlock_release(&(buf->priv.lock));
473 return NULL; 490 return NULL;
474 } 491 }
475#ifdef EVAS_CSERVE2 492#ifdef EVAS_CSERVE2
@@ -495,6 +512,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
495 { 512 {
496 _unfind_xcbob(obr->xcbob, EINA_FALSE); 513 _unfind_xcbob(obr->xcbob, EINA_FALSE);
497 free(obr); 514 free(obr);
515 eina_spinlock_release(&(buf->priv.lock));
498 return NULL; 516 return NULL;
499 } 517 }
500 im->extended_info = obr; 518 im->extended_info = obr;
@@ -525,6 +543,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
525 if (!im) 543 if (!im)
526 { 544 {
527 free(obr); 545 free(obr);
546 eina_spinlock_release(&(buf->priv.lock));
528 return NULL; 547 return NULL;
529 } 548 }
530 im->cache_entry.flags.alpha |= (alpha ? 1 : 0); 549 im->cache_entry.flags.alpha |= (alpha ? 1 : 0);
@@ -558,6 +577,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
558#endif 577#endif
559 evas_cache_image_drop(&im->cache_entry); 578 evas_cache_image_drop(&im->cache_entry);
560 free(obr); 579 free(obr);
580 eina_spinlock_release(&(buf->priv.lock));
561 return NULL; 581 return NULL;
562 } 582 }
563 if (buf->priv.x11.xcb.mask) 583 if (buf->priv.x11.xcb.mask)
@@ -577,6 +597,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
577 597
578 buf->priv.pending_writes = eina_list_append(buf->priv.pending_writes, im); 598 buf->priv.pending_writes = eina_list_append(buf->priv.pending_writes, im);
579 599
600 eina_spinlock_release(&(buf->priv.lock));
580 return im; 601 return im;
581} 602}
582 603
@@ -587,14 +608,13 @@ evas_software_xcb_outbuf_free_region_for_update(Outbuf *buf EINA_UNUSED, RGBA_Im
587} 608}
588 609
589void 610void
590evas_software_xcb_outbuf_flush(Outbuf *buf, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode render_mode) 611evas_software_xcb_outbuf_flush(Outbuf *buf, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode render_mode EINA_UNUSED)
591{ 612{
592 Eina_List *l = NULL; 613 Eina_List *l = NULL;
593 RGBA_Image *im = NULL; 614 RGBA_Image *im = NULL;
594 Outbuf_Region *obr = NULL; 615 Outbuf_Region *obr = NULL;
595 616
596 if (render_mode == EVAS_RENDER_MODE_ASYNC_INIT) return; 617 eina_spinlock_take(&(buf->priv.lock));
597
598 if ((buf->priv.onebuf) && (eina_array_count(&buf->priv.onebuf_regions))) 618 if ((buf->priv.onebuf) && (eina_array_count(&buf->priv.onebuf_regions)))
599 { 619 {
600 Eina_Array_Iterator it; 620 Eina_Array_Iterator it;
@@ -743,12 +763,14 @@ evas_software_xcb_outbuf_flush(Outbuf *buf, Tilebuf_Rect *rects EINA_UNUSED, Eva
743 } 763 }
744#endif 764#endif
745 } 765 }
766 eina_spinlock_release(&(buf->priv.lock));
746 evas_common_cpu_end_opt(); 767 evas_common_cpu_end_opt();
747} 768}
748 769
749void 770void
750evas_software_xcb_outbuf_idle_flush(Outbuf *buf) 771evas_software_xcb_outbuf_idle_flush(Outbuf *buf)
751{ 772{
773 eina_spinlock_release(&(buf->priv.lock));
752 if (buf->priv.onebuf) 774 if (buf->priv.onebuf)
753 { 775 {
754 RGBA_Image *im; 776 RGBA_Image *im;
@@ -795,6 +817,7 @@ evas_software_xcb_outbuf_idle_flush(Outbuf *buf)
795 } 817 }
796 _clear_xcbob(EINA_FALSE); 818 _clear_xcbob(EINA_FALSE);
797 } 819 }
820 eina_spinlock_release(&(buf->priv.lock));
798} 821}
799 822
800void 823void
@@ -807,8 +830,13 @@ evas_software_xcb_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, in
807 int bpl = 0, yy = 0; 830 int bpl = 0, yy = 0;
808 int bw = 0, bh = 0; 831 int bw = 0, bh = 0;
809 832
833 eina_spinlock_release(&(buf->priv.lock));
810 obr = update->extended_info; 834 obr = update->extended_info;
811 if (!obr->xcbob) return; 835 if (!obr->xcbob)
836 {
837 eina_spinlock_release(&(buf->priv.lock));
838 return;
839 }
812 840
813 if ((buf->rot == 0) || (buf->rot == 180)) 841 if ((buf->rot == 0) || (buf->rot == 180))
814 { 842 {
@@ -834,11 +862,22 @@ evas_software_xcb_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, in
834 buf->priv.mask.g, buf->priv.mask.b, 862 buf->priv.mask.g, buf->priv.mask.b,
835 PAL_MODE_NONE, buf->rot); 863 PAL_MODE_NONE, buf->rot);
836 } 864 }
837 if (!func_conv) return; 865 if (!func_conv)
866 {
867 eina_spinlock_release(&(buf->priv.lock));
868 return;
869 }
838 870
839 if (!(data = evas_software_xcb_output_buffer_data(obr->xcbob, &bpl))) 871 if (!(data = evas_software_xcb_output_buffer_data(obr->xcbob, &bpl)))
840 return; 872 {
841 if (!(src_data = update->image.data)) return; 873 eina_spinlock_release(&(buf->priv.lock));
874 return;
875 }
876 if (!(src_data = update->image.data))
877 {
878 eina_spinlock_release(&(buf->priv.lock));
879 return;
880 }
842 if (buf->rot == 0) 881 if (buf->rot == 0)
843 { 882 {
844 obr->x = x; 883 obr->x = x;
@@ -965,6 +1004,7 @@ evas_software_xcb_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, in
965#else 1004#else
966 xcb_flush(buf->priv.x11.xcb.conn); 1005 xcb_flush(buf->priv.x11.xcb.conn);
967#endif 1006#endif
1007 eina_spinlock_release(&(buf->priv.lock));
968} 1008}
969 1009
970void 1010void
diff --git a/src/modules/evas/engines/software_x11/evas_xlib_buffer.c b/src/modules/evas/engines/software_x11/evas_xlib_buffer.c
index 9faf9eb7d7..6ab127839f 100644
--- a/src/modules/evas/engines/software_x11/evas_xlib_buffer.c
+++ b/src/modules/evas/engines/software_x11/evas_xlib_buffer.c
@@ -288,7 +288,7 @@ evas_software_xlib_x_output_buffer_new(Display *d, Visual *v, int depth, int w,
288 xob->shm_info->shmid = shmget(IPC_PRIVATE, 288 xob->shm_info->shmid = shmget(IPC_PRIVATE,
289 xob->xim->bytes_per_line * 289 xob->xim->bytes_per_line *
290 xob->xim->height, 290 xob->xim->height,
291 IPC_CREAT | 0777); 291 IPC_CREAT | 0600);
292 if (xob->shm_info->shmid >= 0) 292 if (xob->shm_info->shmid >= 0)
293 { 293 {
294 xob->shm_info->readOnly = False; 294 xob->shm_info->readOnly = False;
diff --git a/src/modules/evas/engines/software_x11/evas_xlib_outbuf.c b/src/modules/evas/engines/software_x11/evas_xlib_outbuf.c
index d556595acf..196d384f43 100644
--- a/src/modules/evas/engines/software_x11/evas_xlib_outbuf.c
+++ b/src/modules/evas/engines/software_x11/evas_xlib_outbuf.c
@@ -156,6 +156,7 @@ evas_software_xlib_outbuf_init(void)
156void 156void
157evas_software_xlib_outbuf_free(Outbuf *buf) 157evas_software_xlib_outbuf_free(Outbuf *buf)
158{ 158{
159 eina_spinlock_take(&(buf->priv.lock));
159 while (buf->priv.pending_writes) 160 while (buf->priv.pending_writes)
160 { 161 {
161 RGBA_Image *im; 162 RGBA_Image *im;
@@ -176,6 +177,7 @@ evas_software_xlib_outbuf_free(Outbuf *buf)
176 if (obr->mxob) _unfind_xob(obr->mxob, 0); 177 if (obr->mxob) _unfind_xob(obr->mxob, 0);
177 free(obr); 178 free(obr);
178 } 179 }
180 eina_spinlock_release(&(buf->priv.lock));
179 evas_software_xlib_outbuf_idle_flush(buf); 181 evas_software_xlib_outbuf_idle_flush(buf);
180 evas_software_xlib_outbuf_flush(buf, NULL, EVAS_RENDER_MODE_UNDEF); 182 evas_software_xlib_outbuf_flush(buf, NULL, EVAS_RENDER_MODE_UNDEF);
181 if (buf->priv.x11.xlib.gc) 183 if (buf->priv.x11.xlib.gc)
@@ -190,9 +192,9 @@ evas_software_xlib_outbuf_free(Outbuf *buf)
190 XFreeColormap (buf->priv.x11.xlib.disp, buf->priv.x11.xlib.cmap); 192 XFreeColormap (buf->priv.x11.xlib.disp, buf->priv.x11.xlib.cmap);
191 193
192 eina_array_flush(&buf->priv.onebuf_regions); 194 eina_array_flush(&buf->priv.onebuf_regions);
195 eina_spinlock_free(&(buf->priv.lock));
193 free(buf); 196 free(buf);
194 _clear_xob(0); 197 _clear_xob(1);
195 eina_spinlock_free(&shmpool_lock);
196} 198}
197 199
198Outbuf * 200Outbuf *
@@ -368,6 +370,7 @@ evas_software_xlib_outbuf_setup_x(int w, int h, int rot, Outbuf_Depth depth,
368 evas_software_xlib_outbuf_drawable_set(buf, draw); 370 evas_software_xlib_outbuf_drawable_set(buf, draw);
369 evas_software_xlib_outbuf_mask_set(buf, mask); 371 evas_software_xlib_outbuf_mask_set(buf, mask);
370 } 372 }
373 eina_spinlock_new(&(buf->priv.lock));
371 return buf; 374 return buf;
372} 375}
373 376
@@ -380,6 +383,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
380 int use_shm = 1; 383 int use_shm = 1;
381 int alpha; 384 int alpha;
382 385
386 eina_spinlock_take(&(buf->priv.lock));
383 if ((buf->onebuf) && (buf->priv.x11.xlib.shm)) 387 if ((buf->onebuf) && (buf->priv.x11.xlib.shm))
384 { 388 {
385 Eina_Rectangle *rect; 389 Eina_Rectangle *rect;
@@ -387,7 +391,11 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
387 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, buf->w, buf->h); 391 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, buf->w, buf->h);
388 392
389 rect = eina_rectangle_new(x, y, w, h); 393 rect = eina_rectangle_new(x, y, w, h);
390 if (!rect) return NULL; 394 if (!rect)
395 {
396 eina_spinlock_release(&(buf->priv.lock));
397 return NULL;
398 }
391 399
392 if ((eina_array_push(&buf->priv.onebuf_regions, rect)) && 400 if ((eina_array_push(&buf->priv.onebuf_regions, rect)) &&
393 (buf->priv.onebuf)) 401 (buf->priv.onebuf))
@@ -401,13 +409,18 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
401 XSync(buf->priv.x11.xlib.disp, False); 409 XSync(buf->priv.x11.xlib.disp, False);
402 buf->priv.synced = 1; 410 buf->priv.synced = 1;
403 } 411 }
412 eina_spinlock_release(&(buf->priv.lock));
404 return buf->priv.onebuf; 413 return buf->priv.onebuf;
405 } 414 }
406 415
407 if (rect) eina_rectangle_free(rect); 416 if (rect) eina_rectangle_free(rect);
408 417
409 obr = calloc(1, sizeof(Outbuf_Region)); 418 obr = calloc(1, sizeof(Outbuf_Region));
410 if (!obr) return NULL; 419 if (!obr)
420 {
421 eina_spinlock_release(&(buf->priv.lock));
422 return NULL;
423 }
411 424
412 obr->x = 0; 425 obr->x = 0;
413 obr->y = 0; 426 obr->y = 0;
@@ -436,6 +449,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
436 if (!obr->xob) 449 if (!obr->xob)
437 { 450 {
438 free(obr); 451 free(obr);
452 eina_spinlock_release(&(buf->priv.lock));
439 return NULL; 453 return NULL;
440 } 454 }
441#ifdef EVAS_CSERVE2 455#ifdef EVAS_CSERVE2
@@ -456,6 +470,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
456 { 470 {
457 evas_software_xlib_x_output_buffer_free(obr->xob, 0); 471 evas_software_xlib_x_output_buffer_free(obr->xob, 0);
458 free(obr); 472 free(obr);
473 eina_spinlock_release(&(buf->priv.lock));
459 return NULL; 474 return NULL;
460 } 475 }
461 im->extended_info = obr; 476 im->extended_info = obr;
@@ -478,6 +493,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
478 if (!im) 493 if (!im)
479 { 494 {
480 free(obr); 495 free(obr);
496 eina_spinlock_release(&(buf->priv.lock));
481 return NULL; 497 return NULL;
482 } 498 }
483 im->cache_entry.flags.alpha |= alpha ? 1 : 0; 499 im->cache_entry.flags.alpha |= alpha ? 1 : 0;
@@ -507,6 +523,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
507#endif 523#endif
508 evas_cache_image_drop(&im->cache_entry); 524 evas_cache_image_drop(&im->cache_entry);
509 free(obr); 525 free(obr);
526 eina_spinlock_release(&(buf->priv.lock));
510 return NULL; 527 return NULL;
511 } 528 }
512 if (buf->priv.x11.xlib.mask) 529 if (buf->priv.x11.xlib.mask)
@@ -535,6 +552,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
535#endif 552#endif
536 evas_cache_image_drop(&im->cache_entry); 553 evas_cache_image_drop(&im->cache_entry);
537 free(obr); 554 free(obr);
555 eina_spinlock_release(&(buf->priv.lock));
538 return NULL; 556 return NULL;
539 } 557 }
540 if (buf->priv.x11.xlib.mask) 558 if (buf->priv.x11.xlib.mask)
@@ -554,11 +572,16 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
554 } 572 }
555 573
556 buf->priv.onebuf = im; 574 buf->priv.onebuf = im;
575 eina_spinlock_release(&(buf->priv.lock));
557 return im; 576 return im;
558 } 577 }
559 578
560 obr = calloc(1, sizeof(Outbuf_Region)); 579 obr = calloc(1, sizeof(Outbuf_Region));
561 if (!obr) return NULL; 580 if (!obr)
581 {
582 eina_spinlock_release(&(buf->priv.lock));
583 return NULL;
584 }
562 obr->x = x; 585 obr->x = x;
563 obr->y = y; 586 obr->y = y;
564 obr->w = w; 587 obr->w = w;
@@ -592,6 +615,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
592 if (!obr->xob) 615 if (!obr->xob)
593 { 616 {
594 free(obr); 617 free(obr);
618 eina_spinlock_release(&(buf->priv.lock));
595 return NULL; 619 return NULL;
596 } 620 }
597#ifdef EVAS_CSERVE2 621#ifdef EVAS_CSERVE2
@@ -610,6 +634,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
610 { 634 {
611 _unfind_xob(obr->xob, 0); 635 _unfind_xob(obr->xob, 0);
612 free(obr); 636 free(obr);
637 eina_spinlock_release(&(buf->priv.lock));
613 return NULL; 638 return NULL;
614 } 639 }
615 im->extended_info = obr; 640 im->extended_info = obr;
@@ -631,6 +656,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
631 if (!im) 656 if (!im)
632 { 657 {
633 free(obr); 658 free(obr);
659 eina_spinlock_release(&(buf->priv.lock));
634 return NULL; 660 return NULL;
635 } 661 }
636 im->cache_entry.w = w; 662 im->cache_entry.w = w;
@@ -662,6 +688,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
662#endif 688#endif
663 evas_cache_image_drop(&im->cache_entry); 689 evas_cache_image_drop(&im->cache_entry);
664 free(obr); 690 free(obr);
691 eina_spinlock_release(&(buf->priv.lock));
665 return NULL; 692 return NULL;
666 } 693 }
667 if (buf->priv.x11.xlib.mask) 694 if (buf->priv.x11.xlib.mask)
@@ -690,6 +717,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
690#endif 717#endif
691 evas_cache_image_drop(&im->cache_entry); 718 evas_cache_image_drop(&im->cache_entry);
692 free(obr); 719 free(obr);
720 eina_spinlock_release(&(buf->priv.lock));
693 return NULL; 721 return NULL;
694 } 722 }
695 if (buf->priv.x11.xlib.mask) 723 if (buf->priv.x11.xlib.mask)
@@ -710,6 +738,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
710 } 738 }
711 739
712 buf->priv.pending_writes = eina_list_append(buf->priv.pending_writes, im); 740 buf->priv.pending_writes = eina_list_append(buf->priv.pending_writes, im);
741 eina_spinlock_release(&(buf->priv.lock));
713 return im; 742 return im;
714} 743}
715 744
@@ -720,14 +749,13 @@ evas_software_xlib_outbuf_free_region_for_update(Outbuf *buf EINA_UNUSED, RGBA_I
720} 749}
721 750
722void 751void
723evas_software_xlib_outbuf_flush(Outbuf *buf, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode render_mode) 752evas_software_xlib_outbuf_flush(Outbuf *buf, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode render_mode EINA_UNUSED)
724{ 753{
725 Eina_List *l; 754 Eina_List *l;
726 RGBA_Image *im; 755 RGBA_Image *im;
727 Outbuf_Region *obr; 756 Outbuf_Region *obr;
728 757
729 if (render_mode == EVAS_RENDER_MODE_ASYNC_INIT) return; 758 eina_spinlock_take(&(buf->priv.lock));
730
731 if ((buf->priv.onebuf) && eina_array_count(&buf->priv.onebuf_regions)) 759 if ((buf->priv.onebuf) && eina_array_count(&buf->priv.onebuf_regions))
732 { 760 {
733 Eina_Rectangle *rect; 761 Eina_Rectangle *rect;
@@ -886,12 +914,14 @@ evas_software_xlib_outbuf_flush(Outbuf *buf, Tilebuf_Rect *rects EINA_UNUSED, Ev
886 } 914 }
887#endif 915#endif
888 } 916 }
917 eina_spinlock_release(&(buf->priv.lock));
889 evas_common_cpu_end_opt(); 918 evas_common_cpu_end_opt();
890} 919}
891 920
892void 921void
893evas_software_xlib_outbuf_idle_flush(Outbuf *buf) 922evas_software_xlib_outbuf_idle_flush(Outbuf *buf)
894{ 923{
924 eina_spinlock_take(&(buf->priv.lock));
895 if (buf->priv.onebuf) 925 if (buf->priv.onebuf)
896 { 926 {
897 RGBA_Image *im; 927 RGBA_Image *im;
@@ -939,6 +969,7 @@ evas_software_xlib_outbuf_idle_flush(Outbuf *buf)
939 } 969 }
940 _clear_xob(0); 970 _clear_xob(0);
941 } 971 }
972 eina_spinlock_release(&(buf->priv.lock));
942} 973}
943 974
944void 975void
@@ -950,6 +981,7 @@ evas_software_xlib_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, i
950 unsigned char *data; 981 unsigned char *data;
951 int bpl = 0, yy; 982 int bpl = 0, yy;
952 983
984 eina_spinlock_take(&(buf->priv.lock));
953 obr = update->extended_info; 985 obr = update->extended_info;
954 if (buf->priv.pal) 986 if (buf->priv.pal)
955 { 987 {
@@ -981,13 +1013,29 @@ evas_software_xlib_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, i
981 buf->priv.mask.g, buf->priv.mask.b, 1013 buf->priv.mask.g, buf->priv.mask.b,
982 PAL_MODE_NONE, buf->rot); 1014 PAL_MODE_NONE, buf->rot);
983 } 1015 }
984 if (!conv_func) return; 1016 if (!conv_func)
1017 {
1018 eina_spinlock_release(&(buf->priv.lock));
1019 return;
1020 }
985 1021
986 if (!obr->xob) return; 1022 if (!obr->xob)
1023 {
1024 eina_spinlock_release(&(buf->priv.lock));
1025 return;
1026 }
987 data = evas_software_xlib_x_output_buffer_data(obr->xob, &bpl); 1027 data = evas_software_xlib_x_output_buffer_data(obr->xob, &bpl);
988 if (!data) return; 1028 if (!data)
1029 {
1030 eina_spinlock_release(&(buf->priv.lock));
1031 return;
1032 }
989 src_data = update->image.data; 1033 src_data = update->image.data;
990 if (!src_data) return; 1034 if (!src_data)
1035 {
1036 eina_spinlock_release(&(buf->priv.lock));
1037 return;
1038 }
991 if (buf->rot == 0) 1039 if (buf->rot == 0)
992 { 1040 {
993 obr->x = x; 1041 obr->x = x;
@@ -1121,6 +1169,7 @@ evas_software_xlib_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, i
1121#else 1169#else
1122 XFlush(buf->priv.x11.xlib.disp); 1170 XFlush(buf->priv.x11.xlib.disp);
1123#endif 1171#endif
1172 eina_spinlock_release(&(buf->priv.lock));
1124} 1173}
1125 1174
1126void 1175void
diff --git a/src/modules/evas/engines/software_x11/evas_xlib_swapper.c b/src/modules/evas/engines/software_x11/evas_xlib_swapper.c
index c60c9d7ee4..6749f8c113 100644
--- a/src/modules/evas/engines/software_x11/evas_xlib_swapper.c
+++ b/src/modules/evas/engines/software_x11/evas_xlib_swapper.c
@@ -59,7 +59,7 @@ _buf_new(X_Swapper *swp, Buffer *buf)
59 buf->bpl = buf->xim->bytes_per_line; 59 buf->bpl = buf->xim->bytes_per_line;
60 60
61 buf->shm_info.shmid = shmget(IPC_PRIVATE, buf->bpl * buf->h, 61 buf->shm_info.shmid = shmget(IPC_PRIVATE, buf->bpl * buf->h,
62 IPC_CREAT | 0777); 62 IPC_CREAT | 0600);
63 if (buf->shm_info.shmid >= 0) 63 if (buf->shm_info.shmid >= 0)
64 { 64 {
65 buf->shm_info.readOnly = False; 65 buf->shm_info.readOnly = False;