summaryrefslogtreecommitdiff
path: root/src/lib/evas/cserve2/evas_cs2_utils.c
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-11-04 11:51:42 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-11-04 11:51:42 +0000
commitc15e9c6575c3b5f39ded167dda5259de3de96151 (patch)
tree5115d7ae3620af24c2bc094cd062575af7adeda9 /src/lib/evas/cserve2/evas_cs2_utils.c
parenta5ac6a987caec5a7f7596a25d0a065b9cc94c50c (diff)
merge: and now Evas
I've tested make -j 3 install and it works nicely I've tested expedite with software and opengl xlib, and it works. Not tested other engines, so please report any problems (engines or other) on the ML. TODO: examples and tests, I'll add them later ISSUE: Eina_Unicode size check. It indirectly depends on eina_config.h, which is created at the end of the configure script. So its size is always 0. I don't know how that size is used, so I can't do a lot, for now. SVN revision: 78895
Diffstat (limited to 'src/lib/evas/cserve2/evas_cs2_utils.c')
-rw-r--r--src/lib/evas/cserve2/evas_cs2_utils.c121
1 files changed, 121 insertions, 0 deletions
diff --git a/src/lib/evas/cserve2/evas_cs2_utils.c b/src/lib/evas/cserve2/evas_cs2_utils.c
new file mode 100644
index 0000000000..b1a3df28ea
--- /dev/null
+++ b/src/lib/evas/cserve2/evas_cs2_utils.c
@@ -0,0 +1,121 @@
1/* THIS FILE TO BE SHARED WITH THE BIN PART. KEEP IT CLEAN. THERE BE DRAGONS */
2
3#ifdef HAVE_CONFIG_H
4# include "config.h"
5#endif
6
7#include <stdlib.h>
8#include <Eina.h>
9
10#include "evas_cs2_utils.h"
11
12/* fash */
13typedef struct _Fash_Glyph_Map Fash_Glyph_Map;
14typedef struct _Fash_Glyph_Map2 Fash_Glyph_Map2;
15
16struct _Fash_Glyph_Map
17{
18 void *item[256];
19};
20
21struct _Fash_Glyph_Map2
22{
23 Fash_Glyph_Map *bucket[256];
24};
25
26struct _Fash_Glyph2
27{
28 Fash_Glyph_Map2 *bucket[256];
29 void (*free_cb)(void *glyph);
30};
31
32static void
33_fash_item_free(Fash_Glyph2 *fash, Fash_Glyph_Map *map)
34{
35 int i;
36
37 if (fash->free_cb)
38 for (i = 0; i < 256; i++)
39 if (map->item[i])
40 fash->free_cb(map->item[i]);
41 free(map);
42}
43
44static void
45_fash_gl2_free(Fash_Glyph2 *fash, Fash_Glyph_Map2 *fash2)
46{
47 int i;
48
49 for (i = 0; i < 256; i++)
50 if (fash2->bucket[i]) _fash_item_free(fash, fash2->bucket[i]);
51 free(fash2);
52}
53
54void
55fash_gl_free(Fash_Glyph2 *fash)
56{
57 int i;
58
59 for (i = 0; i < 256; i++)
60 if (fash->bucket[i]) _fash_gl2_free(fash, fash->bucket[i]);
61 free(fash);
62}
63
64Fash_Glyph2 *
65fash_gl_new(void (*free_cb)(void *glyph))
66{
67 Fash_Glyph2 *fash = calloc(1, sizeof(Fash_Glyph2));
68 fash->free_cb = free_cb;
69 return fash;
70}
71
72void *
73fash_gl_find(Fash_Glyph2 *fash, int item)
74{
75 int grp, maj, min;
76
77 // 24bits for unicode - v6 up to E01EF (chrs) & 10FFFD for private use (plane 16)
78 grp = (item >> 16) & 0xff;
79 maj = (item >> 8) & 0xff;
80 min = item & 0xff;
81 if (!fash->bucket[grp]) return NULL;
82 if (!fash->bucket[grp]->bucket[maj]) return NULL;
83 return fash->bucket[grp]->bucket[maj]->item[min];
84}
85
86void
87fash_gl_add(Fash_Glyph2 *fash, int item, void *glyph)
88{
89 int grp, maj, min;
90
91 // 24bits for unicode - v6 up to E01EF (chrs) & 10FFFD for private use (plane 16)
92 grp = (item >> 16) & 0xff;
93 maj = (item >> 8) & 0xff;
94 min = item & 0xff;
95 if (!fash->bucket[grp])
96 fash->bucket[grp] = calloc(1, sizeof(Fash_Glyph_Map2));
97 EINA_SAFETY_ON_NULL_RETURN(fash->bucket[grp]);
98 if (!fash->bucket[grp]->bucket[maj])
99 fash->bucket[grp]->bucket[maj] = calloc(1, sizeof(Fash_Glyph_Map));
100 EINA_SAFETY_ON_NULL_RETURN(fash->bucket[grp]->bucket[maj]);
101 fash->bucket[grp]->bucket[maj]->item[min] = glyph;
102}
103
104void
105fash_gl_del(Fash_Glyph2 *fash, int item)
106{
107 int grp, maj, min;
108 void *data;
109
110 // 24bits for unicode - v6 up to E01EF (chrs) & 10FFFD for private use (plane 16)
111 grp = (item >> 16) & 0xff;
112 maj = (item >> 8) & 0xff;
113 min = item & 0xff;
114 if (!fash->bucket[grp]) return;
115 if (!fash->bucket[grp]->bucket[maj]) return;
116 if (!fash->bucket[grp]->bucket[maj]->item[min]) return;
117
118 data = fash->bucket[grp]->bucket[maj]->item[min];
119 fash->free_cb(data);
120 fash->bucket[grp]->bucket[maj]->item[min] = NULL;
121}