4 * Copyright 1999 Patrik Stridvall
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(ttydrv);
33 /**********************************************************************/
35 extern const DC_FUNCTIONS *TTYDRV_DC_Funcs; /* hack */
37 static LONG TTYDRV_DC_GetBitmapBits(BITMAPOBJ *bitmap, void *bits, LONG count);
38 static LONG TTYDRV_DC_SetBitmapBits(BITMAPOBJ *bitmap, void *bits, LONG count);
40 /***********************************************************************
41 * TTYDRV_DC_AllocBitmap
43 TTYDRV_PHYSBITMAP *TTYDRV_DC_AllocBitmap(BITMAPOBJ *bitmap)
45 TTYDRV_PHYSBITMAP *physBitmap;
47 if(!(physBitmap = HeapAlloc(GetProcessHeap(), 0, sizeof(TTYDRV_PHYSBITMAP)))) {
48 ERR("Can't alloc TTYDRV_PHYSBITMAP\n");
52 bitmap->physBitmap = physBitmap;
53 bitmap->funcs = TTYDRV_DC_Funcs;
58 /***********************************************************************
59 * TTYDRV_DC_BitmapBits
61 LONG TTYDRV_DC_BitmapBits(HBITMAP hbitmap, void *bits, LONG count, WORD flags)
66 if(!(bitmap = (BITMAPOBJ *) GDI_GetObjPtr(hbitmap, BITMAP_MAGIC)))
70 result = TTYDRV_DC_GetBitmapBits(bitmap, bits, count);
71 else if(flags == DDB_SET)
72 result = TTYDRV_DC_SetBitmapBits(bitmap, bits, count);
74 ERR("Unknown flags value %d\n", flags);
78 GDI_ReleaseObj(hbitmap);
82 /***********************************************************************
83 * TTYDRV_DC_CreateBitmap
85 BOOL TTYDRV_DC_CreateBitmap(HBITMAP hbitmap)
87 TTYDRV_PHYSBITMAP *physBitmap;
90 TRACE("(0x%04x)\n", hbitmap);
92 if(!(bitmap = (BITMAPOBJ *) GDI_GetObjPtr(hbitmap, BITMAP_MAGIC)))
95 if(!(physBitmap = TTYDRV_DC_AllocBitmap(bitmap))) {
96 GDI_ReleaseObj(hbitmap);
100 /* Set bitmap bits */
101 if(bitmap->bitmap.bmBits) {
102 TTYDRV_DC_BitmapBits(hbitmap, bitmap->bitmap.bmBits,
103 bitmap->bitmap.bmHeight * bitmap->bitmap.bmWidthBytes,
107 GDI_ReleaseObj(hbitmap);
112 /***********************************************************************
113 * TTYDRV_DC_BITMAP_DeleteObject
115 BOOL TTYDRV_DC_BITMAP_DeleteObject(HBITMAP hbitmap, BITMAPOBJ *bitmap)
117 TRACE("(0x%04x, %p)\n", hbitmap, bitmap);
119 HeapFree(GetProcessHeap(), 0, bitmap->physBitmap);
120 bitmap->physBitmap = NULL;
121 bitmap->funcs = NULL;
126 /***********************************************************************
127 * TTYDRV_DC_GetBitmapBits
129 static LONG TTYDRV_DC_GetBitmapBits(BITMAPOBJ *bitmap, void *bits, LONG count)
131 FIXME("(%p, %p, %ld): stub\n", bitmap, bits, count);
133 memset(bits, 0, count);
138 /***********************************************************************
139 * TTYDRV_DC_BITMAP_SelectObject
141 HBITMAP TTYDRV_DC_BITMAP_SelectObject(DC *dc, HBITMAP hbitmap, BITMAPOBJ *bitmap)
143 HBITMAP hPreviousBitmap;
145 TRACE("(%p, 0x%04x, %p)\n", dc, hbitmap, bitmap);
147 if(!(dc->flags & DC_MEMORY))
150 /* Assure that the bitmap device dependent */
151 if(!bitmap->physBitmap && !TTYDRV_DC_CreateBitmap(hbitmap))
154 if(bitmap->funcs != dc->funcs) {
155 ERR("Trying to select a non-TTY DDB into a TTY DC\n");
159 dc->totalExtent.left = 0;
160 dc->totalExtent.top = 0;
161 dc->totalExtent.right = bitmap->bitmap.bmWidth;
162 dc->totalExtent.bottom = bitmap->bitmap.bmHeight;
164 /* FIXME: Should be done in the common code instead */
166 SetRectRgn(dc->hVisRgn, 0, 0,
167 bitmap->bitmap.bmWidth, bitmap->bitmap.bmHeight);
171 if(!(hrgn = CreateRectRgn(0, 0, bitmap->bitmap.bmWidth, bitmap->bitmap.bmHeight)))
177 hPreviousBitmap = dc->hBitmap;
178 dc->hBitmap = hbitmap;
180 return hPreviousBitmap;
183 /***********************************************************************
184 * TTYDRV_DC_SetBitmapBits
186 static LONG TTYDRV_DC_SetBitmapBits(BITMAPOBJ *bitmap, void *bits, LONG count)
188 FIXME("(%p, %p, %ld): semistub\n", bitmap, bits, count);
193 /***********************************************************************
194 * TTYDRV_BITMAP_CreateDIBSection
196 HBITMAP TTYDRV_BITMAP_CreateDIBSection(
197 DC *dc, BITMAPINFO *bmi, UINT usage,
198 LPVOID *bits, HANDLE section, DWORD offset)
200 FIXME("(%p, %p, %u, %p, 0x%04x, %ld): stub\n",
201 dc, bmi, usage, bits, section, offset);
203 return (HBITMAP) NULL;
206 /***********************************************************************
207 * TTYDRV_BITMAP_DeleteDIBSection
209 void TTYDRV_BITMAP_DeleteDIBSection(BITMAPOBJ *bmp)
211 FIXME("(%p): stub\n", bmp);
214 /***********************************************************************
215 * TTYDRV_BITMAP_SetDIBColorTable
217 UINT TTYDRV_BITMAP_SetDIBColorTable(BITMAPOBJ *bmp, DC *dc, UINT start, UINT count, const RGBQUAD *colors)
219 FIXME("(%p): stub\n", bmp);
223 /***********************************************************************
224 * TTYDRV_BITMAP_GetDIBColorTable
226 UINT TTYDRV_BITMAP_GetDIBColorTable(BITMAPOBJ *bmp, DC *dc, UINT start, UINT count, RGBQUAD *colors)
228 FIXME("(%p): stub\n", bmp);
232 /***********************************************************************
235 INT TTYDRV_BITMAP_Lock(BITMAPOBJ *bmp, INT req, BOOL lossy)
237 FIXME("(%p): stub\n", bmp);
238 return DIB_Status_None;
241 /***********************************************************************
242 * TTYDRV_BITMAP_Unlock
244 void TTYDRV_BITMAP_Unlock(BITMAPOBJ *bmp, BOOL commit)
246 FIXME("(%p): stub\n", bmp);
249 /***********************************************************************
250 * TTYDRV_BITMAP_GetDIBits
252 INT TTYDRV_BITMAP_GetDIBits(
253 BITMAPOBJ *bmp, DC *dc, UINT startscan, UINT lines,
254 LPVOID bits, BITMAPINFO *info, UINT coloruse, HBITMAP hbitmap)
256 FIXME("(%p, %p, %u, %u, %p, %p, %u, 0x%04x): stub\n",
257 bmp, dc, startscan, lines, bits, info, coloruse, hbitmap);
263 /***********************************************************************
264 * TTYDRV_BITMAP_SetDIBits
266 INT TTYDRV_BITMAP_SetDIBits(
267 BITMAPOBJ *bmp, DC *dc, UINT startscan, UINT lines,
268 LPCVOID bits, const BITMAPINFO *info, UINT coloruse, HBITMAP hbitmap)
270 FIXME("(%p, %p, %u, %u, %p, %p, %u, 0x%04x): stub\n",
271 bmp, dc, startscan, lines, bits, info, coloruse, hbitmap);
276 /***********************************************************************
277 * TTYDRV_DC_SetDIBitsToDevice
279 INT TTYDRV_DC_SetDIBitsToDevice(DC *dc, INT xDest, INT yDest, DWORD cx,
280 DWORD cy, INT xSrc, INT ySrc,
281 UINT startscan, UINT lines, LPCVOID bits,
282 const BITMAPINFO *info, UINT coloruse)
284 FIXME("(%p, %d, %d, %ld, %ld, %d, %d, %u, %u, %p, %p, %u): stub\n",
285 dc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, bits, info, coloruse);