Changes in uspace/lib/ui/test/paint.c [1eaead4:1fa6292] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/paint.c
r1eaead4 r1fa6292 34 34 #include <ui/paint.h> 35 35 #include <ui/resource.h> 36 #include "../private/testgc.h" 36 37 37 38 PCUT_INIT; 38 39 39 40 PCUT_TEST_SUITE(paint); 40 41 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);42 static errno_t testgc_set_color(void *, gfx_color_t *);43 static errno_t testgc_fill_rect(void *, gfx_rect_t *);44 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,45 gfx_bitmap_alloc_t *, void **);46 static errno_t testgc_bitmap_destroy(void *);47 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);48 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);49 50 static gfx_context_ops_t ops = {51 .set_clip_rect = testgc_set_clip_rect,52 .set_color = testgc_set_color,53 .fill_rect = testgc_fill_rect,54 .bitmap_create = testgc_bitmap_create,55 .bitmap_destroy = testgc_bitmap_destroy,56 .bitmap_render = testgc_bitmap_render,57 .bitmap_get_alloc = testgc_bitmap_get_alloc58 };59 60 typedef struct {61 bool bm_created;62 bool bm_destroyed;63 gfx_bitmap_params_t bm_params;64 void *bm_pixels;65 gfx_rect_t bm_srect;66 gfx_coord2_t bm_offs;67 bool bm_rendered;68 bool bm_got_alloc;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 41 77 42 /** Test box characters */ … … 591 556 } 592 557 593 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)594 {595 (void) arg;596 (void) rect;597 return EOK;598 }599 600 static errno_t testgc_set_color(void *arg, gfx_color_t *color)601 {602 (void) arg;603 (void) color;604 return EOK;605 }606 607 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)608 {609 (void) arg;610 (void) rect;611 return EOK;612 }613 614 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,615 gfx_bitmap_alloc_t *alloc, void **rbm)616 {617 test_gc_t *tgc = (test_gc_t *) arg;618 testgc_bitmap_t *tbm;619 620 tbm = calloc(1, sizeof(testgc_bitmap_t));621 if (tbm == NULL)622 return ENOMEM;623 624 if (alloc == NULL) {625 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *626 sizeof(uint32_t);627 tbm->alloc.off0 = 0;628 tbm->alloc.pixels = calloc(sizeof(uint32_t),629 (params->rect.p1.x - params->rect.p0.x) *630 (params->rect.p1.y - params->rect.p0.y));631 tbm->myalloc = true;632 if (tbm->alloc.pixels == NULL) {633 free(tbm);634 return ENOMEM;635 }636 } else {637 tbm->alloc = *alloc;638 }639 640 tbm->tgc = tgc;641 tgc->bm_created = true;642 tgc->bm_params = *params;643 tgc->bm_pixels = tbm->alloc.pixels;644 *rbm = (void *)tbm;645 return EOK;646 }647 648 static errno_t testgc_bitmap_destroy(void *bm)649 {650 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;651 if (tbm->myalloc)652 free(tbm->alloc.pixels);653 tbm->tgc->bm_destroyed = true;654 free(tbm);655 return EOK;656 }657 658 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,659 gfx_coord2_t *offs)660 {661 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;662 tbm->tgc->bm_rendered = true;663 tbm->tgc->bm_srect = *srect;664 tbm->tgc->bm_offs = *offs;665 return EOK;666 }667 668 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)669 {670 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;671 *alloc = tbm->alloc;672 tbm->tgc->bm_got_alloc = true;673 return EOK;674 }675 676 558 PCUT_EXPORT(paint);
Note:
See TracChangeset
for help on using the changeset viewer.