summaryrefslogtreecommitdiff
path: root/apps/plugins/lib
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-02-11 19:35:50 +0000
committerJens Arnold <amiconn@rockbox.org>2005-02-11 19:35:50 +0000
commitb66f94b03dc6d2d6b9478274ba69607f14cbd39e (patch)
tree2ff3b5b3ef81b05915449d93e2a0a9273bb6ff98 /apps/plugins/lib
parent707cb7bc049a036f19ae8b89973502cd1752b9d8 (diff)
downloadrockbox-b66f94b03dc6d2d6b9478274ba69607f14cbd39e.zip
rockbox-b66f94b03dc6d2d6b9478274ba69607f14cbd39e.tar.gz
rockbox-b66f94b03dc6d2d6b9478274ba69607f14cbd39e.tar.bz2
rockbox-b66f94b03dc6d2d6b9478274ba69607f14cbd39e.tar.xz
Split the display & update function in two, and added invertpixel(), invertline() and invertrect().
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5916 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lib')
-rw-r--r--apps/plugins/lib/playergfx.c60
-rw-r--r--apps/plugins/lib/playergfx.h4
2 files changed, 57 insertions, 7 deletions
diff --git a/apps/plugins/lib/playergfx.c b/apps/plugins/lib/playergfx.c
index 01dfca4..0289e7a 100644
--- a/apps/plugins/lib/playergfx.c
+++ b/apps/plugins/lib/playergfx.c
@@ -29,9 +29,15 @@ static struct plugin_api *pgfx_rb = NULL; /* global api struct pointer */
static int char_width;
static int char_height;
static int pixel_height;
+static int pixel_width;
static unsigned char gfx_chars[8];
static unsigned char gfx_buffer[56];
+/* Private function declarations */
+static void linefunc(int x1, int y1, int x2, int y2,
+ void (*pixelfunc)(int x, int y));
+
+/* Implementation */
bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight)
{
@@ -44,7 +50,8 @@ bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight)
char_width = cwidth;
char_height = cheight;
pixel_height = 7 * char_height;
-
+ pixel_width = 5 * char_width;
+
for (i = 0; i < cwidth * cheight; i++)
{
if ((gfx_chars[i] = pgfx_rb->lcd_get_locked_pattern()) == 0)
@@ -69,16 +76,20 @@ void pgfx_release(void)
void pgfx_display(int cx, int cy)
{
int i, j;
-
- for (i = 0; i < char_width * char_height; i++)
- pgfx_rb->lcd_define_pattern(gfx_chars[i], gfx_buffer + 7 * i);
-
for (i = 0; i < char_width; i++)
for (j = 0; j < char_height; j++)
pgfx_rb->lcd_putc(cx + i, cy + j, gfx_chars[char_height * i + j]);
}
+void pgfx_update(void)
+{
+ int i;
+
+ for (i = 0; i < char_width * char_height; i++)
+ pgfx_rb->lcd_define_pattern(gfx_chars[i], gfx_buffer + 7 * i);
+}
+
void pgfx_clear_display(void)
{
pgfx_rb->memset(gfx_buffer, 0, char_width * pixel_height);
@@ -89,7 +100,13 @@ void pgfx_drawpixel(int x, int y)
gfx_buffer[pixel_height * (x/5) + y] |= 0x10 >> (x%5);
}
-void pgfx_drawline(int x1, int y1, int x2, int y2)
+void pgfx_invertpixel(int x, int y)
+{
+ gfx_buffer[pixel_height * (x/5) + y] ^= 0x10 >> (x%5);
+}
+
+static void linefunc(int x1, int y1, int x2, int y2,
+ void (*pixelfunc)(int x, int y))
{
int numpixels;
int i;
@@ -140,7 +157,7 @@ void pgfx_drawline(int x1, int y1, int x2, int y2)
for (i = 0; i < numpixels; i++)
{
- pgfx_drawpixel(x, y);
+ pixelfunc(x, y);
if (d < 0)
{
@@ -157,4 +174,33 @@ void pgfx_drawline(int x1, int y1, int x2, int y2)
}
}
+void pgfx_drawline(int x1, int y1, int x2, int y2)
+{
+ linefunc(x1, y1, x2, y2, pgfx_drawpixel);
+}
+
+void pgfx_invertline(int x1, int y1, int x2, int y2)
+{
+ linefunc(x1, y1, x2, y2, pgfx_invertpixel);
+}
+
+void pgfx_invertrect (int x, int y, int nx, int ny)
+{
+ int i, j;
+
+ if (x > pixel_width)
+ return;
+ if (y > pixel_height)
+ return;
+
+ if (x + nx > pixel_width)
+ nx = pixel_width - x;
+ if (y + ny > pixel_height)
+ ny = pixel_height - y;
+
+ for (i = 0; i < nx; i++)
+ for (j = 0; j < ny; j++)
+ pgfx_invertpixel(x + i, y + j);
+}
+
#endif /* HAVE_LCD_CHARCELLS */
diff --git a/apps/plugins/lib/playergfx.h b/apps/plugins/lib/playergfx.h
index 761c75f..929452f 100644
--- a/apps/plugins/lib/playergfx.h
+++ b/apps/plugins/lib/playergfx.h
@@ -29,9 +29,13 @@
bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight);
void pgfx_release(void);
void pgfx_display(int cx, int cy);
+void pgfx_update(void);
void pgfx_clear_display(void);
void pgfx_drawpixel(int x, int y);
+void pgfx_invertpixel(int x, int y);
void pgfx_drawline(int x1, int y1, int x2, int y2);
+void pgfx_invertline(int x1, int y1, int x2, int y2);
+void pgfx_invertrect (int x, int y, int nx, int ny);
#endif /* HAVE_LCD_CHARCELLS */
#endif /* __PGFX_H__ */