Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/rasops Scaling dimensions of underline by font height.



details:   https://anonhg.NetBSD.org/src/rev/f804b524d6c4
branches:  trunk
changeset: 964566:f804b524d6c4
user:      rin <rin%NetBSD.org@localhost>
date:      Wed Aug 07 12:27:49 2019 +0000

description:
Scaling dimensions of underline by font height.

Currently,
- offset of underline is fixed to 1-row from bottom of characters, and
- height of underline is fixed to 1.

Both are good for standard 8x16 fonts. However, it is too thin for
larger fonts, especially when used on display of high resolution.

Also, 1-row offset of underline is ugly for small fonts, e.g.,
spleen5x8.

Therefore, adjust offset and height as,
- no changes for standard 16-height fonts.
- scaling by font height for larger fonts.
- set offset to zero for fonts of height smaller than 16.

diffstat:

 sys/dev/rasops/rasops.c                |  11 +++++--
 sys/dev/rasops/rasops1.c               |  46 +++++++++++++++++++++------------
 sys/dev/rasops/rasops1_putchar_width.h |  17 ++++++++----
 sys/dev/rasops/rasops_putchar_width.h  |  18 ++++++++----
 4 files changed, 60 insertions(+), 32 deletions(-)

diffs (176 lines):

diff -r 736b46392d3d -r f804b524d6c4 sys/dev/rasops/rasops.c
--- a/sys/dev/rasops/rasops.c   Wed Aug 07 12:09:30 2019 +0000
+++ b/sys/dev/rasops/rasops.c   Wed Aug 07 12:27:49 2019 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: rasops.c,v 1.116 2019/08/07 11:57:40 rin Exp $        */
+/*      $NetBSD: rasops.c,v 1.117 2019/08/07 12:27:49 rin Exp $        */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.116 2019/08/07 11:57:40 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.117 2019/08/07 12:27:49 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_rasops.h"
@@ -332,7 +332,7 @@
 int
 rasops_reconfig(struct rasops_info *ri, int wantrows, int wantcols)
 {
-       int bpp, s;
+       int bpp, height, s;
        size_t len;
 
        s = splhigh();
@@ -483,6 +483,11 @@
        } else
                ri->ri_xorigin = ri->ri_yorigin = 0;
 
