1999-04-01 10:16:08 +02:00
|
|
|
/*
|
|
|
|
* TTY bitmap driver
|
|
|
|
*
|
|
|
|
* Copyright 1999 Patrik Stridvall
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1999-04-01 10:16:08 +02:00
|
|
|
*/
|
|
|
|
|
2001-11-06 21:57:11 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-01-26 21:43:40 +01:00
|
|
|
#include <string.h>
|
2001-11-06 21:57:11 +01:00
|
|
|
|
1999-04-01 10:16:08 +02:00
|
|
|
#include "bitmap.h"
|
2000-11-05 03:05:07 +01:00
|
|
|
#include "gdi.h"
|
1999-04-01 10:16:08 +02:00
|
|
|
#include "ttydrv.h"
|
1999-12-12 00:08:48 +01:00
|
|
|
#include "winbase.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-04-01 10:16:08 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ttydrv);
|
1999-11-24 00:43:29 +01:00
|
|
|
|
1999-12-12 00:08:48 +01:00
|
|
|
/**********************************************************************/
|
1999-04-01 10:16:08 +02:00
|
|
|
|
2001-07-27 21:37:31 +02:00
|
|
|
extern const DC_FUNCTIONS *TTYDRV_DC_Funcs; /* hack */
|
|
|
|
|
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-04-01 10:16:08 +02:00
|
|
|
|
1999-12-12 00:08:48 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* TTYDRV_DC_AllocBitmap
|
1999-04-01 10:16:08 +02:00
|
|
|
*/
|
1999-12-12 00:08:48 +01:00
|
|
|
TTYDRV_PHYSBITMAP *TTYDRV_DC_AllocBitmap(BITMAPOBJ *bitmap)
|
1999-04-01 10:16:08 +02:00
|
|
|
{
|
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;
|
|
|
|
}
|
1999-04-01 10:16:08 +02:00
|
|
|
|
2000-03-28 15:37:50 +02:00
|
|
|
bitmap->physBitmap = physBitmap;
|
2001-07-27 21:37:31 +02:00
|
|
|
bitmap->funcs = TTYDRV_DC_Funcs;
|
1999-12-12 00:08:48 +01:00
|
|
|
|
|
|
|
return physBitmap;
|
1999-04-01 10:16:08 +02:00
|
|
|
}
|
|
|
|
|
1999-12-12 00:08:48 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* TTYDRV_DC_BitmapBits
|
1999-04-01 10:16:08 +02:00
|
|
|
*/
|
1999-12-12 00:08:48 +01:00
|
|
|
LONG TTYDRV_DC_BitmapBits(HBITMAP hbitmap, void *bits, LONG count, WORD flags)
|
1999-04-01 10:16:08 +02:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2000-08-19 23:38:55 +02:00
|
|
|
GDI_ReleaseObj(hbitmap);
|
1999-12-12 00:08:48 +01:00
|
|
|
return result;
|
1999-04-01 10:16:08 +02:00
|
|
|
}
|
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))) {
|
2000-08-19 23:38:55 +02:00
|
|
|
GDI_ReleaseObj(hbitmap);
|
1999-12-12 00:08:48 +01:00
|
|
|
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
|
|
|
|
2000-08-19 23:38:55 +02:00
|
|
|
GDI_ReleaseObj(hbitmap);
|
1999-12-12 00:08:48 +01:00
|
|
|
|
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
|
|
|
|
2000-03-28 15:37:50 +02: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
|
|
|
/***********************************************************************
|
2002-04-03 04:37:09 +02:00
|
|
|
* SelectBitmap (TTYDRV.@)
|
1999-11-24 00:43:29 +01:00
|
|
|
*/
|
2002-03-28 23:22:05 +01:00
|
|
|
HBITMAP TTYDRV_SelectBitmap(TTYDRV_PDEVICE *physDev, HBITMAP hbitmap)
|
1999-11-24 00:43:29 +01:00
|
|
|
{
|
2002-03-28 23:22:05 +01:00
|
|
|
DC *dc = physDev->dc;
|
|
|
|
BITMAPOBJ *bitmap;
|
1999-12-12 00:08:48 +01:00
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
TRACE("(%p, 0x%04x)\n", dc, hbitmap);
|
1999-11-24 00:43:29 +01:00
|
|
|
|
2000-11-05 03:05:07 +01:00
|
|
|
if(!(dc->flags & DC_MEMORY))
|
1999-12-27 06:26:00 +01:00
|
|
|
return 0;
|
1999-11-24 00:43:29 +01:00
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
if (!(bitmap = GDI_GetObjPtr( hbitmap, BITMAP_MAGIC ))) return 0;
|
1999-12-12 00:08:48 +01:00
|
|
|
/* Assure that the bitmap device dependent */
|
2000-03-28 15:37:50 +02:00
|
|
|
if(!bitmap->physBitmap && !TTYDRV_DC_CreateBitmap(hbitmap))
|
2002-03-28 23:22:05 +01:00
|
|
|
{
|
|
|
|
GDI_ReleaseObj( hbitmap );
|
|
|
|
return 0;
|
|
|
|
}
|
1999-12-12 00:08:48 +01:00
|
|
|
|
2000-03-28 15:37:50 +02: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");
|
2002-03-28 23:22:05 +01:00
|
|
|
GDI_ReleaseObj( hbitmap );
|
1999-12-27 06:26:00 +01:00
|
|
|
return 0;
|
1999-12-12 00:08:48 +01:00
|
|
|
}
|
|
|
|
|
2000-11-05 03:05:07 +01:00
|
|
|
dc->totalExtent.left = 0;
|
|
|
|
dc->totalExtent.top = 0;
|
|
|
|
dc->totalExtent.right = bitmap->bitmap.bmWidth;
|
|
|
|
dc->totalExtent.bottom = bitmap->bitmap.bmHeight;
|
1999-12-12 00:08:48 +01:00
|
|
|
|
|
|
|
/* FIXME: Should be done in the common code instead */
|
2000-11-05 03:05:07 +01:00
|
|
|
if(dc->hVisRgn) {
|
|
|
|
SetRectRgn(dc->hVisRgn, 0, 0,
|
1999-12-12 00:08:48 +01:00
|
|
|
bitmap->bitmap.bmWidth, bitmap->bitmap.bmHeight);
|
|
|
|
} else {
|
|
|
|
HRGN hrgn;
|
|
|
|
|
|
|
|
if(!(hrgn = CreateRectRgn(0, 0, bitmap->bitmap.bmWidth, bitmap->bitmap.bmHeight)))
|
2002-03-28 23:22:05 +01:00
|
|
|
{
|
|
|
|
GDI_ReleaseObj( hbitmap );
|
|
|
|
return 0;
|
|
|
|
}
|
2000-11-05 03:05:07 +01:00
|
|
|
dc->hVisRgn = hrgn;
|
1999-12-12 00:08:48 +01:00
|
|
|
}
|
2002-03-28 23:22:05 +01:00
|
|
|
GDI_ReleaseObj( hbitmap );
|
|
|
|
return hbitmap;
|
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;
|
|
|
|
}
|
2000-08-10 03:16:19 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* TTYDRV_BITMAP_CreateDIBSection
|
|
|
|
*/
|
|
|
|
HBITMAP TTYDRV_BITMAP_CreateDIBSection(
|
2002-03-28 23:22:05 +01:00
|
|
|
TTYDRV_PDEVICE *physDev, BITMAPINFO *bmi, UINT usage,
|
2000-08-10 03:16:19 +02:00
|
|
|
LPVOID *bits, HANDLE section, DWORD offset)
|
|
|
|
{
|
2002-03-28 23:22:05 +01:00
|
|
|
FIXME("(%x, %p, %u, %p, 0x%04x, %ld): stub\n",
|
|
|
|
physDev->hdc, bmi, usage, bits, section, offset);
|
2000-08-10 03:16:19 +02:00
|
|
|
|
|
|
|
return (HBITMAP) NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* TTYDRV_DC_SetDIBitsToDevice
|
|
|
|
*/
|
2002-03-28 23:22:05 +01:00
|
|
|
INT TTYDRV_DC_SetDIBitsToDevice(TTYDRV_PDEVICE *physDev, INT xDest, INT yDest, DWORD cx,
|
2000-08-10 03:16:19 +02:00
|
|
|
DWORD cy, INT xSrc, INT ySrc,
|
|
|
|
UINT startscan, UINT lines, LPCVOID bits,
|
|
|
|
const BITMAPINFO *info, UINT coloruse)
|
|
|
|
{
|
2002-03-28 23:22:05 +01:00
|
|
|
FIXME("(%x, %d, %d, %ld, %ld, %d, %d, %u, %u, %p, %p, %u): stub\n",
|
|
|
|
physDev->hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, bits, info, coloruse);
|
2000-08-10 03:16:19 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|