2 *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
4 *Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 *"Software"), to deal in the Software without restriction, including
7 *without limitation the rights to use, copy, modify, merge, publish,
8 *distribute, sublicense, and/or sell copies of the Software, and to
9 *permit persons to whom the Software is furnished to do so, subject to
10 *the following conditions:
12 *The above copyright notice and this permission notice shall be
13 *included in all copies or substantial portions of the Software.
15 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
19 *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20 *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *Except as contained in this notice, the name of the XFree86 Project
24 *shall not be used in advertising or otherwise to promote the sale, use
25 *or other dealings in this Software without prior written authorization
26 *from the XFree86 Project.
28 * Authors: Harold L Hunt II
29 * Alan Hourihane <alanh@fairlite.demon.co.uk>
32 #ifdef HAVE_XWIN_CONFIG_H
33 #include <xwin-config.h>
37 /* See Porting Layer Definition - p. 55 */
39 winSetSpansNativeGDI(DrawablePtr pDrawable
,
43 int *piWidths
, int iSpans
, int fSorted
)
46 PixmapPtr pPixmap
= NULL
;
47 winPrivPixmapPtr pPixmapPriv
= NULL
;
48 HBITMAP hbmpOrig
= NULL
;
50 HRGN hrgn
= NULL
, combined
= NULL
;
54 nbox
= RegionNumRects(pGC
->pCompositeClip
);
55 pbox
= RegionRects(pGC
->pCompositeClip
);
60 pbmi
= malloc(sizeof(BITMAPINFO
) + sizeof(RGBQUAD
));
62 combined
= CreateRectRgn(pbox
->x1
, pbox
->y1
, pbox
->x2
, pbox
->y2
);
66 hrgn
= CreateRectRgn(pbox
->x1
, pbox
->y1
, pbox
->x2
, pbox
->y2
);
67 CombineRgn(combined
, combined
, hrgn
, RGN_OR
);
73 /* Branch on the drawable type */
74 switch (pDrawable
->type
) {
77 SelectClipRgn(pGCPriv
->hdcMem
, combined
);
78 DeleteObject(combined
);
81 pPixmap
= (PixmapPtr
) pDrawable
;
82 pPixmapPriv
= winGetPixmapPriv(pPixmap
);
84 /* Select the drawable pixmap into a DC */
85 hbmpOrig
= SelectObject(pGCPriv
->hdcMem
, pPixmapPriv
->hBitmap
);
87 FatalError("winSetSpans - DRAWABLE_PIXMAP - SelectObject () "
88 "failed on pPixmapPriv->hBitmap\n");
91 ZeroMemory(pbmi
, sizeof(BITMAPINFO
));
92 pbmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
93 pbmi
->bmiHeader
.biWidth
= *piWidths
;
94 pbmi
->bmiHeader
.biHeight
= 1;
95 pbmi
->bmiHeader
.biPlanes
= 1;
96 pbmi
->bmiHeader
.biBitCount
= pDrawable
->depth
;
97 pbmi
->bmiHeader
.biCompression
= BI_RGB
;
99 /* Setup color table for mono DIBs */
100 if (pDrawable
->depth
== 1) {
101 RGBQUAD
*bmiColors
= &(pbmi
->bmiColors
[0]);
102 bmiColors
[1].rgbBlue
= 255;
103 bmiColors
[1].rgbGreen
= 255;
104 bmiColors
[1].rgbRed
= 255;
107 StretchDIBits(pGCPriv
->hdcMem
,
108 pPoints
->x
, pPoints
->y
,
114 DIB_RGB_COLORS
, g_copyROP
[pGC
->alu
]);
116 pSrcs
+= PixmapBytePad(*piWidths
, pDrawable
->depth
);
121 /* Reset the clip region */
122 SelectClipRgn(pGCPriv
->hdcMem
, NULL
);
124 /* Push the drawable pixmap out of the GC HDC */
125 SelectObject(pGCPriv
->hdcMem
, hbmpOrig
);
128 case DRAWABLE_WINDOW
:
130 SelectClipRgn(pGCPriv
->hdc
, combined
);
131 DeleteObject(combined
);
135 ZeroMemory(pbmi
, sizeof(BITMAPINFO
));
136 pbmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
137 pbmi
->bmiHeader
.biWidth
= *piWidths
;
138 pbmi
->bmiHeader
.biHeight
= 1;
139 pbmi
->bmiHeader
.biPlanes
= 1;
140 pbmi
->bmiHeader
.biBitCount
= pDrawable
->depth
;
141 pbmi
->bmiHeader
.biCompression
= BI_RGB
;
143 /* Setup color table for mono DIBs */
144 if (pDrawable
->depth
== 1) {
145 RGBQUAD
*bmiColors
= &(pbmi
->bmiColors
[0]);
146 bmiColors
[1].rgbBlue
= 255;
147 bmiColors
[1].rgbGreen
= 255;
148 bmiColors
[1].rgbRed
= 255;
151 StretchDIBits(pGCPriv
->hdc
,
152 pPoints
->x
, pPoints
->y
,
158 DIB_RGB_COLORS
, g_copyROP
[pGC
->alu
]);
160 pSrcs
+= PixmapBytePad(*piWidths
, pDrawable
->depth
);
165 /* Reset the clip region */
166 SelectClipRgn(pGCPriv
->hdc
, NULL
);
170 FatalError("\nwinSetSpansNativeGDI - Unknown drawable type\n\n");