summaryrefslogtreecommitdiff
path: root/legacy/evas/src/lib/engines/common/evas_pipe.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-10-16 08:57:18 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-10-16 08:57:18 +0000
commit800279c23bdb0e925f112c96516dcc96a5487684 (patch)
tree1fe206b4245ec11b3be67bff7a5100c61c6a4818 /legacy/evas/src/lib/engines/common/evas_pipe.c
parent4c8e4957e79ad572a28b8378b7c45496460693ce (diff)
pthread stuff is no longer optional at all in evas - smae with preload
and async events, but pthread_attr_setaffinity_np is optionally detected and used if there. it's an opti8mization anyway. SVN revision: 78041
Diffstat (limited to '')
-rw-r--r--legacy/evas/src/lib/engines/common/evas_pipe.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/legacy/evas/src/lib/engines/common/evas_pipe.c b/legacy/evas/src/lib/engines/common/evas_pipe.c
index 1cba912606..6803154246 100644
--- a/legacy/evas/src/lib/engines/common/evas_pipe.c
+++ b/legacy/evas/src/lib/engines/common/evas_pipe.c
@@ -1,9 +1,12 @@
1#include "evas_common.h" 1#include "evas_common.h"
2#include <unistd.h> 2#include <unistd.h>
3#include <pthread.h>
4#ifdef HAVE_PTHREAD_AFFINITY
5#include <sched.h>
6#endif
3 7
4#ifdef BUILD_PIPE_RENDER 8#ifdef BUILD_PIPE_RENDER
5 9
6# ifdef BUILD_PTHREAD
7typedef struct _Thinfo 10typedef struct _Thinfo
8{ 11{
9 RGBA_Image *im; 12 RGBA_Image *im;
@@ -14,7 +17,6 @@ typedef struct _Thinfo
14 Eina_Array cutout_trash; 17 Eina_Array cutout_trash;
15 Eina_Array rects_task; 18 Eina_Array rects_task;
16} Thinfo; 19} Thinfo;
17#endif
18 20
19static RGBA_Pipe *evas_common_pipe_add(RGBA_Pipe *pipe, RGBA_Pipe_Op **op); 21static RGBA_Pipe *evas_common_pipe_add(RGBA_Pipe *pipe, RGBA_Pipe_Op **op);
20static void evas_common_pipe_draw_context_copy(RGBA_Draw_Context *dc, RGBA_Pipe_Op *op); 22static void evas_common_pipe_draw_context_copy(RGBA_Draw_Context *dc, RGBA_Pipe_Op *op);
@@ -71,7 +73,6 @@ evas_common_pipe_op_free(RGBA_Pipe_Op *op)
71 evas_common_draw_context_apply_clean_cutouts(&op->context.cutout); 73 evas_common_draw_context_apply_clean_cutouts(&op->context.cutout);
72} 74}
73 75
74#ifdef BUILD_PTHREAD
75/* main api calls */ 76/* main api calls */
76static void * 77static void *
77evas_common_pipe_thread(void *data) 78evas_common_pipe_thread(void *data)
@@ -109,9 +110,7 @@ evas_common_pipe_thread(void *data)
109 } 110 }
110 return NULL; 111 return NULL;
111} 112}
112#endif
113 113
114#ifdef BUILD_PTHREAD
115static Eina_List *im_task = NULL; 114static Eina_List *im_task = NULL;
116static Eina_List *text_task = NULL; 115static Eina_List *text_task = NULL;
117static Thinfo task_thinfo[TH_MAX]; 116static Thinfo task_thinfo[TH_MAX];
@@ -164,13 +163,10 @@ evas_pipe_prepare_push(RGBA_Pipe_Op *op)
164 current++; 163 current++;
165} 164}
166 165
167#endif
168
169static void 166static void
170evas_common_pipe_begin(RGBA_Image *im) 167evas_common_pipe_begin(RGBA_Image *im)
171{ 168{
172#define SZ 128 169#define SZ 128
173#ifdef BUILD_PTHREAD
174 unsigned int x, y, cpu; 170 unsigned int x, y, cpu;
175 RGBA_Pipe_Thread_Info *info; 171 RGBA_Pipe_Thread_Info *info;
176 unsigned int estimatex, estimatey; 172 unsigned int estimatex, estimatey;
@@ -217,21 +213,18 @@ evas_common_pipe_begin(RGBA_Image *im)
217 213
218 /* tell worker threads to start */ 214 /* tell worker threads to start */
219 pthread_barrier_wait(&(thbarrier[0])); 215 pthread_barrier_wait(&(thbarrier[0]));
220#endif
221} 216}
222 217
223EAPI void 218EAPI void
224evas_common_pipe_flush(RGBA_Image *im) 219evas_common_pipe_flush(RGBA_Image *im)
225{ 220{
226 if (!im->cache_entry.pipe) return; 221 if (!im->cache_entry.pipe) return;
227#ifdef BUILD_PTHREAD
228 if (thread_num > 1) 222 if (thread_num > 1)
229 { 223 {
230 /* sync worker threads */ 224 /* sync worker threads */
231 pthread_barrier_wait(&(thbarrier[1])); 225 pthread_barrier_wait(&(thbarrier[1]));
232 } 226 }
233 else 227 else
234#endif
235 { 228 {
236 RGBA_Pipe_Thread_Info info; 229 RGBA_Pipe_Thread_Info info;
237 RGBA_Pipe *p; 230 RGBA_Pipe *p;
@@ -698,7 +691,6 @@ evas_common_pipe_map_render(RGBA_Image *root)
698 evas_common_pipe_flush(root); 691 evas_common_pipe_flush(root);
699} 692}
700 693
701#ifdef BUILD_PTHREAD
702static void* 694static void*
703evas_common_pipe_load(void *data) 695evas_common_pipe_load(void *data)
704{ 696{
@@ -765,14 +757,12 @@ evas_common_pipe_load(void *data)
765 757
766 return NULL; 758 return NULL;
767} 759}
768#endif
769 760
770static volatile int bval = 0; 761static volatile int bval = 0;
771 762
772static void 763static void
773evas_common_pipe_load_do(RGBA_Image *im) 764evas_common_pipe_load_do(RGBA_Image *im)
774{ 765{
775#ifdef BUILD_PTHREAD
776 int i; 766 int i;
777 767
778 for (i = 0; i < thread_num; i++) 768 for (i = 0; i < thread_num; i++)
@@ -783,7 +773,6 @@ evas_common_pipe_load_do(RGBA_Image *im)
783 773
784 /* sync worker threads */ 774 /* sync worker threads */
785 pthread_barrier_wait(&(task_thbarrier[1])); 775 pthread_barrier_wait(&(task_thbarrier[1]));
786#endif
787} 776}
788 777
789EAPI void 778EAPI void
@@ -884,12 +873,16 @@ evas_common_pipe_init(void)
884 for (i = 0; i < thread_num; i++) 873 for (i = 0; i < thread_num; i++)
885 { 874 {
886 pthread_attr_t attr; 875 pthread_attr_t attr;
876#ifdef HAVE_PTHREAD_AFFINITY
887 cpu_set_t cpu; 877 cpu_set_t cpu;
888 878#endif
879
889 pthread_attr_init(&attr); 880 pthread_attr_init(&attr);
881#ifdef HAVE_PTHREAD_AFFINITY
890 CPU_ZERO(&cpu); 882 CPU_ZERO(&cpu);
891 CPU_SET(i % cpunum, &cpu); 883 CPU_SET(i % cpunum, &cpu);
892 pthread_attr_setaffinity_np(&attr, sizeof(cpu), &cpu); 884 pthread_attr_setaffinity_np(&attr, sizeof(cpu), &cpu);
885#endif
893 thinfo[i].thread_num = i; 886 thinfo[i].thread_num = i;
894 thinfo[i].tasks = NULL; 887 thinfo[i].tasks = NULL;
895 thinfo[i].barrier = thbarrier; 888 thinfo[i].barrier = thbarrier;
@@ -904,12 +897,16 @@ evas_common_pipe_init(void)
904 for (i = 0; i < thread_num; i++) 897 for (i = 0; i < thread_num; i++)
905 { 898 {
906 pthread_attr_t attr; 899 pthread_attr_t attr;
900#ifdef HAVE_PTHREAD_AFFINITY
907 cpu_set_t cpu; 901 cpu_set_t cpu;
908 902#endif
909 pthread_attr_init(&attr); 903
904 pthread_attr_init(&attr);
905#ifdef HAVE_PTHREAD_AFFINITY
910 CPU_ZERO(&cpu); 906 CPU_ZERO(&cpu);
911 CPU_SET(i % cpunum, &cpu); 907 CPU_SET(i % cpunum, &cpu);
912 pthread_attr_setaffinity_np(&attr, sizeof(cpu), &cpu); 908 pthread_attr_setaffinity_np(&attr, sizeof(cpu), &cpu);
909#endif
913 task_thinfo[i].thread_num = i; 910 task_thinfo[i].thread_num = i;
914 task_thinfo[i].tasks = NULL; 911 task_thinfo[i].tasks = NULL;
915 task_thinfo[i].barrier = task_thbarrier; 912 task_thinfo[i].barrier = task_thbarrier;