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

📄 set_trns.c

📁 unix vnc 协议源码. VNC是一款远程控制工具软件.
💻 C
📖 第 1 页 / 共 3 页
字号:
/* $XConsortium: set_trns.c,v 1.6 94/02/10 11:05:59 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.*//*************************** S E T _ T R N S . C ***************************** *                                                                           * * This module is called from do_char.c to set up the intelligent            * * transformation for one character (or sub-character of a composite         * * character. *                                                                           * ****************************************************************************/#include "spdo_prv.h"               /* General definitions for Speedo   */#define   DEBUG      0#if DEBUG#include <stdio.h>#define SHOW(X) printf("X = %d\n", X)#else#define SHOW(X)#endif/***** LOCAL MACROS     *****/#define SQUEEZE_X_ORU(A,B,C) ((((fix31)A * (fix31)B) + C) >> 16)#define ABS(A) ((A < 0)? -A:A) /* absolute value */#define IMPORT_FACTOR    \	shift = 16;\	while (*x_factor > (0x7fffffffL / (isw_scale >> (16 - shift))))\		shift--;\    	*x_factor = (*x_factor * (isw_scale>>(16-shift))) >> shift;/***** GLOBAL VARIABLES *****//*****  GLOBAL FUNCTIONS *****//***** EXTERNAL VARIABLES *****//***** EXTERNAL FUNCTIONS *****//***** STATIC VARIABLES *****//***** STATIC FUNCTIONS *****/#if PROTOS_AVAILstatic void sp_constr_update(PROTO_DECL1);static ufix8 FONTFAR *sp_setup_pix_table(PROTO_DECL2 ufix8 FONTFAR *pointer,boolean short_form,fix15 no_X_ctrl_zones,fix15 no_Y_ctrl_zones);static ufix8 FONTFAR *sp_setup_int_table(PROTO_DECL2 ufix8 FONTFAR *pointer,fix15 no_X_int_zones,fix15 no_Y_int_zones);#elsestatic void sp_constr_update();     /* Update constraint table */static ufix8 FONTFAR *sp_setup_pix_table();   /* Read control zone table */static ufix8 FONTFAR *sp_setup_int_table();   /* Read interpolation zone table */#endifFUNCTION void init_tcb()GDECL/* * Called by sp_make_char() and make_comp_char() to initialize the current * transformation control block to the top level transformation. */{sp_globals.tcb = sp_globals.tcb0;}FUNCTION void scale_tcb(ptcb, x_pos, y_pos, x_scale, y_scale)GDECLtcb_t GLOBALFAR *ptcb;    /* Transformation control block */fix15  x_pos;   /* X position (outline res units) */fix15  y_pos;   /* Y position (outline res units) */fix15  x_scale; /* X scale factor * ONE_SCALE */fix15  y_scale; /* Y scale factor * ONE_SCALE *//* * Called by make_comp_char() to apply position and scale for each of the * components of a compound character. */{     fix15 xx_mult = ptcb->xxmult;fix15 xy_mult = ptcb->xymult;fix31 x_offset = ptcb->xoffset;fix15 yx_mult = ptcb->yxmult;fix15 yy_mult = ptcb->yymult;fix31 y_offset = ptcb->yoffset;ptcb->xxmult = TRANS(xx_mult, x_scale, (fix31)SCALE_RND, SCALE_SHIFT);ptcb->xymult = TRANS(xy_mult, y_scale, (fix31)SCALE_RND, SCALE_SHIFT);ptcb->xoffset = MULT16(xx_mult, x_pos) + MULT16(xy_mult, y_pos) + x_offset;ptcb->yxmult = TRANS(yx_mult, x_scale, (fix31)SCALE_RND, SCALE_SHIFT);ptcb->yymult = TRANS(yy_mult, y_scale, (fix31)SCALE_RND, SCALE_SHIFT);ptcb->yoffset = MULT16(yx_mult, x_pos) + MULT16(yy_mult, y_pos) + y_offset;type_tcb(ptcb); /* Reclassify transformation types */}FUNCTION ufix8 FONTFAR *skip_interpolation_table(pointer,format)GDECLufix8 FONTFAR *pointer;  /* Pointer to next byte in char data */ufix8    format;    /* Character format byte */{fix15 i,n;ufix8 intsize[9];intsize[0] = 1;intsize[1] = 2;intsize[2] = 3;intsize[3] = 1;intsize[4] = 2;intsize[5] = 1;intsize[6] = 2;intsize[7] = 0;intsize[8] = 0;n = ((format & BIT6)? (fix15)NEXT_BYTE(pointer): 0) +    ((format & BIT7)? (fix15)NEXT_BYTE(pointer): 0);for (i = 0; i < n; i++)          /* For each entry in int table ... */    {    format = NEXT_BYTE(pointer); /* Read format byte */    if (format & BIT7)           /* Short Start/End point spec? */        {        pointer++;               /* Skip Start/End point byte */        }    else        {        pointer += intsize[format & 0x7];  /* Skip Start point spec */        pointer += intsize[(format >> 3) & 0x7]; /* Skip End point spec */        }    }return pointer;}FUNCTION ufix8 FONTFAR *skip_control_zone(pointer,format)GDECLufix8 FONTFAR *pointer;  /* Pointer to next byte in char data */ufix8    format;    /* Character format byte */{fix15    i,n;ufix16   tmpufix16;fix15    constr;n = sp_globals.no_X_orus + sp_globals.no_Y_orus - 2;for (i = 0; i < n; i++)          /* For each entry in control table ... */    {    if (format & BIT4)        pointer++;               /* Skip short form From/To fields */    else        pointer += 2;            /* Skip FROM and TO fields */    /* skip constraints field */    constr = NEXT_BYTES (pointer, tmpufix16);    }return pointer;}#if INCL_RULES#elseFUNCTION ufix8 FONTFAR *plaid_tcb(pointer, format)GDECLufix8 FONTFAR *pointer;  /* Pointer to next byte in char data */ufix8    format;    /* Character format byte *//*  * Called by make_simp_char() and make_comp_char() to set up the controlled * coordinate table and skip all other intelligent scaling rules embedded * in the character data. * Updates pointer to first byte after plaid data. * This is used only if intelligent scaling is not supported in the * configuration definitions. */{fix15  i, n;sp_globals.no_X_orus = (format & BIT2)?    (fix15)NEXT_BYTE(pointer):    0;sp_globals.no_Y_orus = (format & BIT3)?    (fix15)NEXT_BYTE(pointer):    0;pointer = read_oru_table(pointer);        /* Updates no_X/Y/orus */sp_globals.Y_edge_org = sp_globals.no_X_orus;/* Skip over control zone table */pointer = skip_control_zone(pointer,format);/* Skip over interpolation table */pointer = skip_interpolation_table(pointer,format);return pointer;}#endif#if INCL_RULESFUNCTION ufix8 FONTFAR *plaid_tcb(pointer, format)GDECLufix8 FONTFAR *pointer;  /* Pointer to next byte in char data */ufix8    format;    /* Character format byte *//*  * Called by make_simp_char() and make_comp_char() to set up the controlled * coordinate table and process all intelligent scaling rules embedded * in the character data. * Updates pointer to first byte after plaid data. * This is used only if intelligent scaling is enabled in the * configuration definitions. */{fix15 no_X_ctrl_zones;fix15 no_Y_ctrl_zones;fix15 no_X_int_zones;fix15 no_Y_int_zones;#if INCL_PLAID_OUT         /* Plaid data monitoring included? */begin_plaid_data();#endifsp_constr_update();           /* Update constraint table if required */sp_globals.no_X_orus = (format & BIT2)?      (fix15)NEXT_BYTE(pointer):    0;sp_globals.no_Y_orus = (format & BIT3)?    (fix15)NEXT_BYTE(pointer):    0;pointer = read_oru_table(pointer);  /* Updates no_X/Y/orus to include zero values */sp_globals.Y_edge_org = sp_globals.no_X_orus;                                                  if (sp_globals.no_X_orus > 1)         /* 2 or more controlled X coordinates? */    sp_globals.tcb.xmode = sp_globals.tcb.xtype; /* Enable intelligent scaling in X */if (sp_globals.no_Y_orus > 1)         /* 2 or more controlled Y coordinates? */    sp_globals.tcb.ymode = sp_globals.tcb.ytype; /* Enable intelligent scaling in Y */no_X_ctrl_zones = sp_globals.no_X_orus - 1;no_Y_ctrl_zones = sp_globals.no_Y_orus - 1;pointer = sp_setup_pix_table(pointer, (boolean)(format & BIT4),     no_X_ctrl_zones, no_Y_ctrl_zones);no_X_int_zones = (format & BIT6)?    (fix15)NEXT_BYTE(pointer):    0;no_Y_int_zones = (format & BIT7)?    (fix15)NEXT_BYTE(pointer):    0;sp_globals.Y_int_org = no_X_int_zones;pointer = sp_setup_int_table(pointer, no_X_int_zones, no_Y_int_zones);#if INCL_PLAID_OUT         /* Plaid data monitoring included? */end_plaid_data();#endifreturn pointer;}#endif#if INCL_RULESFUNCTION static void sp_constr_update()GDECL/* * Called by plaid_tcb() to update the constraint table for the current * transformation. * This is always carried out whenever a character is generated following * a change of font or scale factor or after initialization.      */{fix31    ppo;fix15    xppo;fix15    yppo;ufix8 FONTFAR  *pointer;fix15    no_X_constr;fix15    no_Y_constr;fix15    i, j, k, l, n;fix15    ppm;ufix8    format;ufix8    format1;fix15    limit;ufix16   constr_org;fix15    constr_nr;fix15    size;fix31    off;fix15    min;     fix15    orus;fix15    pix; ufix16   tmpufix16;  /* in extended mode, macro uses secnd term */if (sp_globals.constr.data_valid &&         /* Constr table already done and ... */    (sp_globals.tcb.xppo == sp_globals.constr.xppo) && /* ... X pix per oru unchanged and ... */    (sp_globals.tcb.yppo == sp_globals.constr.yppo))   /* ... Y pix per oru unchanged? */    {    return;                      /* No need to update constraint table */    }sp_globals.constr.xppo = xppo = sp_globals.tcb.xppo;   /* Update X pixels per oru indicator */sp_globals.constr.yppo = yppo = sp_globals.tcb.yppo;   /* Update Y pixels per oru indicator */sp_globals.constr.data_valid = TRUE;        /* Mark constraint table valid */pointer = sp_globals.constr.org;            /* Point to first byte of constraint data */no_X_constr = NEXT_BYTES(pointer, tmpufix16); /* Read nmbr of X constraints */no_Y_constr = NEXT_BYTES(pointer, tmpufix16); /* Read nmbr of Y constraints */i = 0;constr_org = 0;n = no_X_constr;ppo = xppo;for (j = 0; ; j++)    {    sp_globals.c_act[i] = FALSE;            /* Flag constraint 0 not active */    sp_globals.c_pix[i++] = 0;              /* Constraint 0 implies no minimum */    sp_globals.c_act[i] = FALSE;            /* Flag constraint 1 not active */    sp_globals.c_pix[i++] = sp_globals.onepix; /* Constraint 1 implies min 1 pixel*/    ppm = (ppo * (fix31)sp_globals.orus_per_em) >> sp_globals.multshift;    for (k = 0; k < n; k++)        {        format = NEXT_BYTE(pointer);        /* Read format byte */        limit = (fix15)NEXT_BYTE(pointer);  /* Read limit field */        sp_globals.c_act[i] =             ((ppm < limit) || (limit == 255)) &&            sp_globals.constr.active;        if (sp_globals.c_act[i])            /* Constraint active? */            {            if ((format & BIT1) &&          /* Constraint specified and ... */                (constr_nr = constr_org +                    ((format & BIT0)?       /* Read unsigned constraint value */                    NEXT_WORD(pointer):                     (fix15)NEXT_BYTE(pointer)),                 sp_globals.c_act[constr_nr])) /* ... and specified constraint active? */                 {                pix = sp_globals.c_pix[constr_nr]; /* Use constrained pixel value */                format1 = format;                for (l = 2; l > 0; l--)     /* Skip 2 arguments */                    {                    format1 >>= 2;                    if (size = format1 & 0x03)                        pointer += size - 1;                    }                }            else                 /* Constraint absent or inactive? */                {                orus = (format & BIT2)? /* Read unsigned oru value */                    NEXT_WORD(pointer):                    (fix15)NEXT_BYTE(pointer);                if (format & BIT5) /* Specified offset value? */                    {                    off = (fix31)((format & BIT4)? /* Read offset value */                        NEXT_WORD(pointer):                        (fix7)NEXT_BYTE(pointer));                    off = (off << (sp_globals.multshift - 6)) + sp_globals.multrnd;                    }                else             /* Unspecified (zero) offset value? */                    {                    off = sp_globals.multrnd;                    }                pix = (fix15)(((fix31)orus * ppo + off) / (1 << sp_globals.mpshift)) & sp_globals.pixfix;                }            }        else                     /* Constraint inactive? */            {            format1 = format;            for (l = 3; l > 0; l--) /* Skip over 3 arguments */                {                if (size = format1 & 0x03)                    pointer += size - 1;                format1 >>= 2;                }            pix = 0;            }        if (format & 0xc0) /* Specified minimum value? */            {            min = (format & BIT7)? /* Read unsigned minimum value */                (fix15)NEXT_BYTE(pointer) << sp_globals.pixshift:                sp_globals.onepix;            }        else             /* Unspecified (zero) minimum value? */            {            min = 0;            }        sp_globals.c_pix[i] = (pix < min)? min: pix;        i++;        }    if (j) break;                /* Finished if second time around loop */    constr_org = sp_globals.Y_constr_org = i;    n = no_Y_constr;    ppo = yppo;    }#if DEBUGprintf("\nCONSTRAINT TABLE\n");n = no_X_constr + 2;for (i = 0; i < n; i++)    {    printf("%3d   ", i);    if (sp_globals.c_act[i])        {        printf("T ");        }    else        {        printf("F ");        }    printf("%5.1f\n", ((real)sp_globals.c_pix[i] / (real)sp_globals.onepix));    }printf("--------------\n");n = no_Y_constr + 2;for (i = 0; i < n; i++)    {    j = i + sp_globals.Y_constr_org;    printf("%3d   ", i);    if (sp_globals.c_act[j])        {        printf("T ");        }    else        {        printf("F ");        }    printf("%5.1f\n", ((real)sp_globals.c_pix[j] / (real)sp_globals.onepix));    }#endif}#endif

⌨️ 快捷键说明

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