+       /* Scaling underline by font height */
+       height = ri->ri_font->fontheight;
+       ri->ri_ul.off = rounddown(height, 16) / 16;     /* offset from bottom */
+       ri->ri_ul.height = roundup(height, 16) / 16;    /* height */
+
        /*
         * Fill in defaults for operations set.  XXX this nukes private
         * routines used by accelerated fb drivers.
diff -r 736b46392d3d -r f804b524d6c4 sys/dev/rasops/rasops1.c
--- a/sys/dev/rasops/rasops1.c  Wed Aug 07 12:09:30 2019 +0000
+++ b/sys/dev/rasops/rasops1.c  Wed Aug 07 12:27:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rasops1.c,v 1.34 2019/08/02 04:39:09 rin Exp $ */
+/*     $NetBSD: rasops1.c,v 1.35 2019/08/07 12:27:49 rin Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.34 2019/08/02 04:39:09 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.35 2019/08/07 12:27:49 rin Exp $");
 
 #include "opt_rasops.h"
 
@@ -170,12 +170,18 @@
 
                /* Do underline */
                if ((attr & WSATTR_UNDERLINE) != 0) {
-                       DELTA(rp, -(ri->ri_stride << 1), uint32_t *);
-                       tmp = (*rp & lmask) | (fg & rmask);
-                       *rp = tmp;
-                       if (ri->ri_hwbits) {
-                               DELTA(hp, -(ri->ri_stride << 1), uint32_t *);
-                               *hp = tmp;
+                       DELTA(rp, - ri->ri_stride * ri->ri_ul.off, uint32_t *);
+                       if (ri->ri_hwbits)
+                               DELTA(hp, - ri->ri_stride * ri->ri_ul.off,
+                                   uint32_t *);
+                       for (height = ri->ri_ul.height; height; height--) {
+                               DELTA(rp, - ri->ri_stride, uint32_t *);
+                               tmp = (*rp & lmask) | (fg & rmask);
+                               *rp = tmp;
+                               if (ri->ri_hwbits) {
+                                       DELTA(hp, - ri->ri_stride, uint32_t *);
+                                       *hp = tmp;
+                               }
                        }
                }
        } else {
@@ -223,15 +229,21 @@
 
                /* Do underline */
                if ((attr & WSATTR_UNDERLINE) != 0) {
-                       DELTA(rp, -(ri->ri_stride << 1), uint32_t *);
-                       tmp0 = (rp[0] & lmask) | (fg & ~lmask);
-                       tmp1 = (rp[1] & rmask) | (fg & ~rmask);
-                       rp[0] = tmp0;
-                       rp[1] = tmp1;
-                       if (ri->ri_hwbits) {
-                               DELTA(hp, -(ri->ri_stride << 1), uint32_t *);
-                               hp[0] = tmp0;
-                               hp[1] = tmp1;
+                       DELTA(rp, - ri->ri_stride * ri->ri_ul.off, uint32_t *);
+                       if (ri->ri_hwbits)
+                               DELTA(hp, - ri->ri_stride * ri->ri_ul.off,
+                                   uint32_t *);
+                       for (height = ri->ri_ul.height; height; height--) {
+                               DELTA(rp, - ri->ri_stride, uint32_t *);
+                               tmp0 = (rp[0] & lmask) | (fg & ~lmask);
+                               tmp1 = (rp[1] & rmask) | (fg & ~rmask);
+                               rp[0] = tmp0;
+                               rp[1] = tmp1;
+                               if (ri->ri_hwbits) {
+                                       DELTA(hp, - ri->ri_stride, uint32_t *);
+                                       hp[0] = tmp0;
+                                       hp[1] = tmp1;
+                               }
                        }
                }
        }
diff -r 736b46392d3d -r f804b524d6c4 sys/dev/rasops/rasops1_putchar_width.h
--- a/sys/dev/rasops/rasops1_putchar_width.h    Wed Aug 07 12:09:30 2019 +0000
+++ b/sys/dev/rasops/rasops1_putchar_width.h    Wed Aug 07 12:27:49 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops1_putchar_width.h,v 1.3 2019/08/07 11:13:20 rin Exp $ */
+/* $NetBSD: rasops1_putchar_width.h,v 1.4 2019/08/07 12:27:49 rin Exp $ */
 
 /* NetBSD: rasops1.c,v 1.28 2019/07/25 03:02:44 rin Exp */
 /*-
@@ -119,11 +119,16 @@
 
        /* Do underline */
        if ((attr & WSATTR_UNDERLINE) != 0) {
-               DELTA(rp, -(ri->ri_stride << 1), COPY_UNIT *);
-               *rp = fg;
-               if (ri->ri_hwbits) {
-                       DELTA(hp, -(ri->ri_stride << 1), COPY_UNIT *);
-                       *hp = fg;
+               DELTA(rp, - ri->ri_stride * ri->ri_ul.off, COPY_UNIT *);
+               if (ri->ri_hwbits)
+                       DELTA(hp, - ri->ri_stride * ri->ri_ul.off, COPY_UNIT *);
+               for (height = ri->ri_ul.height; height; height--) {
+                       DELTA(rp, - ri->ri_stride, COPY_UNIT *);
+                       *rp = fg;
+                       if (ri->ri_hwbits) {
+                               DELTA(hp, - ri->ri_stride, COPY_UNIT *);
+                               *hp = fg;
+                       }
                }
        }
 }
diff -r 736b46392d3d -r f804b524d6c4 sys/dev/rasops/rasops_putchar_width.h
--- a/sys/dev/rasops/rasops_putchar_width.h     Wed Aug 07 12:09:30 2019 +0000
+++ b/sys/dev/rasops/rasops_putchar_width.h     Wed Aug 07 12:27:49 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops_putchar_width.h,v 1.11 2019/08/07 11:47:33 rin Exp $ */
+/* $NetBSD: rasops_putchar_width.h,v 1.12 2019/08/07 12:27:49 rin Exp $ */
 
 /* NetBSD: rasops8.c,v 1.41 2019/07/25 03:02:44 rin Exp  */
 /*-
@@ -261,11 +261,17 @@
 
        /* Do underline */
        if ((attr & WSATTR_UNDERLINE) != 0) {
-               DELTA(rp, -(ri->ri_stride << 1), STAMP_TYPE *);
-               SUBST_STAMP(FILLED_STAMP);
-               if (ri->ri_hwbits) {
-                       DELTA(hp, -(ri->ri_stride << 1), STAMP_TYPE *);
-                       memcpy(hp, rp, SUBST_BYTES);
+               DELTA(rp, - ri->ri_stride * ri->ri_ul.off, STAMP_TYPE *);
+               if (ri->ri_hwbits)
+                       DELTA(hp, - ri->ri_stride * ri->ri_ul.off,
+                           STAMP_TYPE *);
+               for (height = ri->ri_ul.height; height; height--) {
+                       DELTA(rp, - ri->ri_stride, STAMP_TYPE *);
+                       SUBST_STAMP(FILLED_STAMP);
+                       if (ri->ri_hwbits) {
+                               DELTA(hp, - ri->ri_stride, STAMP_TYPE *);
+                               memcpy(hp, rp, SUBST_BYTES);
+                       }
                }
        }
 }



Home | Main Index | Thread Index | Old Index