summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-01-07 19:35:36 +0000
committerThomas Martitz <kugel@rockbox.org>2010-01-07 19:35:36 +0000
commit5fd54dee4ff3e0299c8b5d6c12e5633728396c72 (patch)
tree126b83a2a83d3df37da4890c53005bd26f2eed62
parent2f2213d63ee6586eb5c4b1c95ac9a8378cec4a16 (diff)
downloadrockbox-5fd54dee4ff3e0299c8b5d6c12e5633728396c72.tar.gz
rockbox-5fd54dee4ff3e0299c8b5d6c12e5633728396c72.zip
e200v2/Fuze: Correct and simplify clipping clipping code in lcd_update_rect().
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24197 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c38
-rw-r--r--firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c40
2 files changed, 39 insertions, 39 deletions
diff --git a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
index 0d990dc538..f4d1a7cf56 100644
--- a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
+++ b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
@@ -493,41 +493,41 @@ void lcd_update(void)
493void lcd_update_rect(int x, int y, int width, int height) 493void lcd_update_rect(int x, int y, int width, int height)
494{ 494{
495 const fb_data *ptr; 495 const fb_data *ptr;
496 int xmax, ymax;
497 496
498 if (!display_on) 497 if (!display_on)
499 return; 498 return;
500 499
501 xmax = x + width; 500 /* nothing to draw? */
502 if (xmax >= LCD_WIDTH) 501 if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) ||
503 xmax = LCD_WIDTH - 1; /* Clip right */ 502 (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0))
504 if (x < 0) 503 return;
505 x = 0; /* Clip left */
506 if (x >= xmax)
507 return; /* nothing left to do */
508
509 width = xmax - x + 1; /* Fix width */
510 504
511 ymax = y + height; 505 if (x < 0)
512 if (ymax >= LCD_HEIGHT) 506 { /* clip left */
513 ymax = LCD_HEIGHT - 1; /* Clip bottom */ 507 width += x;
508 x = 0;
509 }
514 if (y < 0) 510 if (y < 0)
515 y = 0; /* Clip top */ 511 { /* clip top */
516 if (y >= ymax) 512 height += y;
517 return; /* nothing left to do */ 513 y = 0;
514 }
515 if (x + width > LCD_WIDTH)
516 width = LCD_WIDTH - x; /* clip right */
517 if (y + height > LCD_HEIGHT)
518 height = LCD_HEIGHT - y; /* clip bottom */
518 519
519 lcd_write_reg(R_ENTRY_MODE, r_entry_mode); 520 lcd_write_reg(R_ENTRY_MODE, r_entry_mode);
520 521
521 lcd_window(x, y, xmax, ymax); 522 lcd_window(x, y, x+width-1, y+height-1);
522 lcd_write_cmd(R_WRITE_DATA_2_GRAM); 523 lcd_write_cmd(R_WRITE_DATA_2_GRAM);
523 524
524 ptr = &lcd_framebuffer[y][x]; 525 ptr = &lcd_framebuffer[y][x];
525 526
526 height = ymax - y; /* fix height */
527 do 527 do
528 { 528 {
529 lcd_write_data(ptr, width); 529 lcd_write_data(ptr, width);
530 ptr += LCD_WIDTH; 530 ptr += LCD_WIDTH;
531 } 531 }
532 while (--height >= 0); 532 while (--height > 0);
533} 533}
diff --git a/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c b/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c
index f9d5e5ace1..3332e0c78c 100644
--- a/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c
+++ b/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c
@@ -444,43 +444,43 @@ void lcd_update(void)
444void lcd_update_rect(int x, int y, int width, int height) 444void lcd_update_rect(int x, int y, int width, int height)
445{ 445{
446 const fb_data *ptr; 446 const fb_data *ptr;
447 int xmax, ymax;
448 447
449 if (!display_on) 448 if (!display_on)
450 return; 449 return;
451 450
452 xmax = x + width; 451 /* nothing to draw? */
453 if (xmax >= LCD_WIDTH) 452 if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) ||
454 xmax = LCD_WIDTH - 1; /* Clip right */ 453 (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0))
455 if (x < 0) 454 return;
456 x = 0; /* Clip left */
457 if (x >= xmax)
458 return; /* nothing left to do */
459
460 width = xmax - x + 1; /* Fix width */
461 455
462 ymax = y + height; 456 if (x < 0)
463 if (ymax >= LCD_HEIGHT) 457 { /* clip left */
464 ymax = LCD_HEIGHT - 1; /* Clip bottom */ 458 width += x;
459 x = 0;
460 }
465 if (y < 0) 461 if (y < 0)
466 y = 0; /* Clip top */ 462 { /* clip top */
467 if (y >= ymax) 463 height += y;
468 return; /* nothing left to do */ 464 y = 0;
465 }
466 if (x + width > LCD_WIDTH)
467 width = LCD_WIDTH - x; /* clip right */
468 if (y + height > LCD_HEIGHT)
469 height = LCD_HEIGHT - y; /* clip bottom */
469 470
470 lcd_write_reg(R_ENTRY_MODE, r_entry_mode); 471 lcd_write_reg(R_ENTRY_MODE, r_entry_mode);
471 472
472 lcd_window_x(x, xmax); 473 lcd_window_x(x, x + width - 1);
473 lcd_window_y(y, ymax); 474 lcd_window_y(y, y + height -1);
474 475
475 lcd_write_cmd(R_WRITE_DATA_2_GRAM); 476 lcd_write_cmd(R_WRITE_DATA_2_GRAM);
476 477
477 ptr = &lcd_framebuffer[y][x]; 478 ptr = &lcd_framebuffer[y][x];
478 479
479 height = ymax - y; /* fix height */
480 do 480 do
481 { 481 {
482 lcd_write_data(ptr, width); 482 lcd_write_data(ptr, width);
483 ptr += LCD_WIDTH; 483 ptr += LCD_WIDTH;
484 } 484 }
485 while (--height >= 0); 485 while (--height > 0);
486} 486}