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

📄 tcglyph.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
/*Copyright (c) 1986, 1987 by Hewlett-Packard CompanyCopyright (c) 1986, 1987 by the Massachusetts Institute of TechnologyPermission to use, copy, modify, and distribute thissoftware and its documentation for any purpose and withoutfee is hereby granted, provided that the above copyrightnotice appear in all copies and that both that copyrightnotice and this permission notice appear in supportingdocumentation, and that the name of M.I.T. not be used inadvertising or publicity pertaining to distribution of thesoftware without specific, written prior permission.HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARDTO THIS SOFWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  Hewlett-Packard shall not be liable for errors contained herein or direct, indirect, special, incidental or consequential damages in connection with the furnishing, performance, or use of this material.This software is not subject to any license of the AmericanTelephone and Telegraph Company or of the Regents of theUniversity of California.*//*********************************************************************** *  file: topcatGlyph.c * * *  ****************************************************************** *  *  (c) Copyright Hewlett-Packard Company, 1987.  All rights are  * *  *  reserved.  Copying or other reproduction of this program      * *  *  except for archival purposes is prohibited without prior      * *  *  written consent of Hewlett-Packard Company.		     * *  ****************************************************************** * *  Glyph output routines * *		Hewlett Packard -- Corvallis Workstation Operation *		Project -- port of X11 to HP9000 *		Harry Phinney -- MTS * * */#include <sys/types.h>#include "X.h"#include "Xmd.h"#include "Xproto.h"#include "../cfb/cfb.h"#include "fontstruct.h"#include "dixfontstr.h"#include "gcstruct.h"#include "regionstr.h"#include "region.h"#include "pixmapstr.h"#include "pixmap.h"#include "scrnintstr.h"#include "windowstr.h"#include "topcat.h"extern u_char XHP_NewRule[16][6];extern int XHP_pmap[256][2];extern int XHP_QUADALIGN;#if 0static unsigned char masks[8] = { 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80 };#endifstatic unsigned char trailMasks[8] = { 0x80, 0x40, 0x20, 0x10, 0x8, 0x4,                                       0x2, 0x1 };#define DispAddr(pScreen, x, y) \      ((getPrivScreenPtr(pScreen)->bits) + \       ((y) * getPrivScreenPtr(pScreen)->stride) + \       (x));/************************************************************************ *  Routine:	tcWholeGlyph *		Output an entire glyph with no clipping *		Used for putting chars in offscreen memory * *  Inputs: pScn points to the ScreenRec for the screen the glyph is going to *	    pGlyph points to the bits of the glyph we're outputing *	    pCi points to the character info struct for the glyph *	    x,y specifies the screen location of the upper-left corner of glyph *	    func is the display function (ROP) *	    fore, back are the foreground and background colors *	    planes is the plane mask (zmask) *   *  Returns: nothing (it's a void...) * *  Side Effects:  none * */voidtcWholeGlyph(pScn, pGlyph, pCi, x,y, func, fore, back, planes)     ScreenPtr pScn;     char *pGlyph;     CharInfoPtr pCi;     int x, y;     int func;     int fore, back;     int planes;{    int gwidth, gheight, rowBytes;    int i, j;    TOPCAT *hardware = getTcHardware(pScn);    int XHP_bits = hardware->bits;    gwidth = GLYPHWIDTHPIXELS(pCi);    gheight = GLYPHHEIGHTPIXELS(pCi);    rowBytes = GLYPHWIDTHBYTESPADDED(pCi);    /*     * call the MaskConfig routine to set the regs     */    SET_REGISTERS_FOR_WRITING(pScn, planes, func);    /*     * if word/pixel (low res topcat) then write words, else write bytes     */    if (XHP_bits)    {	register u_short *dest, *base;	char srcbyte;	char *pNextByte;	base = (u_short *) DispAddr(pScn, x << XHP_bits, y);	/*	 * make the colors word-wide symetric	 */	fore |= fore << 8;	if (back != -1) back |= back << 8;	while (gheight--)	{	    dest = base;	    base += ((hpPrivScreen *)(pScn->devPrivate))->stride;	    srcbyte = *pGlyph;	    pNextByte = pGlyph + 1;	    pGlyph += rowBytes;	    i = 0;	    j = gwidth;	    while (j--)	    {		if (i++ == 8)		{		    srcbyte = *pNextByte++;		    i = 1;		}		if (srcbyte & 128) /* put out the MSB */		    *dest++ = fore;		else if(back != -1)		    *dest++ = back;		else		    dest++;	    		srcbyte <<= 1; /* get next pix value in MSB */	    }	}	return;    }    else    {				/* high res topcat - copy bytes */	/*	 * code for byte/pixel displays	 * XXX This could/should be sped up by writing more than one pixel at	 * a time - i.e. write longs & shorts when appropriate.	 */	register u_char *dest, *base;	register char srcbyte;	char *pNextByte;	base = (u_char *) DispAddr(pScn, x, y);	while (gheight--)	{			/* for each row of pixels in glyph */	    dest = base;	    base += ((hpPrivScreen *)(pScn->devPrivate))->stride;  	    srcbyte = *pGlyph;	    pNextByte = pGlyph + 1;	    pGlyph += rowBytes;	    i = 0; /* counter of bits put out from current byte */	    j = gwidth; /* total bits in this row */	    while (j--)	    {		if (i++ == 8)		{ /* if we've used up the byte, go to next one */		    srcbyte = *pNextByte++;		    i = 1;		}		if (srcbyte & 128)		    *dest++ = fore;		else if(back != -1)		    *dest++ = back;		else		    dest++;		srcbyte <<= 1; /* get next pix bit in MSB */	    } /* next bit in this row */	} /* next pixel row */    } /* end of byte/pixel code */}/************************************************************************ *  Routine:	tcImageGlyphBlt *		Output a set of glyphs *		Called by the tcImageText routine(s) iff the glyphs  * 		are not in offscreen memory and the destination drawable  *		is a window. * *  Inputs: pDraw points to the *window* we're drawing to *	    pGC points to the graphics context *	    dstx,dsty is the screen location of the glyph baseline *	    nglyph is the number of glyphs *	    ppCI is a pointer to the array of CharInfo's for the glyphs *	    pGlyphBase points to the array of glyph bits *   *  Returns: nothing (it's a void...) * *  Side Effects:  none * */voidtcImageVarGlyph(pDraw, pGC, dstx, dsty, nglyph, ppCI, pGlyphBase)    DrawablePtr pDraw;    GC *pGC;    unsigned int dstx, dsty;    unsigned int nglyph;    CharInfoPtr *ppCI;    char *pGlyphBase;{#if 0    ExtentInfoRec info;		/* used by QueryGlyphExtents() */    xRectangle backrect;    RegionPtr pRegion = ((cfbPrivGC *)			 pGC->devPrivates[cfbGCPrivateIndex].ptr)->pCompositeClip;    register BoxPtr pBox;    int nbox;    TOPCAT *hardware = getTcHardware(pDraw->pScreen);    unsigned long screenPlanes = getPlanesMask(pDraw->pScreen);    unsigned long zmask = pGC->planemask & screenPlanes;    int back = pGC->bgPixel;    u_char *dest, *base;    int stride = ((hpPrivScreen *)(pDraw->pScreen->devPrivate))->stride;    register int i, x, y, dx, dy, h, w;    int XHP_bits = hardware->bits;    int fontAscent = FONTASCENT(pGC->font);    if (pDraw->type != DRAWABLE_WINDOW)    {	if (pGC->bgPixel== -1) 	   miPolyGlyphBlt(pDraw, pGC, dstx, dsty, nglyph, ppCI, pGlyphBase);	else	   miImageGlyphBlt(pDraw, pGC, dstx, dsty, nglyph, ppCI, pGlyphBase);    }    if (!nglyph)	return;    if (pGC->miTranslate)    {				/* absolutize the coordinates */	dstx += pDraw->x;	dsty += pDraw->y;    }    QueryGlyphExtents(pGC->font, ppCI, nglyph, &info);    backrect.x = dstx;    backrect.y = dsty - fontAscent;    backrect.width = info.overallWidth;    backrect.height = fontAscent + FONTDESCENT(pGC->font);    for (nbox = REGION_NUM_RECTS(pRegion), pBox = REGION_RECTS(pRegion);	 nbox--; pBox++)    {	/* 	 * for each rectangle in the list of clip rects, block fill the	 * background for the characters and put down the foreground pixels	 * from the glyphs	 */	x = backrect.x;	y = backrect.y;	w = backrect.width;	h = backrect.height;	dx = 0;	dy = 0;	/*	 * figure out the intersection between the character background box	 * and the clip box, and fill the resulting rectangle	 */	if (y < pBox->y1)	{	    dy = pBox->y1 - y;	    h -= dy;	    if (h <= 0) continue;	    y = pBox->y1;	}	if (y+h > pBox->y2)	{	    h = pBox->y2 - y;	    if (h <= 0) continue;	}	if (x < pBox->x1)	{	    dx = pBox->x1 - x;	    w -= dx;	    if (w <= 0) continue;	    x = pBox->x1;	}	if (x+w > pBox->x2)	{	    w = pBox->x2 - x;	    if (w <= 0) continue;	}	if (h > 0 && w > 0)	{			/* if the intersection was non-null */	    int charx = dstx;	    int slen = nglyph;	    CharInfoPtr *ppci = ppCI;	    register CharInfoPtr pci = *ppci++;	    char *pGlyph;	    /*	     * clear the rect to the background color	     */	    waitbusy(screenPlanes, hardware); 	    hardware->write_enable = zmask & back;	    hardware->window_move_replacement_rule = XHP_NewRule[GXcopy][3];	    hardware->write_enable = zmask & ~back;	    hardware->window_move_replacement_rule = XHP_NewRule[GXcopy][0];	    hardware->write_enable = zmask;	    hardware->pixel_write_replacement_rule = GXcopy;                	    hardware->source_x = x << XHP_bits;	    hardware->source_y = y;	    hardware->dest_x = x << XHP_bits;	    hardware->dest_y = y;	    hardware->window_width = w << XHP_bits;	    hardware->window_height = h;	    hardware->start_move = zmask;	    /*	     * while the character is to the left of the clipping rectangle,	     * go to the next character	     */	    while (charx + pci->metrics.characterWidth < pBox->x1)	    {		if (--slen == 0) break;		charx += pci->metrics.characterWidth;		pci = *ppci++;	    }	    /*	     * clip the first (partially) in char to the left edge of pBox	     */	    dx = pBox->x1 - (charx + pci->metrics.leftSideBearing);	    if (dx < 0) dx = 0;	    if (charx+dx > pBox->x2) continue;	    /*	     * Set up the registers so that writing 0xff will get us the	     * foreground and writing 0x00 is a noop	     */	    waitbusy(screenPlanes, hardware);	    hardware->write_enable = zmask & pGC->fgPixel;

⌨️ 快捷键说明

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