1706f2543Smrg/*
2706f2543Smrg *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
3706f2543Smrg *
4706f2543Smrg *Permission is hereby granted, free of charge, to any person obtaining
5706f2543Smrg * a copy of this software and associated documentation files (the
6706f2543Smrg *"Software"), to deal in the Software without restriction, including
7706f2543Smrg *without limitation the rights to use, copy, modify, merge, publish,
8706f2543Smrg *distribute, sublicense, and/or sell copies of the Software, and to
9706f2543Smrg *permit persons to whom the Software is furnished to do so, subject to
10706f2543Smrg *the following conditions:
11706f2543Smrg *
12706f2543Smrg *The above copyright notice and this permission notice shall be
13706f2543Smrg *included in all copies or substantial portions of the Software.
14706f2543Smrg *
15706f2543Smrg *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16706f2543Smrg *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17706f2543Smrg *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18706f2543Smrg *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
19706f2543Smrg *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20706f2543Smrg *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21706f2543Smrg *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22706f2543Smrg *
23706f2543Smrg *Except as contained in this notice, the name of the XFree86 Project
24706f2543Smrg *shall not be used in advertising or otherwise to promote the sale, use
25706f2543Smrg *or other dealings in this Software without prior written authorization
26706f2543Smrg *from the XFree86 Project.
27706f2543Smrg *
28706f2543Smrg * Authors:	drewry, september 1986
29706f2543Smrg *		Harold L Hunt II
30706f2543Smrg */
31706f2543Smrg
32706f2543Smrg#ifdef HAVE_XWIN_CONFIG_H
33706f2543Smrg#include <xwin-config.h>
34706f2543Smrg#endif
35706f2543Smrg#include "win.h"
36706f2543Smrg
37706f2543Smrg
38706f2543Smrg/*
39706f2543Smrg * Local prototypes
40706f2543Smrg */
41706f2543Smrg
42706f2543Smrg#if 0
43706f2543Smrgstatic void
44706f2543SmrgwinXRotatePixmapNativeGDI (PixmapPtr pPix, int rw);
45706f2543Smrg
46706f2543Smrgstatic void
47706f2543SmrgwinYRotatePixmapNativeGDI (PixmapPtr pPix, int rh);
48706f2543Smrg
49706f2543Smrgstatic void
50706f2543SmrgwinCopyRotatePixmapNativeGDI (PixmapPtr psrcPix, PixmapPtr *ppdstPix,
51706f2543Smrg			      int xrot, int yrot);
52706f2543Smrg#endif
53706f2543Smrg
54706f2543Smrg
55706f2543Smrg/* See Porting Layer Definition - p. 34 */
56706f2543Smrg/* See mfb/mfbpixmap.c - mfbCreatePixmap() */
57706f2543SmrgPixmapPtr
58706f2543SmrgwinCreatePixmapNativeGDI (ScreenPtr pScreen,
59706f2543Smrg			  int iWidth, int iHeight,
60706f2543Smrg			  int iDepth, unsigned usage_hint)
61706f2543Smrg{
62706f2543Smrg  winPrivPixmapPtr	pPixmapPriv = NULL;
63706f2543Smrg  PixmapPtr		pPixmap = NULL;
64706f2543Smrg
65706f2543Smrg  /* Allocate pixmap memory */
66706f2543Smrg  pPixmap = AllocatePixmap (pScreen, 0);
67706f2543Smrg  if (!pPixmap)
68706f2543Smrg    {
69706f2543Smrg      ErrorF ("winCreatePixmapNativeGDI () - Couldn't allocate a pixmap\n");
70706f2543Smrg      return NullPixmap;
71706f2543Smrg    }
72706f2543Smrg
73706f2543Smrg#if CYGDEBUG
74706f2543Smrg  winDebug ("winCreatePixmap () - w %d h %d d %d uh %d bw %d\n",
75706f2543Smrg	  iWidth, iHeight, iDepth, usage_hint,
76706f2543Smrg	  PixmapBytePad (iWidth, iDepth));
77706f2543Smrg#endif
78706f2543Smrg
79706f2543Smrg  /* Setup pixmap values */
80706f2543Smrg  pPixmap->drawable.type = DRAWABLE_PIXMAP;
81706f2543Smrg  pPixmap->drawable.class = 0;
82706f2543Smrg  pPixmap->drawable.pScreen = pScreen;
83706f2543Smrg  pPixmap->drawable.depth = iDepth;
84706f2543Smrg  pPixmap->drawable.bitsPerPixel = BitsPerPixel (iDepth);
85706f2543Smrg  pPixmap->drawable.id = 0;
86706f2543Smrg  pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
87706f2543Smrg  pPixmap->drawable.x = 0;
88706f2543Smrg  pPixmap->drawable.y = 0;
89706f2543Smrg  pPixmap->drawable.width = iWidth;
90706f2543Smrg  pPixmap->drawable.height = iHeight;
91706f2543Smrg  pPixmap->devKind = 0;
92706f2543Smrg  pPixmap->refcnt = 1;
93706f2543Smrg  pPixmap->devPrivate.ptr = NULL;
94706f2543Smrg  pPixmap->usage_hint = usage_hint;
95706f2543Smrg
96706f2543Smrg  /* Pixmap privates are allocated by AllocatePixmap */
97706f2543Smrg  pPixmapPriv = winGetPixmapPriv (pPixmap);
98706f2543Smrg
99706f2543Smrg  /* Initialize pixmap privates */
100706f2543Smrg  pPixmapPriv->hBitmap = NULL;
101706f2543Smrg  pPixmapPriv->hdcSelected = NULL;
102706f2543Smrg  pPixmapPriv->pbBits = NULL;
103706f2543Smrg  pPixmapPriv->dwScanlineBytes = PixmapBytePad (iWidth, iDepth);
104706f2543Smrg
105706f2543Smrg  /* Check for zero width or height pixmaps */
106706f2543Smrg  if (iWidth == 0 || iHeight == 0)
107706f2543Smrg    {
108706f2543Smrg      /* Don't allocate a real pixmap, just set fields and return */
109706f2543Smrg      return pPixmap;
110706f2543Smrg    }
111706f2543Smrg
112706f2543Smrg  /* Create a DIB for the pixmap */
113706f2543Smrg  pPixmapPriv->hBitmap = winCreateDIBNativeGDI (iWidth, iHeight, iDepth,
114706f2543Smrg						&pPixmapPriv->pbBits,
115706f2543Smrg						(BITMAPINFO **) &pPixmapPriv->pbmih);
116706f2543Smrg
117706f2543Smrg#if CYGDEBUG
118706f2543Smrg  winDebug ("winCreatePixmap () - Created a pixmap %08x, %dx%dx%d, for " \
119706f2543Smrg	  "screen: %08x\n",
120706f2543Smrg	  pPixmapPriv->hBitmap, iWidth, iHeight, iDepth, pScreen);
121706f2543Smrg#endif
122706f2543Smrg
123706f2543Smrg  return pPixmap;
124706f2543Smrg}
125706f2543Smrg
126706f2543Smrg
127706f2543Smrg/*
128706f2543Smrg * See Porting Layer Definition - p. 35
129706f2543Smrg *
130706f2543Smrg * See mfb/mfbpixmap.c - mfbDestroyPixmap()
131706f2543Smrg */
132706f2543Smrg
133706f2543SmrgBool
134706f2543SmrgwinDestroyPixmapNativeGDI (PixmapPtr pPixmap)
135706f2543Smrg{
136706f2543Smrg  winPrivPixmapPtr		pPixmapPriv = NULL;
137706f2543Smrg
138706f2543Smrg#if CYGDEBUG
139706f2543Smrg  winDebug ("winDestroyPixmapNativeGDI ()\n");
140706f2543Smrg#endif
141706f2543Smrg
142706f2543Smrg  /* Bail early if there is not a pixmap to destroy */
143706f2543Smrg  if (pPixmap == NULL)
144706f2543Smrg    {
145706f2543Smrg      ErrorF ("winDestroyPixmapNativeGDI () - No pixmap to destroy\n");
146706f2543Smrg      return TRUE;
147706f2543Smrg    }
148706f2543Smrg
149706f2543Smrg  /* Get a handle to the pixmap privates */
150706f2543Smrg  pPixmapPriv = winGetPixmapPriv (pPixmap);
151706f2543Smrg
152706f2543Smrg#if CYGDEBUG
153706f2543Smrg  winDebug ("winDestroyPixmapNativeGDI - pPixmapPriv->hBitmap: %08x\n",
154706f2543Smrg	  pPixmapPriv->hBitmap);
155706f2543Smrg#endif
156706f2543Smrg
157706f2543Smrg  /* Decrement reference count, return if nonzero */
158706f2543Smrg  --pPixmap->refcnt;
159706f2543Smrg  if (pPixmap->refcnt != 0)
160706f2543Smrg    return TRUE;
161706f2543Smrg
162706f2543Smrg  /* Free GDI bitmap */
163706f2543Smrg  if (pPixmapPriv->hBitmap) DeleteObject (pPixmapPriv->hBitmap);
164706f2543Smrg
165706f2543Smrg  /* Free the bitmap info header memory */
166706f2543Smrg  free(pPixmapPriv->pbmih);
167706f2543Smrg  pPixmapPriv->pbmih = NULL;
168706f2543Smrg
169706f2543Smrg  /* Free the pixmap memory */
170706f2543Smrg  free (pPixmap);
171706f2543Smrg  pPixmap = NULL;
172706f2543Smrg
173706f2543Smrg  return TRUE;
174706f2543Smrg}
175706f2543Smrg
176706f2543Smrg
177706f2543Smrg/*
178706f2543Smrg * Not used yet
179706f2543Smrg */
180706f2543Smrg
181706f2543SmrgBool
182706f2543SmrgwinModifyPixmapHeaderNativeGDI (PixmapPtr pPixmap,
183706f2543Smrg				int iWidth, int iHeight,
184706f2543Smrg				int iDepth,
185706f2543Smrg				int iBitsPerPixel,
186706f2543Smrg				int devKind,
187706f2543Smrg				pointer pPixData)
188706f2543Smrg{
189706f2543Smrg  FatalError ("winModifyPixmapHeaderNativeGDI ()\n");
190706f2543Smrg  return TRUE;
191706f2543Smrg}
192706f2543Smrg
193706f2543Smrg
194706f2543Smrg#if 0
195706f2543Smrg/*
196706f2543Smrg * Not used yet.
197706f2543Smrg * See cfb/cfbpixmap.c
198706f2543Smrg */
199706f2543Smrg
200706f2543Smrgstatic void
201706f2543SmrgwinXRotatePixmapNativeGDI (PixmapPtr pPix, int rw)
202706f2543Smrg{
203706f2543Smrg  ErrorF ("winXRotatePixmap()\n");
204706f2543Smrg  /* fill in this function, look at CFB */
205706f2543Smrg}
206706f2543Smrg
207706f2543Smrg
208706f2543Smrg/*
209706f2543Smrg * Not used yet.
210706f2543Smrg * See cfb/cfbpixmap.c
211706f2543Smrg */
212706f2543Smrgstatic void
213706f2543SmrgwinYRotatePixmapNativeGDI (PixmapPtr pPix, int rh)
214706f2543Smrg{
215706f2543Smrg  ErrorF ("winYRotatePixmap()\n");
216706f2543Smrg  /* fill in this function, look at CFB */
217706f2543Smrg}
218706f2543Smrg
219706f2543Smrg
220706f2543Smrg/*
221706f2543Smrg * Not used yet.
222706f2543Smrg * See cfb/cfbpixmap.c
223706f2543Smrg */
224706f2543Smrg
225706f2543Smrgstatic void
226706f2543SmrgwinCopyRotatePixmapNativeGDI (PixmapPtr psrcPix, PixmapPtr *ppdstPix,
227706f2543Smrg			      int xrot, int yrot)
228706f2543Smrg{
229706f2543Smrg  ErrorF ("winCopyRotatePixmap()\n");
230706f2543Smrg  /* fill in this function, look at CFB */
231706f2543Smrg}
232706f2543Smrg#endif
233