summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/rasops/rasops.c34
-rw-r--r--sys/dev/rasops/rasops.h11
-rw-r--r--sys/dev/wsfont/wsfont.c81
-rw-r--r--sys/dev/wsfont/wsfont.h4
4 files changed, 90 insertions, 40 deletions
diff --git a/sys/dev/rasops/rasops.c b/sys/dev/rasops/rasops.c
index 2f8604dc67d..2fdbfb1266a 100644
--- a/sys/dev/rasops/rasops.c
+++ b/sys/dev/rasops/rasops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rasops.c,v 1.46 2017/08/13 22:28:23 kettenis Exp $ */
+/* $OpenBSD: rasops.c,v 1.47 2017/08/17 20:21:53 kettenis Exp $ */
/* $NetBSD: rasops.c,v 1.35 2001/02/02 06:01:01 marcus Exp $ */
/*-
@@ -150,7 +150,7 @@ int rasops_copyrows_rotated(void *, int, int, int);
int rasops_erasecols_rotated(void *, int, int, int, long);
int rasops_eraserows_rotated(void *, int, int, long);
int rasops_putchar_rotated(void *, int, int, u_int, long);
-void rasops_rotate_font(int *);
+void rasops_rotate_font(int *, int);
/*
* List of all rotated fonts
@@ -218,8 +218,9 @@ rasops_init(struct rasops_info *ri, int wantrows, int wantcols)
* Pick the rotated version of this font. This will create it
* if necessary.
*/
- if (ri->ri_flg & RI_ROTATE_CW)
- rasops_rotate_font(&cookie);
+ if (ri->ri_flg & (RI_ROTATE_CW | RI_ROTATE_CCW))
+ rasops_rotate_font(&cookie,
+ ISSET(ri->ri_flg, RI_ROTATE_CCW));
#endif
if (wsfont_lock(cookie, &ri->ri_font,
@@ -341,7 +342,7 @@ rasops_reconfig(struct rasops_info *ri, int wantrows, int wantcols)
ri->ri_emuwidth--;
#if NRASOPS_ROTATION > 0
- if (ri->ri_flg & RI_ROTATE_CW) {
+ if (ri->ri_flg & (RI_ROTATE_CW | RI_ROTATE_CCW)) {
ri->ri_rows = ri->ri_emuwidth / ri->ri_font->fontwidth;
ri->ri_cols = ri->ri_emuheight / ri->ri_font->fontheight;
} else
@@ -460,7 +461,7 @@ rasops_reconfig(struct rasops_info *ri, int wantrows, int wantcols)
}
#if NRASOPS_ROTATION > 0
- if (ri->ri_flg & RI_ROTATE_CW) {
+ if (ri->ri_flg & (RI_ROTATE_CW | RI_ROTATE_CCW)) {
ri->ri_real_ops = ri->ri_ops;
ri->ri_ops.copycols = rasops_copycols_rotated;
ri->ri_ops.copyrows = rasops_copyrows_rotated;
@@ -958,7 +959,11 @@ rasops_do_cursor(struct rasops_info *ri)
/* Rotate rows/columns */
row = ri->ri_ccol;
col = ri->ri_rows - ri->ri_crow - 1;
- } else
+ } else if (ri->ri_flg & RI_ROTATE_CCW) {
+ /* Rotate rows/columns */
+ row = ri->ri_cols - ri->ri_ccol - 1;
+ col = ri->ri_crow;
+ } else
#endif
{
row = ri->ri_crow;
@@ -1153,7 +1158,7 @@ rasops_erasecols(void *cookie, int row, int col, int num, long attr)
#include <sys/malloc.h>
void
-rasops_rotate_font(int *cookie)
+rasops_rotate_font(int *cookie, int ccw)
{
struct rotatedfont *f;
int ncookie;
@@ -1169,7 +1174,7 @@ rasops_rotate_font(int *cookie)
* We did not find a rotated version of this font. Ask the wsfont
* code to compute one for us.
*/
- if ((ncookie = wsfont_rotate(*cookie)) == -1)
+ if ((ncookie = wsfont_rotate(*cookie, ccw)) == -1)
return;
f = malloc(sizeof(struct rotatedfont), M_DEVBUF, M_WAITOK);
@@ -1230,15 +1235,18 @@ rasops_putchar_rotated(void *cookie, int row, int col, u_int uc, long attr)
ri = (struct rasops_info *)cookie;
+ if (ri->ri_flg & RI_ROTATE_CW)
+ row = ri->ri_rows - row - 1;
+ else
+ col = ri->ri_cols - col - 1;
+
/* Do rotated char sans (side)underline */
- rc = ri->ri_real_ops.putchar(cookie, col, ri->ri_rows - row - 1, uc,
- attr & ~1);
+ rc = ri->ri_real_ops.putchar(cookie, col, row, uc, attr & ~1);
if (rc != 0)
return rc;
/* Do rotated underline */
- rp = ri->ri_bits + col * ri->ri_yscale + (ri->ri_rows - row - 1) *
- ri->ri_xscale;
+ rp = ri->ri_bits + col * ri->ri_yscale + row * ri->ri_xscale;
height = ri->ri_font->fontheight;
/* XXX this assumes 16-bit color depth */
diff --git a/sys/dev/rasops/rasops.h b/sys/dev/rasops/rasops.h
index 71302e93f4f..d338441d8cd 100644
--- a/sys/dev/rasops/rasops.h
+++ b/sys/dev/rasops/rasops.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rasops.h,v 1.18 2016/12/15 19:18:41 fcambus Exp $ */
+/* $OpenBSD: rasops.h,v 1.19 2017/08/17 20:21:53 kettenis Exp $ */
/* $NetBSD: rasops.h,v 1.13 2000/06/13 13:36:54 ad Exp $ */
/*-
@@ -52,10 +52,11 @@ struct wsdisplay_font;
#define RI_CLEARMARGINS 0x0020 /* clear display margins on startup */
#define RI_CENTER 0x0040 /* center onscreen output */
#define RI_CURSORCLIP 0x0080 /* cursor is currently clipped */
-#define RI_ROTATE_CW 0x0100 /* display is rotated, quarter clockwise */
-#define RI_CFGDONE 0x0200 /* rasops_reconfig() completed successfully */
-#define RI_VCONS 0x0400 /* virtual consoles */
-#define RI_WRONLY 0x0800 /* avoid framebuffer reads */
+#define RI_ROTATE_CW 0x0100 /* display is rotated, 90 deg clockwise */
+#define RI_ROTATE_CCW 0x0200 /* display is rotated, 90 deg anti-clockwise */
+#define RI_CFGDONE 0x0400 /* rasops_reconfig() completed successfully */
+#define RI_VCONS 0x0800 /* virtual consoles */
+#define RI_WRONLY 0x1000 /* avoid framebuffer reads */
struct rasops_screen;
diff --git a/sys/dev/wsfont/wsfont.c b/sys/dev/wsfont/wsfont.c
index 1f4046bdd62..24eec85d56b 100644
--- a/sys/dev/wsfont/wsfont.c
+++ b/sys/dev/wsfont/wsfont.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsfont.c,v 1.48 2017/05/30 13:14:44 fcambus Exp $ */
+/* $OpenBSD: wsfont.c,v 1.49 2017/08/17 20:21:53 kettenis Exp $ */
/* $NetBSD: wsfont.c,v 1.17 2001/02/07 13:59:24 ad Exp $ */
/*-
@@ -231,25 +231,14 @@ wsfont_enum(int (*cb)(void *, struct wsdisplay_font *), void *cbarg)
#if NRASOPS_ROTATION > 0
-struct wsdisplay_font *wsfont_rotate_internal(struct wsdisplay_font *);
+void wsfont_rotate_cw(struct wsdisplay_font *, char *, int);
+void wsfont_rotate_ccw(struct wsdisplay_font *, char *, int);
+struct wsdisplay_font *wsfont_rotate_internal(struct wsdisplay_font *, int);
-struct wsdisplay_font *
-wsfont_rotate_internal(struct wsdisplay_font *font)
+void
+wsfont_rotate_cw(struct wsdisplay_font *font, char *newbits, int newstride)
{
- int b, n, r, newstride;
- struct wsdisplay_font *newfont;
- char *newbits;
-
- /* Duplicate the existing font... */
- newfont = malloc(sizeof *font, M_DEVBUF, M_WAITOK);
-
- bcopy(font, newfont, sizeof *font);
- newfont->cookie = NULL;
-
- /* Allocate a buffer big enough for the rotated font. */
- newstride = (font->fontheight + 7) / 8;
- newbits = mallocarray(font->numchars, newstride * font->fontwidth,
- M_DEVBUF, M_WAITOK | M_ZERO);
+ int b, n, r;
/* Rotate the font a bit at a time. */
for (n = 0; n < font->numchars; n++) {
@@ -271,6 +260,58 @@ wsfont_rotate_internal(struct wsdisplay_font *font)
}
}
}
+}
+
+void
+wsfont_rotate_ccw(struct wsdisplay_font *font, char *newbits, int newstride)
+{
+ int b, n, r;
+
+ /* Rotate the font a bit at a time. */
+ for (n = 0; n < font->numchars; n++) {
+ char *ch = font->data + (n * font->stride * font->fontheight);
+
+ for (r = 0; r < font->fontheight; r++) {
+ for (b = 0; b < font->fontwidth; b++) {
+ int bb = font->fontwidth - 1 - b;
+ unsigned char *rb;
+
+ rb = ch + (font->stride * r) + (b / 8);
+ if (*rb & (0x80 >> (b % 8))) {
+ unsigned char *rrb;
+
+ rrb = newbits + (r / 8)
+ + (n * newstride * font->fontwidth)
+ + (newstride * bb);
+ *rrb |= (1 << (7 - (r % 8)));
+ }
+ }
+ }
+ }
+}
+
+struct wsdisplay_font *
+wsfont_rotate_internal(struct wsdisplay_font *font, int ccw)
+{
+ int newstride;
+ struct wsdisplay_font *newfont;
+ char *newbits;
+
+ /* Duplicate the existing font... */
+ newfont = malloc(sizeof *font, M_DEVBUF, M_WAITOK);
+
+ bcopy(font, newfont, sizeof *font);
+ newfont->cookie = NULL;
+
+ /* Allocate a buffer big enough for the rotated font. */
+ newstride = (font->fontheight + 7) / 8;
+ newbits = mallocarray(font->numchars, newstride * font->fontwidth,
+ M_DEVBUF, M_WAITOK | M_ZERO);
+
+ if (ccw)
+ wsfont_rotate_ccw(font, newbits, newstride);
+ else
+ wsfont_rotate_cw(font, newbits, newstride);
newfont->data = newbits;
@@ -294,7 +335,7 @@ wsfont_rotate_internal(struct wsdisplay_font *font)
}
int
-wsfont_rotate(int cookie)
+wsfont_rotate(int cookie, int ccw)
{
int s, ncookie;
struct wsdisplay_font *font;
@@ -304,7 +345,7 @@ wsfont_rotate(int cookie)
origfont = wsfont_find0(cookie);
splx(s);
- font = wsfont_rotate_internal(origfont->font);
+ font = wsfont_rotate_internal(origfont->font, ccw);
if (font == NULL)
return (-1);
diff --git a/sys/dev/wsfont/wsfont.h b/sys/dev/wsfont/wsfont.h
index f1b989ec300..ea11f155c89 100644
--- a/sys/dev/wsfont/wsfont.h
+++ b/sys/dev/wsfont/wsfont.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsfont.h,v 1.10 2013/10/20 21:24:01 miod Exp $ */
+/* $OpenBSD: wsfont.h,v 1.11 2017/08/17 20:21:53 kettenis Exp $ */
/* $NetBSD: wsfont.h,v 1.12 2000/06/13 13:37:07 ad Exp $ */
/*-
@@ -73,6 +73,6 @@ void wsfont_enum(int (*)(void *, struct wsdisplay_font *), void *);
int wsfont_lock(int, struct wsdisplay_font **, int, int);
int wsfont_unlock(int);
int wsfont_map_unichar(struct wsdisplay_font *, int);
-int wsfont_rotate(int);
+int wsfont_rotate(int, int);
#endif /* !_WSFONT_H_ */