📄 topcatgc.c
字号:
/***********************************************************Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,and the Massachusetts Institute of Technology, Cambridge, Massachusetts. All Rights ReservedPermission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and thatboth that copyright notice and this permission notice appear in supporting documentation, and that the names of Digital or MIT not beused in advertising or publicity pertaining to distribution of thesoftware without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THISSOFTWARE.******************************************************************//* $XConsortium: cfbgc.c,v 5.32.1.1 90/03/21 10:16:47 rws Exp $ */#include "X.h"#include "Xmd.h"#include "Xproto.h"#include "../cfb/cfb.h"#include "fontstruct.h"#include "dixfontstr.h"#include "gcstruct.h"#include "windowstr.h"#include "pixmapstr.h"#include "scrnintstr.h"#include "region.h"#include "topcat.h"#include "mistruct.h"#include "mibstore.h"#include "../cfb/cfbmskbits.h"#include "../cfb/cfb8bit.h"extern RegionPtr hpcCopyArea();static void topcatValidateGC(), cfbChangeGC(), cfbCopyGC(), cfbDestroyGC();static void cfbChangeClip(), cfbDestroyClip(), cfbCopyClip();static cfbDestroyOps();static GCFuncs cfbGCFuncs = { topcatValidateGC, cfbChangeGC, cfbCopyGC, cfbDestroyGC, cfbChangeClip, cfbDestroyClip, cfbCopyClip,};#define tcImageGlyphBlt cfbImageGlyphBlt8static GCOps cfbTEOps1Rect = { cfbSolidSpansCopy, cfbSetSpans, tcPutImage, hpcCopyArea, tcCopyPlane, cfbPolyPoint,#if PPW == 4 cfb8LineSS1Rect, cfb8SegmentSS1Rect,#else cfbLineSS, cfbSegmentSS,#endif miPolyRectangle,#if PPW == 4 cfbZeroPolyArcSS8Copy,#else miZeroPolyArc,#endif cfbFillPoly1RectCopy, tcPolyFillRect, cfbPolyFillArcSolidCopy, miPolyText8, miPolyText16, miImageText8, miImageText16,#if PPW == 4 cfbTEGlyphBlt8, cfbPolyGlyphBlt8, cfbPushPixels8,#else cfbTEGlyphBlt, miPolyGlyphBlt, mfbPushPixels,#endif NULL,};static GCOps cfbTEOps = { cfbSolidSpansCopy, cfbSetSpans, tcPutImage, hpcCopyArea, tcCopyPlane, cfbPolyPoint, cfbLineSS, cfbSegmentSS, miPolyRectangle,#if PPW == 4 cfbZeroPolyArcSS8Copy,#else miZeroPolyArc,#endif miFillPolygon, tcPolyFillRect, cfbPolyFillArcSolidCopy, miPolyText8, miPolyText16, miImageText8, miImageText16,#if PPW == 4 cfbTEGlyphBlt8, cfbPolyGlyphBlt8, cfbPushPixels8,#else cfbTEGlyphBlt, miPolyGlyphBlt, mfbPushPixels,#endif NULL,};static GCOps cfbNonTEOps1Rect = { cfbSolidSpansCopy, cfbSetSpans, tcPutImage, hpcCopyArea, tcCopyPlane, cfbPolyPoint,#if PPW == 4 cfb8LineSS1Rect, cfb8SegmentSS1Rect,#else cfbLineSS, cfbSegmentSS,#endif miPolyRectangle,#if PPW == 4 cfbZeroPolyArcSS8Copy,#else miZeroPolyArc,#endif cfbFillPoly1RectCopy, tcPolyFillRect, cfbPolyFillArcSolidCopy, miPolyText8, miPolyText16, miImageText8, miImageText16,#if PPW == 4 cfbImageGlyphBlt8, cfbPolyGlyphBlt8, cfbPushPixels8,#else miImageGlyphBlt, miPolyGlyphBlt, mfbPushPixels,#endif NULL,};static GCOps cfbNonTEOps = { cfbSolidSpansCopy, cfbSetSpans, tcPutImage, hpcCopyArea, tcCopyPlane, cfbPolyPoint, cfbLineSS, cfbSegmentSS, miPolyRectangle,#if PPW == 4 cfbZeroPolyArcSS8Copy,#else miZeroPolyArc,#endif miFillPolygon, tcPolyFillRect, cfbPolyFillArcSolidCopy, miPolyText8, miPolyText16, miImageText8, miImageText16,#if PPW == 4 cfbImageGlyphBlt8, cfbPolyGlyphBlt8, cfbPushPixels8,#else miImageGlyphBlt, miPolyGlyphBlt, mfbPushPixels,#endif NULL,};static GCOps tcWinOps1Rect = { tcSolidFS, cfbSetSpans, tcPutImage, hpcCopyArea, tcCopyPlane, cfbPolyPoint,#if PPW == 4 cfb8LineSS1Rect, cfb8SegmentSS1Rect,#else cfbLineSS, cfbSegmentSS,#endif miPolyRectangle, cfbZeroPolyArcSS8Copy, cfbFillPoly1RectCopy, tcPolyFillRect, cfbPolyFillArcSolidCopy, miPolyText8, miPolyText16, miImageText8, miImageText16, tcImageGlyphBlt, cfbPolyGlyphBlt8, cfbPushPixels8, NULL,};static GCOps tcWinOps = { tcSolidFS, cfbSetSpans, tcPutImage, hpcCopyArea, tcCopyPlane, cfbPolyPoint, cfbLineSS, cfbSegmentSS, miPolyRectangle, cfbZeroPolyArcSS8Copy, miFillPolygon, tcPolyFillRect, cfbPolyFillArcSolidCopy, miPolyText8, miPolyText16, miImageText8, miImageText16, tcImageGlyphBlt, cfbPolyGlyphBlt8, cfbPushPixels8, NULL,};static GCOps tcWinOTEOps1Rect = { tcSolidFS, cfbSetSpans, tcPutImage, hpcCopyArea, tcCopyPlane, cfbPolyPoint,#if PPW == 4 cfb8LineSS1Rect, cfb8SegmentSS1Rect,#else cfbLineSS, cfbSegmentSS,#endif miPolyRectangle, cfbZeroPolyArcSS8Copy, cfbFillPoly1RectCopy, tcPolyFillRect, cfbPolyFillArcSolidCopy, tcPolyOptText8, miPolyText16, tcImageOptTEText8, miImageText16, tcImageGlyphBlt, cfbPolyGlyphBlt8, cfbPushPixels8, NULL,};static GCOps tcWinOTEOps = { tcSolidFS, cfbSetSpans, tcPutImage, hpcCopyArea, tcCopyPlane, cfbPolyPoint, cfbLineSS, cfbSegmentSS, miPolyRectangle, cfbZeroPolyArcSS8Copy, miFillPolygon, tcPolyFillRect, cfbPolyFillArcSolidCopy, tcPolyOptText8, miPolyText16, tcImageOptTEText8, miImageText16, tcImageGlyphBlt, cfbPolyGlyphBlt8, cfbPushPixels8, NULL,};static GCOps tcWinONonTEOps1Rect = { tcSolidFS, cfbSetSpans, tcPutImage, hpcCopyArea, tcCopyPlane, cfbPolyPoint,#if PPW == 4 cfb8LineSS1Rect, cfb8SegmentSS1Rect,#else cfbLineSS, cfbSegmentSS,#endif miPolyRectangle, cfbZeroPolyArcSS8Copy, cfbFillPoly1RectCopy, tcPolyFillRect, cfbPolyFillArcSolidCopy, tcPolyOptText8, miPolyText16, tcImageOptText8, miImageText16, tcImageGlyphBlt, cfbPolyGlyphBlt8, cfbPushPixels8, NULL,};static GCOps tcWinONonTEOps = { tcSolidFS, cfbSetSpans, tcPutImage, hpcCopyArea, tcCopyPlane, cfbPolyPoint, cfbLineSS, cfbSegmentSS, miPolyRectangle, cfbZeroPolyArcSS8Copy, miFillPolygon, tcPolyFillRect, cfbPolyFillArcSolidCopy, tcPolyOptText8, miPolyText16, tcImageOptText8, miImageText16, tcImageGlyphBlt, cfbPolyGlyphBlt8, cfbPushPixels8, NULL,};static GCOps *tcMatchCommon (pGC, devPriv, pWin) GCPtr pGC; cfbPrivGCPtr devPriv; WindowPtr pWin;{ if (pGC->lineWidth != 0) return 0; if (pGC->lineStyle != LineSolid) return 0; if (pGC->fillStyle != FillSolid) return 0; if (devPriv->rop != GXcopy) return 0; if (!pWin) { if (pGC->font && FONTMAXBOUNDS(pGC->font,rightSideBearing) - FONTMINBOUNDS(pGC->font,leftSideBearing) <= 32 && FONTMINBOUNDS(pGC->font,characterWidth) >= 0) { if (TERMINALFONT(pGC->font)#if PPW == 4 && FONTMAXBOUNDS(pGC->font,characterWidth) >= 4#endif ) if (devPriv->oneRect) return &cfbTEOps1Rect; else return &cfbTEOps; else if (devPriv->oneRect) return &cfbNonTEOps1Rect; else return &cfbNonTEOps; } } else {#if 0 /* XXXX */ if (pGC->font && pGC->font->devPriv[pGC->pScreen->myNum]) { if (TERMINALFONT(pGC->font)) if (devPriv->oneRect) return &tcWinOTEOps1Rect; else return &tcWinOTEOps; else if (devPriv->oneRect) return &tcWinONonTEOps1Rect; else return &tcWinONonTEOps; }#endif if (devPriv->oneRect) return &tcWinOps1Rect; else return &tcWinOps; } return 0;}BooltopcatCreateGC(pGC) register GCPtr pGC;{ cfbPrivGC *pPriv; if (pGC->depth == 1) return mfbCreateGC(pGC); pGC->clientClip = NULL; pGC->clientClipType = CT_NONE; /* * some of the output primitives aren't really necessary, since they * will be filled in ValidateGC because of dix/CreateGC() setting all * the change bits. Others are necessary because although they depend * on being a color frame buffer, they don't change */ pGC->ops = &cfbNonTEOps; pGC->funcs = &cfbGCFuncs; /* cfb wants to translate before scan conversion */ pGC->miTranslate = 1; pPriv = (cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr); pPriv->rop = pGC->alu; pPriv->oneRect = FALSE; pPriv->fExpose = TRUE; pPriv->freeCompClip = FALSE; pPriv->pRotatedPixmap = (PixmapPtr) NULL; return TRUE;}/*ARGSUSED*/static voidcfbChangeGC(pGC, mask) GC *pGC; BITS32 mask;{ return;}static voidcfbDestroyGC(pGC) GC *pGC;{ cfbPrivGC *pPriv; pPriv = (cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr); if (pPriv->pRotatedPixmap) cfbDestroyPixmap(pPriv->pRotatedPixmap); if (pPriv->freeCompClip) (*pGC->pScreen->RegionDestroy)(pPriv->pCompositeClip); cfbDestroyOps (pGC->ops);}/* * create a private op array for a gc */static GCOps *cfbCreateOps (prototype) GCOps *prototype;{ GCOps *ret; extern Bool Must_have_memory; /* XXX */ Must_have_memory = TRUE; ret = (GCOps *) xalloc (sizeof(GCOps)); /* XXX */ Must_have_memory = FALSE; if (!ret) return 0; *ret = *prototype; ret->devPrivate.val = 1; return ret;}staticcfbDestroyOps (ops) GCOps *ops;{ if (ops->devPrivate.val) xfree (ops);}/* Clipping conventions if the drawable is a window CT_REGION ==> pCompositeClip really is the composite CT_other ==> pCompositeClip is the window clip region if the drawable is a pixmap CT_REGION ==> pCompositeClip is the translated client region clipped to the pixmap boundary CT_other ==> pCompositeClip is the pixmap bounding box*/static voidtopcatValidateGC(pGC, changes, pDrawable) register GCPtr pGC; Mask changes; DrawablePtr pDrawable;{ WindowPtr pWin; int mask; /* stateChanges */ int index; /* used for stepping through bitfields */ int new_rrop; int new_line, new_text, new_fillspans, new_fillarea; int new_rotate; int xrot, yrot; /* flags for changing the proc vector */ cfbPrivGCPtr devPriv; int oneRect; new_rotate = pGC->lastWinOrg.x != pDrawable->x || pGC->lastWinOrg.y != pDrawable->y; pGC->lastWinOrg.x = pDrawable->x; pGC->lastWinOrg.y = pDrawable->y; if (pDrawable->type == DRAWABLE_WINDOW) { pWin = (WindowPtr) pDrawable; } else { pWin = (WindowPtr) NULL; } devPriv = ((cfbPrivGCPtr) (pGC->devPrivates[cfbGCPrivateIndex].ptr)); new_rrop = FALSE; new_line = FALSE; new_text = FALSE; new_fillspans = FALSE; new_fillarea = FALSE; /* * if the client clip is different or moved OR the subwindowMode has * changed OR the window's clip has changed since the last validation * we need to recompute the composite clip */ if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) || (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS)) ) { ScreenPtr pScreen = pGC->pScreen; if (pWin) { RegionPtr pregWin; Bool freeTmpClip, freeCompClip; if (pGC->subWindowMode == IncludeInferiors) { pregWin = NotClippedByChildren(pWin); freeTmpClip = TRUE; } else { pregWin = &pWin->clipList; freeTmpClip = FALSE; } freeCompClip = devPriv->freeCompClip; /* * if there is no client clip, we can get by with just keeping * the pointer we got, and remembering whether or not should * destroy (or maybe re-use) it later. this way, we avoid * unnecessary copying of regions. (this wins especially if * many clients clip by children and have no client clip.) */ if (pGC->clientClipType == CT_NONE) { if (freeCompClip) (*pScreen->RegionDestroy) (devPriv->pCompositeClip); devPriv->pCompositeClip = pregWin; devPriv->freeCompClip = freeTmpClip; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -