Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/rasops Provide and use FONT_GLYPH macro, tiny optimi...



details:   https://anonhg.NetBSD.org/src/rev/eb4ddc5fdddb
branches:  trunk
changeset: 462115:eb4ddc5fdddb
user:      rin <rin%NetBSD.org@localhost>
date:      Thu Jul 25 03:02:44 2019 +0000

description:
Provide and use FONT_GLYPH macro, tiny optimization version of WSFONT_GLYPH.

diffstat:

 sys/dev/rasops/rasops.h   |   6 +++++-
 sys/dev/rasops/rasops1.c  |  13 +++++--------
 sys/dev/rasops/rasops15.c |  18 +++++++-----------
 sys/dev/rasops/rasops2.c  |  16 ++++++----------
 sys/dev/rasops/rasops24.c |  16 ++++++----------
 sys/dev/rasops/rasops32.c |   8 ++++----
 sys/dev/rasops/rasops4.c  |  16 ++++++----------
 sys/dev/rasops/rasops8.c  |  14 +++++++-------
 8 files changed, 46 insertions(+), 61 deletions(-)

diffs (truncated from 408 to 300 lines):

diff -r 2b289bd28068 -r eb4ddc5fdddb sys/dev/rasops/rasops.h
--- a/sys/dev/rasops/rasops.h   Thu Jul 25 02:26:32 2019 +0000
+++ b/sys/dev/rasops/rasops.h   Thu Jul 25 03:02:44 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rasops.h,v 1.35 2019/07/24 18:33:49 rin Exp $ */
+/*     $NetBSD: rasops.h,v 1.36 2019/07/25 03:02:44 rin Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -149,6 +149,10 @@
                          (ri->ri_optfont.data != NULL)) ? \
                         &ri->ri_optfont : ri->ri_font
 
+#define        FONT_GLYPH(uc, font, ri)                                        \
+       ((uint8_t *)(font)->data + ((uc) - ((font)->firstchar)) *       \
+           (ri)->ri_fontscale)
+
 /*
  * rasops_init().
  *
diff -r 2b289bd28068 -r eb4ddc5fdddb sys/dev/rasops/rasops1.c
--- a/sys/dev/rasops/rasops1.c  Thu Jul 25 02:26:32 2019 +0000
+++ b/sys/dev/rasops/rasops1.c  Thu Jul 25 03:02:44 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rasops1.c,v 1.27 2019/07/25 02:26:32 rin Exp $ */
+/*     $NetBSD: rasops1.c,v 1.28 2019/07/25 03:02:44 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.27 2019/07/25 02:26:32 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.28 2019/07/25 03:02:44 rin Exp $");
 
 #include "opt_rasops.h"
 
@@ -123,8 +123,7 @@
                fr = 0;         /* shutup gcc */
                fs = 0;         /* shutup gcc */
        } else {
-               uc -= font->firstchar;
-               fr = (uint8_t *)font->data + uc * ri->ri_fontscale;
+               fr = FONT_GLYPH(uc, font, ri);
                fs = font->stride;
        }
 
