Changes in uspace/lib/gfxfont/test/glyph.c [06b8383:1fa6292] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gfxfont/test/glyph.c
r06b8383 r1fa6292 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 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_color(void *, gfx_color_t *);46 static errno_t testgc_fill_rect(void *, gfx_rect_t *);47 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,48 gfx_bitmap_alloc_t *, void **);49 static errno_t testgc_bitmap_destroy(void *);50 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);51 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);52 53 static gfx_context_ops_t test_ops = {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 45 75 46 /** Test creating and destroying glyph */ … … 569 540 } 570 541 571 static errno_t testgc_set_color(void *arg, gfx_color_t *color)572 {573 return EOK;574 }575 576 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)577 {578 return EOK;579 }580 581 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,582 gfx_bitmap_alloc_t *alloc, void **rbm)583 {584 test_gc_t *tgc = (test_gc_t *) arg;585 testgc_bitmap_t *tbm;586 587 tbm = calloc(1, sizeof(testgc_bitmap_t));588 if (tbm == NULL)589 return ENOMEM;590 591 if (alloc == NULL) {592 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *593 sizeof(uint32_t);594 tbm->alloc.off0 = 0;595 tbm->alloc.pixels = calloc(sizeof(uint32_t),596 tbm->alloc.pitch * (params->rect.p1.y - params->rect.p0.y));597 tbm->myalloc = true;598 if (tbm->alloc.pixels == NULL) {599 free(tbm);600 return ENOMEM;601 }602 } else {603 tbm->alloc = *alloc;604 }605 606 tbm->tgc = tgc;607 tgc->bm_params = *params;608 tgc->bm_pixels = tbm->alloc.pixels;609 *rbm = (void *)tbm;610 return EOK;611 }612 613 static errno_t testgc_bitmap_destroy(void *bm)614 {615 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;616 if (tbm->myalloc)617 free(tbm->alloc.pixels);618 free(tbm);619 return EOK;620 }621 622 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,623 gfx_coord2_t *offs)624 {625 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;626 tbm->tgc->bm_srect = *srect;627 tbm->tgc->bm_offs = *offs;628 return EOK;629 }630 631 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)632 {633 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;634 *alloc = tbm->alloc;635 return EOK;636 }637 638 542 PCUT_EXPORT(glyph);
Note:
See TracChangeset
for help on using the changeset viewer.