summaryrefslogtreecommitdiff
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
parent13ecefe6700cdafae1b07231774f93429067f7e3 (diff)
downloadefl-7166e6b85994b19a29f05c9e2b6d75a314a3cb91.tar.gz
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
-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 bf5141bf66..c61e92190c 100644
--- a/src/lib/evas/common/evas_font_draw.c
+++ b/src/lib/evas/common/evas_font_draw.c
@@ -348,7 +348,12 @@ error:
EAPI Eina_Bool
evas_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)
{
+#ifdef HAVE_THREAD_SPECIFIER
+ static __thread int rects_used = 0;
static __thread Cutout_Rects *rects = NULL;
+#else
+ Cutout_Rects *rects = NULL;
+#endif
int ext_x, ext_y, ext_w, ext_h;
int im_w, im_h;
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
func, r->x, r->y, r->w, r->h,
im_w, im_h);
}
+#ifdef HAVE_THREAD_SPECIFIER
+ rects_used++;
+ if (rects_used >= 4096)
+ {
+ evas_common_draw_context_cutouts_free(rects);
+ rects = NULL;
+ }
+#else
+ evas_common_draw_context_cutouts_free(rects);
+#endif
}
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_map_image.c b/src/lib/evas/common/evas_map_image.c
index eb94adad54..f5b1a32101 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,
int smooth, int level,
Evas_Common_Map_RGBA_Cb cb)
{
+#ifdef HAVE_THREAD_SPECIFIER
+ static __thread int rects_used = 0;
static __thread Cutout_Rects *rects = NULL;
+#else
+ Cutout_Rects *rects = NULL;
+#endif
Cutout_Rect *r;
int c, cx, cy, cw, ch;
int i;
@@ -784,6 +789,16 @@ evas_common_map_rgba_cb(RGBA_Image *src, RGBA_Image *dst,
evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
cb(src, dst, dc, p, smooth, level);
}
+#ifdef HAVE_THREAD_SPECIFIER
+ rects_used++;
+ if (rects_used >= 4096)
+ {
+ evas_common_draw_context_cutouts_free(rects);
+ rects = NULL;
+ }
+#else
+ evas_common_draw_context_cutouts_free(rects);
+#endif
/* restore clip info */
dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
}
@@ -791,7 +806,12 @@ evas_common_map_rgba_cb(RGBA_Image *src, RGBA_Image *dst,
EAPI Eina_Bool
evas_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)
{
+#ifdef HAVE_THREAD_SPECIFIER
+ static __thread int rects_used = 0;
static __thread Cutout_Rects *rects = NULL;
+#else
+ Cutout_Rects *rects = NULL;
+#endif
Cutout_Rect *r;
int c, cx, cy, cw, ch;
int i;
@@ -833,7 +853,16 @@ evas_common_map_thread_rgba_cb(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Conte
evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
ret |= cb(src, dst, dc, map, smooth, level, offset);
}
-
+#ifdef HAVE_THREAD_SPECIFIER
+ rects_used++;
+ if (rects_used >= 4096)
+ {
+ evas_common_draw_context_cutouts_free(rects);
+ rects = NULL;
+ }
+#else
+ evas_common_draw_context_cutouts_free(rects);
+#endif
/* restore clip info */
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_rectangle_main.c b/src/lib/evas/common/evas_rectangle_main.c
index bd4649baa3..388fba663a 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)
EAPI void
evas_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)
{
+#ifdef HAVE_THREAD_SPECIFIER
+ static __thread int rects_used = 0;
static __thread Cutout_Rects *rects = NULL;
+#else
+ Cutout_Rects *rects = NULL;
+#endif
Cutout_Rect *r;
int c, cx, cy, cw, ch;
int i;
@@ -27,22 +32,32 @@ evas_common_rectangle_draw_cb(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int
/* no cutouts - cut right to the chase */
if (!dc->cutout.rects)
{
- cb(dst, dc, x, y, w, h);
+ cb(dst, dc, x, y, w, h);
}
else
{
- evas_common_draw_context_clip_clip(dc, x, y, w, h);
- /* our clip is 0 size.. abort */
- if ((dc->clip.w > 0) && (dc->clip.h > 0))
- {
+ evas_common_draw_context_clip_clip(dc, x, y, w, h);
+ /* our clip is 0 size.. abort */
+ if ((dc->clip.w > 0) && (dc->clip.h > 0))
+ {
rects = evas_common_draw_context_apply_cutouts(dc, rects);
- for (i = 0; i < rects->active; ++i)
- {
- r = rects->rects + i;
- evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
- cb(dst, dc, x, y, w, h);
- }
- }
+ for (i = 0; i < rects->active; ++i)
+ {
+ r = rects->rects + i;
+ evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
+ cb(dst, dc, x, y, w, h);
+ }
+#ifdef HAVE_THREAD_SPECIFIER
+ rects_used++;
+ if (rects_used >= 4096)
+ {
+ evas_common_draw_context_cutouts_free(rects);
+ rects = NULL;
+ }
+#else
+ evas_common_draw_context_cutouts_free(rects);
+#endif
+ }
}
/* restore clip info */
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 bd30a4778d..6c8a262588 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,
int dst_region_w, int dst_region_h,
Evas_Common_Scale_In_To_Out_Clip_Cb cb)
{
+#ifdef HAVE_THREAD_SPECIFIER
+ static __thread int rects_used = 0;
static __thread Cutout_Rects *rects = NULL;
+#else
+ Cutout_Rects *rects = NULL;
+#endif
Cutout_Rect *r;
int c, cx, cy, cw, ch;
int i;
@@ -67,20 +72,29 @@ evas_common_scale_rgba_in_to_out_clip_cb(RGBA_Image *src, RGBA_Image *dst,
/* our clip is 0 size.. abort */
if ((dc->clip.w <= 0) || (dc->clip.h <= 0))
{
- dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
- return EINA_FALSE;
+ dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
+ return EINA_FALSE;
}
rects = evas_common_draw_context_apply_cutouts(dc, rects);
for (i = 0; i < rects->active; ++i)
{
- r = rects->rects + i;
- evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
+ r = rects->rects + i;
+ evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
ret |= cb(src, dst, dc,
src_region_x, src_region_y, src_region_w, src_region_h,
dst_region_x, dst_region_y, dst_region_w, dst_region_h);
}
-
+#ifdef HAVE_THREAD_SPECIFIER
+ rects_used++;
+ if (rects_used >= 4096)
+ {
+ evas_common_draw_context_cutouts_free(rects);
+ rects = NULL;
+ }
+#else
+ evas_common_draw_context_cutouts_free(rects);
+#endif
/* restore clip info */
dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;