summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-02-22 01:28:19 +0000
committerJens Arnold <amiconn@rockbox.org>2006-02-22 01:28:19 +0000
commita13f8471863e868a2d744baac4a5f5b20b3fa842 (patch)
tree234fee16ef388d22769cb7057f6767455701cc27
parenteb65f89f0e1b88e3d7576eee3e490c007d02076d (diff)
downloadrockbox-a13f8471863e868a2d744baac4a5f5b20b3fa842.tar.gz
rockbox-a13f8471863e868a2d744baac4a5f5b20b3fa842.zip
Optimised lcd_clear_display(), lcd_hline() and lcd_fillrect().
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8774 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/lcd-16bit.c123
1 files changed, 102 insertions, 21 deletions
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c
index 414cb877b6..b0e37e5510 100644
--- a/firmware/drivers/lcd-16bit.c
+++ b/firmware/drivers/lcd-16bit.c
@@ -26,6 +26,7 @@
26#include "thread.h" 26#include "thread.h"
27#include <string.h> 27#include <string.h>
28#include <stdlib.h> 28#include <stdlib.h>
29#include "memory.h"
29#include "file.h" 30#include "file.h"
30#include "debug.h" 31#include "debug.h"
31#include "system.h" 32#include "system.h"
@@ -35,6 +36,12 @@
35 36
36#define SCROLLABLE_LINES 26 37#define SCROLLABLE_LINES 26
37 38
39enum fill_opt {
40 OPT_NONE = 0,
41 OPT_SET,
42 OPT_COPY
43};
44
38/*** globals ***/ 45/*** globals ***/
39fb_data lcd_framebuffer[LCD_HEIGHT][LCD_WIDTH] __attribute__ ((aligned (16))); 46fb_data lcd_framebuffer[LCD_HEIGHT][LCD_WIDTH] __attribute__ ((aligned (16)));
40 47
@@ -217,19 +224,18 @@ fb_data* lcd_get_backdrop(void)
217/* Clear the whole display */ 224/* Clear the whole display */
218void lcd_clear_display(void) 225void lcd_clear_display(void)
219{ 226{
220 fb_data *dst = LCDADDR(0, 0); 227 fb_data *dst = LCDADDR(0, 0);
221 228
222 if (!lcd_backdrop || (drawmode & DRMODE_INVERSEVID)) 229 if (drawmode & DRMODE_INVERSEVID)
223 { 230 {
224 fb_data bits = (drawmode & DRMODE_INVERSEVID) ? fg_pattern : bg_pattern; 231 memset16(dst, fg_pattern, LCD_WIDTH*LCD_HEIGHT);
225 fb_data *dst_end = dst + LCD_HEIGHT*LCD_WIDTH;
226 do
227 *dst++ = bits;
228 while (dst < dst_end);
229 } 232 }
230 else 233 else
231 { 234 {
232 memcpy(dst, lcd_backdrop, sizeof(lcd_framebuffer)); 235 if (!lcd_backdrop)
236 memset16(dst, bg_pattern, LCD_WIDTH*LCD_HEIGHT);
237 else
238 memcpy(dst, lcd_backdrop, sizeof(lcd_framebuffer));
233 } 239 }
234 scrolling_lines = 0; 240 scrolling_lines = 0;
235} 241}
@@ -315,7 +321,9 @@ void lcd_drawline(int x1, int y1, int x2, int y2)
315/* Draw a horizontal line (optimised) */ 321/* Draw a horizontal line (optimised) */
316void lcd_hline(int x1, int x2, int y) 322void lcd_hline(int x1, int x2, int y)
317{ 323{
318 int x; 324 int x, width;
325 unsigned bits = 0;
326 enum fill_opt fillopt = OPT_NONE;
319 fb_data *dst, *dst_end; 327 fb_data *dst, *dst_end;
320 lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[drawmode]; 328 lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[drawmode];
321 329
@@ -337,12 +345,48 @@ void lcd_hline(int x1, int x2, int y)
337 if (x2 >= LCD_WIDTH) 345 if (x2 >= LCD_WIDTH)
338 x2 = LCD_WIDTH-1; 346 x2 = LCD_WIDTH-1;
339 347
348 if (drawmode & DRMODE_INVERSEVID)
349 {
350 if (drawmode & DRMODE_BG)
351 {
352 if (!lcd_backdrop)
353 {
354 fillopt = OPT_SET;
355 bits = bg_pattern;
356 }
357 else
358 fillopt = OPT_COPY;
359 }
360 }
361 else
362 {
363 if (drawmode & DRMODE_FG)
364 {
365 fillopt = OPT_SET;
366 bits = fg_pattern;
367 }
368 }
340 dst = LCDADDR(x1, y); 369 dst = LCDADDR(x1, y);
341 dst_end = dst + x2 - x1; 370 width = x2 - x1 + 1;
342 371
343 do 372 switch (fillopt)
344 pfunc(dst++); 373 {
345 while (dst <= dst_end); 374 case OPT_SET:
375 memset16(dst, bits, width);
376 break;
377
378 case OPT_COPY:
379 memcpy(dst, (void *)((int)dst + lcd_backdrop_offset),
380 width * sizeof(fb_data));
381 break;
382
383 case OPT_NONE:
384 dst_end = dst + width;
385 do
386 pfunc(dst++);
387 while (dst < dst_end);
388 break;
389 }
346} 390}
347 391
348/* Draw a vertical line (optimised) */ 392/* Draw a vertical line (optimised) */
@@ -399,6 +443,8 @@ void lcd_drawrect(int x, int y, int width, int height)
399/* Fill a rectangular area */ 443/* Fill a rectangular area */
400void lcd_fillrect(int x, int y, int width, int height) 444void lcd_fillrect(int x, int y, int width, int height)
401{ 445{
446 unsigned bits = 0;
447 enum fill_opt fillopt = OPT_NONE;
402 fb_data *dst, *dst_end; 448 fb_data *dst, *dst_end;
403 lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[drawmode]; 449 lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[drawmode];
404 450
@@ -423,18 +469,53 @@ void lcd_fillrect(int x, int y, int width, int height)
423 if (y + height > LCD_HEIGHT) 469 if (y + height > LCD_HEIGHT)
424 height = LCD_HEIGHT - y; 470 height = LCD_HEIGHT - y;
425 471
472 if (drawmode & DRMODE_INVERSEVID)
473 {
474 if (drawmode & DRMODE_BG)
475 {
476 if (!lcd_backdrop)
477 {
478 fillopt = OPT_SET;
479 bits = bg_pattern;
480 }
481 else
482 fillopt = OPT_COPY;
483 }
484 }
485 else
486 {
487 if (drawmode & DRMODE_FG)
488 {
489 fillopt = OPT_SET;
490 bits = fg_pattern;
491 }
492 }
426 dst = LCDADDR(x, y); 493 dst = LCDADDR(x, y);
427 dst_end = dst + height * LCD_WIDTH; 494 dst_end = dst + height * LCD_WIDTH;
428 495
429 do 496 do
430 { 497 {
431 fb_data *dst_row = dst; 498 fb_data *dst_row, *row_end;
432 fb_data *row_end = dst_row + width;
433
434 do
435 pfunc(dst_row++);
436 while (dst_row < row_end);
437 499
500 switch (fillopt)
501 {
502 case OPT_SET:
503 memset16(dst, bits, width);
504 break;
505
506 case OPT_COPY:
507 memcpy(dst, (void *)((int)dst + lcd_backdrop_offset),
508 width * sizeof(fb_data));
509 break;
510
511 case OPT_NONE:
512 dst_row = dst;
513 row_end = dst_row + width;
514 do
515 pfunc(dst_row++);
516 while (dst_row < row_end);
517 break;
518 }
438 dst += LCD_WIDTH; 519 dst += LCD_WIDTH;
439 } 520 }
440 while (dst < dst_end); 521 while (dst < dst_end);