LCOV - code coverage report
Current view: top level - dev/rasops - rasops32.c (source / functions) Hit Total Coverage
Test: 6.4 Lines: 0 44 0.0 %
Date: 2018-10-19 03:25:38 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*      $OpenBSD: rasops32.c,v 1.8 2017/02/20 15:35:05 jcs Exp $        */
       2             : /*      $NetBSD: rasops32.c,v 1.7 2000/04/12 14:22:29 pk Exp $  */
       3             : 
       4             : /*-
       5             :  * Copyright (c) 1999 The NetBSD Foundation, Inc.
       6             :  * All rights reserved.
       7             :  *
       8             :  * This code is derived from software contributed to The NetBSD Foundation
       9             :  * by Andrew Doran.
      10             :  *
      11             :  * Redistribution and use in source and binary forms, with or without
      12             :  * modification, are permitted provided that the following conditions
      13             :  * are met:
      14             :  * 1. Redistributions of source code must retain the above copyright
      15             :  *    notice, this list of conditions and the following disclaimer.
      16             :  * 2. Redistributions in binary form must reproduce the above copyright
      17             :  *    notice, this list of conditions and the following disclaimer in the
      18             :  *    documentation and/or other materials provided with the distribution.
      19             :  *
      20             :  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
      21             :  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
      22             :  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
      23             :  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
      24             :  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      25             :  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
      26             :  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
      27             :  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
      28             :  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
      29             :  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      30             :  * POSSIBILITY OF SUCH DAMAGE.
      31             :  */
      32             : 
      33             : #include <sys/param.h>
      34             : #include <sys/systm.h>
      35             : #include <sys/time.h>
      36             : 
      37             : #include <dev/wscons/wsdisplayvar.h>
      38             : #include <dev/wscons/wsconsio.h>
      39             : #include <dev/rasops/rasops.h>
      40             : 
      41             : int     rasops32_putchar(void *, int, int, u_int, long);
      42             : 
      43             : /*
      44             :  * Initialize a 'rasops_info' descriptor for this depth.
      45             :  */
      46             : void
      47           0 : rasops32_init(struct rasops_info *ri)
      48             : {
      49             : 
      50           0 :         if (ri->ri_rnum == 0) {
      51           0 :                 ri->ri_rnum = 8;
      52           0 :                 ri->ri_rpos = 0;
      53           0 :                 ri->ri_gnum = 8;
      54           0 :                 ri->ri_gpos = 8;
      55           0 :                 ri->ri_bnum = 8;
      56           0 :                 ri->ri_bpos = 16;
      57           0 :         }
      58             : 
      59           0 :         ri->ri_ops.putchar = rasops32_putchar;
      60           0 : }
      61             : 
      62             : /*
      63             :  * Paint a single character.
      64             :  */
      65             : int
      66           0 : rasops32_putchar(void *cookie, int row, int col, u_int uc, long attr)
      67             : {
      68           0 :         int width, height, cnt, fs, fb, clr[2];
      69             :         struct rasops_info *ri;
      70             :         int32_t *dp, *rp;
      71             :         u_char *fr;
      72           0 :         uint32_t buffer[64];
      73             : 
      74           0 :         ri = (struct rasops_info *)cookie;
      75             : 
      76             : #ifdef RASOPS_CLIPPING
      77             :         /* Catches 'row < 0' case too */
      78             :         if ((unsigned)row >= (unsigned)ri->ri_rows)
      79             :                 return 0;
      80             : 
      81             :         if ((unsigned)col >= (unsigned)ri->ri_cols)
      82             :                 return 0;
      83             : #endif
      84             : 
      85           0 :         rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
      86             : 
      87           0 :         height = ri->ri_font->fontheight;
      88           0 :         width = ri->ri_font->fontwidth;
      89             : 
      90           0 :         clr[0] = ri->ri_devcmap[(attr >> 16) & 0xf];
      91           0 :         clr[1] = ri->ri_devcmap[(attr >> 24) & 0xf];
      92             : 
      93           0 :         if (uc == ' ') {
      94           0 :                 for (cnt = 0; cnt < width; cnt++)
      95           0 :                         buffer[cnt] = clr[0];
      96           0 :                 while (height--) {
      97             :                         dp = rp;
      98           0 :                         DELTA(rp, ri->ri_stride, int32_t *);
      99             : 
     100           0 :                         memcpy(dp, buffer, width << 2);
     101             :                 }
     102             :         } else {
     103           0 :                 uc -= ri->ri_font->firstchar;
     104           0 :                 fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
     105           0 :                 fs = ri->ri_font->stride;
     106             : 
     107           0 :                 while (height--) {
     108             :                         dp = rp;
     109           0 :                         fb = fr[3] | (fr[2] << 8) | (fr[1] << 16) |
     110           0 :                             (fr[0] << 24);
     111           0 :                         fr += fs;
     112           0 :                         DELTA(rp, ri->ri_stride, int32_t *);
     113             : 
     114           0 :                         for (cnt = 0; cnt < width; cnt++) {
     115           0 :                                 buffer[cnt] = clr[(fb >> 31) & 1];
     116           0 :                                 fb <<= 1;
     117             :                         }
     118           0 :                         memcpy(dp, buffer, width << 2);
     119             :                 }
     120             :         }
     121             : 
     122             :         /* Do underline */
     123           0 :         if ((attr & 1) != 0) {
     124           0 :                 DELTA(rp, -(ri->ri_stride << 1), int32_t *);
     125             : 
     126           0 :                 while (width--)
     127           0 :                         *rp++ = clr[1];
     128             :         }
     129             : 
     130           0 :         return 0;
     131           0 : }

Generated by: LCOV version 1.13