Changes in uspace/lib/ui/test/slider.c [1fa6292:5ef85c0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/slider.c
r1fa6292 r5ef85c0 36 36 #include <ui/resource.h> 37 37 #include "../private/slider.h" 38 #include "../private/testgc.h"39 38 40 39 PCUT_INIT; 41 40 42 41 PCUT_TEST_SUITE(slider); 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_slider_moved(ui_slider_t *, void *, gfx_coord_t); … … 50 70 static ui_slider_cb_t dummy_slider_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 { … … 425 462 } 426 463 464 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 465 { 466 (void) arg; 467 (void) rect; 468 return EOK; 469 } 470 471 static errno_t testgc_set_color(void *arg, gfx_color_t *color) 472 { 473 (void) arg; 474 (void) color; 475 return EOK; 476 } 477 478 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect) 479 { 480 (void) arg; 481 (void) rect; 482 return EOK; 483 } 484 485 static errno_t testgc_update(void *arg) 486 { 487 (void) arg; 488 return EOK; 489 } 490 491 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params, 492 gfx_bitmap_alloc_t *alloc, void **rbm) 493 { 494 test_gc_t *tgc = (test_gc_t *) arg; 495 testgc_bitmap_t *tbm; 496 497 tbm = calloc(1, sizeof(testgc_bitmap_t)); 498 if (tbm == NULL) 499 return ENOMEM; 500 501 if (alloc == NULL) { 502 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) * 503 sizeof(uint32_t); 504 tbm->alloc.off0 = 0; 505 tbm->alloc.pixels = calloc(sizeof(uint32_t), 506 (params->rect.p1.x - params->rect.p0.x) * 507 (params->rect.p1.y - params->rect.p0.y)); 508 tbm->myalloc = true; 509 if (tbm->alloc.pixels == NULL) { 510 free(tbm); 511 return ENOMEM; 512 } 513 } else { 514 tbm->alloc = *alloc; 515 } 516 517 tbm->tgc = tgc; 518 tgc->bm_created = true; 519 tgc->bm_params = *params; 520 tgc->bm_pixels = tbm->alloc.pixels; 521 *rbm = (void *)tbm; 522 return EOK; 523 } 524 525 static errno_t testgc_bitmap_destroy(void *bm) 526 { 527 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm; 528 if (tbm->myalloc) 529 free(tbm->alloc.pixels); 530 tbm->tgc->bm_destroyed = true; 531 free(tbm); 532 return EOK; 533 } 534 535 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect, 536 gfx_coord2_t *offs) 537 { 538 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm; 539 tbm->tgc->bm_rendered = true; 540 tbm->tgc->bm_srect = *srect; 541 tbm->tgc->bm_offs = *offs; 542 return EOK; 543 } 544 545 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc) 546 { 547 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm; 548 *alloc = tbm->alloc; 549 tbm->tgc->bm_got_alloc = true; 550 return EOK; 551 } 552 427 553 static void test_slider_moved(ui_slider_t *slider, void *arg, gfx_coord_t pos) 428 554 {
Note:
See TracChangeset
for help on using the changeset viewer.