Changeset 1fa6292 in mainline for uspace/lib/gfxfont/test/glyph.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/glyph.c
r97116a2 r1fa6292 38 38 #include <str.h> 39 39 #include "../private/glyph.h" 40 #include "../private/testgc.h" 40 41 41 42 PCUT_INIT; 42 43 43 44 PCUT_TEST_SUITE(glyph); 44 45 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);46 static errno_t testgc_set_color(void *, gfx_color_t *);47 static errno_t testgc_fill_rect(void *, gfx_rect_t *);48 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,49 gfx_bitmap_alloc_t *, void **);50 static errno_t testgc_bitmap_destroy(void *);51 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);52 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);53 54 static gfx_context_ops_t test_ops = {55 .set_clip_rect = testgc_set_clip_rect,56 .set_color = testgc_set_color,57 .fill_rect = testgc_fill_rect,58 .bitmap_create = testgc_bitmap_create,59 .bitmap_destroy = testgc_bitmap_destroy,60 .bitmap_render = testgc_bitmap_render,61 .bitmap_get_alloc = testgc_bitmap_get_alloc62 };63 64 typedef struct {65 gfx_bitmap_params_t bm_params;66 void *bm_pixels;67 gfx_rect_t bm_srect;68 gfx_coord2_t bm_offs;69 } test_gc_t;70 71 typedef struct {72 test_gc_t *tgc;73 gfx_bitmap_alloc_t alloc;74 bool myalloc;75 } testgc_bitmap_t;76 45 77 46 /** Test creating and destroying glyph */ … … 571 540 } 572 541 573 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)574 {575 return EOK;576 }577 578 static errno_t testgc_set_color(void *arg, gfx_color_t *color)579 {580 return EOK;581 }582 583 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)584 {585 return EOK;586 }587 588 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,589 gfx_bitmap_alloc_t *alloc, void **rbm)590 {591 test_gc_t *tgc = (test_gc_t *) arg;592 testgc_bitmap_t *tbm;593 594 tbm = calloc(1, sizeof(testgc_bitmap_t));595 if (tbm == NULL)596 return ENOMEM;597 598 if (alloc == NULL) {599 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *600 sizeof(uint32_t);601 tbm->alloc.off0 = 0;602 tbm->alloc.pixels = calloc(sizeof(uint32_t),603 tbm->alloc.pitch * (params->rect.p1.y - params->rect.p0.y));604 tbm->myalloc = true;605 if (tbm->alloc.pixels == NULL) {606 free(tbm);607 return ENOMEM;608 }609 } else {610 tbm->alloc = *alloc;611 }612 613 tbm->tgc = tgc;614 tgc->bm_params = *params;615 tgc->bm_pixels = tbm->alloc.pixels;616 *rbm = (void *)tbm;617 return EOK;618 }619 620 static errno_t testgc_bitmap_destroy(void *bm)621 {622 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;623 if (tbm->myalloc)624 free(tbm->alloc.pixels);625 free(tbm);626 return EOK;627 }628 629 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,630 gfx_coord2_t *offs)631 {632 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;633 tbm->tgc->bm_srect = *srect;634 tbm->tgc->bm_offs = *offs;635 return EOK;636 }637 638 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)639 {640 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;641 *alloc = tbm->alloc;642 return EOK;643 }644 645 542 PCUT_EXPORT(glyph);
Note:
See TracChangeset
for help on using the changeset viewer.