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 winGetSpansNativeGDI(DrawablePtr pDrawable
,
42 int *piWidths
, int iSpans
, char *pDsts
)
44 PixmapPtr pPixmap
= NULL
;
45 winPrivPixmapPtr pPixmapPriv
= NULL
;
47 DDXPointPtr pPoint
= NULL
;
50 HBITMAP hbmpWindow
, hbmpOrig
, hbmpOrig1
;
51 BYTE
*pbWindow
= NULL
;
53 ScreenPtr pScreen
= pDrawable
->pScreen
;
55 winScreenPriv(pScreen
);
57 /* Branch on the drawable type */
58 switch (pDrawable
->type
) {
61 ErrorF("winGetSpans - DRAWABLE_PIXMAP %08x\n", pDrawable
);
64 pPixmap
= (PixmapPtr
) pDrawable
;
65 pPixmapPriv
= winGetPixmapPriv(pPixmap
);
67 /* Open a memory HDC */
68 hdcMem1
= CreateCompatibleDC(NULL
);
69 hdcMem
= CreateCompatibleDC(NULL
);
71 /* Select the drawable pixmap into a DC */
72 hbmpOrig1
= SelectObject(hdcMem1
, pPixmapPriv
->hBitmap
);
74 if (hbmpOrig1
== NULL
)
75 FatalError("winGetSpans - DRAWABLE_PIXMAP - SelectObject () "
76 "failed on pPixmapPriv->hBitmap\n");
78 /* Loop through spans */
79 for (iSpan
= 0; iSpan
< iSpans
; ++iSpan
) {
80 pPoint
= pPoints
+ iSpan
;
81 piWidth
= piWidths
+ iSpan
;
83 hbmpWindow
= winCreateDIBNativeGDI(*piWidth
, 1,
87 hbmpOrig
= SelectObject(hdcMem
, hbmpWindow
);
89 /* Transfer the window bits to the window bitmap */
91 0, 0, *piWidth
, 1, hdcMem1
, pPoint
->x
, pPoint
->y
, SRCCOPY
);
95 PixmapBytePad(*piWidth
, pDrawable
->depth
));
97 /* Pop the window bitmap out of the HDC and delete the bitmap */
98 SelectObject(hdcMem
, hbmpOrig
);
99 DeleteObject(hbmpWindow
);
102 ErrorF("(%dx%dx%d) (%d,%d) w: %d\n",
103 pDrawable
->width
, pDrawable
->height
, pDrawable
->depth
,
104 pPoint
->x
, pPoint
->y
, *piWidth
);
107 /* Calculate offset of next bit destination */
108 pDst
+= PixmapBytePad(*piWidth
, pDrawable
->depth
);
111 /* Pop the pixmap's bitmap out of the HDC */
112 SelectObject(hdcMem1
, hbmpOrig1
);
114 /* Delete the HDCs */
119 case DRAWABLE_WINDOW
:
121 ErrorF("winGetSpans - DRAWABLE_WINDOW\n");
124 /* Open a memory HDC */
125 hdcMem
= CreateCompatibleDC(NULL
);
127 /* Loop through spans */
128 for (iSpan
= 0; iSpan
< iSpans
; ++iSpan
) {
129 pPoint
= pPoints
+ iSpan
;
130 piWidth
= piWidths
+ iSpan
;
132 hbmpWindow
= winCreateDIBNativeGDI(*piWidth
, 1,
136 hbmpOrig
= SelectObject(hdcMem
, hbmpWindow
);
138 /* Transfer the window bits to the window bitmap */
142 pScreenPriv
->hdcScreen
, pPoint
->x
, pPoint
->y
, SRCCOPY
);
146 PixmapBytePad(*piWidth
, pDrawable
->depth
));
148 /* Pop the window bitmap out of the HDC */
149 SelectObject(hdcMem
, hbmpOrig
);
151 DeleteObject(hbmpWindow
);
154 ErrorF("(%dx%dx%d) (%d,%d) w: %d\n",
155 pDrawable
->width
, pDrawable
->height
, pDrawable
->depth
,
156 pPoint
->x
, pPoint
->y
, *piWidth
);
159 /* Calculate offset of next bit destination */
160 pDst
+= PixmapBytePad(*piWidth
, pDrawable
->depth
);
163 /* Delete the window bitmap */
168 FatalError("winGetSpans - Unknown drawable type\n");