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>
39 * References to external symbols
42 extern int g_iPixmapPrivateIndex
;
43 extern int g_iGCPrivateIndex
;
44 extern int g_copyROP
[];
47 /* See Porting Layer Definition - p. 55 */
49 winSetSpansNativeGDI (DrawablePtr pDrawable
,
58 PixmapPtr pPixmap
= NULL
;
59 winPrivPixmapPtr pPixmapPriv
= NULL
;
60 HBITMAP hbmpOrig
= NULL
;
62 HRGN hrgn
= NULL
, combined
= NULL
;
66 nbox
= REGION_NUM_RECTS (pGC
->pCompositeClip
);
67 pbox
= REGION_RECTS (pGC
->pCompositeClip
);
71 combined
= CreateRectRgn (pbox
->x1
, pbox
->y1
, pbox
->x2
, pbox
->y2
);
75 hrgn
= CreateRectRgn (pbox
->x1
, pbox
->y1
, pbox
->x2
, pbox
->y2
);
76 CombineRgn (combined
, combined
, hrgn
, RGN_OR
);
82 /* Branch on the drawable type */
83 switch (pDrawable
->type
)
87 SelectClipRgn (pGCPriv
->hdcMem
, combined
);
88 DeleteObject (combined
);
91 pPixmap
= (PixmapPtr
) pDrawable
;
92 pPixmapPriv
= winGetPixmapPriv (pPixmap
);
94 /* Select the drawable pixmap into a DC */
95 hbmpOrig
= SelectObject (pGCPriv
->hdcMem
, pPixmapPriv
->hBitmap
);
97 FatalError ("winSetSpans - DRAWABLE_PIXMAP - SelectObject () "
98 "failed on pPixmapPriv->hBitmap\n");
102 ZeroMemory (&bmi
, sizeof (BITMAPINFO
));
103 bmi
.bmiHeader
.biSize
= sizeof (BITMAPINFOHEADER
);
104 bmi
.bmiHeader
.biWidth
= *piWidths
;
105 bmi
.bmiHeader
.biHeight
= 1;
106 bmi
.bmiHeader
.biPlanes
= 1;
107 bmi
.bmiHeader
.biBitCount
= pDrawable
->depth
;
108 bmi
.bmiHeader
.biCompression
= BI_RGB
;
110 /* Setup color table for mono DIBs */
111 if (pDrawable
->depth
== 1)
113 bmi
.bmiColors
[1].rgbBlue
= 255;
114 bmi
.bmiColors
[1].rgbGreen
= 255;
115 bmi
.bmiColors
[1].rgbRed
= 255;
118 StretchDIBits (pGCPriv
->hdcMem
,
119 pPoints
->x
, pPoints
->y
,
126 g_copyROP
[pGC
->alu
]);
128 pSrcs
+= PixmapBytePad (*piWidths
, pDrawable
->depth
);
133 /* Reset the clip region */
134 SelectClipRgn (pGCPriv
->hdcMem
, NULL
);
136 /* Push the drawable pixmap out of the GC HDC */
137 SelectObject (pGCPriv
->hdcMem
, hbmpOrig
);
140 case DRAWABLE_WINDOW
:
142 SelectClipRgn (pGCPriv
->hdc
, combined
);
143 DeleteObject (combined
);
148 ZeroMemory (&bmi
, sizeof (BITMAPINFO
));
149 bmi
.bmiHeader
.biSize
= sizeof (BITMAPINFOHEADER
);
150 bmi
.bmiHeader
.biWidth
= *piWidths
;
151 bmi
.bmiHeader
.biHeight
= 1;
152 bmi
.bmiHeader
.biPlanes
= 1;
153 bmi
.bmiHeader
.biBitCount
= pDrawable
->depth
;
154 bmi
.bmiHeader
.biCompression
= BI_RGB
;
156 /* Setup color table for mono DIBs */
157 if (pDrawable
->depth
== 1)
159 bmi
.bmiColors
[1].rgbBlue
= 255;
160 bmi
.bmiColors
[1].rgbGreen
= 255;
161 bmi
.bmiColors
[1].rgbRed
= 255;
164 StretchDIBits (pGCPriv
->hdc
,
165 pPoints
->x
, pPoints
->y
,
172 g_copyROP
[pGC
->alu
]);
174 pSrcs
+= PixmapBytePad (*piWidths
, pDrawable
->depth
);
179 /* Reset the clip region */
180 SelectClipRgn (pGCPriv
->hdc
, NULL
);
183 case UNDRAWABLE_WINDOW
:
184 FatalError ("\nwinSetSpansNativeGDI - UNDRAWABLE_WINDOW\n\n");
187 case DRAWABLE_BUFFER
:
188 FatalError ("\nwinSetSpansNativeGDI - DRAWABLE_BUFFER\n\n");
192 FatalError ("\nwinSetSpansNativeGDI - Unknown drawable type\n\n");