summaryrefslogtreecommitdiff
path: root/firmware/drivers/lcd-2bit-vert.c
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-09-26 09:23:18 +0100
committerAidan MacDonald <amachronic@protonmail.com>2022-10-09 22:07:46 +0100
commit4f9e4ddb9914ff73259f006a4cbcf520656f06e0 (patch)
treea2e9bc09589316ffe2f7a9748369dadbe15662fa /firmware/drivers/lcd-2bit-vert.c
parent4b8fe8acd1c079e75bb9229791170c549188fc08 (diff)
downloadrockbox-4f9e4ddb9914ff73259f006a4cbcf520656f06e0.tar.gz
rockbox-4f9e4ddb9914ff73259f006a4cbcf520656f06e0.zip
lcd: Consolidate drawpixel, drawline, and drawrect functions
All three functions are nearly identical regardless of the LCD pixel format. Consolidate them into a generic version in lcd-bitmap-common.c. Change-Id: Iab13429ea27ea2b0150b9004535bd27d4a4121a0
Diffstat (limited to 'firmware/drivers/lcd-2bit-vert.c')
-rw-r--r--firmware/drivers/lcd-2bit-vert.c111
1 files changed, 0 insertions, 111 deletions
diff --git a/firmware/drivers/lcd-2bit-vert.c b/firmware/drivers/lcd-2bit-vert.c
index 5fd86c409a..9e1eb0ed37 100644
--- a/firmware/drivers/lcd-2bit-vert.c
+++ b/firmware/drivers/lcd-2bit-vert.c
@@ -419,102 +419,6 @@ void lcd_clear_viewport(void)
419 lcd_current_viewport->flags &= ~(VP_FLAG_VP_SET_CLEAN); 419 lcd_current_viewport->flags &= ~(VP_FLAG_VP_SET_CLEAN);
420} 420}
421 421
422/* Set a single pixel */
423void lcd_drawpixel(int x, int y)
424{
425 if (lcd_clip_viewport_pixel(&x, &y))
426 lcd_pixelfuncs[lcd_current_viewport->drawmode](x, y);
427}
428
429/* Draw a line */
430void lcd_drawline(int x1, int y1, int x2, int y2)
431{
432 int numpixels;
433 int i;
434 int deltax, deltay;
435 int d, dinc1, dinc2;
436 int x, xinc1, xinc2;
437 int y, yinc1, yinc2;
438 int x_vp, y_vp, w_vp, h_vp;
439 lcd_pixelfunc_type *pfunc = lcd_pixelfuncs[lcd_current_viewport->drawmode];
440
441 deltax = abs(x2 - x1);
442 if (deltax == 0)
443 {
444 /* DEBUGF("lcd_drawline() called for vertical line - optimisation.\n"); */
445 lcd_vline(x1, y1, y2);
446 return;
447 }
448 deltay = abs(y2 - y1);
449 if (deltay == 0)
450 {
451 /* DEBUGF("lcd_drawline() called for horizontal line - optimisation.\n"); */
452 lcd_hline(x1, x2, y1);
453 return;
454 }
455 xinc2 = 1;
456 yinc2 = 1;
457
458 if (deltax >= deltay)
459 {
460 numpixels = deltax;
461 d = 2 * deltay - deltax;
462 dinc1 = deltay * 2;
463 dinc2 = (deltay - deltax) * 2;
464 xinc1 = 1;
465 yinc1 = 0;
466 }
467 else
468 {
469 numpixels = deltay;
470 d = 2 * deltax - deltay;
471 dinc1 = deltax * 2;
472 dinc2 = (deltax - deltay) * 2;
473 xinc1 = 0;
474 yinc1 = 1;
475 }
476 numpixels++; /* include endpoints */
477
478 if (x1 > x2)
479 {
480 xinc1 = -xinc1;
481 xinc2 = -xinc2;
482 }
483
484 if (y1 > y2)
485 {
486 yinc1 = -yinc1;
487 yinc2 = -yinc2;
488 }
489
490 x = x1;
491 y = y1;
492
493 x_vp = lcd_current_viewport->x;
494 y_vp = lcd_current_viewport->y;
495 w_vp = lcd_current_viewport->width;
496 h_vp = lcd_current_viewport->height;
497
498 for (i = 0; i < numpixels; i++)
499 {
500 if (x >= 0 && y >= 0 && x < w_vp && y < h_vp)
501 pfunc(x + x_vp, y + y_vp);
502
503 if (d < 0)
504 {
505 d += dinc1;
506 x += xinc1;
507 y += yinc1;
508 }
509 else
510 {
511 d += dinc2;
512 x += xinc2;
513 y += yinc2;
514 }
515 }
516}
517
518/* Draw a horizontal line (optimised) */ 422/* Draw a horizontal line (optimised) */
519void lcd_hline(int x1, int x2, int y) 423void lcd_hline(int x1, int x2, int y)
520{ 424{
@@ -567,21 +471,6 @@ void lcd_vline(int x, int y1, int y2)
567 bfunc(dst, mask, 0xFFu); 471 bfunc(dst, mask, 0xFFu);
568} 472}
569 473
570/* Draw a rectangular box */
571void lcd_drawrect(int x, int y, int width, int height)
572{
573 if ((width <= 0) || (height <= 0))
574 return;
575
576 int x2 = x + width - 1;
577 int y2 = y + height - 1;
578
579 lcd_vline(x, y, y2);
580 lcd_vline(x2, y, y2);
581 lcd_hline(x, x2, y);
582 lcd_hline(x, x2, y2);
583}
584
585/* Fill a rectangular area */ 474/* Fill a rectangular area */
586void lcd_fillrect(int x, int y, int width, int height) 475void lcd_fillrect(int x, int y, int width, int height)
587{ 476{