fbsetsp.c revision 35c4bbdf
105b261ecSmrg/* 205b261ecSmrg * Copyright © 1998 Keith Packard 305b261ecSmrg * 405b261ecSmrg * Permission to use, copy, modify, distribute, and sell this software and its 505b261ecSmrg * documentation for any purpose is hereby granted without fee, provided that 605b261ecSmrg * the above copyright notice appear in all copies and that both that 705b261ecSmrg * copyright notice and this permission notice appear in supporting 805b261ecSmrg * documentation, and that the name of Keith Packard not be used in 905b261ecSmrg * advertising or publicity pertaining to distribution of the software without 1005b261ecSmrg * specific, written prior permission. Keith Packard makes no 1105b261ecSmrg * representations about the suitability of this software for any purpose. It 1205b261ecSmrg * is provided "as is" without express or implied warranty. 1305b261ecSmrg * 1405b261ecSmrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 1505b261ecSmrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 1605b261ecSmrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR 1705b261ecSmrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 1805b261ecSmrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 1905b261ecSmrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 2005b261ecSmrg * PERFORMANCE OF THIS SOFTWARE. 2105b261ecSmrg */ 2205b261ecSmrg 2305b261ecSmrg#ifdef HAVE_DIX_CONFIG_H 2405b261ecSmrg#include <dix-config.h> 2505b261ecSmrg#endif 2605b261ecSmrg 2705b261ecSmrg#include "fb.h" 2805b261ecSmrg 2905b261ecSmrgvoid 3035c4bbdfSmrgfbSetSpans(DrawablePtr pDrawable, 3135c4bbdfSmrg GCPtr pGC, 3235c4bbdfSmrg char *src, DDXPointPtr ppt, int *pwidth, int nspans, int fSorted) 3305b261ecSmrg{ 3435c4bbdfSmrg FbGCPrivPtr pPriv = fbGetGCPrivate(pGC); 3535c4bbdfSmrg RegionPtr pClip = fbGetCompositeClip(pGC); 3635c4bbdfSmrg FbBits *dst, *d, *s; 3735c4bbdfSmrg FbStride dstStride; 3835c4bbdfSmrg int dstBpp; 3935c4bbdfSmrg int dstXoff, dstYoff; 4035c4bbdfSmrg BoxPtr pbox; 4135c4bbdfSmrg int n; 4235c4bbdfSmrg int xoff; 4335c4bbdfSmrg int x1, x2; 4405b261ecSmrg 4535c4bbdfSmrg if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth)) { 4635c4bbdfSmrg fb24_32SetSpans(pDrawable, pGC, src, ppt, pwidth, nspans, fSorted); 4735c4bbdfSmrg return; 4835c4bbdfSmrg } 4935c4bbdfSmrg fbGetDrawable(pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); 5035c4bbdfSmrg while (nspans--) { 5135c4bbdfSmrg d = dst + (ppt->y + dstYoff) * dstStride; 5235c4bbdfSmrg xoff = (int) (((long) src) & (FB_MASK >> 3)); 5335c4bbdfSmrg s = (FbBits *) (src - xoff); 5435c4bbdfSmrg xoff <<= 3; 5535c4bbdfSmrg n = RegionNumRects(pClip); 5635c4bbdfSmrg pbox = RegionRects(pClip); 5735c4bbdfSmrg while (n--) { 5835c4bbdfSmrg if (pbox->y1 > ppt->y) 5935c4bbdfSmrg break; 6035c4bbdfSmrg if (pbox->y2 > ppt->y) { 6135c4bbdfSmrg x1 = ppt->x; 6235c4bbdfSmrg x2 = x1 + *pwidth; 6335c4bbdfSmrg if (pbox->x1 > x1) 6435c4bbdfSmrg x1 = pbox->x1; 6535c4bbdfSmrg if (pbox->x2 < x2) 6635c4bbdfSmrg x2 = pbox->x2; 6735c4bbdfSmrg if (x1 < x2) 6835c4bbdfSmrg fbBlt((FbBits *) s, 6935c4bbdfSmrg 0, 7035c4bbdfSmrg (x1 - ppt->x) * dstBpp + xoff, 7135c4bbdfSmrg d, 7235c4bbdfSmrg dstStride, 7335c4bbdfSmrg (x1 + dstXoff) * dstBpp, 7435c4bbdfSmrg (x2 - x1) * dstBpp, 7535c4bbdfSmrg 1, pGC->alu, pPriv->pm, dstBpp, FALSE, FALSE); 7635c4bbdfSmrg } 7735c4bbdfSmrg } 7835c4bbdfSmrg src += PixmapBytePad(*pwidth, pDrawable->depth); 7935c4bbdfSmrg ppt++; 8035c4bbdfSmrg pwidth++; 8105b261ecSmrg } 8235c4bbdfSmrg fbValidateDrawable(pDrawable); 8335c4bbdfSmrg fbFinishAccess(pDrawable); 8405b261ecSmrg} 85