summaryrefslogtreecommitdiff
path: root/src/lib/evas/cserve2/evas_cs2.h
blob: 7bd4c51f4dd70961e20552683af7d560f9531513 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
#ifndef EVAS_CS2_H
#define EVAS_CS2_H 1

#include <Eina.h>

#ifdef EVAS_CSERVE2

typedef enum {
   CSERVE2_OPEN = 1,
   CSERVE2_OPENED,
   CSERVE2_SETOPTS,
   CSERVE2_SETOPTSED,
   CSERVE2_LOAD,
   CSERVE2_LOADED,
   CSERVE2_PRELOAD,
   CSERVE2_UNLOAD,
   CSERVE2_CLOSE,
   CSERVE2_FONT_LOAD,
   CSERVE2_FONT_LOADED,
   CSERVE2_FONT_UNLOAD,
   CSERVE2_FONT_GLYPHS_LOAD,
   CSERVE2_FONT_GLYPHS_LOADED,
   CSERVE2_FONT_GLYPHS_USED,
   CSERVE2_STATS,
   CSERVE2_FONT_DEBUG,
   CSERVE2_ERROR
} Message_Type;

typedef enum {
   CSERVE2_NONE,
   CSERVE2_GENERIC,
   CSERVE2_DOES_NOT_EXIST,
   CSERVE2_PERMISSION_DENIED,
   CSERVE2_RESOURCE_ALLOCATION_FAILED,
   CSERVE2_CORRUPT_FILE,
   CSERVE2_UNKNOWN_FORMAT,
   CSERVE2_INVALID_COMMAND,
   CSERVE2_LOADER_DIED,
   CSERVE2_LOADER_EXEC_ERR,
   CSERVE2_INVALID_CACHE, // invalid cserve cache entry
   CSERVE2_FILE_CHANGED,
   CSERVE2_REQUEST_CANCEL
} Error_Type;

struct _Msg_Base {
   int type;
   unsigned int rid;
};

typedef struct _Msg_Base Msg_Base;

struct _Msg_Open {
   Msg_Base base;
   unsigned int file_id;
   int path_offset;
   int key_offset;
};

struct _Msg_Opened {
   Msg_Base base;
   struct {
      int w, h;
      int frame_count;
      int loop_count;
      int loop_hint; /* include Evas.h? Copy the enum around? */
      Eina_Bool alpha : 1;
   } image;
};

struct _Msg_Setopts {
   Msg_Base base;
   unsigned int file_id;
   unsigned int image_id;
   struct {
      double dpi;
      int w, h;
      int scale_down;
      int rx, ry, rw, rh;
      int scale_src_x, scale_src_y, scale_src_w, scale_src_h;
      int scale_dst_w, scale_dst_h;
      int scale_smooth;
      int scale_hint;
      Eina_Bool orientation;
   } opts;
};

struct _Msg_Setoptsed {
   Msg_Base base;
};

struct _Msg_Load {
   Msg_Base base;
   unsigned int image_id;
};

struct _Msg_Loaded {
   Msg_Base base;
   struct {
      int mmap_offset;
      int use_offset;
      int mmap_size;
      int image_size;
   } shm;
   Eina_Bool alpha_sparse : 1;
};

struct _Msg_Preload {
   Msg_Base base;
   unsigned int image_id;
};

struct _Msg_Preloaded {
   Msg_Base base;
};

struct _Msg_Unload {
   Msg_Base base;
   unsigned int image_id;
};

struct _Msg_Close {
   Msg_Base base;
   unsigned int file_id;
};

/**
 * @struct _Msg_Font_Load
 *
 * Message from client to request load or unload of a font.
 *
 * The path strings follow the struct inside the message.
 */
struct _Msg_Font_Load {
   Msg_Base base;
   unsigned int sourcelen; // font id
   unsigned int pathlen; // font id
   unsigned int rend_flags; // font id
   unsigned int size; // font id
   unsigned int dpi; // font id
};

/**
 * @struct _Msg_Font_Loaded
 *
 * Message from server to inform that a font was loaded.
 */
struct _Msg_Font_Loaded {
   Msg_Base base;
};

/**
 * @struct _Msg_Font_Glyphs_Request
 *
 * Message from client to request load of glyphs, or inform usage of them.
 *
 * The path strings follow the struct inside the message, as well as
 * the list of glyphs to be loaded.
 */
struct _Msg_Font_Glyphs_Request {
   Msg_Base base;
   unsigned int sourcelen; // font id
   unsigned int pathlen; // font id
   unsigned int rend_flags; // font id
   unsigned int size; // font id
   unsigned int dpi; // font id
   unsigned int hint;
   unsigned int nglyphs;
};

