no need to convert cell number to coordinates every time we draw a glyph

from cache - just stick the coordinates directly into the map
This commit is contained in:
macallan 2012-04-19 08:46:17 +00:00
parent efeff40d67
commit 4d3aa5644d
2 changed files with 6 additions and 7 deletions

View File

@ -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;

View File

@ -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;