📄 hpfb.c
字号:
/*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.*//***********************************************************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: hpfb.c,v 1.7 88/09/06 15:18:15 jim Exp $ *//* Author: Todd Newman (aided and abetted by Mr. Drewry) */#include "X.h"#include "Xprotostr.h"#include "misc.h"#include "gcstruct.h"#include "pixmapstr.h"#include "windowstr.h"#include "scrnintstr.h"#include "regionstr.h"#include "servermd.h"#include "cfb.h"/* DoBitblt() does multiple rectangle moves into the rectangles we have to cope with the direction on a per band basis,rather than a per rectangle basis. moving bottom to topmeans we have to invert the order of the bands; moving rightto left requires reversing the order of the rectangles ineach band. if src or dst is a window, the points have already beentranslated.*/voidhpfbDoBitblt(pSrcDrawable, pDstDrawable, alu, prgnDst, pptSrc, planemask) DrawablePtr pSrcDrawable; DrawablePtr pDstDrawable; int alu; RegionPtr prgnDst; DDXPointPtr pptSrc; unsigned long planemask;{ register BoxPtr pbox; int nbox; BoxPtr pboxTmp, pboxNext, pboxBase, pboxNewY, pboxNewX; /* temporaries for shuffling rectangles */ DDXPointPtr pptTmp, pptNewY, pptNewX; /* shuffling boxes entails shuffling the source points too */ int w, h; void (*bitMover)(); /* check whether we should use this routine... call cfb code if not. */ if (((pSrcDrawable->type == DRAWABLE_PIXMAP) && (((PixmapPtr)(pSrcDrawable))->devKind != PIXMAP_FRAME_BUFFER)) && (pSrcDrawable->type != DRAWABLE_WINDOW)) { cfbDoBitblt(pSrcDrawable, pDstDrawable, alu, prgnDst, pptSrc, planemask); return; } if (((pDstDrawable->type == DRAWABLE_PIXMAP) && (((PixmapPtr)(pDstDrawable))->devKind != PIXMAP_FRAME_BUFFER)) && (pDstDrawable->type != DRAWABLE_WINDOW)) { cfbDoBitblt(pSrcDrawable, pDstDrawable, alu, prgnDst, pptSrc, planemask); return; } if (pSrcDrawable->pScreen != pDstDrawable->pScreen) { cfbDoBitblt(pSrcDrawable, pDstDrawable, alu, prgnDst, pptSrc, planemask); return; } pbox = REGION_RECTS(prgnDst); nbox = REGION_NUM_RECTS(prgnDst); pboxNewY = 0; pptNewY = 0; pboxNewX = 0; pptNewX = 0; if (pptSrc->y < pbox->y1) { /* walk source botttom to top */ if (nbox > 1) { /* keep ordering in each band, reverse order of bands */ pboxNewY = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox); pptNewY = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox); if (!pboxNewY || !pptNewY) { DEALLOCATE_LOCAL(pptNewY); DEALLOCATE_LOCAL(pboxNewY); return; } pboxBase = pboxNext = pbox+nbox-1; while (pboxBase >= pbox) { while ((pboxNext >= pbox) && (pboxBase->y1 == pboxNext->y1)) pboxNext--; pboxTmp = pboxNext+1; pptTmp = pptSrc + (pboxTmp - pbox); while (pboxTmp <= pboxBase) { *pboxNewY++ = *pboxTmp++; *pptNewY++ = *pptTmp++; } pboxBase = pboxNext; } pboxNewY -= nbox; pbox = pboxNewY; pptNewY -= nbox; pptSrc = pptNewY; } } if (pptSrc->x < pbox->x1) { /* walk source right to left */ if (nbox > 1) { /* reverse order of rects in each band */ pboxNewX = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox); pptNewX = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox); if (!pboxNewX || !pptNewX) { DEALLOCATE_LOCAL(pptNewX); DEALLOCATE_LOCAL(pboxNewX); return; } pboxBase = pboxNext = pbox; while (pboxBase < pbox+nbox) { while ((pboxNext < pbox+nbox) && (pboxNext->y1 == pboxBase->y1)) pboxNext++; pboxTmp = pboxNext; pptTmp = pptSrc + (pboxTmp - pbox); while (pboxTmp != pboxBase) { *pboxNewX++ = *--pboxTmp; *pptNewX++ = *--pptTmp; } pboxBase = pboxNext; } pboxNewX -= nbox; pbox = pboxNewX; pptNewX -= nbox; pptSrc = pptNewX; } } bitMover = ((hpPrivScreenPtr) (pSrcDrawable->pScreen->devPrivate))->MoveBits; while (nbox--) { w = pbox->x2 - pbox->x1; h = pbox->y2 - pbox->y1; (*bitMover)(pSrcDrawable->pScreen, ~0, alu, pptSrc->x, pptSrc->y, pbox->x1, pbox->y1, w, h); pbox++; pptSrc++; } if (pptNewY) DEALLOCATE_LOCAL(pptNewY); if (pboxNewY) DEALLOCATE_LOCAL(pboxNewY); if (pptNewX) DEALLOCATE_LOCAL(pptNewX); if (pboxNewX) DEALLOCATE_LOCAL(pboxNewX);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -