summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rwxr-xr-xapps/plugins/lua/rocklib_aux.pl1
-rw-r--r--apps/plugins/lua/rocklib_img.c173
2 files changed, 106 insertions, 68 deletions
diff --git a/apps/plugins/lua/rocklib_aux.pl b/apps/plugins/lua/rocklib_aux.pl
index 542a928a12..7202d8dff9 100755
--- a/apps/plugins/lua/rocklib_aux.pl
+++ b/apps/plugins/lua/rocklib_aux.pl
@@ -77,6 +77,7 @@ my @forbidden_functions = ('^open$',
77 '^utf16', 77 '^utf16',
78 '^codec_', 78 '^codec_',
79 '^timer_', 79 '^timer_',
80 '^lcd_blit_(mono|grey_phase)$',
80 '^lcd_(mono_)?+bitmap', 81 '^lcd_(mono_)?+bitmap',
81 '^lcd_(draw|fill|update_)rect$', 82 '^lcd_(draw|fill|update_)rect$',
82 '^lcd_draw(line|pixel)$', 83 '^lcd_draw(line|pixel)$',
diff --git a/apps/plugins/lua/rocklib_img.c b/apps/plugins/lua/rocklib_img.c
index 1150b511c3..7b3ed9d2d7 100644
--- a/apps/plugins/lua/rocklib_img.c
+++ b/apps/plugins/lua/rocklib_img.c
@@ -1394,48 +1394,45 @@ RB_WRAP(lcd_setfont)
1394} 1394}
1395 1395
1396/* helper function for lcd_xxx_bitmap/rect functions */ 1396/* helper function for lcd_xxx_bitmap/rect functions */
1397static void get_rect_bounds(lua_State *L, int narg, int *x, int *y, int *w, int* h) 1397static void checkint_arr(lua_State *L, int *val, int narg, int elems)
1398{ 1398{
1399 *x = luaL_checkint(L, narg); 1399 /* fills passed array of integers with lua integers from stack */
1400 *y = luaL_checkint(L, narg + 1); 1400 for (int i = 0; i < elems; i++)
1401 *w = luaL_checkint(L, narg + 2); 1401 val[i] = luaL_checkint(L, narg + i);
1402 *h = luaL_checkint(L, narg + 3);
1403} 1402}
1404 1403
1405RB_WRAP(gui_scrollbar_draw) 1404RB_WRAP(gui_scrollbar_draw)
1406{ 1405{
1407 int x, y, width, height; 1406 enum {x = 0, y, w, h, items, min_shown, max_shown, flags, eCNT};
1408 get_rect_bounds(L, 1, &x, &y, &width, &height); 1407 int v[eCNT];
1409 int items = luaL_checkint(L, 5); 1408 checkint_arr(L, v, 1, eCNT);
1410 int min_shown = luaL_checkint(L, 6); 1409
1411 int max_shown = luaL_checkint(L, 7); 1410 rb->gui_scrollbar_draw(RB_SCREEN_STRUCT(L, 9), v[x], v[y], v[w], v[h],
1412 unsigned flags = (unsigned) luaL_checkint(L, 8); 1411 v[items], v[min_shown], v[max_shown], (unsigned) v[flags]);
1413 rb->gui_scrollbar_draw(RB_SCREEN_STRUCT(L, 9), x, y, width, height,
1414 items, min_shown, max_shown, flags);
1415return 0; 1412return 0;
1416} 1413}
1417 1414
1418RB_WRAP(lcd_mono_bitmap_part) 1415RB_WRAP(lcd_mono_bitmap_part)
1419{ 1416{
1420 struct rocklua_image *src = rli_checktype(L, 1); 1417 struct rocklua_image *src = rli_checktype(L, 1);
1421 int src_x = luaL_checkint(L, 2); 1418 enum {src_x = 0, src_y, stride, x, y, w, h, eCNT};
1422 int src_y = luaL_checkint(L, 3); 1419 int v[eCNT];
1423 int stride = luaL_checkint(L, 4); 1420 checkint_arr(L, v, 2, eCNT);;
1424 int x, y, width, height;
1425 get_rect_bounds(L, 5, &x, &y, &width, &height);
1426 1421
1427 RB_SCREENS(L, 9, mono_bitmap_part, (const unsigned char *)src->data, 1422 RB_SCREENS(L, 9, mono_bitmap_part, (const unsigned char *)src->data,
1428 src_x, src_y, stride, x, y, width, height); 1423 v[src_x], v[src_y], v[stride], v[x], v[y], v[w], v[h]);
1429 return 0; 1424 return 0;
1430} 1425}
1431 1426
1432RB_WRAP(lcd_mono_bitmap) 1427RB_WRAP(lcd_mono_bitmap)
1433{ 1428{
1434 struct rocklua_image *src = rli_checktype(L, 1); 1429 struct rocklua_image *src = rli_checktype(L, 1);
1435 int x, y, width, height; 1430 enum {x = 0, y, w, h, eCNT};
1436 get_rect_bounds(L, 2, &x, &y, &width, &height); 1431 int v[eCNT];
1432 checkint_arr(L, v, 2, eCNT);
1437 1433
1438 RB_SCREENS(L, 6, mono_bitmap, (const unsigned char *)src->data, x, y, width, height); 1434 RB_SCREENS(L, 6, mono_bitmap, (const unsigned char *)src->data,
1435 v[x], v[y], v[w], v[h]);
1439 return 0; 1436 return 0;
1440} 1437}
1441 1438
@@ -1443,23 +1440,23 @@ RB_WRAP(lcd_mono_bitmap)
1443RB_WRAP(lcd_bitmap_part) 1440RB_WRAP(lcd_bitmap_part)
1444{ 1441{
1445 struct rocklua_image *src = rli_checktype(L, 1); 1442 struct rocklua_image *src = rli_checktype(L, 1);
1446 int src_x = luaL_checkint(L, 2); 1443 enum {src_x = 0, src_y, stride, x, y, w, h, eCNT};
1447 int src_y = luaL_checkint(L, 3); 1444 int v[eCNT];
1448 int stride = luaL_checkint(L, 4); 1445 checkint_arr(L, v, 2, eCNT);
1449 int x, y, width, height;
1450 get_rect_bounds(L, 5, &x, &y, &width, &height);
1451 1446
1452 RB_SCREENS(L, 9, bitmap_part, src->data, src_x, src_y, stride, x, y, width, height); 1447 RB_SCREENS(L, 9, bitmap_part, src->data,
1448 v[src_x], v[src_y], v[stride], v[x], v[y], v[w], v[h]);
1453 return 0; 1449 return 0;
1454} 1450}
1455 1451
1456RB_WRAP(lcd_bitmap) 1452RB_WRAP(lcd_bitmap)
1457{ 1453{
1458 struct rocklua_image *src = rli_checktype(L, 1); 1454 struct rocklua_image *src = rli_checktype(L, 1);
1459 int x, y, width, height; 1455 enum {x = 0, y, w, h, eCNT};
1460 get_rect_bounds(L, 2, &x, &y, &width, &height); 1456 int v[eCNT];
1457 checkint_arr(L, v, 2, eCNT);
1461 1458
1462 RB_SCREENS(L, 6, bitmap, src->data, x, y, width, height); 1459 RB_SCREENS(L, 6, bitmap, src->data, v[x], v[y], v[w], v[h]);
1463 return 0; 1460 return 0;
1464} 1461}
1465 1462
@@ -1501,82 +1498,117 @@ RB_WRAP(lcd_get_background)
1501 lua_pushinteger(L, result); 1498 lua_pushinteger(L, result);
1502 return 1; 1499 return 1;
1503} 1500}
1504
1505#endif /* LCD_DEPTH > 1 */ 1501#endif /* LCD_DEPTH > 1 */
1506 1502
1503#if (LCD_DEPTH < 4) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
1504RB_WRAP(lcd_blit_grey_phase)
1505{
1506 /* note that by and bheight are in 8-pixel units! */
1507 unsigned char * values = (unsigned char *) luaL_checkstring(L, 1);
1508 unsigned char * phases = (unsigned char *) luaL_checkstring(L, 2);
1509 enum {bx = 0, by, bw, bh, stride, eCNT};
1510 int v[eCNT];
1511 checkint_arr(L, v, 3, eCNT);
1512
1513 rb->lcd_blit_grey_phase(values, phases, v[bx], v[by], v[bw], v[bh], v[stride]);
1514 return 0;
1515}
1516
1517RB_WRAP(lcd_blit_mono)
1518{
1519 /* note that by and bheight are in 8-pixel units! */
1520 const unsigned char * data = (const unsigned char *) luaL_checkstring(L, 1);
1521 enum {x = 0, by, w, bh, stride, eCNT};
1522 int v[eCNT];
1523 checkint_arr(L, v, 3, eCNT);
1524
1525 rb->lcd_blit_mono(data, v[x], v[by], v[w], v[bh], v[stride]);
1526 return 0;
1527}
1528#endif /* LCD_DEPTH < 4 && CONFIG_PLATFORM & PLATFORM_NATIVE */
1529
1507#if LCD_DEPTH == 16 1530#if LCD_DEPTH == 16
1508RB_WRAP(lcd_bitmap_transparent_part) 1531RB_WRAP(lcd_bitmap_transparent_part)
1509{ 1532{
1510 struct rocklua_image *src = rli_checktype(L, 1); 1533 struct rocklua_image *src = rli_checktype(L, 1);
1511 int src_x = luaL_checkint(L, 2); 1534 enum {src_x = 0, src_y, stride, x, y, w, h, eCNT};
1512 int src_y = luaL_checkint(L, 3); 1535 int v[eCNT];
1513 int stride = luaL_checkint(L, 4); 1536 checkint_arr(L, v, 2, eCNT);
1514 int x, y, width, height; 1537
1515 get_rect_bounds(L, 5, &x, &y, &width, &height); 1538 RB_SCREENS(L, 9, transparent_bitmap_part, src->data,
1516 1539 v[src_x], v[src_y], v[stride], v[x], v[y], v[w], v[h]);
1517 RB_SCREENS(L, 9, transparent_bitmap_part, src->data, src_x,
1518 src_y, stride, x, y, width, height);
1519 return 0; 1540 return 0;
1520} 1541}
1521 1542
1522RB_WRAP(lcd_bitmap_transparent) 1543RB_WRAP(lcd_bitmap_transparent)
1523{ 1544{
1524 struct rocklua_image *src = rli_checktype(L, 1); 1545 struct rocklua_image *src = rli_checktype(L, 1);
1525 int x, y, width, height; 1546 enum {x = 0, y, w, h, eCNT};
1526 get_rect_bounds(L, 2, &x, &y, &width, &height); 1547 int v[eCNT];
1548 checkint_arr(L, v, 2, eCNT);
1527 1549
1528 RB_SCREENS(L, 6, transparent_bitmap, src->data, x, y, width, height); 1550 RB_SCREENS(L, 6, transparent_bitmap, src->data, v[x], v[y], v[w], v[h]);
1529 return 0; 1551 return 0;
1530} 1552}
1531#endif /* LCD_DEPTH == 16 */ 1553#endif /* LCD_DEPTH == 16 */
1532 1554
1533RB_WRAP(lcd_update_rect) 1555RB_WRAP(lcd_update_rect)
1534{ 1556{
1535 int x, y, width, height; 1557 enum {x = 0, y, w, h, eCNT};
1536 get_rect_bounds(L, 1, &x, &y, &width, &height); 1558 int v[eCNT];
1537 RB_SCREENS(L, 5, update_rect, x, y, width, height); 1559 checkint_arr(L, v, 1, eCNT);
1560
1561 RB_SCREENS(L, 5, update_rect, v[x], v[y], v[w], v[h]);
1538 return 0; 1562 return 0;
1539} 1563}
1540 1564
1541RB_WRAP(lcd_drawrect) 1565RB_WRAP(lcd_drawrect)
1542{ 1566{
1543 int x, y, width, height; 1567 enum {x = 0, y, w, h, eCNT};
1544 get_rect_bounds(L, 1, &x, &y, &width, &height); 1568 int v[eCNT];
1545 RB_SCREENS(L, 5, drawrect, x, y, width, height); 1569 checkint_arr(L, v, 1, eCNT);
1570
1571 RB_SCREENS(L, 5, drawrect, v[x], v[y], v[w], v[h]);
1546 return 0; 1572 return 0;
1547} 1573}
1548 1574
1549RB_WRAP(lcd_fillrect) 1575RB_WRAP(lcd_fillrect)
1550{ 1576{
1551 int x, y, width, height; 1577 enum {x = 0, y, w, h, eCNT};
1552 get_rect_bounds(L, 1, &x, &y, &width, &height); 1578 int v[eCNT];
1553 RB_SCREENS(L, 5, fillrect, x, y, width, height); 1579 checkint_arr(L, v, 1, eCNT);
1580
1581 RB_SCREENS(L, 5, fillrect, v[x], v[y], v[w], v[h]);
1554 return 0; 1582 return 0;
1555} 1583}
1556 1584
1557RB_WRAP(lcd_drawline) 1585RB_WRAP(lcd_drawline)
1558{ 1586{
1559 int x1, y1, x2, y2; 1587 enum {x1 = 0, y1, x2, y2, eCNT};
1560 get_rect_bounds(L, 1, &x1, &y1, &x2, &y2); 1588 int v[eCNT];
1561 RB_SCREENS(L, 5, drawline, x1, y1, x2, y2); 1589 checkint_arr(L, v, 1, eCNT);
1590
1591 RB_SCREENS(L, 5, drawline, v[x1], v[y1], v[x2], v[y2]);
1562 return 0; 1592 return 0;
1563} 1593}
1564 1594
1565RB_WRAP(lcd_hline) 1595RB_WRAP(lcd_hline)
1566{ 1596{
1567 int x1 = (int) luaL_checkint(L, 1); 1597 enum {x1 = 0, x2, y, eCNT};
1568 int x2 = (int) luaL_checkint(L, 2); 1598 int v[eCNT];
1569 int y = (int) luaL_checkint(L, 3); 1599 checkint_arr(L, v, 1, eCNT);
1570 RB_SCREENS(L, 4, hline, x1, x2, y); 1600
1601 RB_SCREENS(L, 4, hline, v[x1], v[x2], v[y]);
1571 return 0; 1602 return 0;
1572} 1603}
1573 1604
1574RB_WRAP(lcd_vline) 1605RB_WRAP(lcd_vline)
1575{ 1606{
1576 int x = (int) luaL_checkint(L, 1); 1607 enum {x = 0, y1, y2, eCNT};
1577 int y1 = (int) luaL_checkint(L, 2); 1608 int v[eCNT];
1578 int y2 = (int) luaL_checkint(L, 3); 1609 checkint_arr(L, v, 1, eCNT);
1579 RB_SCREENS(L, 4, vline, x, y1, y2); 1610
1611 RB_SCREENS(L, 4, vline, v[x], v[y1], v[y2]);
1580 return 0; 1612 return 0;
1581} 1613}
1582 1614
@@ -1593,10 +1625,11 @@ RB_WRAP(lcd_drawpixel)
1593#ifdef HAVE_LCD_COLOR 1625#ifdef HAVE_LCD_COLOR
1594RB_WRAP(lcd_rgbpack) 1626RB_WRAP(lcd_rgbpack)
1595{ 1627{
1596 int r = luaL_checkint(L, 1); 1628 enum {r = 0, g, b, eCNT};
1597 int g = luaL_checkint(L, 2); 1629 int v[eCNT];
1598 int b = luaL_checkint(L, 3); 1630 checkint_arr(L, v, 1, eCNT);
1599 int result = LCD_RGBPACK(r, g, b); 1631
1632 int result = LCD_RGBPACK(v[r], v[g], v[b]);
1600 lua_pushinteger(L, result); 1633 lua_pushinteger(L, result);
1601 return 1; 1634 return 1;
1602} 1635}
@@ -1671,7 +1704,11 @@ static const luaL_Reg rocklib_img[] =
1671 R(lcd_get_foreground), 1704 R(lcd_get_foreground),
1672 R(lcd_set_background), 1705 R(lcd_set_background),
1673 R(lcd_get_background), 1706 R(lcd_get_background),
1674#endif 1707#endif /* LCD_DEPTH > 1 */
1708#if (LCD_DEPTH < 4) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
1709 R(lcd_blit_grey_phase),
1710 R(lcd_blit_mono),
1711#endif /* LCD_DEPTH < 4 && CONFIG_PLATFORM & PLATFORM_NATIVE */
1675#if LCD_DEPTH == 16 1712#if LCD_DEPTH == 16
1676 R(lcd_bitmap_transparent_part), 1713 R(lcd_bitmap_transparent_part),
1677 R(lcd_bitmap_transparent), 1714 R(lcd_bitmap_transparent),