From 4d3aa5644d864394fdb63b228c8e3e1b0966cad9 Mon Sep 17 00:00:00 2001 From: macallan Date: Thu, 19 Apr 2012 08:46:17 +0000 Subject: [PATCH] no need to convert cell number to coordinates every time we draw a glyph from cache - just stick the coordinates directly into the map --- sys/dev/wscons/wsdisplay_glyphcache.c | 9 ++++----- sys/dev/wscons/wsdisplay_glyphcachevar.h | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/sys/dev/wscons/wsdisplay_glyphcache.c b/sys/dev/wscons/wsdisplay_glyphcache.c index af50f9e77588..e0ea54ed01ed 100644 --- a/sys/dev/wscons/wsdisplay_glyphcache.c +++ b/sys/dev/wscons/wsdisplay_glyphcache.c @@ -1,4 +1,4 @@ -/* $NetBSD: wsdisplay_glyphcache.c,v 1.1 2012/02/16 17:29:21 macallan Exp $ */ +/* $NetBSD: wsdisplay_glyphcache.c,v 1.2 2012/04/19 08:46:17 macallan Exp $ */ /* * Copyright (c) 2012 Michael Lorenz @@ -82,10 +82,10 @@ glyphcache_add(glyphcache *gc, int c, int x, int y) if (gc->gc_usedcells >= gc->gc_numcells) return ENOMEM; cell = atomic_add_int_nv(&gc->gc_usedcells, 1) - 1; - gc->gc_map[c] = cell; cy = gc->gc_firstline + (cell / gc->gc_cellsperline) * gc->gc_cellheight; cx = (cell % gc->gc_cellsperline) * gc->gc_cellwidth; + gc->gc_map[c] = (cx << 16) | cy; gc->gc_bitblt(gc->gc_blitcookie, x, y, cx, cy, gc->gc_cellwidth, gc->gc_cellheight, gc->gc_rop); return 0; @@ -109,9 +109,8 @@ glyphcache_try(glyphcache *gc, int c, int x, int y, long attr) cell = gc->gc_map[c]; if (cell == -1) return GC_ADD; - cy = gc->gc_firstline + - (cell / gc->gc_cellsperline) * gc->gc_cellheight; - cx = (cell % gc->gc_cellsperline) * gc->gc_cellwidth; + cy = cell & 0xffff; + cx = (cell >> 16) & 0xffff; gc->gc_bitblt(gc->gc_blitcookie, cx, cy, x, y, gc->gc_cellwidth, gc->gc_cellheight, gc->gc_rop); return GC_OK; diff --git a/sys/dev/wscons/wsdisplay_glyphcachevar.h b/sys/dev/wscons/wsdisplay_glyphcachevar.h index 4abee1d69aa5..d7b0ea6f8c03 100644 --- a/sys/dev/wscons/wsdisplay_glyphcachevar.h +++ b/sys/dev/wscons/wsdisplay_glyphcachevar.h @@ -1,4 +1,4 @@ -/* $NetBSD: wsdisplay_glyphcachevar.h,v 1.1 2012/02/16 17:29:21 macallan Exp $ */ +/* $NetBSD: wsdisplay_glyphcachevar.h,v 1.2 2012/04/19 08:46:17 macallan Exp $ */ /* * Copyright (c) 2012 Michael Lorenz @@ -34,7 +34,7 @@ typedef struct _glyphcache { /* mapping char codes to cache cells */ volatile unsigned int gc_usedcells; int gc_numcells; - int gc_map[256]; + uint32_t gc_map[256]; /* geometry */ int gc_cellwidth; int gc_cellheight;