Sweden-Number/graphics/ttydrv/bitmap.c

172 lines
4.2 KiB
C
Raw Normal View History

/*
* TTY bitmap driver
*
* Copyright 1999 Patrik Stridvall
*/
#include "bitmap.h"
1999-11-24 00:43:29 +01:00
#include "dc.h"
#include "ttydrv.h"
1999-12-12 00:08:48 +01:00
#include "winbase.h"
#include "debugtools.h"
1999-11-24 00:43:29 +01:00
DEFAULT_DEBUG_CHANNEL(ttydrv)
1999-12-12 00:08:48 +01:00
/**********************************************************************/
1999-12-12 00:08:48 +01:00
static LONG TTYDRV_DC_GetBitmapBits(BITMAPOBJ *bitmap, void *bits, LONG count);
static LONG TTYDRV_DC_SetBitmapBits(BITMAPOBJ *bitmap, void *bits, LONG count);
1999-12-12 00:08:48 +01:00
/***********************************************************************
* TTYDRV_DC_AllocBitmap
*/
1999-12-12 00:08:48 +01:00
TTYDRV_PHYSBITMAP *TTYDRV_DC_AllocBitmap(BITMAPOBJ *bitmap)
{
1999-12-12 00:08:48 +01:00
TTYDRV_PHYSBITMAP *physBitmap;
if(!(physBitmap = HeapAlloc(GetProcessHeap(), 0, sizeof(TTYDRV_PHYSBITMAP)))) {
ERR("Can't alloc TTYDRV_PHYSBITMAP\n");
return NULL;
}
bitmap->physBitmap = physBitmap;
bitmap->funcs = DRIVER_FindDriver("DISPLAY");
1999-12-12 00:08:48 +01:00
return physBitmap;
}
1999-12-12 00:08:48 +01:00
/***********************************************************************
* TTYDRV_DC_BitmapBits
*/
1999-12-12 00:08:48 +01:00
LONG TTYDRV_DC_BitmapBits(HBITMAP hbitmap, void *bits, LONG count, WORD flags)
{
1999-12-12 00:08:48 +01:00
BITMAPOBJ *bitmap;
LONG result;
if(!(bitmap = (BITMAPOBJ *) GDI_GetObjPtr(hbitmap, BITMAP_MAGIC)))
return FALSE;
if(flags == DDB_GET)
result = TTYDRV_DC_GetBitmapBits(bitmap, bits, count);
else if(flags == DDB_SET)
result = TTYDRV_DC_SetBitmapBits(bitmap, bits, count);
else {
ERR("Unknown flags value %d\n", flags);
result = 0;
}
GDI_HEAP_UNLOCK(hbitmap);
return result;
}
1999-11-24 00:43:29 +01:00
/***********************************************************************
* TTYDRV_DC_CreateBitmap
*/
BOOL TTYDRV_DC_CreateBitmap(HBITMAP hbitmap)
{
1999-12-12 00:08:48 +01:00
TTYDRV_PHYSBITMAP *physBitmap;
BITMAPOBJ *bitmap;
TRACE("(0x%04x)\n", hbitmap);
if(!(bitmap = (BITMAPOBJ *) GDI_GetObjPtr(hbitmap, BITMAP_MAGIC)))
return FALSE;
if(!(physBitmap = TTYDRV_DC_AllocBitmap(bitmap))) {
GDI_HEAP_UNLOCK(hbitmap);
return FALSE;
}
/* Set bitmap bits */
if(bitmap->bitmap.bmBits) {
TTYDRV_DC_BitmapBits(hbitmap, bitmap->bitmap.bmBits,
bitmap->bitmap.bmHeight * bitmap->bitmap.bmWidthBytes,
DDB_SET );
}
1999-11-24 00:43:29 +01:00
1999-12-12 00:08:48 +01:00
GDI_HEAP_UNLOCK(hbitmap);
1999-11-24 00:43:29 +01:00
return TRUE;
}
/***********************************************************************
* TTYDRV_DC_BITMAP_DeleteObject
*/
BOOL TTYDRV_DC_BITMAP_DeleteObject(HBITMAP hbitmap, BITMAPOBJ *bitmap)
{
1999-12-12 00:08:48 +01:00
TRACE("(0x%04x, %p)\n", hbitmap, bitmap);
1999-11-24 00:43:29 +01:00
HeapFree(GetProcessHeap(), 0, bitmap->physBitmap);
bitmap->physBitmap = NULL;
bitmap->funcs = NULL;
1999-11-24 00:43:29 +01:00
return TRUE;
}
1999-12-12 00:08:48 +01:00
/***********************************************************************
* TTYDRV_DC_GetBitmapBits
*/
static LONG TTYDRV_DC_GetBitmapBits(BITMAPOBJ *bitmap, void *bits, LONG count)
{
FIXME("(%p, %p, %ld): stub\n", bitmap, bits, count);
memset(bits, 0, count);
return count;
}
1999-11-24 00:43:29 +01:00
/***********************************************************************
* TTYDRV_DC_BITMAP_SelectObject
*/
HBITMAP TTYDRV_DC_BITMAP_SelectObject(DC *dc, HBITMAP hbitmap, BITMAPOBJ *bitmap)
{
1999-12-12 00:08:48 +01:00
HBITMAP hPreviousBitmap;
TRACE("(%p, 0x%04x, %p)\n", dc, hbitmap, bitmap);
1999-11-24 00:43:29 +01:00
if(!(dc->w.flags & DC_MEMORY))
1999-12-27 06:26:00 +01:00
return 0;
1999-11-24 00:43:29 +01:00
1999-12-12 00:08:48 +01:00
/* Assure that the bitmap device dependent */
if(!bitmap->physBitmap && !TTYDRV_DC_CreateBitmap(hbitmap))
1999-12-27 06:26:00 +01:00
return 0;
1999-12-12 00:08:48 +01:00
if(bitmap->funcs != dc->funcs) {
1999-12-12 00:08:48 +01:00
ERR("Trying to select a non-TTY DDB into a TTY DC\n");
1999-12-27 06:26:00 +01:00
return 0;
1999-12-12 00:08:48 +01:00
}
dc->w.totalExtent.left = 0;
dc->w.totalExtent.top = 0;
dc->w.totalExtent.right = bitmap->bitmap.bmWidth;
dc->w.totalExtent.bottom = bitmap->bitmap.bmHeight;
/* FIXME: Should be done in the common code instead */
if(dc->w.hVisRgn) {
SetRectRgn(dc->w.hVisRgn, 0, 0,
bitmap->bitmap.bmWidth, bitmap->bitmap.bmHeight);
} else {
HRGN hrgn;
if(!(hrgn = CreateRectRgn(0, 0, bitmap->bitmap.bmWidth, bitmap->bitmap.bmHeight)))
1999-12-27 06:26:00 +01:00
return 0;
1999-12-12 00:08:48 +01:00
dc->w.hVisRgn = hrgn;
}
hPreviousBitmap = dc->w.hBitmap;
dc->w.hBitmap = hbitmap;
return hPreviousBitmap;
1999-11-24 00:43:29 +01:00
}
1999-12-12 00:08:48 +01:00
/***********************************************************************
* TTYDRV_DC_SetBitmapBits
*/
static LONG TTYDRV_DC_SetBitmapBits(BITMAPOBJ *bitmap, void *bits, LONG count)
{
FIXME("(%p, %p, %ld): semistub\n", bitmap, bits, count);
return count;
}