/* $NetBSD: rasops24.c,v 1.50 2019/08/14 00:51:10 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.
*/
/*
* Erase rows. This is nice and easy due to alignment.
*/
static void
rasops24_eraserows(void *cookie, int row, int num, long attr)
{
struct rasops_info *ri = (struct rasops_info *)cookie;
int bytes, full, slop, cnt;
uint32_t bg, xstamp[3];
uint32_t *dp, *rp, *hp;
hp = NULL; /* XXX GCC */
/*
* If the color is gray, we can cheat and use the generic routines
* (which are faster, hopefully) since the r,g,b values are the same.
*/
if ((attr & WSATTR_PRIVATE2) != 0) {
rasops_eraserows(cookie, row, num, attr);
return;
}
#ifdef RASOPS_CLIPPING
if (row < 0) {
num += row;
row = 0;
}
if (row + num > ri->ri_rows)
num = ri->ri_rows - row;
/*
* XXX the wsdisplay_emulops interface seems a little deficient in
* that there is no way to clear the *entire* screen. We provide a
* workaround here: if the entire console area is being cleared, and
* the RI_FULLCLEAR flag is set, clear the entire display.
*/
if (num == ri->ri_rows && (ri->ri_flg & RI_FULLCLEAR) != 0) {
bytes = ri->ri_stride;
num = ri->ri_height;
rp = (uint32_t *)ri->ri_origbits;
if (ri->ri_hwbits)
hp = (uint32_t *)ri->ri_hworigbits;
} else {
bytes = ri->ri_emustride;
num *= ri->ri_font->fontheight;
rp = (uint32_t *)(ri->ri_bits + row * ri->ri_yscale);
if (ri->ri_hwbits)
hp = (uint32_t *)(ri->ri_hwbits + row * ri->ri_yscale);
}
full = bytes / (4 * 3);
slop = (bytes - full * (4 * 3)) / 4;
/*
* Erase columns.
*/
static void
rasops24_erasecols(void *cookie, int row, int col, int num, long attr)
{
struct rasops_info *ri = (struct rasops_info *)cookie;
int height, slop1, slop2, full, cnt;
uint32_t bg, xstamp[3];
uint32_t *dp;
uint8_t *bp, *rp, *hp;
hp = NULL; /* XXX GCC */
/*
* If the color is gray, we can cheat and use the generic routines
* (which are faster, hopefully) since the r,g,b values are the same.
*/
if ((attr & WSATTR_PRIVATE2) != 0) {
rasops_erasecols(cookie, row, col, num, attr);
return;
}
#ifdef RASOPS_CLIPPING
/* Catches 'row < 0' case too */
if ((unsigned)row >= (unsigned)ri->ri_rows)
return;
if (col < 0) {
num += col;
col = 0;
}
if (col + num > ri->ri_cols)
num = ri->ri_cols - col;
if (num <= 0)
return;
#endif
height = ri->ri_font->fontheight;
num *= ri->ri_xscale;
rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
if (ri->ri_hwbits)
hp = ri->ri_hwbits + row * ri->ri_yscale + col * ri->ri_xscale;