📄 out_scrn.c
字号:
/* $XConsortium: out_scrn.c,v 1.5 94/02/10 14:15:39 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 _ S C R N . C ***************************** * * * This is an output module for screen-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 PROTOS_AVAILstatic void sp_add_intercept_screen(PROTO_DECL2 fix15 y,fix31 x);static void sp_proc_intercepts_screen(PROTO_DECL1);#elsestatic void sp_add_intercept_screen();static void sp_proc_intercepts_screen();#endif#if INCL_SCREENFUNCTION boolean init_screen(specsarg)GDECLspecs_t FONTFAR *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_SCREEN()\n");#endifreturn (TRUE);}#endif#if INCL_SCREENFUNCTION boolean begin_char_screen(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_SCREEN(%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);#endifif (sp_globals.pixshift > 8) sp_intercepts.fracpix = sp_globals.onepix << (8 - sp_globals.pixshift);else sp_intercepts.fracpix = sp_globals.onepix >> (sp_globals.pixshift - 8);init_char_out(Psw,Pmin,Pmax);return TRUE;}#endif#if INCL_SCREENFUNCTION void begin_contour_screen(P1, outside)GDECLpoint_t P1; boolean outside;/* Called at the start of each contour */{#if DEBUGprintf("BEGIN_CONTOUR_SCREEN(%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_SCREENFUNCTION void curve_screen(P1, P2, P3, depth)GDECLpoint_t P1, P2, P3;fix15 depth;{fix31 X0;fix31 Y0;fix31 X1;fix31 Y1;fix31 X2;fix31 Y2;fix31 X3;fix31 Y3;#if DEBUGprintf("CURVE_SCREEN(%6.4f, %6.4f, %6.4f, %6.4f, %6.4f, %6.4f)\n", (real)P1.x / (real)sp_globals.onepix, (real)P1.y / (real)sp_globals.onepix, (real)P2.x / (real)sp_globals.onepix, (real)P2.y / (real)sp_globals.onepix, (real)P3.x / (real)sp_globals.onepix, (real)P3.y / (real)sp_globals.onepix);#endifif (sp_globals.extents_running) /* Accumulate actual character extents if required */ { if (P3.x > sp_globals.bmap_xmax) sp_globals.bmap_xmax = P3.x; if (P3.x < sp_globals.bmap_xmin) sp_globals.bmap_xmin = P3.x; if (P3.y > sp_globals.bmap_ymax) sp_globals.bmap_ymax = P3.y; if (P3.y < sp_globals.bmap_ymin) sp_globals.bmap_ymin = P3.y; }X0 = ((fix31)sp_globals.x0_spxl << sp_globals.poshift) + (fix31)32768;Y0 = ((fix31)sp_globals.y0_spxl << sp_globals.poshift) + (fix31)32768;X1 = ((fix31)P1.x << sp_globals.poshift) + (fix31)32768;Y1 = ((fix31)P1.y << sp_globals.poshift) + (fix31)32768;X2 = ((fix31)P2.x << sp_globals.poshift) + (fix31)32768;Y2 = ((fix31)P2.y << sp_globals.poshift) + (fix31)32768;X3 = ((fix31)P3.x << sp_globals.poshift) + (fix31)32768;Y3 = ((fix31)P3.y << sp_globals.poshift) + (fix31)32768;if (((Y0 - Y3) * sp_globals.tcb.mirror) > 0) { sp_intercepts.leftedge = LEFT_INT; }else { sp_intercepts.leftedge = 0; }scan_curve_screen(X0,Y0,X1,Y1,X2,Y2,X3,Y3);sp_globals.x0_spxl = P3.x;sp_globals.y0_spxl = P3.y;sp_globals.y_pxl = (P3.y + sp_globals.pixrnd) >> sp_globals.pixshift; /* calculate new end-scan sp_globals.line */}FUNCTION void scan_curve_screen(X0,Y0,X1,Y1,X2,Y2,X3,Y3)GDECLfix31 X0,Y0,X1,Y1,X2,Y2,X3,Y3;/* Called for each curve in the transformed character if curves out enabled */{fix31 Pmidx;fix31 Pmidy;fix31 Pctrl1x;fix31 Pctrl1y;fix31 Pctrl2x;fix31 Pctrl2y;#if DBGCRVprintf("SCAN_CURVE_SCREEN(%6.4f, %6.4f, %6.4f, %6.4f, %6.4f, %6.4f, %6.4f, %6.4f)\n", (real)(X0-32768) / 65536.0, (real)(Y0-32768) / 65536.0, (real)(X1-32768) / 65536.0, (real)(Y1-32768) / 65536.0, (real)(X2-32768) / 65536.0, (real)(Y2-32768) / 65536.0, (real)(X3-32768) / 65536.0, (real)(Y3-32768) / 65536.0);#endifif (((Y3 >> 16)) == (Y0 >> 16) || (Y3+1) == Y0 || Y3 == (Y0+1)) { return; }if ((X3 >> 16) == (X0 >> 16)) { vert_line_screen(X3,(Y0>>16),(Y3>>16)); return; }Pmidx = (X0 + (X1 + X2) * 3 + X3 + 4 ) >> 3;Pmidy = (Y0 + (Y1 + Y2) * 3 + Y3 + 4 ) >> 3;Pctrl1x = (X0 + X1 + 1 ) >> 1;Pctrl1y = (Y0 + Y1 + 1) >> 1;Pctrl2x = (X0 + (X1 << 1) + X2 + 2 ) >> 2;Pctrl2y = (Y0 + (Y1 << 1) + Y2 + 2 ) >> 2;scan_curve_screen(X0,Y0, Pctrl1x, Pctrl1y, Pctrl2x,Pctrl2y, Pmidx,Pmidy);Pctrl1x = (X1 + (X2 << 1) + X3 + 2 ) >> 2;Pctrl1y = (Y1 + (Y2 << 1) + Y3 + 2 ) >> 2;Pctrl2x = (X2 + X3 + 1 ) >> 1;Pctrl2y = (Y2 + Y3 + 1 ) >> 1;scan_curve_screen(Pmidx,Pmidy, Pctrl1x,Pctrl1y, Pctrl2x,Pctrl2y, X3,Y3);} FUNCTION void vert_line_screen(x,y1,y2)GDECLfix31 x;fix15 y1, y2;{ #if DBGCRVprintf("VERT_LINE_SCREEN(%6.4f, %6.4f, %6.4f)\n", (real)(x - 32768) / 65536.0, (real)(y1 - 32768) / 65536.0, (real)(y2 - 32768) / 65536.0);#endifif (sp_globals.intercept_oflo) return;if (y1 > y2) /* Line goes downwards ? */ { if (y1 > (sp_globals.y_band.band_max + 1)) /* Start point above top of band? */ y1 = sp_globals.y_band.band_max + 1; /* Adjust start point to top of band */ if (y2 < sp_globals.y_band.band_min) /* End point below bottom of band? */ y2 = sp_globals.y_band.band_min; /* Adjust end point bottom of band */ y1 -= sp_globals.y_band.band_min; /* Translate start point to band origin */ y2 -= sp_globals.y_band.band_min; /* Translate end point to band origin */ while (y2 < y1) /* At least one intercept left? */ { sp_add_intercept_screen(--y1, x); /* Add intercept */ } }else if (y2 > y1) /* Line goes upwards ? */ { if (y1 < sp_globals.y_band.band_min) /* Start point below bottom of band? */ y1 = sp_globals.y_band.band_min; /* Adjust start point to bottom of band */ if (y2 > (sp_globals.y_band.band_max + 1)) /* End point above top of band? */ y2 = sp_globals.y_band.band_max + 1; /* Adjust end point to top of band */ y1 -= sp_globals.y_band.band_min; /* Translate start point to band origin */ y2 -= sp_globals.y_band.band_min; /* Translate end point to band origin */ while (y1 < y2) /* At least one intercept left? */ { sp_add_intercept_screen(y1++, x); /* Add intercept */ } }} #endif#if INCL_SCREENFUNCTION void line_screen(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; /* 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_SCREEN(%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 */xc = (fix31)(x0 + sp_globals.pixrnd) << (16 - sp_globals.pixshift); /* Original x coordinate with built in */ /* rounding. 16.16 form */if (how_many_y < 0) { yc--; /* Predecrment downward lines */ }if ((how_many_y * sp_globals.tcb.mirror) < 0) { sp_intercepts.leftedge = LEFT_INT; }else { sp_intercepts.leftedge = 0; }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 */ }if ( (temp1 = (x1 - x0)) == 0) /* check for vertical line */ {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -