diff options
Diffstat (limited to 'apps/plugins/lib/grey_draw.c')
-rw-r--r-- | apps/plugins/lib/grey_draw.c | 78 |
1 files changed, 31 insertions, 47 deletions
diff --git a/apps/plugins/lib/grey_draw.c b/apps/plugins/lib/grey_draw.c index 9b8acd4c37..335d6d1b20 100644 --- a/apps/plugins/lib/grey_draw.c +++ b/apps/plugins/lib/grey_draw.c | |||
@@ -30,17 +30,17 @@ | |||
30 | 30 | ||
31 | static void setpixel(unsigned char *address) | 31 | static void setpixel(unsigned char *address) |
32 | { | 32 | { |
33 | *address = _grey_info.fg_val; | 33 | *address = _grey_info.fg_brightness; |
34 | } | 34 | } |
35 | 35 | ||
36 | static void clearpixel(unsigned char *address) | 36 | static void clearpixel(unsigned char *address) |
37 | { | 37 | { |
38 | *address = _grey_info.bg_val; | 38 | *address = _grey_info.bg_brightness; |
39 | } | 39 | } |
40 | 40 | ||
41 | static void flippixel(unsigned char *address) | 41 | static void flippixel(unsigned char *address) |
42 | { | 42 | { |
43 | *address = 128 - *address; | 43 | *address = ~(*address); |
44 | } | 44 | } |
45 | 45 | ||
46 | static void nopixel(unsigned char *address) | 46 | static void nopixel(unsigned char *address) |
@@ -59,7 +59,7 @@ void (* const _grey_pixelfuncs[8])(unsigned char *address) = { | |||
59 | void grey_clear_display(void) | 59 | void grey_clear_display(void) |
60 | { | 60 | { |
61 | int value = (_grey_info.drawmode & DRMODE_INVERSEVID) ? | 61 | int value = (_grey_info.drawmode & DRMODE_INVERSEVID) ? |
62 | _grey_info.fg_val : _grey_info.bg_val; | 62 | _grey_info.fg_brightness : _grey_info.bg_brightness; |
63 | 63 | ||
64 | _grey_info.rb->memset(_grey_info.buffer, value, | 64 | _grey_info.rb->memset(_grey_info.buffer, value, |
65 | _GREY_MULUQ(_grey_info.width, _grey_info.height)); | 65 | _GREY_MULUQ(_grey_info.width, _grey_info.height)); |
@@ -179,7 +179,7 @@ void grey_hline(int x1, int x2, int y) | |||
179 | if (_grey_info.drawmode & DRMODE_BG) | 179 | if (_grey_info.drawmode & DRMODE_BG) |
180 | { | 180 | { |
181 | fillopt = true; | 181 | fillopt = true; |
182 | value = _grey_info.bg_val; | 182 | value = _grey_info.bg_brightness; |
183 | } | 183 | } |
184 | } | 184 | } |
185 | else | 185 | else |
@@ -187,7 +187,7 @@ void grey_hline(int x1, int x2, int y) | |||
187 | if (_grey_info.drawmode & DRMODE_FG) | 187 | if (_grey_info.drawmode & DRMODE_FG) |
188 | { | 188 | { |
189 | fillopt = true; | 189 | fillopt = true; |
190 | value = _grey_info.fg_val; | 190 | value = _grey_info.fg_brightness; |
191 | } | 191 | } |
192 | } | 192 | } |
193 | pfunc = _grey_pixelfuncs[_grey_info.drawmode]; | 193 | pfunc = _grey_pixelfuncs[_grey_info.drawmode]; |
@@ -361,7 +361,7 @@ void grey_fillrect(int x, int y, int width, int height) | |||
361 | if (_grey_info.drawmode & DRMODE_BG) | 361 | if (_grey_info.drawmode & DRMODE_BG) |
362 | { | 362 | { |
363 | fillopt = true; | 363 | fillopt = true; |
364 | value = _grey_info.bg_val; | 364 | value = _grey_info.bg_brightness; |
365 | } | 365 | } |
366 | } | 366 | } |
367 | else | 367 | else |
@@ -369,7 +369,7 @@ void grey_fillrect(int x, int y, int width, int height) | |||
369 | if (_grey_info.drawmode & DRMODE_FG) | 369 | if (_grey_info.drawmode & DRMODE_FG) |
370 | { | 370 | { |
371 | fillopt = true; | 371 | fillopt = true; |
372 | value = _grey_info.fg_val; | 372 | value = _grey_info.fg_brightness; |
373 | } | 373 | } |
374 | } | 374 | } |
375 | pfunc = _grey_pixelfuncs[_grey_info.drawmode]; | 375 | pfunc = _grey_pixelfuncs[_grey_info.drawmode]; |
@@ -514,16 +514,9 @@ void grey_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
514 | 514 | ||
515 | do | 515 | do |
516 | { | 516 | { |
517 | const unsigned char *src_row = src; | 517 | _grey_info.rb->memcpy(dst, src, width); |
518 | unsigned char *dst_row = dst; | ||
519 | unsigned char *row_end = dst_row + width; | ||
520 | |||
521 | do | ||
522 | *dst_row++ = _grey_info.gvalue[*src_row++]; | ||
523 | while (dst_row < row_end); | ||
524 | |||
525 | src += stride; | ||
526 | dst += _grey_info.width; | 518 | dst += _grey_info.width; |
519 | src += stride; | ||
527 | } | 520 | } |
528 | while (dst < dst_end); | 521 | while (dst < dst_end); |
529 | } | 522 | } |
@@ -578,39 +571,27 @@ void grey_putsxy(int x, int y, const unsigned char *str) | |||
578 | 571 | ||
579 | /*** Unbuffered drawing functions ***/ | 572 | /*** Unbuffered drawing functions ***/ |
580 | 573 | ||
581 | #ifdef SIMULATOR | ||
582 | |||
583 | /* Clear the whole display */ | ||
584 | void grey_ub_clear_display(void) | ||
585 | { | ||
586 | grey_clear_display(); | ||
587 | grey_update(); | ||
588 | } | ||
589 | |||
590 | /* Draw a partial greyscale bitmap, canonical format */ | ||
591 | void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | ||
592 | int stride, int x, int y, int width, int height) | ||
593 | { | ||
594 | grey_gray_bitmap_part(src, src_x, src_y, stride, x, y, width, height); | ||
595 | grey_update_rect(x, y, width, height); | ||
596 | } | ||
597 | |||
598 | #else /* !SIMULATOR */ | ||
599 | |||
600 | /* Clear the greyscale display (sets all pixels to white) */ | 574 | /* Clear the greyscale display (sets all pixels to white) */ |
601 | void grey_ub_clear_display(void) | 575 | void grey_ub_clear_display(void) |
602 | { | 576 | { |
603 | int value = (_grey_info.drawmode & DRMODE_INVERSEVID) ? | 577 | int value = _grey_info.gvalue[(_grey_info.drawmode & DRMODE_INVERSEVID) ? |
604 | _grey_info.fg_val : _grey_info.bg_val; | 578 | _grey_info.fg_brightness : |
605 | 579 | _grey_info.bg_brightness]; | |
580 | |||
606 | _grey_info.rb->memset(_grey_info.values, value, | 581 | _grey_info.rb->memset(_grey_info.values, value, |
607 | _GREY_MULUQ(_grey_info.width, _grey_info.height)); | 582 | _GREY_MULUQ(_grey_info.width, _grey_info.height)); |
583 | #ifdef SIMULATOR | ||
584 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, | ||
585 | _grey_info.width, _grey_info.height); | ||
586 | #endif | ||
608 | } | 587 | } |
609 | 588 | ||
610 | /* Draw a partial greyscale bitmap, canonical format */ | 589 | /* Draw a partial greyscale bitmap, canonical format */ |
611 | void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | 590 | void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, |
612 | int stride, int x, int y, int width, int height) | 591 | int stride, int x, int y, int width, int height) |
613 | { | 592 | { |
593 | int yc, ye; | ||
594 | |||
614 | /* nothing to draw? */ | 595 | /* nothing to draw? */ |
615 | if ((width <= 0) || (height <= 0) || (x >= _grey_info.width) | 596 | if ((width <= 0) || (height <= 0) || (x >= _grey_info.width) |
616 | || (y >= _grey_info.height) || (x + width <= 0) || (y + height <= 0)) | 597 | || (y >= _grey_info.height) || (x + width <= 0) || (y + height <= 0)) |
@@ -634,15 +615,17 @@ void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
634 | if (y + height > _grey_info.height) | 615 | if (y + height > _grey_info.height) |
635 | height = _grey_info.height - y; | 616 | height = _grey_info.height - y; |
636 | 617 | ||
637 | src += _GREY_MULUQ(stride, src_y) + src_x; /* move starting point */ | 618 | src += _GREY_MULUQ(stride, src_y) + src_x; /* move starting point */ |
619 | yc = y; | ||
620 | ye = y + height; | ||
638 | 621 | ||
639 | do | 622 | do |
640 | { | 623 | { |
641 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING | 624 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING |
642 | int idx = _GREY_MULUQ(_grey_info.width, y) + x; | 625 | int idx = _GREY_MULUQ(_grey_info.width, yc) + x; |
643 | #else | 626 | #else |
644 | int idx = _GREY_MULUQ(_grey_info.width, y & ~_GREY_BMASK) | 627 | int idx = _GREY_MULUQ(_grey_info.width, yc & ~_GREY_BMASK) |
645 | + (x << _GREY_BSHIFT) + (~y & _GREY_BMASK); | 628 | + (x << _GREY_BSHIFT) + (~yc & _GREY_BMASK); |
646 | #endif /* LCD_PIXELFORMAT */ | 629 | #endif /* LCD_PIXELFORMAT */ |
647 | unsigned char *dst_row = _grey_info.values + idx; | 630 | unsigned char *dst_row = _grey_info.values + idx; |
648 | const unsigned char *src_row = src; | 631 | const unsigned char *src_row = src; |
@@ -655,14 +638,15 @@ void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
655 | } | 638 | } |
656 | while (src_row < src_end); | 639 | while (src_row < src_end); |
657 | 640 | ||
658 | y++; | ||
659 | src += stride; | 641 | src += stride; |
660 | } | 642 | } |
661 | while (--height > 0); | 643 | while (++yc < ye); |
644 | #ifdef SIMULATOR | ||
645 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x + x, _grey_info.y + y, | ||
646 | width, height); | ||
647 | #endif | ||
662 | } | 648 | } |
663 | 649 | ||
664 | #endif /* !SIMULATOR */ | ||
665 | |||
666 | /* Draw a full greyscale bitmap, canonical format */ | 650 | /* Draw a full greyscale bitmap, canonical format */ |
667 | void grey_ub_gray_bitmap(const unsigned char *src, int x, int y, int width, | 651 | void grey_ub_gray_bitmap(const unsigned char *src, int x, int y, int width, |
668 | int height) | 652 | int height) |