Changes in uspace/lib/gfxfont/test/tpf.c [1fa6292:cc73f6d4] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gfxfont/test/tpf.c
r1fa6292 rcc73f6d4 36 36 #include "../private/font.h" 37 37 #include "../private/typeface.h" 38 #include "../private/testgc.h"39 38 40 39 PCUT_INIT; 41 40 42 41 PCUT_TEST_SUITE(tpf); 42 43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 44 static errno_t testgc_set_color(void *, gfx_color_t *); 45 static errno_t testgc_fill_rect(void *, gfx_rect_t *); 46 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *, 47 gfx_bitmap_alloc_t *, void **); 48 static errno_t testgc_bitmap_destroy(void *); 49 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *); 50 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *); 51 52 static gfx_context_ops_t test_ops = { 53 .set_clip_rect = testgc_set_clip_rect, 54 .set_color = testgc_set_color, 55 .fill_rect = testgc_fill_rect, 56 .bitmap_create = testgc_bitmap_create, 57 .bitmap_destroy = testgc_bitmap_destroy, 58 .bitmap_render = testgc_bitmap_render, 59 .bitmap_get_alloc = testgc_bitmap_get_alloc 60 }; 61 62 typedef struct { 63 gfx_bitmap_params_t bm_params; 64 void *bm_pixels; 65 gfx_rect_t bm_srect; 66 gfx_coord2_t bm_offs; 67 } test_gc_t; 68 69 typedef struct { 70 test_gc_t *tgc; 71 gfx_bitmap_alloc_t alloc; 72 bool myalloc; 73 } testgc_bitmap_t; 43 74 44 75 static const gfx_font_flags_t test_font_flags = gff_bold_italic; … … 180 211 } 181 212 213 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 214 { 215 return EOK; 216 } 217 218 static errno_t testgc_set_color(void *arg, gfx_color_t *color) 219 { 220 return EOK; 221 } 222 223 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect) 224 { 225 return EOK; 226 } 227 228 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params, 229 gfx_bitmap_alloc_t *alloc, void **rbm) 230 { 231 test_gc_t *tgc = (test_gc_t *) arg; 232 testgc_bitmap_t *tbm; 233 234 tbm = calloc(1, sizeof(testgc_bitmap_t)); 235 if (tbm == NULL) 236 return ENOMEM; 237 238 if (alloc == NULL) { 239 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) * 240 sizeof(uint32_t); 241 tbm->alloc.off0 = 0; 242 tbm->alloc.pixels = calloc(sizeof(uint32_t), 243 tbm->alloc.pitch * (params->rect.p1.y - params->rect.p0.y)); 244 tbm->myalloc = true; 245 if (tbm->alloc.pixels == NULL) { 246 free(tbm); 247 return ENOMEM; 248 } 249 } else { 250 tbm->alloc = *alloc; 251 } 252 253 tbm->tgc = tgc; 254 tgc->bm_params = *params; 255 tgc->bm_pixels = tbm->alloc.pixels; 256 *rbm = (void *)tbm; 257 return EOK; 258 } 259 260 static errno_t testgc_bitmap_destroy(void *bm) 261 { 262 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm; 263 if (tbm->myalloc) 264 free(tbm->alloc.pixels); 265 free(tbm); 266 return EOK; 267 } 268 269 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect, 270 gfx_coord2_t *offs) 271 { 272 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm; 273 tbm->tgc->bm_srect = *srect; 274 tbm->tgc->bm_offs = *offs; 275 return EOK; 276 } 277 278 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc) 279 { 280 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm; 281 *alloc = tbm->alloc; 282 return EOK; 283 } 284 182 285 PCUT_EXPORT(tpf);
Note:
See TracChangeset
for help on using the changeset viewer.