Changeset 1fa6292 in mainline for uspace/lib/gfxfont/test/tpf.c
- Timestamp:
- 2025-01-28T14:48:04Z (4 weeks ago)
- Branches:
- master
- Children:
- 56210a7
- Parents:
- 97116a2
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2025-01-28 14:46:24)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2025-01-28 14:48:04)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gfxfont/test/tpf.c
r97116a2 r1fa6292 36 36 #include "../private/font.h" 37 37 #include "../private/typeface.h" 38 #include "../private/testgc.h" 38 39 39 40 PCUT_INIT; 40 41 41 42 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_alloc60 };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;74 43 75 44 static const gfx_font_flags_t test_font_flags = gff_bold_italic; … … 211 180 } 212 181 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 285 182 PCUT_EXPORT(tpf);
Note:
See TracChangeset
for help on using the changeset viewer.