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 30706f2543SmrgfbPolyFillRect(DrawablePtr pDrawable, 31706f2543Smrg GCPtr pGC, 32706f2543Smrg int nrect, 33706f2543Smrg xRectangle *prect) 34706f2543Smrg{ 35706f2543Smrg RegionPtr pClip = fbGetCompositeClip(pGC); 36706f2543Smrg register BoxPtr pbox; 37706f2543Smrg BoxPtr pextent; 38706f2543Smrg int extentX1, extentX2, extentY1, extentY2; 39706f2543Smrg int fullX1, fullX2, fullY1, fullY2; 40706f2543Smrg int partX1, partX2, partY1, partY2; 41706f2543Smrg int xorg, yorg; 42706f2543Smrg int n; 43706f2543Smrg 44706f2543Smrg xorg = pDrawable->x; 45706f2543Smrg yorg = pDrawable->y; 46706f2543Smrg 47706f2543Smrg pextent = RegionExtents(pClip); 48706f2543Smrg extentX1 = pextent->x1; 49706f2543Smrg extentY1 = pextent->y1; 50706f2543Smrg extentX2 = pextent->x2; 51706f2543Smrg extentY2 = pextent->y2; 52706f2543Smrg while (nrect--) 53706f2543Smrg { 54706f2543Smrg fullX1 = prect->x + xorg; 55706f2543Smrg fullY1 = prect->y + yorg; 56706f2543Smrg fullX2 = fullX1 + (int) prect->width; 57706f2543Smrg fullY2 = fullY1 + (int) prect->height; 58706f2543Smrg prect++; 59706f2543Smrg 60706f2543Smrg if (fullX1 < extentX1) 61706f2543Smrg fullX1 = extentX1; 62706f2543Smrg 63706f2543Smrg if (fullY1 < extentY1) 64706f2543Smrg fullY1 = extentY1; 65706f2543Smrg 66706f2543Smrg if (fullX2 > extentX2) 67706f2543Smrg fullX2 = extentX2; 68706f2543Smrg 69706f2543Smrg if (fullY2 > extentY2) 70706f2543Smrg fullY2 = extentY2; 71706f2543Smrg 72706f2543Smrg if ((fullX1 >= fullX2) || (fullY1 >= fullY2)) 73706f2543Smrg continue; 74706f2543Smrg n = RegionNumRects (pClip); 75706f2543Smrg if (n == 1) 76706f2543Smrg { 77706f2543Smrg fbFill (pDrawable, 78706f2543Smrg pGC, 79706f2543Smrg fullX1, fullY1, fullX2-fullX1, fullY2-fullY1); 80706f2543Smrg } 81706f2543Smrg else 82706f2543Smrg { 83706f2543Smrg pbox = RegionRects(pClip); 84706f2543Smrg /* 85706f2543Smrg * clip the rectangle to each box in the clip region 86706f2543Smrg * this is logically equivalent to calling Intersect() 87706f2543Smrg */ 88706f2543Smrg while(n--) 89706f2543Smrg { 90706f2543Smrg partX1 = pbox->x1; 91706f2543Smrg if (partX1 < fullX1) 92706f2543Smrg partX1 = fullX1; 93706f2543Smrg partY1 = pbox->y1; 94706f2543Smrg if (partY1 < fullY1) 95706f2543Smrg partY1 = fullY1; 96706f2543Smrg partX2 = pbox->x2; 97706f2543Smrg if (partX2 > fullX2) 98706f2543Smrg partX2 = fullX2; 99706f2543Smrg partY2 = pbox->y2; 100706f2543Smrg if (partY2 > fullY2) 101706f2543Smrg partY2 = fullY2; 102706f2543Smrg 103706f2543Smrg pbox++; 104706f2543Smrg 105706f2543Smrg if (partX1 < partX2 && partY1 < partY2) 106706f2543Smrg fbFill (pDrawable, pGC, 107706f2543Smrg partX1, partY1, 108706f2543Smrg partX2 - partX1, partY2 - partY1); 109706f2543Smrg } 110706f2543Smrg } 111706f2543Smrg } 112706f2543Smrg} 113