Changes in uspace/lib/gfxfont/test/glyph_bmp.c [dd65f4f7:1fa6292] in mainline
- File:
-
- 1 edited
-
uspace/lib/gfxfont/test/glyph_bmp.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gfxfont/test/glyph_bmp.c
rdd65f4f7 r1fa6292 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 34 34 #include <pcut/pcut.h> 35 35 #include "../private/glyph_bmp.h" 36 #include "../private/testgc.h" 36 37 37 38 PCUT_INIT; 38 39 39 40 PCUT_TEST_SUITE(glyph_bmp); 40 41 static errno_t testgc_set_color(void *, gfx_color_t *);42 static errno_t testgc_fill_rect(void *, gfx_rect_t *);43 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,44 gfx_bitmap_alloc_t *, void **);45 static errno_t testgc_bitmap_destroy(void *);46 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);47 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);48 49 static gfx_context_ops_t test_ops = {50 .set_color = testgc_set_color,51 .fill_rect = testgc_fill_rect,52 .bitmap_create = testgc_bitmap_create,53 .bitmap_destroy = testgc_bitmap_destroy,54 .bitmap_render = testgc_bitmap_render,55 .bitmap_get_alloc = testgc_bitmap_get_alloc56 };57 58 typedef struct {59 gfx_bitmap_params_t bm_params;60 void *bm_pixels;61 gfx_rect_t bm_srect;62 gfx_coord2_t bm_offs;63 } test_gc_t;64 65 typedef struct {66 test_gc_t *tgc;67 gfx_bitmap_alloc_t alloc;68 bool myalloc;69 } testgc_bitmap_t;70 41 71 42 /** Test opening and closing glyph bitmap */ … … 583 554 } 584 555 585 static errno_t testgc_set_color(void *arg, gfx_color_t *color)586 {587 return EOK;588 }589 590 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)591 {592 return EOK;593 }594 595 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,596 gfx_bitmap_alloc_t *alloc, void **rbm)597 {598 test_gc_t *tgc = (test_gc_t *) arg;599 testgc_bitmap_t *tbm;600 601 tbm = calloc(1, sizeof(testgc_bitmap_t));602 if (tbm == NULL)603 return ENOMEM;604 605 if (alloc == NULL) {606 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *607 sizeof(uint32_t);608 tbm->alloc.off0 = 0;609 tbm->alloc.pixels = calloc(sizeof(uint32_t),610 tbm->alloc.pitch * (params->rect.p1.y - params->rect.p0.y));611 tbm->myalloc = true;612 if (tbm->alloc.pixels == NULL) {613 free(tbm);614 return ENOMEM;615 }616 } else {617 tbm->alloc = *alloc;618 }619 620 tbm->tgc = tgc;621 tgc->bm_params = *params;622 tgc->bm_pixels = tbm->alloc.pixels;623 *rbm = (void *)tbm;624 return EOK;625 }626 627 static errno_t testgc_bitmap_destroy(void *bm)628 {629 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;630 if (tbm->myalloc)631 free(tbm->alloc.pixels);632 free(tbm);633 return EOK;634 }635 636 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,637 gfx_coord2_t *offs)638 {639 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;640 tbm->tgc->bm_srect = *srect;641 tbm->tgc->bm_offs = *offs;642 return EOK;643 }644 645 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)646 {647 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;648 *alloc = tbm->alloc;649 return EOK;650 }651 652 556 PCUT_EXPORT(glyph_bmp);
Note:
See TracChangeset
for help on using the changeset viewer.
