4 * Copyright 1999 Patrik Stridvall
11 #include "debugtools.h"
13 DEFAULT_DEBUG_CHANNEL(ttydrv
)
15 /**********************************************************************/
17 static LONG
TTYDRV_DC_GetBitmapBits(BITMAPOBJ
*bitmap
, void *bits
, LONG count
);
18 static LONG
TTYDRV_DC_SetBitmapBits(BITMAPOBJ
*bitmap
, void *bits
, LONG count
);
20 /***********************************************************************
21 * TTYDRV_DC_AllocBitmap
23 TTYDRV_PHYSBITMAP
*TTYDRV_DC_AllocBitmap(BITMAPOBJ
*bitmap
)
25 TTYDRV_PHYSBITMAP
*physBitmap
;
27 if(!(bitmap
->DDBitmap
= HeapAlloc(GetProcessHeap(), 0, sizeof(DDBITMAP
)))) {
28 ERR("Can't alloc DDBITMAP\n");
32 if(!(physBitmap
= HeapAlloc(GetProcessHeap(), 0, sizeof(TTYDRV_PHYSBITMAP
)))) {
33 ERR("Can't alloc TTYDRV_PHYSBITMAP\n");
34 HeapFree(GetProcessHeap(), 0, bitmap
->DDBitmap
);
38 bitmap
->DDBitmap
->physBitmap
= physBitmap
;
39 bitmap
->DDBitmap
->funcs
= DRIVER_FindDriver("DISPLAY");
44 /***********************************************************************
45 * TTYDRV_DC_BitmapBits
47 LONG
TTYDRV_DC_BitmapBits(HBITMAP hbitmap
, void *bits
, LONG count
, WORD flags
)
52 if(!(bitmap
= (BITMAPOBJ
*) GDI_GetObjPtr(hbitmap
, BITMAP_MAGIC
)))
56 result
= TTYDRV_DC_GetBitmapBits(bitmap
, bits
, count
);
57 else if(flags
== DDB_SET
)
58 result
= TTYDRV_DC_SetBitmapBits(bitmap
, bits
, count
);
60 ERR("Unknown flags value %d\n", flags
);
64 GDI_HEAP_UNLOCK(hbitmap
);
68 /***********************************************************************
69 * TTYDRV_DC_CreateBitmap
71 BOOL
TTYDRV_DC_CreateBitmap(HBITMAP hbitmap
)
73 TTYDRV_PHYSBITMAP
*physBitmap
;
76 TRACE("(0x%04x)\n", hbitmap
);
78 if(!(bitmap
= (BITMAPOBJ
*) GDI_GetObjPtr(hbitmap
, BITMAP_MAGIC
)))
81 if(!(physBitmap
= TTYDRV_DC_AllocBitmap(bitmap
))) {
82 GDI_HEAP_UNLOCK(hbitmap
);
87 if(bitmap
->bitmap
.bmBits
) {
88 TTYDRV_DC_BitmapBits(hbitmap
, bitmap
->bitmap
.bmBits
,
89 bitmap
->bitmap
.bmHeight
* bitmap
->bitmap
.bmWidthBytes
,
93 GDI_HEAP_UNLOCK(hbitmap
);
98 /***********************************************************************
99 * TTYDRV_DC_BITMAP_DeleteObject
101 BOOL
TTYDRV_DC_BITMAP_DeleteObject(HBITMAP hbitmap
, BITMAPOBJ
*bitmap
)
103 TRACE("(0x%04x, %p)\n", hbitmap
, bitmap
);
105 HeapFree(GetProcessHeap(), 0, bitmap
->DDBitmap
->physBitmap
);
106 HeapFree(GetProcessHeap(), 0, bitmap
->DDBitmap
);
107 bitmap
->DDBitmap
= NULL
;
112 /***********************************************************************
113 * TTYDRV_DC_GetBitmapBits
115 static LONG
TTYDRV_DC_GetBitmapBits(BITMAPOBJ
*bitmap
, void *bits
, LONG count
)
117 FIXME("(%p, %p, %ld): stub\n", bitmap
, bits
, count
);
119 memset(bits
, 0, count
);
124 /***********************************************************************
125 * TTYDRV_DC_BITMAP_SelectObject
127 HBITMAP
TTYDRV_DC_BITMAP_SelectObject(DC
*dc
, HBITMAP hbitmap
, BITMAPOBJ
*bitmap
)
129 HBITMAP hPreviousBitmap
;
131 TRACE("(%p, 0x%04x, %p)\n", dc
, hbitmap
, bitmap
);
133 if(!(dc
->w
.flags
& DC_MEMORY
))
136 /* Assure that the bitmap device dependent */
137 if(!bitmap
->DDBitmap
&& !TTYDRV_DC_CreateBitmap(hbitmap
))
140 if(bitmap
->DDBitmap
->funcs
!= dc
->funcs
) {
141 ERR("Trying to select a non-TTY DDB into a TTY DC\n");
145 dc
->w
.totalExtent
.left
= 0;
146 dc
->w
.totalExtent
.top
= 0;
147 dc
->w
.totalExtent
.right
= bitmap
->bitmap
.bmWidth
;
148 dc
->w
.totalExtent
.bottom
= bitmap
->bitmap
.bmHeight
;
150 /* FIXME: Should be done in the common code instead */
152 SetRectRgn(dc
->w
.hVisRgn
, 0, 0,
153 bitmap
->bitmap
.bmWidth
, bitmap
->bitmap
.bmHeight
);
157 if(!(hrgn
= CreateRectRgn(0, 0, bitmap
->bitmap
.bmWidth
, bitmap
->bitmap
.bmHeight
)))
160 dc
->w
.hVisRgn
= hrgn
;
163 hPreviousBitmap
= dc
->w
.hBitmap
;
164 dc
->w
.hBitmap
= hbitmap
;
166 return hPreviousBitmap
;
169 /***********************************************************************
170 * TTYDRV_DC_SetBitmapBits
172 static LONG
TTYDRV_DC_SetBitmapBits(BITMAPOBJ
*bitmap
, void *bits
, LONG count
)
174 FIXME("(%p, %p, %ld): semistub\n", bitmap
, bits
, count
);