summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-10-07 15:59:13 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2013-10-28 15:47:16 +0900
commit6b6e33e262387380af4507e94a123a352ac6ee1c (patch)
treeca5239ef78104d012135dc977135a2a54dd14de5 /src/lib/evas/common
parente74cac57e412bcd71f2cc58ba46d326aef0996c4 (diff)
evas/cserve2: Fix refcount for glyphs & glyph buffers
Maybe a little overkill on the iterations (ref/unref), but at least we can really track down which glyphs are currently being used.
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r--src/lib/evas/common/evas_font_draw.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/lib/evas/common/evas_font_draw.c b/src/lib/evas/common/evas_font_draw.c
index 2b8203597a..02f681c93f 100644
--- a/src/lib/evas/common/evas_font_draw.c
+++ b/src/lib/evas/common/evas_font_draw.c
@@ -7,6 +7,10 @@
7 7
8#include "evas_font_ot.h" 8#include "evas_font_ot.h"
9 9
10#ifdef EVAS_CSERVE2
11#include "../cserve2/evas_cs2_private.h"
12#endif
13
10struct _Evas_Glyph 14struct _Evas_Glyph
11{ 15{
12 RGBA_Font_Glyph *fg; 16 RGBA_Font_Glyph *fg;
@@ -227,6 +231,19 @@ evas_common_font_rgba_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y,
227void 231void
228evas_common_font_glyphs_ref(Evas_Glyph_Array *array) 232evas_common_font_glyphs_ref(Evas_Glyph_Array *array)
229{ 233{
234#ifdef EVAS_CSERVE2
235 if (evas_cserve2_use_get() && !array->refcount)
236 {
237 Eina_Iterator *iter;
238 Evas_Glyph *glyph;
239
240 iter = eina_inarray_iterator_new(array->array);
241 EINA_ITERATOR_FOREACH(iter, glyph)
242 evas_cserve2_font_glyph_ref(glyph->fg->glyph_out, EINA_TRUE);
243 eina_iterator_free(iter);
244 }
245#endif
246
230 array->refcount++; 247 array->refcount++;
231} 248}
232 249
@@ -235,6 +252,19 @@ evas_common_font_glyphs_unref(Evas_Glyph_Array *array)
235{ 252{
236 if (--array->refcount) return; 253 if (--array->refcount) return;
237 254
255#ifdef EVAS_CSERVE2
256 if (evas_cserve2_use_get())
257 {
258 Eina_Iterator *iter;
259 Evas_Glyph *glyph;
260
261 iter = eina_inarray_iterator_new(array->array);
262 EINA_ITERATOR_FOREACH(iter, glyph)
263 evas_cserve2_font_glyph_ref(glyph->fg->glyph_out, EINA_FALSE);
264 eina_iterator_free(iter);
265 }
266#endif
267
238 eina_inarray_free(array->array); 268 eina_inarray_free(array->array);
239 evas_common_font_int_unref(array->fi); 269 evas_common_font_int_unref(array->fi);
240 free(array); 270 free(array);
@@ -274,6 +304,18 @@ evas_common_font_draw_prepare(Evas_Text_Props *text_props)
274 if (text_props->len < unit) unit = text_props->len; 304 if (text_props->len < unit) unit = text_props->len;
275 if (text_props->glyphs && text_props->glyphs->refcount == 1) 305 if (text_props->glyphs && text_props->glyphs->refcount == 1)
276 { 306 {
307#ifdef EVAS_CSERVE2
308 if (evas_cserve2_use_get())
309 {
310 Eina_Iterator *iter;
311 Evas_Glyph *glyph;
312
313 iter = eina_inarray_iterator_new(text_props->glyphs->array);
314 EINA_ITERATOR_FOREACH(iter, glyph)
315 evas_cserve2_font_glyph_ref(glyph->fg->glyph_out, EINA_FALSE);
316 eina_iterator_free(iter);
317 }
318#endif
277 glyphs = text_props->glyphs->array; 319 glyphs = text_props->glyphs->array;
278 glyphs->len = 0; 320 glyphs->len = 0;
279 reused_glyphs = EINA_TRUE; 321 reused_glyphs = EINA_TRUE;
@@ -318,6 +360,11 @@ evas_common_font_draw_prepare(Evas_Text_Props *text_props)
318 glyph->idx = idx; 360 glyph->idx = idx;
319 glyph->coord.x = EVAS_FONT_WALK_PEN_X + EVAS_FONT_WALK_X_OFF + EVAS_FONT_WALK_X_BEAR; 361 glyph->coord.x = EVAS_FONT_WALK_PEN_X + EVAS_FONT_WALK_X_OFF + EVAS_FONT_WALK_X_BEAR;
320 glyph->coord.y = EVAS_FONT_WALK_PEN_Y + EVAS_FONT_WALK_Y_OFF + EVAS_FONT_WALK_Y_BEAR; 362 glyph->coord.y = EVAS_FONT_WALK_PEN_Y + EVAS_FONT_WALK_Y_OFF + EVAS_FONT_WALK_Y_BEAR;
363
364#ifdef EVAS_CSERVE2
365 if (reused_glyphs && evas_cserve2_use_get())
366 evas_cserve2_font_glyph_ref(glyph->fg->glyph_out, EINA_TRUE);
367#endif
321 } 368 }
322 EVAS_FONT_WALK_TEXT_END(); 369 EVAS_FONT_WALK_TEXT_END();
323 370
@@ -327,10 +374,11 @@ evas_common_font_draw_prepare(Evas_Text_Props *text_props)
327 374
328 text_props->glyphs = malloc(sizeof(*text_props->glyphs)); 375 text_props->glyphs = malloc(sizeof(*text_props->glyphs));
329 if (!text_props->glyphs) goto error; 376 if (!text_props->glyphs) goto error;
330 text_props->glyphs->refcount = 1; 377 text_props->glyphs->refcount = 0;
331 text_props->glyphs->array = glyphs; 378 text_props->glyphs->array = glyphs;
332 text_props->glyphs->fi = fi; 379 text_props->glyphs->fi = fi;
333 fi->references++; 380 fi->references++;
381 evas_common_font_glyphs_ref(text_props->glyphs);
334 } 382 }
335 383
336 /* check if there's a request queue in fi, if so ask cserve2 to render 384 /* check if there's a request queue in fi, if so ask cserve2 to render