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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
|
/****************************************************************************
*
* The MIT License (MIT)
*
* Copyright 2020 NXP
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* 'Software'), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL VIVANTE AND/OR ITS SUPPLIERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
/** Include Files */
#include <stdio.h>
#include <stdlib.h>
#include "vg_lite_text.h"
#include "vft_draw.h"
#include "vft_debug.h"
#ifdef ENABLE_DEBUG_TRACE
/** Macros */
/** Data structures */
typedef enum path_type {
PATH_DONE,
PATH_CLOSE,
MOVE_TO,
MOVE_TO_REL,
LINE_TO,
LINE_TO_REL,
QUAD_TO,
QUAD_TO_REL,
CUBI_TO,
CUBI_TO_REL,
NUM_PATH_CMD
} path_type_t;
/** Internal or external API prototypes */
/** Globals */
static const int data_count[] =
{
0,
0,
2,
2,
2,
2,
4,
4,
6,
6
};
static char s_cmd_name[][16] =
{
{"PATH_DONE" },
{"PATH_CLOSE" },
{"MOVE_TO" },
{"MOVE_TO_REL" },
{"LINE_TO" },
{"LINE_TO_REL" },
{"QUAD_TO" },
{"QUAD_TO_REL" },
{"CUBI_TO" },
{"CUBI_TO_REL" },
{"NUM_PATH_CMD"},
};
/** Externs if any */
/** Code section */
void vfg_dbg_path_data(path_desc_t* path_data_desc, int offset)
{
float* draw_cmds;
draw_cmds = &path_data_desc->draw_cmds[0];
for (int i = 0; i < path_data_desc->num_draw_cmds; i++) {
uint32_t cmd, j;
cmd = *((uint32_t*)(&draw_cmds[i]));
if (cmd < NUM_PATH_CMD) {
TRACE_BIN(("BIN: %08x: %s(%d) [",
offset + i * 4,
s_cmd_name[cmd], cmd));
for (j = 0; j < data_count[cmd]; j++) {
TRACE_BIN((" %.2f", draw_cmds[i + j + 1]));
}
i += j;
TRACE_BIN(("]\n"));
}
}
}
void vft_dbg_path(char *prefix, void *draw_cmds_args, int num_draw_cmds)
{
float* draw_cmds;
draw_cmds = draw_cmds_args;
int offset = 0;
for (int i = 0; i < num_draw_cmds; i++) {
uint32_t cmd, j;
cmd = *((uint32_t*)(&draw_cmds[i]));
if (cmd < NUM_PATH_CMD) {
printf("BIN: %08x: %s(%d) [",
offset + i * 4,
s_cmd_name[cmd], cmd);
for (j = 0; j < data_count[cmd]; j++) {
printf(" %.2f", draw_cmds[i + j + 1]);
}
i += j;
printf("]\n");
}
}
}
void vft_dbg_path_bounds(char *name, float *ary, int num_elements)
{
float* array_data;
array_data = ary;
printf("%s [",name);
for (int i = 0; i < num_elements; i++) {
printf(" %.2f", array_data[i]);
}
printf("]\n");
}
void vft_dbg_kern_desc(kern_desc_t* kern_desc, int num_kern_entries, int offset)
{
for (int i = 0; i < num_kern_entries; i++) {
TRACE_BIN(("BIN: %08x: [%d] (u,k)=(%hu, %hu)\n",
(int)(offset + i * sizeof(kern_desc_t)),
i,
kern_desc[i].unicode,
kern_desc[i].kern));
}
}
void vft_dbg_glyph_desc(glyph_desc_t* g, int offset)
{
glyph_desc_t _desc = *g; /* Temporary copy descriptor*/
TRACE_BIN_FIELD_UINT16(unicode);
TRACE_BIN_FIELD_UINT16(horiz_adv_x);
TRACE_BIN_FIELD_UINT32(kern_num_entries);
TRACE_BIN_FIELD_UINT32(kern_table_offset);
TRACE_BIN_FIELD_FLOAT(path.bounds[0]);
TRACE_BIN_FIELD_FLOAT(path.bounds[1]);
TRACE_BIN_FIELD_FLOAT(path.bounds[2]);
TRACE_BIN_FIELD_FLOAT(path.bounds[3]);
TRACE_BIN_FIELD_UINT32(path.num_draw_cmds);
TRACE_BIN_FIELD_UINT32(path.draw_cmds_offset);
}
/* TRACE values for debugging purpose */
void vft_dbg_font_face_desc(font_face_desc_t* font_face, int offset)
{
font_face_desc_t _desc = *font_face; /* Temporary copy descriptor*/
TRACE_INFO(("font-face-block\n"));
TRACE_BIN_FIELD_STR(font_family_name); offset += sizeof(_desc.font_family_name);
TRACE_BIN_FIELD_UINT16(units_per_em);
TRACE_BIN_FIELD_UINT16(ascent);
TRACE_BIN_FIELD_UINT16(descent);
TRACE_BIN_FIELD_UINT16(vg_font);
TRACE_BIN_FIELD_UINT32(num_glyphs);
}
void vft_dbg_matrix(char *name, vg_lite_matrix_t *mat)
{
printf("%s\n",name);
printf(" %0.3f %0.3f %0.3f\n",
mat->m[0][0],mat->m[0][1],mat->m[0][2]);
printf(" %0.3f %0.3f %0.3f\n",
mat->m[1][0],mat->m[1][1],mat->m[1][2]);
printf(" %0.3f %0.3f %0.3f\n",
mat->m[2][0],mat->m[1][1],mat->m[2][2]);
}
void vft_dbg_path_table(font_face_desc_t* font_face, int offset)
{
TRACE_INFO(("path-block\n"));
for (uint32_t i = 0; i < font_face->num_glyphs; i++) {
glyph_desc_t* g = &font_face->glyphs[i];
TRACE_BIN(("Glyph - path: '%c' unicode = %d\n", g->unicode, g->unicode));
offset = g->path.draw_cmds_offset;
vfg_dbg_path_data(&g->path, offset);
}
}
void vft_dbg_kern_table(font_face_desc_t* font_face, int offset)
{
TRACE_INFO(("kern-block\n"));
for (uint32_t i = 0; i < font_face->num_glyphs; i++) {
glyph_desc_t* g = &font_face->glyphs[i];
TRACE_INFO(("Kern: '%c' unicode=%hu\n", g->unicode, g->unicode));
vft_dbg_kern_desc(&g->kern_table[0],
g->kern_num_entries,
offset);
offset += (g->kern_num_entries * sizeof(kern_desc_t));
}
}
void vft_dbg_glyph_table(font_face_desc_t* font_face, int offset)
{
TRACE_INFO(("glyph-block\n"));
for (uint32_t i = 0; i < font_face->num_glyphs; i++) {
glyph_desc_t* g = &font_face->glyphs[i];
TRACE_INFO(("Glyph: '%c'\n", g->unicode));
vft_dbg_glyph_desc(g, offset);
offset += sizeof(glyph_desc_t);
}
}
int g_offset = 0;
void dbg_float_ary(char *name, float *ary, int count, int *disk_offset)
{
int i;
int offset = *disk_offset;
for (i=0; i<count; i++) {
DBG_TRACE(("DBG: %s[%d]=%f offset=%d\n", \
name, \
i, \
ary[i], offset));
offset+= 4;
}
*disk_offset = offset;
}
void dbg_int_ary(char *name, uint32_t *ary, int count, int *disk_offset)
{
int i;
int offset = *disk_offset;
for (i=0; i<count; i++) {
DBG_TRACE(("DBG: %s[%d]=%d offset=%d\n", \
name, \
i, \
ary[i], offset));
offset+= 4;
}
*disk_offset = offset;
}
void dbg_int_param(char *name, uint32_t value, int *disk_offset)
{
int offset = *disk_offset;
DBG_TRACE(("DBG: %s=%d offset=%d\n", \
name, \
value, offset));
offset+= 4;
*disk_offset = offset;
}
void dbg_float_ary_no_offset_update(char *name, float *ary,
int count, int disk_offset)
{
int i;
int offset = disk_offset;
for (i=0; i<count; i++) {
DBG_TRACE(("DBG: %s[%d]=%f offset=%d\n", \
name, \
i, \
ary[i], offset));
offset+= 4;
}
}
void dbg_int_ary_no_offset_update(char *name, uint32_t *ary,
int count, int disk_offset)
{
int i;
int offset = disk_offset;
for (i=0; i<count; i++) {
DBG_TRACE(("DBG: %s[%d]=%d offset=%d\n", \
name, \
i, \
ary[i], offset));
offset+= 4;
}
}
void dbg_int_param_no_offset_update(char *name, uint32_t value, int disk_offset)
{
int offset = disk_offset;
DBG_TRACE(("DBG: %s=%d offset=%d\n", \
name, \
value, offset));
offset+= 4;
}
#endif
|