Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/wscons allow drivers to specify horizontal alignment...
details: https://anonhg.NetBSD.org/src/rev/3e35d50894ec
branches: trunk
changeset: 376267:3e35d50894ec
user: macallan <macallan%NetBSD.org@localhost>
date: Thu Jun 08 05:48:41 2023 +0000
description:
allow drivers to specify horizontal alignment of glyph cache cells
for things like SX which have alignment restrictions
diffstat:
sys/dev/wscons/wsdisplay_glyphcache.c | 27 ++++++++++++++++++++++-----
sys/dev/wscons/wsdisplay_glyphcachevar.h | 7 ++++++-
2 files changed, 28 insertions(+), 6 deletions(-)
diffs (108 lines):
diff -r ecacea3e9c08 -r 3e35d50894ec sys/dev/wscons/wsdisplay_glyphcache.c
--- a/sys/dev/wscons/wsdisplay_glyphcache.c Thu Jun 08 00:27:34 2023 +0000
+++ b/sys/dev/wscons/wsdisplay_glyphcache.c Thu Jun 08 05:48:41 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsdisplay_glyphcache.c,v 1.11 2018/09/03 16:29:34 riastradh Exp $ */
+/* $NetBSD: wsdisplay_glyphcache.c,v 1.12 2023/06/08 05:48:41 macallan Exp $ */
/*
* Copyright (c) 2012 Michael Lorenz
@@ -53,17 +53,24 @@
static inline int
attr2idx(long attr)
{
- if ((attr & 0xf0f0fff8) != 0)
+ if ((attr & 0xf0f00ff8) != 0)
return -1;
return (((attr >> 16) & 0x0f) | ((attr >> 20) & 0xf0));
}
-/* first line, lines, width, attr */
int
glyphcache_init(glyphcache *gc, int first, int lines, int width,
int cellwidth, int cellheight, long attr)
{
+ return glyphcache_init_align(gc, first, lines, width, cellwidth, cellheight,
+ attr, 0);
+}
+
+int
+glyphcache_init_align(glyphcache *gc, int first, int lines, int width,
+ int cellwidth, int cellheight, long attr, int alignment)
+{
/* first the geometry stuff */
if (lines < 0) lines = 0;
@@ -72,6 +79,7 @@ glyphcache_init(glyphcache *gc, int firs
gc->gc_cellheight = -1;
gc->gc_firstline = first;
gc->gc_lines = lines;
+ gc->gc_cellalign = alignment;
gc->gc_buckets = NULL;
gc->gc_numbuckets = 0;
// XXX: Never free?
@@ -97,9 +105,16 @@ glyphcache_reconfig(glyphcache *gc, int
}
gc->gc_cellwidth = cellwidth;
+ if (gc->gc_cellalign != 0) {
+ /* alignment in bytes */
+ gc->gc_cellstride =
+ (gc->gc_cellwidth + gc->gc_cellalign - 1) &
+ ~(gc->gc_cellalign - 1);
+ } else
+ gc->gc_cellstride = cellwidth;
gc->gc_cellheight = cellheight;
- gc->gc_cellsperline = gc->gc_width / cellwidth;
+ gc->gc_cellsperline = gc->gc_width / gc->gc_cellstride;
cache_lines = gc->gc_lines / cellheight;
gc->gc_numcells = cache_lines * gc->gc_cellsperline;
@@ -144,6 +159,8 @@ glyphcache_reconfig(glyphcache *gc, int
glyphcache_wipe(gc);
DPRINTF("%s: using %d cells total, from %d width %d\n", __func__,
gc->gc_numcells, gc->gc_firstline, gc->gc_cellsperline);
+ DPRINTF("%s: cell size %d x %d, stride %d\n", __func__,
+ gc->gc_cellwidth, gc->gc_cellheight, gc->gc_cellstride);
return 0;
}
@@ -209,7 +226,7 @@ glyphcache_add(glyphcache *gc, int c, in
cell += b->gb_firstcell;
cy = gc->gc_firstline +
(cell / gc->gc_cellsperline) * gc->gc_cellheight;
- cx = (cell % gc->gc_cellsperline) * gc->gc_cellwidth;
+ cx = (cell % gc->gc_cellsperline) * gc->gc_cellstride;
b->gb_map[c - 33] = (cx << 16) | cy;
gc->gc_bitblt(gc->gc_blitcookie, x, y, cx, cy,
gc->gc_cellwidth, gc->gc_cellheight, gc->gc_rop);
diff -r ecacea3e9c08 -r 3e35d50894ec sys/dev/wscons/wsdisplay_glyphcachevar.h
--- a/sys/dev/wscons/wsdisplay_glyphcachevar.h Thu Jun 08 00:27:34 2023 +0000
+++ b/sys/dev/wscons/wsdisplay_glyphcachevar.h Thu Jun 08 05:48:41 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsdisplay_glyphcachevar.h,v 1.5 2017/06/02 19:30:10 macallan Exp $ */
+/* $NetBSD: wsdisplay_glyphcachevar.h,v 1.6 2023/06/08 05:48:41 macallan Exp $ */
/*
* Copyright (c) 2012 Michael Lorenz
@@ -45,6 +45,8 @@ typedef struct _glyphcache {
/* geometry */
int gc_numcells;
int gc_cellwidth;
+ int gc_cellstride;
+ int gc_cellalign;
int gc_cellheight;
int gc_cellsperline;
int gc_firstline; /* first line in vram to use for glyphs */
@@ -71,6 +73,9 @@ typedef struct _glyphcache {
/* first line, lines, width, cellwidth, cellheight, attr */
int glyphcache_init(glyphcache *, int, int, int, int, int, long);
+/* first line, lines, width, cellwidth, cellheight, attr, alignment */
+int glyphcache_init_align(glyphcache *, int, int, int, int, int, long, int);
+
/* adapt to changed font */
int glyphcache_reconfig(glyphcache *, int, int, long);
Home |
Main Index |
Thread Index |
Old Index