/* $NetBSD: rasops1.c,v 1.37 2019/08/10 01:24:17 rin Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Paint a single character. This is the generic version, this is ugly.
*/
static void
rasops1_putchar(void *cookie, int row, int col, u_int uc, long attr)
{
struct rasops_info *ri = (struct rasops_info *)cookie;
struct wsdisplay_font *font = PICK_FONT(ri, uc);
int height, width;
uint32_t bg, fg, lbg, rbg, fb, lmask, rmask, tmp, tmp0, tmp1;
uint32_t *rp, *hp;
uint8_t *fr;
bool space;
hp = NULL; /* XXX GCC */
if (__predict_false(!CHAR_IN_FONT(uc, font)))
return;
#ifdef RASOPS_CLIPPING
/* Catches 'row < 0' case too */
if ((unsigned)row >= (unsigned)ri->ri_rows)
return;
if ((unsigned)col >= (unsigned)ri->ri_cols)
return;
#endif
height = font->fontheight;
width = font->fontwidth;
col *= width;
rp = (uint32_t *)(ri->ri_bits + row * ri->ri_yscale +
((col >> 3) & ~3));
if (ri->ri_hwbits)
hp = (uint32_t *)(ri->ri_hwbits + row * ri->ri_yscale +
((col >> 3) & ~3));
col &= 31;
bg = ATTR_BG(ri, attr);
fg = ATTR_FG(ri, attr);
/* If fg and bg match this becomes a space character */
if (uc == ' ' || __predict_false(fg == bg)) {
space = true;
fr = NULL; /* XXX GCC */
} else {
space = false;
fr = FONT_GLYPH(uc, font, ri);
}
if (col + width <= 32) {
/* Single word, only one mask */
rmask = rasops_pmask[col][width & 31];
lmask = ~rmask;