Changes in uspace/lib/ui/test/checkbox.c [1fa6292:806d761] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/checkbox.c
r1fa6292 r806d761 36 36 #include <ui/resource.h> 37 37 #include "../private/checkbox.h" 38 #include "../private/testgc.h"39 38 40 39 PCUT_INIT; 41 40 42 41 PCUT_TEST_SUITE(checkbox); 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_update(void *); 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 ops = { 54 .set_clip_rect = testgc_set_clip_rect, 55 .set_color = testgc_set_color, 56 .fill_rect = testgc_fill_rect, 57 .update = testgc_update, 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_alloc 62 }; 43 63 44 64 static void test_checkbox_switched(ui_checkbox_t *, void *, bool); … … 50 70 static ui_checkbox_cb_t dummy_checkbox_cb = { 51 71 }; 72 73 typedef struct { 74 bool bm_created; 75 bool bm_destroyed; 76 gfx_bitmap_params_t bm_params; 77 void *bm_pixels; 78 gfx_rect_t bm_srect; 79 gfx_coord2_t bm_offs; 80 bool bm_rendered; 81 bool bm_got_alloc; 82 } test_gc_t; 83 84 typedef struct { 85 test_gc_t *tgc; 86 gfx_bitmap_alloc_t alloc; 87 bool myalloc; 88 } testgc_bitmap_t; 52 89 53 90 typedef struct { … … 512 549 } 513 550 551 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 552 { 553 (void) arg; 554 (void) rect; 555 return EOK; 556 } 557 558 static errno_t testgc_set_color(void *arg, gfx_color_t *color) 559 { 560 (void) arg; 561 (void) color; 562 return EOK; 563 } 564 565 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect) 566 { 567 (void) arg; 568 (void) rect; 569 return EOK; 570 } 571 572 static errno_t testgc_update(void *arg) 573 { 574 (void) arg; 575 return EOK; 576 } 577 578 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params, 579 gfx_bitmap_alloc_t *alloc, void **rbm) 580 { 581 test_gc_t *tgc = (test_gc_t *) arg; 582 testgc_bitmap_t *tbm; 583 584 tbm = calloc(1, sizeof(testgc_bitmap_t)); 585 if (tbm == NULL) 586 return ENOMEM; 587 588 if (alloc == NULL) { 589 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) * 590 sizeof(uint32_t); 591 tbm->alloc.off0 = 0; 592 tbm->alloc.pixels = calloc(sizeof(uint32_t), 593 (params->rect.p1.x - params->rect.p0.x) * 594 (params->rect.p1.y - params->rect.p0.y)); 595 tbm->myalloc = true; 596 if (tbm->alloc.pixels == NULL) { 597 free(tbm); 598 return ENOMEM; 599 } 600 } else { 601 tbm->alloc = *alloc; 602 } 603 604 tbm->tgc = tgc; 605 tgc->bm_created = true; 606 tgc->bm_params = *params; 607 tgc->bm_pixels = tbm->alloc.pixels; 608 *rbm = (void *)tbm; 609 return EOK; 610 } 611 612 static errno_t testgc_bitmap_destroy(void *bm) 613 { 614 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm; 615 if (tbm->myalloc) 616 free(tbm->alloc.pixels); 617 tbm->tgc->bm_destroyed = true; 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_rendered = true; 627 tbm->tgc->bm_srect = *srect; 628 tbm->tgc->bm_offs = *offs; 629 return EOK; 630 } 631 632 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc) 633 { 634 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm; 635 *alloc = tbm->alloc; 636 tbm->tgc->bm_got_alloc = true; 637 return EOK; 638 } 639 514 640 static void test_checkbox_switched(ui_checkbox_t *checkbox, void *arg, 515 641 bool checked)
Note:
See TracChangeset
for help on using the changeset viewer.