Changes in uspace/lib/ui/test/resource.c [e0e612b:1fa6292] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/resource.c
re0e612b r1fa6292 33 33 #include <ui/resource.h> 34 34 #include "../private/resource.h" 35 #include "../private/testgc.h" 35 36 36 37 PCUT_INIT; … … 38 39 PCUT_TEST_SUITE(resource); 39 40 40 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,41 gfx_bitmap_alloc_t *, void **);42 static errno_t testgc_bitmap_destroy(void *);43 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);44 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);45 46 41 static void test_expose(void *); 47 48 static gfx_context_ops_t ops = {49 .bitmap_create = testgc_bitmap_create,50 .bitmap_destroy = testgc_bitmap_destroy,51 .bitmap_render = testgc_bitmap_render,52 .bitmap_get_alloc = testgc_bitmap_get_alloc53 };54 55 typedef struct {56 bool bm_created;57 bool bm_destroyed;58 gfx_bitmap_params_t bm_params;59 void *bm_pixels;60 gfx_rect_t bm_srect;61 gfx_coord2_t bm_offs;62 bool bm_rendered;63 bool bm_got_alloc;64 } test_gc_t;65 66 typedef struct {67 test_gc_t *tgc;68 gfx_bitmap_alloc_t alloc;69 bool myalloc;70 } testgc_bitmap_t;71 42 72 43 typedef struct { … … 240 211 } 241 212 242 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,243 gfx_bitmap_alloc_t *alloc, void **rbm)244 {245 test_gc_t *tgc = (test_gc_t *) arg;246 testgc_bitmap_t *tbm;247 248 tbm = calloc(1, sizeof(testgc_bitmap_t));249 if (tbm == NULL)250 return ENOMEM;251 252 if (alloc == NULL) {253 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *254 sizeof(uint32_t);255 tbm->alloc.off0 = 0;256 tbm->alloc.pixels = calloc(sizeof(uint32_t),257 (params->rect.p1.x - params->rect.p0.x) *258 (params->rect.p1.y - params->rect.p0.y));259 tbm->myalloc = true;260 if (tbm->alloc.pixels == NULL) {261 free(tbm);262 return ENOMEM;263 }264 } else {265 tbm->alloc = *alloc;266 }267 268 tbm->tgc = tgc;269 tgc->bm_created = true;270 tgc->bm_params = *params;271 tgc->bm_pixels = tbm->alloc.pixels;272 *rbm = (void *)tbm;273 return EOK;274 }275 276 static errno_t testgc_bitmap_destroy(void *bm)277 {278 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;279 if (tbm->myalloc)280 free(tbm->alloc.pixels);281 tbm->tgc->bm_destroyed = true;282 free(tbm);283 return EOK;284 }285 286 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,287 gfx_coord2_t *offs)288 {289 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;290 tbm->tgc->bm_rendered = true;291 tbm->tgc->bm_srect = *srect;292 tbm->tgc->bm_offs = *offs;293 return EOK;294 }295 296 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)297 {298 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;299 *alloc = tbm->alloc;300 tbm->tgc->bm_got_alloc = true;301 return EOK;302 }303 304 213 static void test_expose(void *arg) 305 214 {
Note:
See TracChangeset
for help on using the changeset viewer.