summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-11-16 16:05:56 -0800
committerCedric BAIL <cedric@osg.samsung.com>2016-11-16 16:05:56 -0800
commit53dd596f437ae53b96d746f0a5cf0963642f76ad (patch)
treedeb3ea334fb4f5e5a2dfc0fb88c81e092f973a07 /src/lib
parent0b6e04d94fc3ff6447b6fbf0fcdbdd8b6958e621 (diff)
evas: reduce usage of __thread directive.
Moved rects caching into draw context to avoid the use of __thread slot. Draw context are defined per thread anyway and should be just fine. This doesn't really change the picture regarding glibc problem when to many __thread are needed, but slightly improve the global picture. Also this patch doesn't affect our performance in expedite benchmark as far as I can tell.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/evas/common/evas_draw_main.c5
-rw-r--r--src/lib/evas/common/evas_font_draw.c24
-rw-r--r--src/lib/evas/common/evas_map_image.c48
-rw-r--r--src/lib/evas/common/evas_rectangle_main.c24
-rw-r--r--src/lib/evas/common/evas_scale_main.c24
-rw-r--r--src/lib/evas/include/evas_common_private.h4
-rw-r--r--src/lib/evas/include/evas_inline.x12
7 files changed, 41 insertions, 100 deletions
diff --git a/src/lib/evas/common/evas_draw_main.c b/src/lib/evas/common/evas_draw_main.c
index 289d6dfdb4..b87c473bd6 100644
--- a/src/lib/evas/common/evas_draw_main.c
+++ b/src/lib/evas/common/evas_draw_main.c
@@ -122,6 +122,10 @@ evas_common_draw_context_dup(RGBA_Draw_Context *dc)
122 pixman_image_ref(dc2->col.pixman_color_image); 122 pixman_image_ref(dc2->col.pixman_color_image);
123#endif 123#endif
124#endif 124#endif
125
126 dc2->cache.rects = NULL;
127 dc2->cache.used = 0;
128
125 return dc2; 129 return dc2;
126} 130}
127 131
@@ -141,6 +145,7 @@ evas_common_draw_context_free(RGBA_Draw_Context *dc)
141#endif 145#endif
142 146
143 evas_common_draw_context_apply_clean_cutouts(&dc->cutout); 147 evas_common_draw_context_apply_clean_cutouts(&dc->cutout);
148 evas_common_draw_context_cutouts_real_free(dc->cache.rects);
144 free(dc); 149 free(dc);
145} 150}
146 151
diff --git a/src/lib/evas/common/evas_font_draw.c b/src/lib/evas/common/evas_font_draw.c
index 79c8900c34..b4b0a994d9 100644
--- a/src/lib/evas/common/evas_font_draw.c
+++ b/src/lib/evas/common/evas_font_draw.c
@@ -348,12 +348,6 @@ error:
348EAPI Eina_Bool 348EAPI Eina_Bool
349evas_common_font_draw_cb(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs, Evas_Common_Font_Draw_Cb cb) 349evas_common_font_draw_cb(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs, Evas_Common_Font_Draw_Cb cb)
350{ 350{
351#ifdef HAVE_THREAD_SPECIFIER
352 static __thread int rects_used = 0;
353 static __thread Cutout_Rects *rects = NULL;
354#else
355 Cutout_Rects *rects = NULL;
356#endif
357 int ext_x, ext_y, ext_w, ext_h; 351 int ext_x, ext_y, ext_w, ext_h;
358 int im_w, im_h; 352 int im_w, im_h;
359 RGBA_Gfx_Func func; 353 RGBA_Gfx_Func func;
@@ -408,26 +402,16 @@ evas_common_font_draw_cb(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, E
408 /* our clip is 0 size.. abort */ 402 /* our clip is 0 size.. abort */
409 if ((dc->clip.w > 0) && (dc->clip.h > 0)) 403 if ((dc->clip.w > 0) && (dc->clip.h > 0))
410 { 404 {
411 rects = evas_common_draw_context_apply_cutouts(dc, rects); 405 dc->cache.rects = evas_common_draw_context_apply_cutouts(dc, dc->cache.rects);
412 for (i = 0; i < rects->active; ++i) 406 for (i = 0; i < dc->cache.rects->active; ++i)
413 { 407 {
414 r = rects->rects + i; 408 r = dc->cache.rects->rects + i;
415 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h); 409 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
416 ret |= cb(dst, dc, x, y, glyphs, 410 ret |= cb(dst, dc, x, y, glyphs,
417 func, r->x, r->y, r->w, r->h, 411 func, r->x, r->y, r->w, r->h,
418 im_w, im_h); 412 im_w, im_h);
419 } 413 }
420#ifdef HAVE_THREAD_SPECIFIER 414 evas_common_draw_context_cache_update(dc);
421 rects_used++;
422 if (rects_used >= 4096)
423 {
424 evas_common_draw_context_cutouts_real_free(rects);
425 rects = NULL;
426 rects_used = 0;
427 }
428#else
429 evas_common_draw_context_cutouts_real_free(rects);
430#endif
431 } 415 }
432 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; 416 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
433 417
diff --git a/src/lib/evas/common/evas_map_image.c b/src/lib/evas/common/evas_map_image.c
index 2a48b20d35..339db5aff4 100644
--- a/src/lib/evas/common/evas_map_image.c
+++ b/src/lib/evas/common/evas_map_image.c
@@ -752,12 +752,6 @@ evas_common_map_rgba_cb(RGBA_Image *src, RGBA_Image *dst,
752 int smooth, int level, 752 int smooth, int level,
753 Evas_Common_Map_RGBA_Cb cb) 753 Evas_Common_Map_RGBA_Cb cb)
754{ 754{
755#ifdef HAVE_THREAD_SPECIFIER
756 static __thread int rects_used = 0;
757 static __thread Cutout_Rects *rects = NULL;
758#else
759 Cutout_Rects *rects = NULL;
760#endif
761 Cutout_Rect *r; 755 Cutout_Rect *r;
762 int c, cx, cy, cw, ch; 756 int c, cx, cy, cw, ch;
763 int i; 757 int i;
@@ -789,24 +783,14 @@ evas_common_map_rgba_cb(RGBA_Image *src, RGBA_Image *dst,
789 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; 783 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
790 return; 784 return;
791 } 785 }
792 rects = evas_common_draw_context_apply_cutouts(dc, rects); 786 dc->cache.rects = evas_common_draw_context_apply_cutouts(dc, dc->cache.rects);
793 for (i = 0; i < rects->active; ++i) 787 for (i = 0; i < dc->cache.rects->active; ++i)
794 { 788 {
795 r = rects->rects + i; 789 r = dc->cache.rects->rects + i;
796 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h); 790 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
797 cb(src, dst, dc, p, smooth, level); 791 cb(src, dst, dc, p, smooth, level);
798 } 792 }
799#ifdef HAVE_THREAD_SPECIFIER 793 evas_common_draw_context_cache_update(dc);
800 rects_used++;
801 if (rects_used >= 4096)
802 {
803 evas_common_draw_context_cutouts_real_free(rects);
804 rects = NULL;
805 rects_used = 0;
806 }
807#else
808 evas_common_draw_context_cutouts_real_free(rects);
809#endif
810 /* restore clip info */ 794 /* restore clip info */
811 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; 795 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
812} 796}
@@ -814,12 +798,6 @@ evas_common_map_rgba_cb(RGBA_Image *src, RGBA_Image *dst,
814EAPI Eina_Bool 798EAPI Eina_Bool
815evas_common_map_thread_rgba_cb(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Map *map, int smooth, int level, int offset, Evas_Common_Map_Thread_RGBA_Cb cb) 799evas_common_map_thread_rgba_cb(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Map *map, int smooth, int level, int offset, Evas_Common_Map_Thread_RGBA_Cb cb)
816{ 800{
817#ifdef HAVE_THREAD_SPECIFIER
818 static __thread int rects_used = 0;
819 static __thread Cutout_Rects *rects = NULL;
820#else
821 Cutout_Rects *rects = NULL;
822#endif
823 Cutout_Rect *r; 801 Cutout_Rect *r;
824 int c, cx, cy, cw, ch; 802 int c, cx, cy, cw, ch;
825 int i; 803 int i;
@@ -854,24 +832,14 @@ evas_common_map_thread_rgba_cb(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Conte
854 return EINA_FALSE; 832 return EINA_FALSE;
855 } 833 }
856 834
857 rects = evas_common_draw_context_apply_cutouts(dc, rects); 835 dc->cache.rects = evas_common_draw_context_apply_cutouts(dc, dc->cache.rects);
858 for (i = 0; i < rects->active; ++i) 836 for (i = 0; i < dc->cache.rects->active; ++i)
859 { 837 {
860 r = rects->rects + i; 838 r = dc->cache.rects->rects + i;
861 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h); 839 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
862 ret |= cb(src, dst, dc, map, smooth, level, offset); 840 ret |= cb(src, dst, dc, map, smooth, level, offset);
863 } 841 }
864#ifdef HAVE_THREAD_SPECIFIER 842 evas_common_draw_context_cache_update(dc);
865 rects_used++;
866 if (rects_used >= 4096)
867 {
868 evas_common_draw_context_cutouts_real_free(rects);
869 rects = NULL;
870 rects_used = 0;
871 }
872#else
873 evas_common_draw_context_cutouts_real_free(rects);
874#endif
875 /* restore clip info */ 843 /* restore clip info */
876 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; 844 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
877 845
diff --git a/src/lib/evas/common/evas_rectangle_main.c b/src/lib/evas/common/evas_rectangle_main.c
index ed78cca58e..29b93e464d 100644
--- a/src/lib/evas/common/evas_rectangle_main.c
+++ b/src/lib/evas/common/evas_rectangle_main.c
@@ -12,12 +12,6 @@ evas_common_rectangle_init(void)
12EAPI void 12EAPI void
13evas_common_rectangle_draw_cb(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, int w, int h, Evas_Common_Rectangle_Draw_Cb cb) 13evas_common_rectangle_draw_cb(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, int w, int h, Evas_Common_Rectangle_Draw_Cb cb)
14{ 14{
15#ifdef HAVE_THREAD_SPECIFIER
16 static __thread int rects_used = 0;
17 static __thread Cutout_Rects *rects = NULL;
18#else
19 Cutout_Rects *rects = NULL;
20#endif
21 Cutout_Rect *r; 15 Cutout_Rect *r;
22 int c, cx, cy, cw, ch; 16 int c, cx, cy, cw, ch;
23 int i; 17 int i;
@@ -40,24 +34,14 @@ evas_common_rectangle_draw_cb(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int
40 /* our clip is 0 size.. abort */ 34 /* our clip is 0 size.. abort */
41 if ((dc->clip.w > 0) && (dc->clip.h > 0)) 35 if ((dc->clip.w > 0) && (dc->clip.h > 0))
42 { 36 {
43 rects = evas_common_draw_context_apply_cutouts(dc, rects); 37 dc->cache.rects = evas_common_draw_context_apply_cutouts(dc, dc->cache.rects);
44 for (i = 0; i < rects->active; ++i) 38 for (i = 0; i < dc->cache.rects->active; ++i)
45 { 39 {
46 r = rects->rects + i; 40 r = dc->cache.rects->rects + i;
47 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h); 41 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
48 cb(dst, dc, x, y, w, h); 42 cb(dst, dc, x, y, w, h);
49 } 43 }
50#ifdef HAVE_THREAD_SPECIFIER 44 evas_common_draw_context_cache_update(dc);
51 rects_used++;
52 if (rects_used >= 4096)
53 {
54 evas_common_draw_context_cutouts_real_free(rects);
55 rects = NULL;
56 rects_used = 0;
57 }
58#else
59 evas_common_draw_context_cutouts_real_free(rects);
60#endif
61 } 45 }
62 } 46 }
63 /* restore clip info */ 47 /* restore clip info */
diff --git a/src/lib/evas/common/evas_scale_main.c b/src/lib/evas/common/evas_scale_main.c
index a09f0c6805..06b20f30e6 100644
--- a/src/lib/evas/common/evas_scale_main.c
+++ b/src/lib/evas/common/evas_scale_main.c
@@ -40,12 +40,6 @@ evas_common_scale_rgba_in_to_out_clip_cb(RGBA_Image *src, RGBA_Image *dst,
40 int dst_region_w, int dst_region_h, 40 int dst_region_w, int dst_region_h,
41 Evas_Common_Scale_In_To_Out_Clip_Cb cb) 41 Evas_Common_Scale_In_To_Out_Clip_Cb cb)
42{ 42{
43#ifdef HAVE_THREAD_SPECIFIER
44 static __thread int rects_used = 0;
45 static __thread Cutout_Rects *rects = NULL;
46#else
47 Cutout_Rects *rects = NULL;
48#endif
49 Cutout_Rect *r; 43 Cutout_Rect *r;
50 int c, cx, cy, cw, ch; 44 int c, cx, cy, cw, ch;
51 int i; 45 int i;
@@ -76,26 +70,16 @@ evas_common_scale_rgba_in_to_out_clip_cb(RGBA_Image *src, RGBA_Image *dst,
76 return EINA_FALSE; 70 return EINA_FALSE;
77 } 71 }
78 72
79 rects = evas_common_draw_context_apply_cutouts(dc, rects); 73 dc->cache.rects = evas_common_draw_context_apply_cutouts(dc, dc->cache.rects);
80 for (i = 0; i < rects->active; ++i) 74 for (i = 0; i < dc->cache.rects->active; ++i)
81 { 75 {
82 r = rects->rects + i; 76 r = dc->cache.rects->rects + i;
83 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h); 77 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
84 ret |= cb(src, dst, dc, 78 ret |= cb(src, dst, dc,
85 src_region_x, src_region_y, src_region_w, src_region_h, 79 src_region_x, src_region_y, src_region_w, src_region_h,
86 dst_region_x, dst_region_y, dst_region_w, dst_region_h); 80 dst_region_x, dst_region_y, dst_region_w, dst_region_h);
87 } 81 }
88#ifdef HAVE_THREAD_SPECIFIER 82 evas_common_draw_context_cache_update(dc);
89 rects_used++;
90 if (rects_used >= 4096)
91 {
92 evas_common_draw_context_cutouts_real_free(rects);
93 rects = NULL;
94 rects_used = 0;
95 }
96#else
97 evas_common_draw_context_cutouts_real_free(rects);
98#endif
99 /* restore clip info */ 83 /* restore clip info */
100 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; 84 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
101 85
diff --git a/src/lib/evas/include/evas_common_private.h b/src/lib/evas/include/evas_common_private.h
index 07ff291761..c0df4ce12d 100644
--- a/src/lib/evas/include/evas_common_private.h
+++ b/src/lib/evas/include/evas_common_private.h
@@ -757,6 +757,10 @@ struct _RGBA_Draw_Context
757 } clip; 757 } clip;
758 Cutout_Rects cutout; 758 Cutout_Rects cutout;
759 struct { 759 struct {
760 Cutout_Rects *rects;
761 int used;
762 } cache;
763 struct {
760 struct { 764 struct {
761 void *(*gl_new) (void *data, RGBA_Font_Glyph *fg); 765 void *(*gl_new) (void *data, RGBA_Font_Glyph *fg);
762 void (*gl_free) (void *ext_dat); 766 void (*gl_free) (void *ext_dat);
diff --git a/src/lib/evas/include/evas_inline.x b/src/lib/evas/include/evas_inline.x
index e60431a10f..8adbd73ae4 100644
--- a/src/lib/evas/include/evas_inline.x
+++ b/src/lib/evas/include/evas_inline.x
@@ -427,6 +427,18 @@ evas_canvas_async_block(Evas_Public_Data *e)
427 } 427 }
428} 428}
429 429
430static inline void
431evas_common_draw_context_cache_update(RGBA_Draw_Context *dc)
432{
433 dc->cache.used++;
434 if (dc->cache.used >= 4096)
435 {
436 evas_common_draw_context_cutouts_real_free(dc->cache.rects);
437 dc->cache.rects = NULL;
438 dc->cache.used = 0;
439 }
440}
441
430#define _EVAS_COLOR_CLAMP(x, y) do { \ 442#define _EVAS_COLOR_CLAMP(x, y) do { \
431 if (x > y) { x = y; bad = 1; } \ 443 if (x > y) { x = y; bad = 1; } \
432 if (x < 0) { x = 0; bad = 1; } } while (0) 444 if (x < 0) { x = 0; bad = 1; } } while (0)