1 /* $NetBSD: wsdisplay_glyphcachevar.h,v 1.5 2017/06/02 19:30:10 macallan Exp $ */ 2 3 /* 4 * Copyright (c) 2012 Michael Lorenz 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 /* a simple glyph cache in offscreen memory */ 29 30 #ifndef WSDISPLAY_GLYPHCACHEVAR_H 31 #define WSDISPLAY_GLYPHCACHEVAR_H 32 33 #include <sys/time.h> 34 35 typedef struct _gc_bucket { 36 int gb_firstcell; 37 int gb_numcells; 38 volatile unsigned int gb_usedcells; 39 int gb_index; /* -1 for unused buckets */ 40 uint32_t gb_map[223]; /* we only care about char codes 0x21 and up */ 41 time_t gb_lastread; 42 } gc_bucket; 43 44 typedef struct _glyphcache { 45 /* geometry */ 46 int gc_numcells; 47 int gc_cellwidth; 48 int gc_cellheight; 49 int gc_cellsperline; 50 int gc_firstline; /* first line in vram to use for glyphs */ 51 int gc_lines; 52 int gc_width; 53 int gc_fontcookie; 54 /* buckets */ 55 int gc_numbuckets; /* buckets we can use */ 56 int gc_nbuckets; /* buckets allocated */ 57 gc_bucket *gc_buckets; /* we allocate as many as we can get into vram */ 58 gc_bucket *gc_next; /* bucket the next glyph goes into */ 59 long gc_underline; /* draw an underline in glyphcache_add() */ 60 int gc_attrmap[256]; /* mapping a colour attribute to a bucket */ 61 /* 62 * method to copy glyphs within vram, 63 * to be initialized before calling glyphcache_init() 64 */ 65 void (*gc_bitblt)(void *, int, int, int, int, int, int, int); 66 void (*gc_rectfill)(void *, int, int, int, int, long); 67 void *gc_blitcookie; 68 int gc_rop; 69 } glyphcache; 70 71 /* first line, lines, width, cellwidth, cellheight, attr */ 72 int glyphcache_init(glyphcache *, int, int, int, int, int, long); 73 74 /* adapt to changed font */ 75 int glyphcache_reconfig(glyphcache *, int, int, long); 76 77 /* helper for showscreen_cb */ 78 void glyphcache_adapt(struct vcons_screen *, void *); 79 80 /* clear out the cache, for example when returning from X */ 81 void glyphcache_wipe(glyphcache *); 82 83 /* add a glyph to the cache */ 84 int glyphcache_add(glyphcache *, int, int, int); /* char code, x, y */ 85 86 /* try to draw a glyph from the cache */ 87 int glyphcache_try(glyphcache *, int, int, int, long); /* char code, x, y, attr */ 88 #define GC_OK 0 /* glyph was in cache and has been drawn */ 89 #define GC_ADD 1 /* glyph is not in cache but can be added */ 90 #define GC_NOPE 2 /* glyph is not in cache and can't be added */ 91 /* 92 * draw an underline in the given attribute 93 * must be called by the driver if glyphcache_try() returns GC_NOPE and for 94 * blanks 95 */ 96 void glyphcache_underline(glyphcache *, int, int, long); 97 98 #endif /* WSDISPLAY_GLYPHCACHEVAR_H */ 99