diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/lcd-bitmap-common.c | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c index 75d31e3453..5c2c23a9cf 100644 --- a/firmware/drivers/lcd-bitmap-common.c +++ b/firmware/drivers/lcd-bitmap-common.c | |||
@@ -374,6 +374,13 @@ void LCDFN(update_viewport_rect)(int x, int y, int width, int height) | |||
374 | LCDFN(update_rect)(vp->x + x, vp->y + y, width, height); | 374 | LCDFN(update_rect)(vp->x + x, vp->y + y, width, height); |
375 | } | 375 | } |
376 | 376 | ||
377 | /* helper to align function signatures between mono_bitmap & alpha_bitmap_part */ | ||
378 | static void LCDFN(mono_bmp_part_helper)(const unsigned char *src, int src_x, | ||
379 | int src_y, int stride, int x, int y, int width, int height) | ||
380 | { | ||
381 | LCDFN(mono_bitmap_part)(src, src_x, src_y, stride, x, y, width, height); | ||
382 | } | ||
383 | |||
377 | #ifndef BOOTLOADER | 384 | #ifndef BOOTLOADER |
378 | /* put a string at a given pixel position, skipping first ofs pixel columns */ | 385 | /* put a string at a given pixel position, skipping first ofs pixel columns */ |
379 | static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) | 386 | static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) |
@@ -404,6 +411,15 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) | |||
404 | } | 411 | } |
405 | } | 412 | } |
406 | 413 | ||
414 | void (*bmp_part_fn)(const unsigned char *src, int src_x, int src_y, | ||
415 | int stride, int x, int y, int width, int height); | ||
416 | #if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR) | ||
417 | if (pf->depth) | ||
418 | bmp_part_fn = lcd_alpha_bitmap_part; | ||
419 | else | ||
420 | #endif | ||
421 | bmp_part_fn = LCDFN(mono_bmp_part_helper); | ||
422 | |||
407 | rtl_next_non_diac_width = 0; | 423 | rtl_next_non_diac_width = 0; |
408 | last_non_diacritic_width = 0; | 424 | last_non_diacritic_width = 0; |
409 | /* Mark diacritic and rtl flags for each character */ | 425 | /* Mark diacritic and rtl flags for each character */ |
@@ -411,7 +427,7 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) | |||
411 | { | 427 | { |
412 | bool is_rtl, is_diac; | 428 | bool is_rtl, is_diac; |
413 | const unsigned char *bits; | 429 | const unsigned char *bits; |
414 | int width, base_width, drawmode = 0, base_ofs = 0; | 430 | int width, base_width, base_ofs = 0; |
415 | const unsigned short next_ch = ucs[1]; | 431 | const unsigned short next_ch = ucs[1]; |
416 | 432 | ||
417 | if (x >= LCDFN(current_viewport)->width) | 433 | if (x >= LCDFN(current_viewport)->width) |
@@ -459,6 +475,8 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) | |||
459 | continue; | 475 | continue; |
460 | } | 476 | } |
461 | 477 | ||
478 | bits = font_get_bits(pf, *ucs); | ||
479 | |||
462 | if (is_diac) | 480 | if (is_diac) |
463 | { | 481 | { |
464 | /* XXX: Suggested by amiconn: | 482 | /* XXX: Suggested by amiconn: |
@@ -475,25 +493,17 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) | |||
475 | * buffer using OR, and then draw the final bitmap instead of the | 493 | * buffer using OR, and then draw the final bitmap instead of the |
476 | * chars, without touching the drawmode | 494 | * chars, without touching the drawmode |
477 | **/ | 495 | **/ |
478 | drawmode = LCDFN(current_viewport)->drawmode; | 496 | int drawmode = LCDFN(current_viewport)->drawmode; |
479 | LCDFN(current_viewport)->drawmode = DRMODE_FG; | 497 | LCDFN(current_viewport)->drawmode = DRMODE_FG; |
480 | |||
481 | base_ofs = (base_width - width) / 2; | 498 | base_ofs = (base_width - width) / 2; |
482 | } | ||
483 | 499 | ||
484 | bits = font_get_bits(pf, *ucs); | 500 | bmp_part_fn(bits, ofs, 0, width, x + base_ofs, y, width - ofs, pf->height); |
485 | 501 | ||
486 | #if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR) | 502 | LCDFN(current_viewport)->drawmode = drawmode; |
487 | if (pf->depth) | 503 | } |
488 | lcd_alpha_bitmap_part(bits, ofs, 0, width, x + base_ofs, y, | ||
489 | width - ofs, pf->height); | ||
490 | else | 504 | else |
491 | #endif | ||
492 | LCDFN(mono_bitmap_part)(bits, ofs, 0, width, x + base_ofs, | ||
493 | y, width - ofs, pf->height); | ||
494 | if (is_diac) | ||
495 | { | 505 | { |
496 | LCDFN(current_viewport)->drawmode = drawmode; | 506 | bmp_part_fn(bits, ofs, 0, width, x + base_ofs, y, width - ofs, pf->height); |
497 | } | 507 | } |
498 | 508 | ||
499 | if (next_ch) | 509 | if (next_ch) |
@@ -544,6 +554,15 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) | |||
544 | } | 554 | } |
545 | } | 555 | } |
546 | 556 | ||
557 | void (*bmp_part_fn)(const unsigned char *src, int src_x, int src_y, | ||
558 | int stride, int x, int y, int width, int height); | ||
559 | #if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR) && !defined(DISABLE_ALPHA_BITMAP) | ||
560 | if (pf->depth) | ||
561 | bmp_part_fn = lcd_alpha_bitmap_part; | ||
562 | else | ||
563 | #endif | ||
564 | bmp_part_fn = mono_bmp_part_helper; | ||
565 | |||
547 | /* allow utf but no diacritics or rtl lang */ | 566 | /* allow utf but no diacritics or rtl lang */ |
548 | for (ucs = bidi_l2v(str, 1); *ucs; ucs++) | 567 | for (ucs = bidi_l2v(str, 1); *ucs; ucs++) |
549 | { | 568 | { |
@@ -563,14 +582,8 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) | |||
563 | 582 | ||
564 | bits = font_get_bits(pf, *ucs); | 583 | bits = font_get_bits(pf, *ucs); |
565 | 584 | ||
566 | #if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR) && !defined(DISABLE_ALPHA_BITMAP) | 585 | bmp_part_fn(bits, ofs, 0, width, x, y, width - ofs, pf->height); |
567 | if (pf->depth) | 586 | |
568 | lcd_alpha_bitmap_part(bits, ofs, 0, width, x, y, | ||
569 | width - ofs, pf->height); | ||
570 | else | ||
571 | #endif | ||
572 | LCDFN(mono_bitmap_part)(bits, ofs, 0, width, x, | ||
573 | y, width - ofs, pf->height); | ||
574 | if (next_ch) | 587 | if (next_ch) |
575 | { | 588 | { |
576 | x += width - ofs; | 589 | x += width - ofs; |