Module Name: src
Committed By: macallan
Date: Thu Jun 8 05:48:41 UTC 2023
Modified Files:
src/sys/dev/wscons: wsdisplay_glyphcache.c wsdisplay_glyphcachevar.h
Log Message:
allow drivers to specify horizontal alignment of glyph cache cells
for things like SX which have alignment restrictions
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/wscons/wsdisplay_glyphcache.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/wscons/wsdisplay_glyphcachevar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/wscons/wsdisplay_glyphcache.c
diff -u src/sys/dev/wscons/wsdisplay_glyphcache.c:1.11 src/sys/dev/wscons/wsdisplay_glyphcache.c:1.12
--- src/sys/dev/wscons/wsdisplay_glyphcache.c:1.11 Mon Sep 3 16:29:34 2018
+++ src/sys/dev/wscons/wsdisplay_glyphcache.c Thu Jun 8 05:48:41 2023
@@ -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);
Index: src/sys/dev/wscons/wsdisplay_glyphcachevar.h
diff -u src/sys/dev/wscons/wsdisplay_glyphcachevar.h:1.5 src/sys/dev/wscons/wsdisplay_glyphcachevar.h:1.6
--- src/sys/dev/wscons/wsdisplay_glyphcachevar.h:1.5 Fri Jun 2 19:30:10 2017
+++ src/sys/dev/wscons/wsdisplay_glyphcachevar.h Thu Jun 8 05:48:41 2023
@@ -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);