⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 out_blk.c

📁 unix vnc 协议源码. VNC是一款远程控制工具软件.
💻 C
📖 第 1 页 / 共 2 页
字号:
/* $XConsortium: out_blk.c,v 1.4 94/02/07 10:01:11 gildea Exp $ *//*Copyright 1989-1991, Bitstream Inc., Cambridge, MA.You are hereby granted permission under all Bitstream propriety rights touse, copy, modify, sublicense, sell, and redistribute the Bitstream Speedosoftware and the Bitstream Charter outline font for any purpose and withoutrestrictions; provided, that this notice is left intact on all copies of suchsoftware or font and that Bitstream's trademark is acknowledged as shown belowon all unmodified copies of such font.BITSTREAM CHARTER is a registered trademark of Bitstream Inc.BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDINGWITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR APARTICULAR PURPOSE.  BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECTDAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHERINCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTEDWITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.*//*************************** O U T _ B L K . C ********************************* *                                                                           * * This is an output module for black-writer mode.                           * *                                                                           * *****************************************************************************/#include "spdo_prv.h"               /* General definitions for Speedo   */#define   DEBUG      0#define   LOCAL      static#define   ABS(X)     ( (X < 0) ? -X : X)#if DEBUG#include <stdio.h>#define SHOW(X) printf("X = %d\n", X)#else#define SHOW(X)#endif/***** GLOBAL VARIABLES *****//***** GLOBAL FUNCTIONS *****//***** EXTERNAL VARIABLES *****//***** EXTERNAL FUNCTIONS *****//***** STATIC VARIABLES *****//***** STATIC FUNCTIONS *****/#if INCL_BLACK#if PROTOS_AVAILstatic void sp_add_intercept_black(PROTO_DECL2 fix15 y, fix15 x);static void sp_proc_intercepts_black(PROTO_DECL1);#elsestatic void    sp_add_intercept_black();static void    sp_proc_intercepts_black();#endif#endif#if INCL_BLACKFUNCTION boolean init_black(specsarg)GDECLspecs_t GLOBALFAR *specsarg;/* * init_out0() is called by sp_set_specs() to initialize the output module. * Returns TRUE if output module can accept requested specifications. * Returns FALSE otherwise. */{#if DEBUGprintf("INIT_BLK()\n");#endifif (specsarg->flags & CURVES_OUT)    return FALSE;           /* Curves out not supported */return (TRUE);}#endif#if INCL_BLACKFUNCTION boolean begin_char_black(Psw, Pmin, Pmax)GDECLpoint_t Psw;                   point_t Pmin;                   point_t Pmax;                   /* Called once at the start of the character generation process */{#if DEBUGprintf("BEGIN_CHAR_BLACK(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f\n",                     (real)Psw.x / (real)sp_globals.onepix, (real)Psw.y / (real)sp_globals.onepix,                    (real)Pmin.x / (real)sp_globals.onepix, (real)Pmin.y / (real)sp_globals.onepix,                    (real)Pmax.x / (real)sp_globals.onepix, (real)Pmax.y / (real)sp_globals.onepix);#endifinit_char_out(Psw,Pmin,Pmax);return TRUE;}#endif#if INCL_BLACKFUNCTION void begin_contour_black(P1, outside)GDECLpoint_t P1;                   boolean outside;/* Called at the start of each contour */{#if DEBUGprintf("BEGIN_CONTOUR_BLACK(%3.1f, %3.1f, %s)\n",     (real)P1.x / (real)sp_globals.onepix, (real)P1.y / (real)sp_globals.onepix, outside? "outside": "inside");#endifsp_globals.x0_spxl = P1.x;sp_globals.y0_spxl = P1.y;sp_globals.y_pxl = (sp_globals.y0_spxl + sp_globals.pixrnd) >> sp_globals.pixshift;}#endif#if INCL_BLACKFUNCTION void line_black(P1)GDECLpoint_t P1;                   /* Called for each vector in the transformed character */{register fix15     how_many_y;       /* # of intercepts at y = n + 1/2  */register fix15     yc, i;            /* Current scan-line */         fix15     temp1;            /* various uses */         fix15     temp2;            /* various uses */register fix31     dx_dy;            /* slope of line in 16.16 form */register fix31     xc;               /* high-precision (16.16) x coordinate */         fix15     x0,y0,x1,y1;      /* PIX.FRAC start and endpoints */x0 = sp_globals.x0_spxl;                 /* get start of line (== current point) */y0 = sp_globals.y0_spxl;sp_globals.x0_spxl = x1 = P1.x; /* end of line */sp_globals.y0_spxl = y1 = P1.y; /*  (also update current point to end of line) */yc = sp_globals.y_pxl;                   /* current scan line = end of last line */sp_globals.y_pxl = (y1 + sp_globals.pixrnd) >> sp_globals.pixshift;   /* calculate new end-scan sp_globals.line */#if DEBUGprintf("LINE_BLACK(%3.4f, %3.4f)\n",        (real)P1.x/(real)sp_globals.onepix,        (real)P1.y/(real)sp_globals.onepix);#endifif (sp_globals.extents_running)    {    if (sp_globals.x0_spxl > sp_globals.bmap_xmax)                 sp_globals.bmap_xmax = sp_globals.x0_spxl;    if (sp_globals.x0_spxl < sp_globals.bmap_xmin)        sp_globals.bmap_xmin = sp_globals.x0_spxl;    if (sp_globals.y0_spxl > sp_globals.bmap_ymax)        sp_globals.bmap_ymax = sp_globals.y0_spxl;    if (sp_globals.y0_spxl < sp_globals.bmap_ymin)        sp_globals.bmap_ymin = sp_globals.y0_spxl;    }if (sp_globals.intercept_oflo) return;if ((how_many_y = sp_globals.y_pxl - yc) == 0) return; /* Don't draw a null line */if (how_many_y < 0) yc--; /* Predecrment downward lines */if (yc > sp_globals.y_band.band_max) /* Is start point above band? */    {    if (sp_globals.y_pxl > sp_globals.y_band.band_max) return; /* line has to go down! */    how_many_y = sp_globals.y_pxl - (yc = sp_globals.y_band.band_max) - 1; /* Yes, limit it */    }if (yc < sp_globals.y_band.band_min)   /* Is start point below band? */    {    if (sp_globals.y_pxl < sp_globals.y_band.band_min) return; /* line has to go up! */    how_many_y = sp_globals.y_pxl - (yc = sp_globals.y_band.band_min);   /* Yes, limit it */    }xc = (fix31)(x0 + sp_globals.pixrnd) << (16 - sp_globals.pixshift); /* Original x coordinate with built in  */                                            /* rounding. 16.16 form */if ( (temp1 = (x1 - x0)) == 0)  /* check for vertical line */    {    yc -= sp_globals.y_band.band_min; /* yc is now an offset relative to the band */    temp1 = (fix15)(xc >> 16);     if (how_many_y < 0)        {   /* Vector down */        if ((how_many_y += yc + 1) < 0) how_many_y = 0; /* can't go below 0 */        for (i = yc; i >= how_many_y; i--)            sp_add_intercept_black(i,temp1);         }    else        {   /* Vector up */     /* check to see that line doesn't extend beyond top of band */        if ((how_many_y += yc) > sp_globals.no_y_lists) how_many_y = sp_globals.no_y_lists;        for (i = yc; i != how_many_y; i++)            sp_add_intercept_black(i,temp1);         }    return;    }          /* calculate dx_dy at 16.16 fixed point */dx_dy = ( (fix31)temp1 << 16 )/(fix31)(y1 - y0);/* We have to check for a @#$%@# possible multiply overflow  *//* by doing another @#$*& multiply.  In assembly language,   *//* the program could just check the OVerflow flag or whatever*//* works on the particular processor.  This C code is meant  *//* to be processor independant.                              */temp1 = (yc << sp_globals.pixshift) - y0 + sp_globals.pixrnd;/* This sees if the sign bits start at bit 15 *//* if they do, no overflow has occurred       */temp2 = (fix15)(MULT16(temp1,(fix15)(dx_dy >> 16)) >> 15);if (  (temp2 != (fix15)0xFFFF) &&      (temp2 != 0x0000) &&      /* Overflow. Pick point closest to yc + .5 */    (ABS(temp1) < ABS((yc << sp_globals.pixshift) - y1 + sp_globals.pixrnd)) )    { /* use x1 instead of x0 */    xc = (fix31)(x1 + sp_globals.pixrnd) << (16 - sp_globals.pixshift);    }else    {/* calculate new xc at the center of the *current* scan line *//* due to banding, yc may be several lines away from y0      *//*  xc += (yc + .5 - y0) * dx_dy *//* This multiply generates a subpixel delta. *//* So we shift it to be a 16.16 delta */    xc += ((fix31)temp1 * dx_dy) >> sp_globals.pixshift;    }yc -= sp_globals.y_band.band_min; /* yc is now an offset relative to the band */if (how_many_y < 0)    {   /* Vector down */    if (how_many_y == -1)        sp_add_intercept_black(yc, (fix15) (xc >> 16));    else        {        if ((how_many_y += yc + 1) < 0) how_many_y = 0; /* can't go below 0 */        for (i = yc; i >= how_many_y; i--)            {            temp1 = (fix15)(xc >> 16);             sp_add_intercept_black(i,temp1);             xc -= dx_dy;            }        }    }    else    {   /* Vector up */     /* check to see that line doesn't extend beyond top of band */    if (how_many_y == 1)        sp_add_intercept_black(yc, (fix15) (xc >> 16));    else        {        if ((how_many_y += yc) > sp_globals.no_y_lists) how_many_y = sp_globals.no_y_lists;        for (i = yc; i != how_many_y; i++)            {            temp1 = (fix15)(xc >> 16);            sp_add_intercept_black(i,temp1);             xc += dx_dy;            }        }    }}#endif#if INCL_BLACKFUNCTION boolean end_char_black()GDECL/* Called when all character data has been output * Return TRUE if output process is complete * Return FALSE to repeat output of the transformed data beginning * with the first contour */{fix31 xorg;fix31 yorg;#if INCL_CLIPPINGfix31 bmap_max, bmap_min;#endif#if DEBUGprintf("END_CHAR_BLACK()\n");#endifif (sp_globals.first_pass)    {    if (sp_globals.bmap_xmax >= sp_globals.bmap_xmin)        {        sp_globals.xmin = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;        sp_globals.xmax = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;        }    else        {        sp_globals.xmin = sp_globals.xmax = 0;        }    if (sp_globals.bmap_ymax >= sp_globals.bmap_ymin)        {#if INCL_CLIPPING    switch(sp_globals.tcb0.xtype)       {       case 1: /* 180 degree rotation */            if (sp_globals.specs.flags & CLIP_TOP)               {               sp_globals.clip_ymin = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));               sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift;               bmap_min = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;	       sp_globals.clip_ymin = -1 * sp_globals.clip_ymin;	       if (bmap_min < sp_globals.clip_ymin)		    sp_globals.ymin = sp_globals.clip_ymin;               else                    sp_globals.ymin = bmap_min;               }            if (sp_globals.specs.flags & CLIP_BOTTOM)               {               sp_globals.clip_ymax = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));               sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift;               bmap_max = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;	       if (bmap_max < sp_globals.clip_ymax)                    sp_globals.ymax = bmap_max;               else		    sp_globals.ymax = sp_globals.clip_ymax;               }               sp_globals.clip_xmax =  -sp_globals.xmin;               sp_globals.clip_xmin = ((sp_globals.set_width.x+32768L) >> 16) -                                      sp_globals.xmin;               break;       case 2: /* 90 degree rotation */            if (sp_globals.specs.flags & CLIP_TOP)               {               sp_globals.clip_xmin = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));               sp_globals.clip_xmin = sp_globals.clip_xmin >> sp_globals.multshift;               sp_globals.clip_xmin = -1 * sp_globals.clip_xmin;               bmap_min = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;	       if (bmap_min > sp_globals.clip_xmin)                    sp_globals.clip_xmin = bmap_min;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -