~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to hw/xwin/winpixmap.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
 
3
 *
 
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:
 
11
 *
 
12
 *The above copyright notice and this permission notice shall be
 
13
 *included in all copies or substantial portions of the Software.
 
14
 *
 
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.
 
22
 *
 
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.
 
27
 *
 
28
 * Authors:     drewry, september 1986
 
29
 *              Harold L Hunt II
 
30
 */
 
31
/* $XFree86: xc/programs/Xserver/hw/xwin/winpixmap.c,v 1.10 2002/10/17 08:18:24 alanh Exp $ */
 
32
 
 
33
#ifdef HAVE_XWIN_CONFIG_H
 
34
#include <xwin-config.h>
 
35
#endif
 
36
#include "win.h"
 
37
 
 
38
 
 
39
/*
 
40
 * References to external symbols
 
41
 */
 
42
 
 
43
extern int                      g_iPixmapPrivateIndex;
 
44
 
 
45
 
 
46
/*
 
47
 * Local prototypes
 
48
 */
 
49
 
 
50
#if 0
 
51
static void
 
52
winXRotatePixmapNativeGDI (PixmapPtr pPix, int rw);
 
53
 
 
54
static void
 
55
winYRotatePixmapNativeGDI (PixmapPtr pPix, int rh);
 
56
 
 
57
static void
 
58
winCopyRotatePixmapNativeGDI (PixmapPtr psrcPix, PixmapPtr *ppdstPix,
 
59
                              int xrot, int yrot);
 
60
#endif
 
61
 
 
62
 
 
63
/* See Porting Layer Definition - p. 34 */
 
64
/* See mfb/mfbpixmap.c - mfbCreatePixmap() */
 
65
PixmapPtr
 
66
winCreatePixmapNativeGDI (ScreenPtr pScreen,
 
67
                          int iWidth, int iHeight,
 
68
                          int iDepth)
 
69
{
 
70
  winPrivPixmapPtr      pPixmapPriv = NULL;
 
71
  PixmapPtr             pPixmap = NULL;
 
72
 
 
73
  /* Allocate pixmap memory */
 
74
  pPixmap = AllocatePixmap (pScreen, 0);
 
75
  if (!pPixmap)
 
76
    {
 
77
      ErrorF ("winCreatePixmapNativeGDI () - Couldn't allocate a pixmap\n");
 
78
      return NullPixmap;
 
79
    }
 
80
 
 
81
#if CYGDEBUG
 
82
  winDebug ("winCreatePixmap () - w %d h %d d %d bw %d\n",
 
83
          iWidth, iHeight, iDepth,
 
84
          PixmapBytePad (iWidth, iDepth));
 
85
#endif
 
86
 
 
87
  /* Setup pixmap values */
 
88
  pPixmap->drawable.type = DRAWABLE_PIXMAP;
 
89
  pPixmap->drawable.class = 0;
 
90
  pPixmap->drawable.pScreen = pScreen;
 
91
  pPixmap->drawable.depth = iDepth;
 
92
  pPixmap->drawable.bitsPerPixel = BitsPerPixel (iDepth);
 
93
  pPixmap->drawable.id = 0;
 
94
  pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 
95
  pPixmap->drawable.x = 0;
 
96
  pPixmap->drawable.y = 0;
 
97
  pPixmap->drawable.width = iWidth;
 
98
  pPixmap->drawable.height = iHeight;
 
99
  pPixmap->devKind = 0;
 
100
  pPixmap->refcnt = 1;
 
101
  pPixmap->devPrivate.ptr = NULL;
 
102
 
 
103
  /* Pixmap privates are allocated by AllocatePixmap */
 
104
  pPixmapPriv = winGetPixmapPriv (pPixmap);
 
105
 
 
106
  /* Initialize pixmap privates */
 
107
  pPixmapPriv->hBitmap = NULL;
 
108
  pPixmapPriv->hdcSelected = NULL;
 
109
  pPixmapPriv->pbBits = NULL;
 
110
  pPixmapPriv->dwScanlineBytes = PixmapBytePad (iWidth, iDepth);
 
111
 
 
112
  /* Check for zero width or height pixmaps */
 
113
  if (iWidth == 0 || iHeight == 0)
 
114
    {
 
115
      /* Don't allocate a real pixmap, just set fields and return */
 
116
      return pPixmap;
 
117
    }
 
118
 
 
119
  /* Create a DIB for the pixmap */
 
120
  pPixmapPriv->hBitmap = winCreateDIBNativeGDI (iWidth, iHeight, iDepth,
 
121
                                                &pPixmapPriv->pbBits,
 
122
                                                (BITMAPINFO **) &pPixmapPriv->pbmih);
 
123
 
 
124
#if CYGDEBUG
 
125
  winDebug ("winCreatePixmap () - Created a pixmap %08x, %dx%dx%d, for " \
 
126
          "screen: %08x\n",
 
127
          pPixmapPriv->hBitmap, iWidth, iHeight, iDepth, pScreen);
 
128
#endif
 
129
 
 
130
  return pPixmap;
 
131
}
 
132
 
 
133
 
 
134
/* 
 
135
 * See Porting Layer Definition - p. 35
 
136
 *
 
137
 * See mfb/mfbpixmap.c - mfbDestroyPixmap()
 
138
 */
 
139
 
 
140
Bool
 
141
winDestroyPixmapNativeGDI (PixmapPtr pPixmap)
 
142
{
 
143
  winPrivPixmapPtr              pPixmapPriv = NULL;
 
144
  
 
145
#if CYGDEBUG
 
146
  winDebug ("winDestroyPixmapNativeGDI ()\n");
 
147
#endif
 
148
 
 
149
  /* Bail early if there is not a pixmap to destroy */
 
150
  if (pPixmap == NULL)
 
151
    {
 
152
      ErrorF ("winDestroyPixmapNativeGDI () - No pixmap to destroy\n");
 
153
      return TRUE;
 
154
    }
 
155
 
 
156
  /* Get a handle to the pixmap privates */
 
157
  pPixmapPriv = winGetPixmapPriv (pPixmap);
 
158
 
 
159
#if CYGDEBUG
 
160
  winDebug ("winDestroyPixmapNativeGDI - pPixmapPriv->hBitmap: %08x\n",
 
161
          pPixmapPriv->hBitmap);
 
162
#endif
 
163
 
 
164
  /* Decrement reference count, return if nonzero */
 
165
  --pPixmap->refcnt;
 
166
  if (pPixmap->refcnt != 0)
 
167
    return TRUE;
 
168
 
 
169
  /* Free GDI bitmap */
 
170
  if (pPixmapPriv->hBitmap) DeleteObject (pPixmapPriv->hBitmap);
 
171
  
 
172
  /* Free the bitmap info header memory */
 
173
  if (pPixmapPriv->pbmih != NULL)
 
174
    {
 
175
      free (pPixmapPriv->pbmih);
 
176
      pPixmapPriv->pbmih = NULL;
 
177
    }
 
178
 
 
179
  /* Free the pixmap memory */
 
180
  free (pPixmap);
 
181
  pPixmap = NULL;
 
182
 
 
183
  return TRUE;
 
184
}
 
185
 
 
186
 
 
187
/* 
 
188
 * Not used yet
 
189
 */
 
190
 
 
191
Bool
 
192
winModifyPixmapHeaderNativeGDI (PixmapPtr pPixmap,
 
193
                                int iWidth, int iHeight,
 
194
                                int iDepth,
 
195
                                int iBitsPerPixel,
 
196
                                int devKind,
 
197
                                pointer pPixData)
 
198
{
 
199
  FatalError ("winModifyPixmapHeaderNativeGDI ()\n");
 
200
  return TRUE;
 
201
}
 
202
 
 
203
 
 
204
#if 0
 
205
/* 
 
206
 * Not used yet.
 
207
 * See cfb/cfbpixmap.c
 
208
 */
 
209
 
 
210
static void
 
211
winXRotatePixmapNativeGDI (PixmapPtr pPix, int rw)
 
212
{
 
213
  ErrorF ("winXRotatePixmap()\n");
 
214
  /* fill in this function, look at CFB */
 
215
}
 
216
 
 
217
 
 
218
/*
 
219
 * Not used yet.
 
220
 * See cfb/cfbpixmap.c
 
221
 */
 
222
static void
 
223
winYRotatePixmapNativeGDI (PixmapPtr pPix, int rh)
 
224
{
 
225
  ErrorF ("winYRotatePixmap()\n");
 
226
  /* fill in this function, look at CFB */
 
227
}
 
228
 
 
229
 
 
230
/* 
 
231
 * Not used yet.
 
232
 * See cfb/cfbpixmap.c
 
233
 */
 
234
 
 
235
static void
 
236
winCopyRotatePixmapNativeGDI (PixmapPtr psrcPix, PixmapPtr *ppdstPix,
 
237
                              int xrot, int yrot)
 
238
{
 
239
  ErrorF ("winCopyRotatePixmap()\n");
 
240
  /* fill in this function, look at CFB */
 
241
}
 
242
#endif