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 * SelectBitmap (TTYDRV.@)
141 HBITMAP TTYDRV_SelectBitmap(TTYDRV_PDEVICE *physDev, HBITMAP hbitmap)
143 DC *dc = physDev->dc;
146 TRACE("(%p, 0x%04x)\n", dc, hbitmap);
148 if (!(bitmap = GDI_GetObjPtr( hbitmap, BITMAP_MAGIC ))) return 0;
149 /* Assure that the bitmap device dependent */
150 if(!bitmap->physBitmap && !TTYDRV_DC_CreateBitmap(hbitmap))
152 GDI_ReleaseObj( hbitmap );
156 if(bitmap->funcs != dc->funcs) {
157 ERR("Trying to select a non-TTY DDB into a TTY DC\n");
158 GDI_ReleaseObj( hbitmap );
162 GDI_ReleaseObj( hbitmap );
166 /***********************************************************************
167 * TTYDRV_DC_SetBitmapBits
169 static LONG TTYDRV_DC_SetBitmapBits(BITMAPOBJ *bitmap, void *bits, LONG count)
171 FIXME("(%p, %p, %ld): semistub\n", bitmap, bits, count);
176 /***********************************************************************
177 * TTYDRV_BITMAP_CreateDIBSection
179 HBITMAP TTYDRV_BITMAP_CreateDIBSection(
180 TTYDRV_PDEVICE *physDev, BITMAPINFO *bmi, UINT usage,
181 LPVOID *bits, HANDLE section, DWORD offset)
183 FIXME("(%x, %p, %u, %p, 0x%04x, %ld): stub\n",
184 physDev->hdc, bmi, usage, bits, section, offset);
186 return (HBITMAP) NULL;
189 /***********************************************************************
190 * TTYDRV_DC_SetDIBitsToDevice
192 INT TTYDRV_DC_SetDIBitsToDevice(TTYDRV_PDEVICE *physDev, INT xDest, INT yDest, DWORD cx,
193 DWORD cy, INT xSrc, INT ySrc,
194 UINT startscan, UINT lines, LPCVOID bits,
195 const BITMAPINFO *info, UINT coloruse)
197 FIXME("(%x, %d, %d, %ld, %ld, %d, %d, %u, %u, %p, %p, %u): stub\n",
198 physDev->hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, bits, info, coloruse);