3 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
5 * Permission to use, copy, modify, distribute, and sell this software and its
6 * documentation for any purpose is hereby granted without fee, provided that
7 * the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting
9 * documentation, and that the name of Keith Packard not be used in
10 * advertising or publicity pertaining to distribution of the software without
11 * specific, written prior permission. Keith Packard makes no
12 * representations about the suitability of this software for any purpose. It
13 * is provided "as is" without express or implied warranty.
15 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21 * PERFORMANCE OF THIS SOFTWARE.
24 #ifdef HAVE_DIX_CONFIG_H
25 #include <dix-config.h>
28 #include "scrnintstr.h"
30 #include "pixmapstr.h"
31 #include "windowstr.h"
33 #include "picturestr.h"
37 miColorRects(PicturePtr pDst
,
40 int nRect
, xRectangle
*rects
, int xoff
, int yoff
)
44 ChangeGCVal tmpval
[5];
48 miRenderColorToPixel(pDst
->pFormat
, color
, &pixel
);
50 pGC
= GetScratchGC(pDst
->pDrawable
->depth
, pDst
->pDrawable
->pScreen
);
53 tmpval
[0].val
= GXcopy
;
54 tmpval
[1].val
= pixel
;
55 tmpval
[2].val
= pDst
->subWindowMode
;
56 mask
= GCFunction
| GCForeground
| GCSubwindowMode
;
57 if (pClipPict
->clientClipType
== CT_REGION
) {
58 tmpval
[3].val
= pDst
->clipOrigin
.x
- xoff
;
59 tmpval
[4].val
= pDst
->clipOrigin
.y
- yoff
;
60 mask
|= GCClipXOrigin
| GCClipYOrigin
;
62 pClip
= RegionCreate(NULL
, 1);
63 RegionCopy(pClip
, (RegionPtr
) pClipPict
->clientClip
);
64 (*pGC
->funcs
->ChangeClip
) (pGC
, CT_REGION
, pClip
, 0);
67 ChangeGC(NullClient
, pGC
, mask
, tmpval
);
68 ValidateGC(pDst
->pDrawable
, pGC
);
72 for (i
= 0; i
< nRect
; i
++) {
77 (*pGC
->ops
->PolyFillRect
) (pDst
->pDrawable
, pGC
, nRect
, rects
);
81 for (i
= 0; i
< nRect
; i
++) {
90 miCompositeRects(CARD8 op
,
92 xRenderColor
* color
, int nRect
, xRectangle
*rects
)
94 ScreenPtr pScreen
= pDst
->pDrawable
->pScreen
;
96 if (color
->alpha
== 0xffff) {
100 if (op
== PictOpClear
)
101 color
->red
= color
->green
= color
->blue
= color
->alpha
= 0;
103 if (op
== PictOpSrc
|| op
== PictOpClear
) {
104 miColorRects(pDst
, pDst
, color
, nRect
, rects
, 0, 0);
106 miColorRects(pDst
->alphaMap
, pDst
,
108 pDst
->alphaOrigin
.x
, pDst
->alphaOrigin
.y
);
111 PictFormatPtr rgbaFormat
;
118 ChangeGCVal gcvals
[2];
121 rgbaFormat
= PictureMatchFormat(pScreen
, 32, PICT_a8r8g8b8
);
125 pPixmap
= (*pScreen
->CreatePixmap
) (pScreen
, 1, 1, rgbaFormat
->depth
,
126 CREATE_PIXMAP_USAGE_SCRATCH
);
130 miRenderColorToPixel(rgbaFormat
, color
, &pixel
);
132 pGC
= GetScratchGC(rgbaFormat
->depth
, pScreen
);
135 gcvals
[0].val
= GXcopy
;
136 gcvals
[1].val
= pixel
;
138 ChangeGC(NullClient
, pGC
, GCFunction
| GCForeground
, gcvals
);
139 ValidateGC(&pPixmap
->drawable
, pGC
);
144 (*pGC
->ops
->PolyFillRect
) (&pPixmap
->drawable
, pGC
, 1, &one
);
147 pSrc
= CreatePicture(0, &pPixmap
->drawable
, rgbaFormat
,
148 CPRepeat
, tmpval
, serverClient
, &error
);
154 CompositePicture(op
, pSrc
, 0, pDst
, 0, 0, 0, 0,
155 rects
->x
, rects
->y
, rects
->width
, rects
->height
);
159 FreePicture((pointer
) pSrc
, 0);
163 (*pScreen
->DestroyPixmap
) (pPixmap
);