@@ -314,8 +313,7 @@
                        }
                }
        } else {
-               uc -= font->firstchar;
-               fr = (uint8_t *)font->data + uc * ri->ri_fontscale;
+               fr = FONT_GLYPH(uc, font, ri);
                fs = font->stride;
 
                /* NOT fontbits if bg is white */
@@ -394,8 +392,7 @@
                        }
                }
        } else {
-               uc -= font->firstchar;
-               fr = (uint8_t *)font->data + uc * ri->ri_fontscale;
+               fr = FONT_GLYPH(uc, font, ri);
                fs = font->stride;
 
                /* NOT fontbits if bg is white */
diff -r 2b289bd28068 -r eb4ddc5fdddb sys/dev/rasops/rasops15.c
--- a/sys/dev/rasops/rasops15.c Thu Jul 25 02:26:32 2019 +0000
+++ b/sys/dev/rasops/rasops15.c Thu Jul 25 03:02:44 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rasops15.c,v 1.26 2019/07/25 02:26:32 rin Exp $        */
+/*     $NetBSD: rasops15.c,v 1.27 2019/07/25 03:02:44 rin Exp $        */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops15.c,v 1.26 2019/07/25 02:26:32 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops15.c,v 1.27 2019/07/25 03:02:44 rin Exp $");
 
 #include "opt_rasops.h"
 
@@ -164,8 +164,7 @@
                        }
                }
        } else {
-               uc -= font->firstchar;
-               fr = (uint8_t *)font->data + uc * ri->ri_fontscale;
+               fr = FONT_GLYPH(uc, font, ri);
 
                while (height--) {
                        dp = rp;
@@ -254,7 +253,7 @@
                        memcpy(dp, buffer, width << 1);
                }
        } else {
-               fr = WSFONT_GLYPH(uc, font);
+               fr = FONT_GLYPH(uc, font, ri);
 
                fgo = ((attr >> 24) & 0xf) * 3;
                bgo = ((attr >> 16) & 0xf) * 3;
@@ -383,8 +382,7 @@
                        }
                }
        } else {
-               uc -= font->firstchar;
-               fr = (uint8_t *)font->data + uc*ri->ri_fontscale;
+               fr = FONT_GLYPH(uc, font, ri);
                fs = font->stride;
 
                while (height--) {
@@ -481,8 +479,7 @@
                        }
                }
        } else {
-               uc -= font->firstchar;
-               fr = (uint8_t *)font->data + uc*ri->ri_fontscale;
+               fr = FONT_GLYPH(uc, font, ri);
                fs = font->stride;
 
                while (height--) {
@@ -587,8 +584,7 @@
                        }
                }
        } else {
-               uc -= font->firstchar;
-               fr = (uint8_t *)font->data + uc*ri->ri_fontscale;
+               fr = FONT_GLYPH(uc, font, ri);
                fs = font->stride;
 
                while (height--) {
diff -r 2b289bd28068 -r eb4ddc5fdddb sys/dev/rasops/rasops2.c
--- a/sys/dev/rasops/rasops2.c  Thu Jul 25 02:26:32 2019 +0000
+++ b/sys/dev/rasops/rasops2.c  Thu Jul 25 03:02:44 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rasops2.c,v 1.22 2019/07/25 02:26:32 rin Exp $ */
+/*     $NetBSD: rasops2.c,v 1.23 2019/07/25 03:02:44 rin Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops2.c,v 1.22 2019/07/25 02:26:32 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops2.c,v 1.23 2019/07/25 03:02:44 rin Exp $");
 
 #include "opt_rasops.h"
 
@@ -133,8 +133,7 @@
                fr = 0;         /* shutup gcc */
                fs = 0;         /* shutup gcc */
        } else {
-               uc -= font->firstchar;
-               fr = (uint8_t *)font->data + uc * ri->ri_fontscale;
+               fr = FONT_GLYPH(uc, font, ri);
                fs = font->stride;
        }
 
@@ -296,8 +295,7 @@
                        rp += rs;
                }
        } else {
-               uc -= font->firstchar;
-               fr = (uint8_t *)font->data + uc * ri->ri_fontscale;
+               fr = FONT_GLYPH(uc, font, ri);
                fs = font->stride;
 
                while (height--) {
@@ -360,8 +358,7 @@
                        rp += rs;
                }
        } else {
-               uc -= font->firstchar;
-               fr = (uint8_t *)font->data + uc * ri->ri_fontscale;
+               fr = FONT_GLYPH(uc, font, ri);
                fs = font->stride;
 
                while (height--) {
@@ -427,8 +424,7 @@
                        rp += rs;
                }
        } else {
-               uc -= font->firstchar;
-               fr = (uint8_t *)font->data + uc * ri->ri_fontscale;
+               fr = FONT_GLYPH(uc, font, ri);
                fs = font->stride;
 
                while (height--) {
diff -r 2b289bd28068 -r eb4ddc5fdddb sys/dev/rasops/rasops24.c
--- a/sys/dev/rasops/rasops24.c Thu Jul 25 02:26:32 2019 +0000
+++ b/sys/dev/rasops/rasops24.c Thu Jul 25 03:02:44 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rasops24.c,v 1.33 2019/07/25 02:26:32 rin Exp $        */
+/*     $NetBSD: rasops24.c,v 1.34 2019/07/25 03:02:44 rin Exp $        */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops24.c,v 1.33 2019/07/25 02:26:32 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops24.c,v 1.34 2019/07/25 03:02:44 rin Exp $");
 
 #include "opt_rasops.h"
 
@@ -153,8 +153,7 @@
                        }
                }
        } else {
-               uc -= font->firstchar;
-               fr = (uint8_t *)font->data + uc * ri->ri_fontscale;
+               fr = FONT_GLYPH(uc, font, ri);
 
                while (height--) {
                        dp = rp;
@@ -278,8 +277,7 @@
                        DELTA(rp, ri->ri_stride, uint32_t *);
                }
        } else {
-               uc -= font->firstchar;
-               fr = (uint8_t *)font->data + uc*ri->ri_fontscale;
+               fr = FONT_GLYPH(uc, font, ri);
                fs = font->stride;
 
                while (height--) {
@@ -352,8 +350,7 @@
                        DELTA(rp, ri->ri_stride, uint32_t *);
                }
        } else {
-               uc -= font->firstchar;
-               fr = (uint8_t *)font->data + uc*ri->ri_fontscale;
+               fr = FONT_GLYPH(uc, font, ri);
                fs = font->stride;
 
                while (height--) {
@@ -433,8 +430,7 @@
                        DELTA(rp, ri->ri_stride, uint32_t *);
                }
        } else {
-               uc -= font->firstchar;
-               fr = (uint8_t *)font->data + uc*ri->ri_fontscale;
+               fr = FONT_GLYPH(uc, font, ri);
                fs = font->stride;
 
                while (height--) {
diff -r 2b289bd28068 -r eb4ddc5fdddb sys/dev/rasops/rasops32.c
--- a/sys/dev/rasops/rasops32.c Thu Jul 25 02:26:32 2019 +0000
+++ b/sys/dev/rasops/rasops32.c Thu Jul 25 03:02:44 2019 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: rasops32.c,v 1.34 2019/07/24 18:33:49 rin Exp $       */
+/*      $NetBSD: rasops32.c,v 1.35 2019/07/25 03:02:44 rin Exp $       */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.34 2019/07/24 18:33:49 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.35 2019/07/25 03:02:44 rin Exp $");
 
 #include "opt_rasops.h"
 
@@ -122,7 +122,7 @@
                        }
                }
        } else {
-               fr = WSFONT_GLYPH(uc, font);
+               fr = FONT_GLYPH(uc, font, ri);
                fs = font->stride;
 
                while (height--) {
@@ -203,7 +203,7 @@
                        memcpy(dp, buffer, width << 2);
                }
        } else {
-               fr = WSFONT_GLYPH(uc, font);
+               fr = FONT_GLYPH(uc, font, ri);
 
                r0 = (clr[0] >> 16) & 0xff;
                r1 = (clr[1] >> 16) & 0xff;
diff -r 2b289bd28068 -r eb4ddc5fdddb sys/dev/rasops/rasops4.c
--- a/sys/dev/rasops/rasops4.c  Thu Jul 25 02:26:32 2019 +0000
+++ b/sys/dev/rasops/rasops4.c  Thu Jul 25 03:02:44 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rasops4.c,v 1.16 2019/07/25 02:26:32 rin Exp $ */
+/*     $NetBSD: rasops4.c,v 1.17 2019/07/25 03:02:44 rin Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>



Home | Main Index | Thread Index | Old Index