First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xwin / winpixmap.c
blobbaff60c927a71e61f7f14d7a3456794a5fc46910
1 /*
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: drewry, september 1986
29 * Harold L Hunt II
32 #ifdef HAVE_XWIN_CONFIG_H
33 #include <xwin-config.h>
34 #endif
35 #include "win.h"
39 * References to external symbols
42 extern int g_iPixmapPrivateIndex;
46 * Local prototypes
49 #if 0
50 static void
51 winXRotatePixmapNativeGDI (PixmapPtr pPix, int rw);
53 static void
54 winYRotatePixmapNativeGDI (PixmapPtr pPix, int rh);
56 static void
57 winCopyRotatePixmapNativeGDI (PixmapPtr psrcPix, PixmapPtr *ppdstPix,
58 int xrot, int yrot);
59 #endif
62 /* See Porting Layer Definition - p. 34 */
63 /* See mfb/mfbpixmap.c - mfbCreatePixmap() */
64 PixmapPtr
65 winCreatePixmapNativeGDI (ScreenPtr pScreen,
66 int iWidth, int iHeight,
67 int iDepth)
69 winPrivPixmapPtr pPixmapPriv = NULL;
70 PixmapPtr pPixmap = NULL;
72 /* Allocate pixmap memory */
73 pPixmap = AllocatePixmap (pScreen, 0);
74 if (!pPixmap)
76 ErrorF ("winCreatePixmapNativeGDI () - Couldn't allocate a pixmap\n");
77 return NullPixmap;
80 #if CYGDEBUG
81 winDebug ("winCreatePixmap () - w %d h %d d %d bw %d\n",
82 iWidth, iHeight, iDepth,
83 PixmapBytePad (iWidth, iDepth));
84 #endif
86 /* Setup pixmap values */
87 pPixmap->drawable.type = DRAWABLE_PIXMAP;
88 pPixmap->drawable.class = 0;
89 pPixmap->drawable.pScreen = pScreen;
90 pPixmap->drawable.depth = iDepth;
91 pPixmap->drawable.bitsPerPixel = BitsPerPixel (iDepth);
92 pPixmap->drawable.id = 0;
93 pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
94 pPixmap->drawable.x = 0;
95 pPixmap->drawable.y = 0;
96 pPixmap->drawable.width = iWidth;
97 pPixmap->drawable.height = iHeight;
98 pPixmap->devKind = 0;
99 pPixmap->refcnt = 1;
100 pPixmap->devPrivate.ptr = NULL;
102 /* Pixmap privates are allocated by AllocatePixmap */
103 pPixmapPriv = winGetPixmapPriv (pPixmap);
105 /* Initialize pixmap privates */
106 pPixmapPriv->hBitmap = NULL;
107 pPixmapPriv->hdcSelected = NULL;
108 pPixmapPriv->pbBits = NULL;
109 pPixmapPriv->dwScanlineBytes = PixmapBytePad (iWidth, iDepth);
111 /* Check for zero width or height pixmaps */
112 if (iWidth == 0 || iHeight == 0)
114 /* Don't allocate a real pixmap, just set fields and return */
115 return pPixmap;
118 /* Create a DIB for the pixmap */
119 pPixmapPriv->hBitmap = winCreateDIBNativeGDI (iWidth, iHeight, iDepth,
120 &pPixmapPriv->pbBits,
121 (BITMAPINFO **) &pPixmapPriv->pbmih);
123 #if CYGDEBUG
124 winDebug ("winCreatePixmap () - Created a pixmap %08x, %dx%dx%d, for " \
125 "screen: %08x\n",
126 pPixmapPriv->hBitmap, iWidth, iHeight, iDepth, pScreen);
127 #endif
129 return pPixmap;
134 * See Porting Layer Definition - p. 35
136 * See mfb/mfbpixmap.c - mfbDestroyPixmap()
139 Bool
140 winDestroyPixmapNativeGDI (PixmapPtr pPixmap)
142 winPrivPixmapPtr pPixmapPriv = NULL;
144 #if CYGDEBUG
145 winDebug ("winDestroyPixmapNativeGDI ()\n");
146 #endif
148 /* Bail early if there is not a pixmap to destroy */
149 if (pPixmap == NULL)
151 ErrorF ("winDestroyPixmapNativeGDI () - No pixmap to destroy\n");
152 return TRUE;
155 /* Get a handle to the pixmap privates */
156 pPixmapPriv = winGetPixmapPriv (pPixmap);
158 #if CYGDEBUG
159 winDebug ("winDestroyPixmapNativeGDI - pPixmapPriv->hBitmap: %08x\n",
160 pPixmapPriv->hBitmap);
161 #endif
163 /* Decrement reference count, return if nonzero */
164 --pPixmap->refcnt;
165 if (pPixmap->refcnt != 0)
166 return TRUE;
168 /* Free GDI bitmap */
169 if (pPixmapPriv->hBitmap) DeleteObject (pPixmapPriv->hBitmap);
171 /* Free the bitmap info header memory */
172 if (pPixmapPriv->pbmih != NULL)
174 free (pPixmapPriv->pbmih);
175 pPixmapPriv->pbmih = NULL;
178 /* Free the pixmap memory */
179 free (pPixmap);
180 pPixmap = NULL;
182 return TRUE;
187 * Not used yet
190 Bool
191 winModifyPixmapHeaderNativeGDI (PixmapPtr pPixmap,
192 int iWidth, int iHeight,
193 int iDepth,
194 int iBitsPerPixel,
195 int devKind,
196 pointer pPixData)
198 FatalError ("winModifyPixmapHeaderNativeGDI ()\n");
199 return TRUE;
203 #if 0
205 * Not used yet.
206 * See cfb/cfbpixmap.c
209 static void
210 winXRotatePixmapNativeGDI (PixmapPtr pPix, int rw)
212 ErrorF ("winXRotatePixmap()\n");
213 /* fill in this function, look at CFB */
218 * Not used yet.
219 * See cfb/cfbpixmap.c
221 static void
222 winYRotatePixmapNativeGDI (PixmapPtr pPix, int rh)
224 ErrorF ("winYRotatePixmap()\n");
225 /* fill in this function, look at CFB */
230 * Not used yet.
231 * See cfb/cfbpixmap.c
234 static void
235 winCopyRotatePixmapNativeGDI (PixmapPtr psrcPix, PixmapPtr *ppdstPix,
236 int xrot, int yrot)
238 ErrorF ("winCopyRotatePixmap()\n");
239 /* fill in this function, look at CFB */
241 #endif