summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-04-01 11:29:50 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-04-01 11:29:50 +0900
commit7166e6b85994b19a29f05c9e2b6d75a314a3cb91 (patch)
tree3e86bef1b03ae8ad58828aa282c7cc016654d93b /src/lib/evas/common
parent13ecefe6700cdafae1b07231774f93429067f7e3 (diff)
evas sw render: fix previous thread fix to be portable
this fixes the fix 4d6a8a7fce51b5654404226668a27d52d1e30eb3 to be portable to platfomrs that do not support __thread - seemingly openbsd does not (argh!) and maybe others. so on these platforms then they dont get the optimization of keeping a cutout rect pool to avoid re-allocation. this also every 4096 draws "resets" the cutout cache so it doesnt expand and stay expanded forever. @fix
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r--src/lib/evas/common/evas_font_draw.c15
-rw-r--r--src/lib/evas/common/evas_map_image.c31
-rw-r--r--src/lib/evas/common/evas_rectangle_main.c39
-rw-r--r--src/lib/evas/common/evas_scale_main.c24
4 files changed, 91 insertions, 18 deletions
diff --git a/src/lib/evas/common/evas_font_draw.c b/src/lib/evas/common/evas_font_draw.c
index bf5141b..c61e921 100644
--- a/src/lib/evas/common/evas_font_draw.c
+++ b/src/lib/evas/common/evas_font_draw.c
@@ -348,7 +348,12 @@ 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;
351 static __thread Cutout_Rects *rects = NULL; 353 static __thread Cutout_Rects *rects = NULL;
354#else
355 Cutout_Rects *rects = NULL;
356#endif
352 int ext_x, ext_y, ext_w, ext_h; 357 int ext_x, ext_y, ext_w, ext_h;
353 int im_w, im_h; 358 int im_w, im_h;
354 RGBA_Gfx_Func func; 359 RGBA_Gfx_Func func;
@@ -412,6 +417,16 @@ evas_common_font_draw_cb(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, E
412 func, r->x, r->y, r->w, r->h, 417 func, r->x, r->y, r->w, r->h,
413 im_w, im_h); 418 im_w, im_h);
414 } 419 }
420#ifdef HAVE_THREAD_SPECIFIER
421 rects_used++;
422 if (rects_used >= 4096)
423 {
424 evas_common_draw_context_cutouts_free(rects);
425 rects = NULL;
426 }
427#else
428 evas_common_draw_context_cutouts_free(rects);
429#endif
415 } 430 }
416 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; 431 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
417 432
diff --git a/src/lib/evas/common/evas_map_image.c b/src/lib/evas/common/evas_map_image.c
index eb94ada..f5b1a32 100644
--- a/src/lib/evas/common/evas_map_image.c
+++ b/src/lib/evas/common/evas_map_image.c
@@ -745,7 +745,12 @@ evas_common_map_rgba_cb(RGBA_Image *src, RGBA_Image *dst,
745 int smooth, int level, 745 int smooth, int level,
746 Evas_Common_Map_RGBA_Cb cb) 746 Evas_Common_Map_RGBA_Cb cb)
747{ 747{
748#ifdef HAVE_THREAD_SPECIFIER
749 static __thread int rects_used = 0;
748 static __thread Cutout_Rects *rects = NULL; 750 static __thread Cutout_Rects *rects = NULL;
751#else
752 Cutout_Rects *rects = NULL;
753#endif
749 Cutout_Rect *r; 754 Cutout_Rect *r;
750 int c, cx, cy, cw, ch; 755 int c, cx, cy, cw, ch;
751 int i; 756 int i;
@@ -784,6 +789,16 @@ evas_common_map_rgba_cb(RGBA_Image *src, RGBA_Image *dst,
784 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h); 789 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
785 cb(src, dst, dc, p, smooth, level); 790 cb(src, dst, dc, p, smooth, level);
786 } 791 }
792#ifdef HAVE_THREAD_SPECIFIER
793 rects_used++;
794 if (rects_used >= 4096)
795 {
796 evas_common_draw_context_cutouts_free(rects);
797 rects = NULL;
798 }
799#else
800 evas_common_draw_context_cutouts_free(rects);
801#endif
787 /* restore clip info */ 802 /* restore clip info */
788 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; 803 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
789} 804}
@@ -791,7 +806,12 @@ evas_common_map_rgba_cb(RGBA_Image *src, RGBA_Image *dst,
791EAPI Eina_Bool 806EAPI Eina_Bool
792evas_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) 807evas_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)
793{ 808{
809#ifdef HAVE_THREAD_SPECIFIER
810 static __thread int rects_used = 0;
794 static __thread Cutout_Rects *rects = NULL; 811 static __thread Cutout_Rects *rects = NULL;
812#else
813 Cutout_Rects *rects = NULL;
814#endif
795 Cutout_Rect *r; 815 Cutout_Rect *r;
796 int c, cx, cy, cw, ch; 816 int c, cx, cy, cw, ch;
797 int i; 817 int i;
@@ -833,7 +853,16 @@ evas_common_map_thread_rgba_cb(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Conte
833 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h); 853 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
834 ret |= cb(src, dst, dc, map, smooth, level, offset); 854 ret |= cb(src, dst, dc, map, smooth, level, offset);
835 } 855 }
836 856#ifdef HAVE_THREAD_SPECIFIER
857 rects_used++;
858 if (rects_used >= 4096)
859 {
860 evas_common_draw_context_cutouts_free(rects);
861 rects = NULL;
862 }
863#else
864 evas_common_draw_context_cutouts_free(rects);
865#endif
837 /* restore clip info */ 866 /* restore clip info */
838 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; 867 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
839 868
diff --git a/src/lib/evas/common/evas_rectangle_main.c b/src/lib/evas/common/evas_rectangle_main.c
index bd4649b..388fba6 100644
--- a/src/lib/evas/common/evas_rectangle_main.c
+++ b/src/lib/evas/common/evas_rectangle_main.c
@@ -12,7 +12,12 @@ 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;
15 static __thread Cutout_Rects *rects = NULL; 17 static __thread Cutout_Rects *rects = NULL;
18#else
19 Cutout_Rects *rects = NULL;
20#endif
16 Cutout_Rect *r; 21 Cutout_Rect *r;
17 int c, cx, cy, cw, ch; 22 int c, cx, cy, cw, ch;
18 int i; 23 int i;
@@ -27,22 +32,32 @@ evas_common_rectangle_draw_cb(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int
27 /* no cutouts - cut right to the chase */ 32 /* no cutouts - cut right to the chase */
28 if (!dc->cutout.rects) 33 if (!dc->cutout.rects)
29 { 34 {
30 cb(dst, dc, x, y, w, h); 35 cb(dst, dc, x, y, w, h);
31 } 36 }
32 else 37 else
33 { 38 {
34 evas_common_draw_context_clip_clip(dc, x, y, w, h); 39 evas_common_draw_context_clip_clip(dc, x, y, w, h);
35 /* our clip is 0 size.. abort */ 40 /* our clip is 0 size.. abort */
36 if ((dc->clip.w > 0) && (dc->clip.h > 0)) 41 if ((dc->clip.w > 0) && (dc->clip.h > 0))
37 { 42 {
38 rects = evas_common_draw_context_apply_cutouts(dc, rects); 43 rects = evas_common_draw_context_apply_cutouts(dc, rects);
39 for (i = 0; i < rects->active; ++i) 44 for (i = 0; i < rects->active; ++i)
40 { 45 {
41 r = rects->rects + i; 46 r = rects->rects + i;
42 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h); 47 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
43 cb(dst, dc, x, y, w, h); 48 cb(dst, dc, x, y, w, h);
44 } 49 }
45 } 50#ifdef HAVE_THREAD_SPECIFIER
51 rects_used++;
52 if (rects_used >= 4096)
53 {
54 evas_common_draw_context_cutouts_free(rects);
55 rects = NULL;
56 }
57#else
58 evas_common_draw_context_cutouts_free(rects);
59#endif
60 }
46 } 61 }
47 /* restore clip info */ 62 /* restore clip info */
48 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; 63 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
diff --git a/src/lib/evas/common/evas_scale_main.c b/src/lib/evas/common/evas_scale_main.c
index bd30a47..6c8a262 100644
--- a/src/lib/evas/common/evas_scale_main.c
+++ b/src/lib/evas/common/evas_scale_main.c
@@ -40,7 +40,12 @@ 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;
43 static __thread Cutout_Rects *rects = NULL; 45 static __thread Cutout_Rects *rects = NULL;
46#else
47 Cutout_Rects *rects = NULL;
48#endif
44 Cutout_Rect *r; 49 Cutout_Rect *r;
45 int c, cx, cy, cw, ch; 50 int c, cx, cy, cw, ch;
46 int i; 51 int i;
@@ -67,20 +72,29 @@ evas_common_scale_rgba_in_to_out_clip_cb(RGBA_Image *src, RGBA_Image *dst,
67 /* our clip is 0 size.. abort */ 72 /* our clip is 0 size.. abort */
68 if ((dc->clip.w <= 0) || (dc->clip.h <= 0)) 73 if ((dc->clip.w <= 0) || (dc->clip.h <= 0))
69 { 74 {
70 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; 75 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
71 return EINA_FALSE; 76 return EINA_FALSE;
72 } 77 }
73 78
74 rects = evas_common_draw_context_apply_cutouts(dc, rects); 79 rects = evas_common_draw_context_apply_cutouts(dc, rects);
75 for (i = 0; i < rects->active; ++i) 80 for (i = 0; i < rects->active; ++i)
76 { 81 {
77 r = rects->rects + i; 82 r = rects->rects + i;
78 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h); 83 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
79 ret |= cb(src, dst, dc, 84 ret |= cb(src, dst, dc,
80 src_region_x, src_region_y, src_region_w, src_region_h, 85 src_region_x, src_region_y, src_region_w, src_region_h,
81 dst_region_x, dst_region_y, dst_region_w, dst_region_h); 86 dst_region_x, dst_region_y, dst_region_w, dst_region_h);
82 } 87 }
83 88#ifdef HAVE_THREAD_SPECIFIER
89 rects_used++;
90 if (rects_used >= 4096)
91 {
92 evas_common_draw_context_cutouts_free(rects);
93 rects = NULL;
94 }
95#else
96 evas_common_draw_context_cutouts_free(rects);
97#endif
84 /* restore clip info */ 98 /* restore clip info */
85 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; 99 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
86 100