Changeset efca2e4 in mainline
- Timestamp:
- 2020-09-25T17:40:47Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- dd65f4f7
- Parents:
- 16357ec
- git-author:
- Jiri Svoboda <jiri@…> (2020-09-24 19:40:35)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-09-25 17:40:47)
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/fontedit/fontedit.c
r16357ec refca2e4 166 166 case KC_4: 167 167 font_edit_adjust_advance(fedit, +1); 168 break; 169 case KC_X: 170 (void) gfx_glyph_bmp_clear(fedit->gbmp); 171 font_edit_paint(fedit); 168 172 break; 169 173 default: -
uspace/lib/gfxfont/include/gfx/glyph_bmp.h
r16357ec refca2e4 49 49 extern errno_t gfx_glyph_bmp_setpix(gfx_glyph_bmp_t *, gfx_coord_t, 50 50 gfx_coord_t, int); 51 extern errno_t gfx_glyph_bmp_clear(gfx_glyph_bmp_t *); 51 52 52 53 #endif -
uspace/lib/gfxfont/src/glyph_bmp.c
r16357ec refca2e4 229 229 } 230 230 231 /** Clear glyph bitmap 232 * 233 * @param bmp Glyph bitmap 234 * 235 * @return EOK on sucesss, ENOMEM if out of memory 236 */ 237 errno_t gfx_glyph_bmp_clear(gfx_glyph_bmp_t *bmp) 238 { 239 int *npixels; 240 241 /* Allocate new pixel array */ 242 npixels = calloc(sizeof(int), 1); 243 if (npixels == NULL) 244 return ENOMEM; 245 246 /* Switch new and old data */ 247 free(bmp->pixels); 248 bmp->pixels = npixels; 249 bmp->rect.p0.x = 0; 250 bmp->rect.p0.y = 0; 251 bmp->rect.p1.x = 0; 252 bmp->rect.p1.y = 0; 253 254 return EOK; 255 } 256 231 257 /** Extend glyph bitmap to cover a patricular pixel. 232 258 * -
uspace/lib/gfxfont/test/glyph_bmp.c
r16357ec refca2e4 342 342 343 343 /** Test glyph_bmp_setpix() properly extends pixel array */ 344 PCUT_TEST(setpix_exte rnd)344 PCUT_TEST(setpix_extend) 345 345 { 346 346 gfx_font_props_t fprops; … … 406 406 } 407 407 } 408 409 gfx_glyph_bmp_close(bmp); 410 411 gfx_glyph_destroy(glyph); 412 413 gfx_font_close(font); 414 gfx_typeface_destroy(tface); 415 rc = gfx_context_delete(gc); 416 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 417 } 418 419 /** Test glyph_bmp_clear() properly clears bitmap */ 420 PCUT_TEST(clear) 421 { 422 gfx_font_props_t fprops; 423 gfx_font_metrics_t fmetrics; 424 gfx_typeface_t *tface; 425 gfx_font_t *font; 426 gfx_glyph_metrics_t gmetrics; 427 gfx_glyph_t *glyph; 428 gfx_context_t *gc; 429 gfx_glyph_bmp_t *bmp; 430 gfx_rect_t rect; 431 test_gc_t tgc; 432 int pix; 433 errno_t rc; 434 435 rc = gfx_context_new(&test_ops, (void *) &tgc, &gc); 436 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 437 438 rc = gfx_typeface_create(gc, &tface); 439 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 440 441 gfx_font_props_init(&fprops); 442 gfx_font_metrics_init(&fmetrics); 443 rc = gfx_font_create(tface, &fprops, &fmetrics, &font); 444 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 445 446 gfx_glyph_metrics_init(&gmetrics); 447 gmetrics.advance = 1; 448 449 rc = gfx_glyph_create(font, &gmetrics, &glyph); 450 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 451 452 bmp = NULL; 453 454 rc = gfx_glyph_bmp_open(glyph, &bmp); 455 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 456 PCUT_ASSERT_NOT_NULL(bmp); 457 458 /* Set some pixels */ 459 460 rc = gfx_glyph_bmp_setpix(bmp, 0, 0, 1); 461 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 462 463 rc = gfx_glyph_bmp_setpix(bmp, 1, 1, 1); 464 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 465 466 /* Clear the bitmap and check */ 467 gfx_glyph_bmp_clear(bmp); 468 469 gfx_glyph_bmp_get_rect(bmp, &rect); 470 PCUT_ASSERT_INT_EQUALS(0, rect.p0.x); 471 PCUT_ASSERT_INT_EQUALS(0, rect.p0.y); 472 PCUT_ASSERT_INT_EQUALS(0, rect.p1.x); 473 PCUT_ASSERT_INT_EQUALS(0, rect.p1.y); 474 475 pix = gfx_glyph_bmp_getpix(bmp, 0, 0); 476 PCUT_ASSERT_INT_EQUALS(0, pix); 477 pix = gfx_glyph_bmp_getpix(bmp, 1, 1); 478 PCUT_ASSERT_INT_EQUALS(0, pix); 408 479 409 480 gfx_glyph_bmp_close(bmp);
Note:
See TracChangeset
for help on using the changeset viewer.