summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2009-03-07 00:16:27 +0000
committerJens Arnold <amiconn@rockbox.org>2009-03-07 00:16:27 +0000
commit5e313256b2d506054de8c1ac35816eb5002506d0 (patch)
treea7d86de76f2a4c6ee4fbe95ce0282ac018e41888
parent031ac442c542b3c712c194636a812ee987c4a455 (diff)
downloadrockbox-5e313256b2d506054de8c1ac35816eb5002506d0.tar.gz
rockbox-5e313256b2d506054de8c1ac35816eb5002506d0.zip
Performance tweaks for SH1. No changes for coldfire and ARM, apart from changing a bunch of signed shifts to unsigned shifts.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20223 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/pictureflow.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/apps/plugins/pictureflow.c b/apps/plugins/pictureflow.c
index 59b7c84f55..57d0bbcd95 100644
--- a/apps/plugins/pictureflow.c
+++ b/apps/plugins/pictureflow.c
@@ -334,7 +334,7 @@ enum pf_states {
334static int pf_state; 334static int pf_state;
335 335
336/** code */ 336/** code */
337static inline pix_t fade_color(pix_t c, unsigned int a); 337static inline unsigned fade_color(pix_t c, unsigned a);
338bool save_pfraw(char* filename, struct bitmap *bm); 338bool save_pfraw(char* filename, struct bitmap *bm);
339bool load_new_slide(void); 339bool load_new_slide(void);
340int load_surface(int); 340int load_surface(int);
@@ -456,6 +456,13 @@ static inline PFreal fdiv(PFreal num, PFreal den)
456#define fabs(a) (a < 0 ? -a : a) 456#define fabs(a) (a < 0 ? -a : a)
457#define fbound(min,val,max) (fmax((min),fmin((max),(val)))) 457#define fbound(min,val,max) (fmax((min),fmin((max),(val))))
458 458
459#if CONFIG_CPU == SH7034
460/* 16*16->32 bit multiplication is a single instrcution on the SH1 */
461#define MULUQ(a, b) ((uint32_t) (((uint16_t) (a)) * ((uint16_t) (b))))
462#else
463#define MULUQ(a, b) ((a) * (b))
464#endif
465
459 466
460#if 0 467#if 0
461#define fmul(a,b) ( ((a)*(b)) >> PFREAL_SHIFT ) 468#define fmul(a,b) ( ((a)*(b)) >> PFREAL_SHIFT )
@@ -1376,7 +1383,7 @@ void recalc_offsets(void)
1376 to an uint, multiply and compress the result back to a ushort. 1383 to an uint, multiply and compress the result back to a ushort.
1377 */ 1384 */
1378#if (LCD_PIXELFORMAT == RGB565SWAPPED) 1385#if (LCD_PIXELFORMAT == RGB565SWAPPED)
1379static inline pix_t fade_color(pix_t c, unsigned int a) 1386static inline unsigned fade_color(pix_t c, unsigned a)
1380{ 1387{
1381 unsigned int result; 1388 unsigned int result;
1382 c = swap16(c); 1389 c = swap16(c);
@@ -1387,7 +1394,7 @@ static inline pix_t fade_color(pix_t c, unsigned int a)
1387 return swap16(result); 1394 return swap16(result);
1388} 1395}
1389#elif LCD_PIXELFORMAT == RGB565 1396#elif LCD_PIXELFORMAT == RGB565
1390static inline pix_t fade_color(pix_t c, unsigned int a) 1397static inline unsigned fade_color(pix_t c, unsigned a)
1391{ 1398{
1392 unsigned int result; 1399 unsigned int result;
1393 a = (a + 2) & 0x1fc; 1400 a = (a + 2) & 0x1fc;
@@ -1397,9 +1404,10 @@ static inline pix_t fade_color(pix_t c, unsigned int a)
1397 return result; 1404 return result;
1398} 1405}
1399#else 1406#else
1400static inline pix_t fade_color(pix_t c, unsigned int a) 1407static inline unsigned fade_color(pix_t c, unsigned a)
1401{ 1408{
1402 return (unsigned int)c * a >> 8; 1409 unsigned val = c;
1410 return MULUQ(val, a) >> 8;
1403} 1411}
1404#endif 1412#endif
1405 1413
@@ -1489,14 +1497,14 @@ void render_slide(struct slide_data *slide, const int alpha)
1489 { 1497 {
1490 while ((y1 >= 0) && (p1 >= 0)) 1498 while ((y1 >= 0) && (p1 >= 0))
1491 { 1499 {
1492 *pixel1 = ptr[p1 >> PFREAL_SHIFT]; 1500 *pixel1 = ptr[((unsigned)p1) >> PFREAL_SHIFT];
1493 p1 -= dy; 1501 p1 -= dy;
1494 y1--; 1502 y1--;
1495 pixel1 -= pixelstep; 1503 pixel1 -= pixelstep;
1496 } 1504 }
1497 while ((p2 < sh * PFREAL_ONE) && (y2 < h)) 1505 while ((p2 < sh * PFREAL_ONE) && (y2 < h))
1498 { 1506 {
1499 *pixel2 = ptr[p2 >> PFREAL_SHIFT]; 1507 *pixel2 = ptr[((unsigned)p2) >> PFREAL_SHIFT];
1500 p2 += dy; 1508 p2 += dy;
1501 y2++; 1509 y2++;
1502 pixel2 += pixelstep; 1510 pixel2 += pixelstep;
@@ -1504,7 +1512,7 @@ void render_slide(struct slide_data *slide, const int alpha)
1504 while ((p2 < MIN(sh + REFLECT_HEIGHT, sh * 2) * PFREAL_ONE) && 1512 while ((p2 < MIN(sh + REFLECT_HEIGHT, sh * 2) * PFREAL_ONE) &&
1505 (y2 < h)) 1513 (y2 < h))
1506 { 1514 {
1507 int ty = (p2 >> PFREAL_SHIFT) - sh; 1515 int ty = (((unsigned)p2) >> PFREAL_SHIFT) - sh;
1508 int lalpha = reflect_table[ty]; 1516 int lalpha = reflect_table[ty];
1509 *pixel2 = fade_color(ptr[sh - 1 - ty],lalpha); 1517 *pixel2 = fade_color(ptr[sh - 1 - ty],lalpha);
1510 p2 += dy; 1518 p2 += dy;
@@ -1516,14 +1524,14 @@ void render_slide(struct slide_data *slide, const int alpha)
1516 { 1524 {
1517 while ((y1 >= 0) && (p1 >= 0)) 1525 while ((y1 >= 0) && (p1 >= 0))
1518 { 1526 {
1519 *pixel1 = fade_color(ptr[p1 >> PFREAL_SHIFT],alpha); 1527 *pixel1 = fade_color(ptr[((unsigned)p1) >> PFREAL_SHIFT],alpha);
1520 p1 -= dy; 1528 p1 -= dy;
1521 y1--; 1529 y1--;
1522 pixel1 -= pixelstep; 1530 pixel1 -= pixelstep;
1523 } 1531 }
1524 while ((p2 < sh * PFREAL_ONE) && (y2 < h)) 1532 while ((p2 < sh * PFREAL_ONE) && (y2 < h))
1525 { 1533 {
1526 *pixel2 = fade_color(ptr[p2 >> PFREAL_SHIFT],alpha); 1534 *pixel2 = fade_color(ptr[((unsigned)p2) >> PFREAL_SHIFT],alpha);
1527 p2 += dy; 1535 p2 += dy;
1528 y2++; 1536 y2++;
1529 pixel2 += pixelstep; 1537 pixel2 += pixelstep;
@@ -1531,8 +1539,9 @@ void render_slide(struct slide_data *slide, const int alpha)
1531 while ((p2 < MIN(sh + REFLECT_HEIGHT, sh * 2) * PFREAL_ONE) && 1539 while ((p2 < MIN(sh + REFLECT_HEIGHT, sh * 2) * PFREAL_ONE) &&
1532 (y2 < h)) 1540 (y2 < h))
1533 { 1541 {
1534 int ty = (p2 >> PFREAL_SHIFT) - sh; 1542 int ty = (((unsigned)p2) >> PFREAL_SHIFT) - sh;
1535 int lalpha = (reflect_table[ty] * alpha + 128) >> 8; 1543 int lalpha = reflect_table[ty];
1544 lalpha = (MULUQ(lalpha, alpha) + 128) >> 8;
1536 *pixel2 = fade_color(ptr[sh - 1 - ty],lalpha); 1545 *pixel2 = fade_color(ptr[sh - 1 - ty],lalpha);
1537 p2 += dy; 1546 p2 += dy;
1538 y2++; 1547 y2++;