1706f2543Smrg/* 2706f2543Smrg * Copyright © 1998 Keith Packard 3706f2543Smrg * 4706f2543Smrg * Permission to use, copy, modify, distribute, and sell this software and its 5706f2543Smrg * documentation for any purpose is hereby granted without fee, provided that 6706f2543Smrg * the above copyright notice appear in all copies and that both that 7706f2543Smrg * copyright notice and this permission notice appear in supporting 8706f2543Smrg * documentation, and that the name of Keith Packard not be used in 9706f2543Smrg * advertising or publicity pertaining to distribution of the software without 10706f2543Smrg * specific, written prior permission. Keith Packard makes no 11706f2543Smrg * representations about the suitability of this software for any purpose. It 12706f2543Smrg * is provided "as is" without express or implied warranty. 13706f2543Smrg * 14706f2543Smrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15706f2543Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16706f2543Smrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17706f2543Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18706f2543Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19706f2543Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 20706f2543Smrg * PERFORMANCE OF THIS SOFTWARE. 21706f2543Smrg */ 22706f2543Smrg 23706f2543Smrg#ifdef HAVE_DIX_CONFIG_H 24706f2543Smrg#include <dix-config.h> 25706f2543Smrg#endif 26706f2543Smrg 27706f2543Smrg#include "fb.h" 28706f2543Smrg 29706f2543Smrgvoid 30706f2543SmrgfbSetSpans (DrawablePtr pDrawable, 31706f2543Smrg GCPtr pGC, 32706f2543Smrg char *src, 33706f2543Smrg DDXPointPtr ppt, 34706f2543Smrg int *pwidth, 35706f2543Smrg int nspans, 36706f2543Smrg int fSorted) 37706f2543Smrg{ 38706f2543Smrg FbGCPrivPtr pPriv = fbGetGCPrivate (pGC); 39706f2543Smrg RegionPtr pClip = fbGetCompositeClip(pGC); 40706f2543Smrg FbBits *dst, *d, *s; 41706f2543Smrg FbStride dstStride; 42706f2543Smrg int dstBpp; 43706f2543Smrg int dstXoff, dstYoff; 44706f2543Smrg BoxPtr pbox; 45706f2543Smrg int n; 46706f2543Smrg int xoff; 47706f2543Smrg int x1, x2; 48706f2543Smrg 49706f2543Smrg#ifdef FB_24_32BIT 50706f2543Smrg if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth)) 51706f2543Smrg { 52706f2543Smrg fb24_32SetSpans (pDrawable, pGC, src, ppt, pwidth, nspans, fSorted); 53706f2543Smrg return; 54706f2543Smrg } 55706f2543Smrg#endif 56706f2543Smrg fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); 57706f2543Smrg while (nspans--) 58706f2543Smrg { 59706f2543Smrg d = dst + (ppt->y + dstYoff) * dstStride; 60706f2543Smrg xoff = (int) (((long) src) & (FB_MASK >> 3)); 61706f2543Smrg s = (FbBits *) (src - xoff); 62706f2543Smrg xoff <<= 3; 63706f2543Smrg n = RegionNumRects(pClip); 64706f2543Smrg pbox = RegionRects (pClip); 65706f2543Smrg while (n--) 66706f2543Smrg { 67706f2543Smrg if (pbox->y1 > ppt->y) 68706f2543Smrg break; 69706f2543Smrg if (pbox->y2 > ppt->y) 70706f2543Smrg { 71706f2543Smrg x1 = ppt->x; 72706f2543Smrg x2 = x1 + *pwidth; 73706f2543Smrg if (pbox->x1 > x1) 74706f2543Smrg x1 = pbox->x1; 75706f2543Smrg if (pbox->x2 < x2) 76706f2543Smrg x2 = pbox->x2; 77706f2543Smrg if (x1 < x2) 78706f2543Smrg fbBlt ((FbBits *) s, 79706f2543Smrg 0, 80706f2543Smrg (x1 - ppt->x) * dstBpp + xoff, 81706f2543Smrg d, 82706f2543Smrg dstStride, 83706f2543Smrg (x1 + dstXoff) * dstBpp, 84706f2543Smrg 85706f2543Smrg (x2 - x1) * dstBpp, 86706f2543Smrg 1, 87706f2543Smrg pGC->alu, 88706f2543Smrg pPriv->pm, 89706f2543Smrg dstBpp, 90706f2543Smrg 91706f2543Smrg FALSE, 92706f2543Smrg FALSE); 93706f2543Smrg } 94706f2543Smrg } 95706f2543Smrg src += PixmapBytePad (*pwidth, pDrawable->depth); 96706f2543Smrg ppt++; 97706f2543Smrg pwidth++; 98706f2543Smrg } 99706f2543Smrg fbValidateDrawable (pDrawable); 100706f2543Smrg fbFinishAccess (pDrawable); 101706f2543Smrg} 102706f2543Smrg 103