summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2012-12-03 20:43:58 +1100
committerJonathan Gordon <rockbox@jdgordon.info>2012-12-09 17:11:19 +1100
commit685cf5900825b10c952f36301abbbd9968567435 (patch)
tree41cdfed9e5a2943c80ac0d4ffe09c45519a3ecf3 /firmware/drivers
parent1fbdc280d7e4b4ffb7ec8dccbfd1c1fc67f1c123 (diff)
downloadrockbox-685cf5900825b10c952f36301abbbd9968567435.zip
rockbox-685cf5900825b10c952f36301abbbd9968567435.tar.gz
rockbox-685cf5900825b10c952f36301abbbd9968567435.tar.bz2
rockbox-685cf5900825b10c952f36301abbbd9968567435.tar.xz
9 segment bitmap drawing:
Use %x9(id) to draw an image in the whole current viewport using the 9 segment drawer (which draws the corners as normal and *tiles* the middle segments to the needed width/height). Future work is to make it scale instead of tile Change-Id: Ic3ed1cad93f96091694801eb442e0da5a2401203
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/lcd-bitmap-common.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c
index 0bae790..a149e8a 100644
--- a/firmware/drivers/lcd-bitmap-common.c
+++ b/firmware/drivers/lcd-bitmap-common.c
@@ -615,3 +615,48 @@ void LCDFN(bmp)(const struct bitmap* bm, int x, int y)
}
#endif
+
+void LCDFN(nine_segment_bmp)(const struct bitmap* bm, int x, int y,
+ int width, int height)
+{
+ int seg_w = bm->width / 3;
+ int seg_h = bm->height / 3;
+ int src_x, src_y, dst_x, dst_y;
+
+ /* top */
+ src_x = seg_w; src_y = 0;
+ dst_x = seg_w; dst_y = 0;
+ for (; dst_x < width - seg_w; dst_x += seg_w)
+ LCDFN(bmp_part)(bm, src_x, src_y, dst_x, dst_y, seg_w, seg_h);
+ /* bottom */
+ src_x = seg_w; src_y = bm->height - seg_h;
+ dst_x = seg_w; dst_y = height - seg_h;
+ for (; dst_x < width - seg_w; dst_x += seg_w)
+ LCDFN(bmp_part)(bm, src_x, src_y, dst_x, dst_y, seg_w, seg_h);
+
+ /* left */
+ src_x = 0; src_y = seg_h;
+ dst_x = 0; dst_y = seg_h;
+ for (; dst_y < height - seg_h; dst_y += seg_h)
+ LCDFN(bmp_part)(bm, src_x, src_y, dst_x, dst_y, seg_w, seg_h);
+ /* right */
+ src_x = bm->width - seg_w; src_y = seg_h;
+ dst_x = width - seg_w; dst_y = seg_h;
+ for (; dst_y < height - seg_h; dst_y += seg_h)
+ LCDFN(bmp_part)(bm, src_x, src_y, dst_x, dst_y, seg_w, seg_h);
+ /* center */
+ dst_y = seg_h; src_y = seg_h; src_x = seg_w;
+ for (; dst_y < height - seg_h; dst_y += seg_h)
+ {
+ dst_x = seg_w;
+ for (; dst_x < width - seg_w; dst_x += seg_w)
+ LCDFN(bmp_part)(bm, src_x, src_y, dst_x, dst_y, seg_w, seg_h);
+ }
+
+ /* 4 corners */
+ LCDFN(bmp_part)(bm, 0, 0, x, y, seg_w, seg_h);
+ LCDFN(bmp_part)(bm, bm->width - seg_w, 0, width - seg_w, 0, seg_w, seg_h);
+ LCDFN(bmp_part)(bm, 0, bm->width - seg_h, 0, height - seg_h, seg_w, seg_h);
+ LCDFN(bmp_part)(bm, bm->width - seg_w, bm->width - seg_h,
+ width - seg_w, height - seg_h, seg_w, seg_h);
+}