/**
 * @struct _Msg_Font_Glyphs_Loaded
 *
 * Message from server to inform that some glyphs were loaded.
 *
 * This message is quite complex: it contains the font id, representing for
 * which font these glyphs should be loaded, and the number of caches on which
 * the loaded glyphs are stored. Each cache is a SHM segment. The information
 * about each SHM comes serialized just after this struct, and can be read in
 * order as follows:
 *
 * shm name:
 *  - unsigned int size;
 *  - char name[];
 * glyphs:
 *  - unsigned int nglyphs;
 *  - struct {
 *      unsigned int index;
 *      unsigned int offset;
 *      unsigned int size;
 *      unsigned int rows;
 *      unsigned int width;
 *      unsigned int pitch;
 *      unsigned int num_grays;
 *      unsigned int pixel_mode;
 *    } glarray[];
 */
struct _Msg_Font_Glyphs_Loaded {
   Msg_Base base;
   unsigned int ncaches;
};

struct _Msg_Stats {
   Msg_Base base;
   struct {
      unsigned int requested_size;
      unsigned int real_size;
      unsigned int unused_size;
      unsigned int fonts_loaded; /* number of loaded fonts */
      unsigned int fonts_unused; /* number of loaded fonts without reference
                                  * from any clients */
      int fonts_load_time; /* total time spent loading fonts */
      int fonts_used_load_time; /* total time spent loading fonts that are
                                 * really used, i.e. fonts that have glyphs
                                 * rendered */
      int fonts_used_saved_time;
      int glyphs_request_time; /* time spent waiting for glyph requests */
      int glyphs_load_time; /* total time spent loading glyphs */
      int glyphs_render_time; /* total time spent rendering glyphs */
      int glyphs_slave_time; /* total time spent on the slave processing glyph load requests */
      int glyphs_saved_time; /* total time spent loading glyphs */
   } fonts;
   struct {
      unsigned int files_loaded; /* number of file headers loaded */
      unsigned int images_loaded; /* number of image data loaded */
      unsigned int images_unused; /* number of image data loaded and unused */

      unsigned int requested_size; /* memory usage originally requested by
                                    * the client */
      unsigned int files_size; /* memory usage from image headers */
      unsigned int images_size; /* memory usage from image data */
      unsigned int unused_size; /* memory usage from image data */

      int files_load_time;
      int files_saved_time;
      int images_load_time;
      int images_saved_time;
   } images;
};

/*
 * @struct _Msg_Font_Debug
 *
 * Message from server containing all font cache info.
 *
 * Content of the message follows:
 *
 * * number of font entries;
 * * each font entry:
 *   - unsigned int filelen
 *   - const char file
 *   - unsigned int namelen
 *   - const char name
 *   - unsigned int rend_flags;
 *   - unsigned int size;
 *   - unsigned int dpi;
 *   - unsigned int unused;
 *   - ncaches:
 *   - each cache:
 *     * usigned int shmnamelen;
 *     * const char shmname;
 *     * unsigned int size;
 *     * unsigned int usage;
 *     * unsigned int nglyphs;
 *     * each glyph:
 *       - unsigned int index;
 *       - unsigned int offset;
 *       - unsigned int size;
 *       - unsigned int rows;
 *       - unsigned int width;
 *       - unsigned int pitch;
 *       - unsigned int num_grays;
 *       - unsigned int pixel_mode;
 */
struct _Msg_Font_Debug {
    Msg_Base base;
};

struct _Msg_Error {
   Msg_Base base;
   int error;
};

typedef struct _Msg_Open Msg_Open;
typedef struct _Msg_Opened Msg_Opened;
typedef struct _Msg_Setopts Msg_Setopts;
typedef struct _Msg_Setoptsed Msg_Setoptsed;
typedef struct _Msg_Load Msg_Load;
typedef struct _Msg_Loaded Msg_Loaded;
typedef struct _Msg_Preload Msg_Preload;
typedef struct _Msg_Preloaded Msg_Preloaded;
typedef struct _Msg_Unload Msg_Unload;
typedef struct _Msg_Close Msg_Close;
typedef struct _Msg_Font_Load Msg_Font_Load;
typedef struct _Msg_Font_Loaded Msg_Font_Loaded;
typedef struct _Msg_Font_Glyphs_Request Msg_Font_Glyphs_Request;
typedef struct _Msg_Font_Glyphs_Loaded Msg_Font_Glyphs_Loaded;
typedef struct _Msg_Stats Msg_Stats;
typedef struct _Msg_Font_Debug Msg_Font_Debug;
typedef struct _Msg_Error Msg_Error;

#endif
#endif