2003-01-19 01:01:00 +00:00
|
|
|
/* $Id: dc.c,v 1.44 2003/01/19 01:01:00 ei Exp $
|
1999-10-31 22:43:40 +00:00
|
|
|
*
|
1999-07-12 23:26:57 +00:00
|
|
|
* DC.C - Device context functions
|
2002-07-13 21:37:27 +00:00
|
|
|
*
|
1999-07-12 23:26:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#undef WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
2002-09-08 10:23:54 +00:00
|
|
|
#include <ddk/ntddk.h>
|
2003-01-19 01:01:00 +00:00
|
|
|
#include <ddk/ntddvid.h>
|
2000-06-16 07:25:41 +00:00
|
|
|
|
1999-10-28 23:37:14 +00:00
|
|
|
#include <win32k/bitmaps.h>
|
|
|
|
#include <win32k/coord.h>
|
1999-07-12 23:26:57 +00:00
|
|
|
#include <win32k/driver.h>
|
|
|
|
#include <win32k/dc.h>
|
1999-10-28 23:37:14 +00:00
|
|
|
#include <win32k/print.h>
|
|
|
|
#include <win32k/region.h>
|
2000-03-01 03:25:11 +00:00
|
|
|
#include <win32k/gdiobj.h>
|
2000-06-16 07:25:41 +00:00
|
|
|
#include <win32k/pen.h>
|
2001-05-02 12:33:42 +00:00
|
|
|
#include <win32k/text.h>
|
2002-08-04 09:55:11 +00:00
|
|
|
#include "../eng/handle.h"
|
1999-07-12 23:26:57 +00:00
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
//#define NDEBUG
|
2000-06-29 23:35:53 +00:00
|
|
|
#include <win32k/debug1.h>
|
1999-07-12 23:26:57 +00:00
|
|
|
|
2003-01-19 01:01:00 +00:00
|
|
|
static GDIDEVICE PrimarySurface;
|
|
|
|
static BOOL PrimarySurfaceCreated = FALSE;
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-07-12 23:26:57 +00:00
|
|
|
/* FIXME: DCs should probably be thread safe */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DC device-independent Get/SetXXX functions
|
|
|
|
* (RJJ) swiped from WINE
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DC_GET_VAL( func_type, func_name, dc_field ) \
|
|
|
|
func_type STDCALL func_name( HDC hdc ) \
|
1999-09-08 04:50:50 +00:00
|
|
|
{ \
|
|
|
|
func_type ft; \
|
|
|
|
PDC dc = DC_HandleToPtr( hdc ); \
|
|
|
|
if (!dc) \
|
2001-03-31 15:35:08 +00:00
|
|
|
{ \
|
|
|
|
return 0; \
|
|
|
|
} \
|
1999-09-08 04:50:50 +00:00
|
|
|
ft = dc->dc_field; \
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_ReleasePtr( hdc ); \
|
1999-09-08 04:50:50 +00:00
|
|
|
return ft; \
|
1999-07-12 23:26:57 +00:00
|
|
|
}
|
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
/* DC_GET_VAL_EX is used to define functions returning a POINT or a SIZE. It is
|
|
|
|
* important that the function has the right signature, for the implementation
|
1999-07-12 23:26:57 +00:00
|
|
|
* we can do whatever we want.
|
|
|
|
*/
|
|
|
|
#define DC_GET_VAL_EX( func_name, ret_x, ret_y, type ) \
|
|
|
|
BOOL STDCALL func_name( HDC hdc, LP##type pt ) \
|
1999-09-08 04:50:50 +00:00
|
|
|
{ \
|
|
|
|
PDC dc = DC_HandleToPtr( hdc ); \
|
|
|
|
if (!dc) \
|
2001-03-31 15:35:08 +00:00
|
|
|
{ \
|
|
|
|
return FALSE; \
|
|
|
|
} \
|
1999-09-08 04:50:50 +00:00
|
|
|
((LPPOINT)pt)->x = dc->ret_x; \
|
|
|
|
((LPPOINT)pt)->y = dc->ret_y; \
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_ReleasePtr( hdc ); \
|
1999-09-08 04:50:50 +00:00
|
|
|
return TRUE; \
|
1999-07-12 23:26:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define DC_SET_MODE( func_name, dc_field, min_val, max_val ) \
|
|
|
|
INT STDCALL func_name( HDC hdc, INT mode ) \
|
1999-09-08 04:50:50 +00:00
|
|
|
{ \
|
|
|
|
INT prevMode; \
|
|
|
|
PDC dc = DC_HandleToPtr( hdc ); \
|
|
|
|
if(!dc) \
|
2001-03-31 15:35:08 +00:00
|
|
|
{ \
|
|
|
|
return 0; \
|
|
|
|
} \
|
|
|
|
if ((mode < min_val) || (mode > max_val)) \
|
|
|
|
{ \
|
|
|
|
return 0; \
|
|
|
|
} \
|
|
|
|
prevMode = dc->dc_field; \
|
|
|
|
dc->dc_field = mode; \
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_ReleasePtr( hdc ); \
|
2001-03-31 15:35:08 +00:00
|
|
|
return prevMode; \
|
1999-07-12 23:26:57 +00:00
|
|
|
}
|
|
|
|
|
2002-09-18 23:56:48 +00:00
|
|
|
|
2002-09-08 10:23:54 +00:00
|
|
|
VOID BitmapToSurf(HDC hdc, PSURFGDI SurfGDI, PSURFOBJ SurfObj, PBITMAPOBJ Bitmap);
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-07-12 23:26:57 +00:00
|
|
|
// --------------------------------------------------------- File Statics
|
|
|
|
|
1999-09-10 21:17:07 +00:00
|
|
|
static void W32kSetDCState16(HDC hDC, HDC hDCSave);
|
1999-07-12 23:26:57 +00:00
|
|
|
|
|
|
|
// ----------------------------------------------------- Public Functions
|
|
|
|
|
|
|
|
BOOL STDCALL W32kCancelDC(HDC hDC)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
HDC STDCALL W32kCreateCompatableDC(HDC hDC)
|
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
PDC NewDC, OrigDC = NULL;
|
1999-09-08 04:50:50 +00:00
|
|
|
HBITMAP hBitmap;
|
2001-11-19 12:06:23 +00:00
|
|
|
SIZEL onebyone;
|
2002-07-13 21:37:27 +00:00
|
|
|
HDC hNewDC;
|
1999-09-08 04:50:50 +00:00
|
|
|
|
2001-08-28 18:16:32 +00:00
|
|
|
OrigDC = DC_HandleToPtr(hDC);
|
|
|
|
if (OrigDC == NULL)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
2002-07-13 21:37:27 +00:00
|
|
|
hNewDC = DC_AllocDC(L"DISPLAY");
|
|
|
|
if( hNewDC )
|
|
|
|
NewDC = DC_HandleToPtr( hNewDC );
|
|
|
|
}
|
|
|
|
else {
|
2001-11-19 12:06:23 +00:00
|
|
|
/* Allocate a new DC based on the original DC's device */
|
2002-07-13 21:37:27 +00:00
|
|
|
hNewDC = DC_AllocDC(OrigDC->DriverName);
|
|
|
|
if( hNewDC )
|
|
|
|
NewDC = DC_HandleToPtr( hNewDC );
|
2001-03-31 15:35:08 +00:00
|
|
|
}
|
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
if (NewDC == NULL)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1999-09-10 21:17:07 +00:00
|
|
|
/* Copy information from original DC to new DC */
|
|
|
|
NewDC->hSelf = NewDC;
|
|
|
|
|
|
|
|
/* FIXME: Should this DC request its own PDEV? */
|
2001-11-19 12:06:23 +00:00
|
|
|
if(OrigDC == NULL) {
|
|
|
|
} else {
|
|
|
|
NewDC->PDev = OrigDC->PDev;
|
|
|
|
NewDC->DMW = OrigDC->DMW;
|
2002-07-13 21:37:27 +00:00
|
|
|
memcpy(NewDC->FillPatternSurfaces,
|
2001-11-19 12:06:23 +00:00
|
|
|
OrigDC->FillPatternSurfaces,
|
|
|
|
sizeof OrigDC->FillPatternSurfaces);
|
|
|
|
NewDC->GDIInfo = OrigDC->GDIInfo;
|
|
|
|
NewDC->DevInfo = OrigDC->DevInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a 1x1 monochrome bitmap surface
|
|
|
|
onebyone.cx = 1;
|
|
|
|
onebyone.cy = 1;
|
|
|
|
NewDC->Surface = EngCreateBitmap(onebyone, 1, BMF_1BPP, 0, NULL);
|
1999-09-10 21:17:07 +00:00
|
|
|
|
|
|
|
/* DriverName is copied in the AllocDC routine */
|
2001-11-19 12:06:23 +00:00
|
|
|
if(OrigDC == NULL) {
|
|
|
|
NewDC->DeviceDriver = DRIVER_FindMPDriver(NewDC->DriverName);
|
|
|
|
} else {
|
|
|
|
NewDC->DeviceDriver = OrigDC->DeviceDriver;
|
|
|
|
NewDC->wndOrgX = OrigDC->wndOrgX;
|
|
|
|
NewDC->wndOrgY = OrigDC->wndOrgY;
|
|
|
|
NewDC->wndExtX = OrigDC->wndExtX;
|
|
|
|
NewDC->wndExtY = OrigDC->wndExtY;
|
|
|
|
NewDC->vportOrgX = OrigDC->vportOrgX;
|
|
|
|
NewDC->vportOrgY = OrigDC->vportOrgY;
|
|
|
|
NewDC->vportExtX = OrigDC->vportExtX;
|
|
|
|
NewDC->vportExtY = OrigDC->vportExtY;
|
|
|
|
}
|
1999-09-10 21:17:07 +00:00
|
|
|
|
1999-09-08 04:50:50 +00:00
|
|
|
/* Create default bitmap */
|
1999-09-10 21:17:07 +00:00
|
|
|
if (!(hBitmap = W32kCreateBitmap( 1, 1, 1, 1, NULL )))
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_ReleasePtr( hNewDC );
|
|
|
|
DC_FreeDC( hNewDC );
|
2001-03-31 15:35:08 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
1999-09-10 21:17:07 +00:00
|
|
|
NewDC->w.flags = DC_MEMORY;
|
2001-03-31 15:35:08 +00:00
|
|
|
NewDC->w.bitsPerPixel = 1;
|
1999-09-10 21:17:07 +00:00
|
|
|
NewDC->w.hBitmap = hBitmap;
|
|
|
|
NewDC->w.hFirstBitmap = hBitmap;
|
2001-11-19 12:06:23 +00:00
|
|
|
|
|
|
|
if(OrigDC != NULL)
|
|
|
|
{
|
|
|
|
NewDC->w.hPalette = OrigDC->w.hPalette;
|
|
|
|
NewDC->w.textColor = OrigDC->w.textColor;
|
|
|
|
NewDC->w.textAlign = OrigDC->w.textAlign;
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_ReleasePtr( hDC );
|
|
|
|
DC_ReleasePtr( hNewDC );
|
2003-01-19 01:01:00 +00:00
|
|
|
DC_InitDC(hNewDC);
|
1999-09-08 04:50:50 +00:00
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
return hNewDC;
|
1999-07-12 23:26:57 +00:00
|
|
|
}
|
|
|
|
|
2002-09-18 23:56:48 +00:00
|
|
|
BOOL STDCALL W32kCreatePrimarySurface(LPCWSTR Driver,
|
|
|
|
LPCWSTR Device)
|
1999-07-12 23:26:57 +00:00
|
|
|
{
|
|
|
|
PGD_ENABLEDRIVER GDEnableDriver;
|
2002-09-18 23:56:48 +00:00
|
|
|
HANDLE DeviceDriver;
|
1999-07-12 23:26:57 +00:00
|
|
|
DRVENABLEDATA DED;
|
2002-09-08 10:23:54 +00:00
|
|
|
PSURFOBJ SurfObj;
|
2000-03-17 21:02:59 +00:00
|
|
|
|
1999-07-12 23:26:57 +00:00
|
|
|
/* Open the miniport driver */
|
2002-09-18 23:56:48 +00:00
|
|
|
if ((DeviceDriver = DRIVER_FindMPDriver(Driver)) == NULL)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
DPRINT("FindMPDriver failed\n");
|
2002-09-18 23:56:48 +00:00
|
|
|
return(FALSE);
|
2001-03-31 15:35:08 +00:00
|
|
|
}
|
2000-03-17 21:02:59 +00:00
|
|
|
|
1999-07-12 23:26:57 +00:00
|
|
|
/* Get the DDI driver's entry point */
|
2000-03-08 21:23:14 +00:00
|
|
|
/* FIXME: Retrieve DDI driver name from registry */
|
2001-10-23 00:22:04 +00:00
|
|
|
if ((GDEnableDriver = DRIVER_FindDDIDriver(L"\\SystemRoot\\system32\\drivers\\vgaddi.dll")) == NULL)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
DPRINT("FindDDIDriver failed\n");
|
2002-09-18 23:56:48 +00:00
|
|
|
return(FALSE);
|
2001-03-31 15:35:08 +00:00
|
|
|
}
|
2000-03-17 21:02:59 +00:00
|
|
|
|
1999-07-12 23:26:57 +00:00
|
|
|
/* Call DDI driver's EnableDriver function */
|
|
|
|
RtlZeroMemory(&DED, sizeof(DED));
|
2000-03-17 21:02:59 +00:00
|
|
|
|
1999-07-12 23:26:57 +00:00
|
|
|
if (!GDEnableDriver(DDI_DRIVER_VERSION, sizeof(DED), &DED))
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
DPRINT("DrvEnableDriver failed\n");
|
2002-09-18 23:56:48 +00:00
|
|
|
return(FALSE);
|
2001-03-31 15:35:08 +00:00
|
|
|
}
|
|
|
|
DPRINT("Building DDI Functions\n");
|
1999-07-12 23:26:57 +00:00
|
|
|
|
|
|
|
/* Construct DDI driver function dispatch table */
|
2002-09-18 23:56:48 +00:00
|
|
|
if (!DRIVER_BuildDDIFunctions(&DED, &PrimarySurface.DriverFunctions))
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
DPRINT("BuildDDIFunctions failed\n");
|
2002-09-18 23:56:48 +00:00
|
|
|
return(FALSE);
|
2001-03-31 15:35:08 +00:00
|
|
|
}
|
2000-03-17 21:02:59 +00:00
|
|
|
|
1999-07-12 23:26:57 +00:00
|
|
|
/* Allocate a phyical device handle from the driver */
|
|
|
|
if (Device != NULL)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
DPRINT("Device in u: %u\n", Device);
|
|
|
|
// wcsncpy(NewDC->DMW.dmDeviceName, Device, DMMAXDEVICENAME); FIXME: this crashes everything?
|
|
|
|
}
|
2000-06-16 07:25:41 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
DPRINT("Enabling PDev\n");
|
2000-06-16 07:25:41 +00:00
|
|
|
|
2002-10-01 06:41:57 +00:00
|
|
|
PrimarySurface.PDev =
|
2002-09-18 23:56:48 +00:00
|
|
|
PrimarySurface.DriverFunctions.EnablePDev(&PrimarySurface.DMW,
|
|
|
|
L"",
|
|
|
|
HS_DDI_MAX,
|
|
|
|
PrimarySurface.FillPatterns,
|
|
|
|
sizeof(PrimarySurface.GDIInfo),
|
|
|
|
(ULONG *) &PrimarySurface.GDIInfo,
|
|
|
|
sizeof(PrimarySurface.DevInfo),
|
|
|
|
&PrimarySurface.DevInfo,
|
|
|
|
NULL,
|
|
|
|
L"",
|
|
|
|
DeviceDriver);
|
|
|
|
if (PrimarySurface.PDev == NULL)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
DPRINT("DrvEnablePDEV failed\n");
|
2002-09-18 23:56:48 +00:00
|
|
|
return(FALSE);
|
2001-03-31 15:35:08 +00:00
|
|
|
}
|
2000-03-17 21:02:59 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
DPRINT("calling completePDev\n");
|
2000-06-16 07:25:41 +00:00
|
|
|
|
1999-07-12 23:26:57 +00:00
|
|
|
/* Complete initialization of the physical device */
|
2002-10-01 06:41:57 +00:00
|
|
|
PrimarySurface.DriverFunctions.CompletePDev(PrimarySurface.PDev,
|
2002-09-18 23:56:48 +00:00
|
|
|
&PrimarySurface);
|
1999-07-12 23:26:57 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
DPRINT("calling DRIVER_ReferenceDriver\n");
|
2000-06-16 07:25:41 +00:00
|
|
|
|
1999-12-09 02:45:06 +00:00
|
|
|
DRIVER_ReferenceDriver (Driver);
|
2000-03-17 21:02:59 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
DPRINT("calling EnableSurface\n");
|
2000-06-16 07:25:41 +00:00
|
|
|
|
1999-07-12 23:26:57 +00:00
|
|
|
/* Enable the drawing surface */
|
2002-10-01 06:41:57 +00:00
|
|
|
PrimarySurface.Handle =
|
|
|
|
PrimarySurface.DriverFunctions.EnableSurface(PrimarySurface.PDev);
|
2002-09-18 23:56:48 +00:00
|
|
|
|
|
|
|
SurfObj = (PSURFOBJ)AccessUserObject(PrimarySurface.Handle);
|
|
|
|
SurfObj->dhpdev = PrimarySurface.PDev;
|
|
|
|
}
|
|
|
|
|
|
|
|
HDC STDCALL W32kCreateDC(LPCWSTR Driver,
|
|
|
|
LPCWSTR Device,
|
|
|
|
LPCWSTR Output,
|
|
|
|
CONST PDEVMODEW InitData)
|
2002-10-01 06:41:57 +00:00
|
|
|
{
|
2002-09-18 23:56:48 +00:00
|
|
|
HDC hNewDC;
|
|
|
|
PDC NewDC;
|
2002-10-01 06:41:57 +00:00
|
|
|
HDC hDC = NULL;
|
2002-09-18 23:56:48 +00:00
|
|
|
|
|
|
|
/* Check for existing DC object */
|
|
|
|
if ((hNewDC = DC_FindOpenDC(Driver)) != NULL)
|
|
|
|
{
|
|
|
|
hDC = hNewDC;
|
|
|
|
return W32kCreateCompatableDC(hDC);
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINT("NAME: %S\n", Driver); // FIXME: Should not crash if NULL
|
|
|
|
|
|
|
|
/* Allocate a DC object */
|
|
|
|
if ((hNewDC = DC_AllocDC(Driver)) == NULL)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2000-04-01 12:31:29 +00:00
|
|
|
|
2002-09-18 23:56:48 +00:00
|
|
|
NewDC = DC_HandleToPtr( hNewDC );
|
|
|
|
ASSERT( NewDC );
|
|
|
|
|
|
|
|
if (!PrimarySurfaceCreated)
|
|
|
|
{
|
|
|
|
if (!W32kCreatePrimarySurface(Driver, Device))
|
|
|
|
{
|
|
|
|
DC_ReleasePtr( hNewDC );
|
|
|
|
DC_FreeDC(hNewDC);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PrimarySurfaceCreated = TRUE;
|
|
|
|
NewDC->DMW = PrimarySurface.DMW;
|
|
|
|
NewDC->DevInfo = PrimarySurface.DevInfo;
|
|
|
|
NewDC->GDIInfo = PrimarySurface.GDIInfo;
|
|
|
|
memcpy(NewDC->FillPatternSurfaces, PrimarySurface.FillPatterns,
|
|
|
|
sizeof(NewDC->FillPatternSurfaces));
|
|
|
|
NewDC->PDev = PrimarySurface.PDev;
|
|
|
|
NewDC->Surface = PrimarySurface.Handle;
|
|
|
|
NewDC->DriverFunctions = PrimarySurface.DriverFunctions;
|
|
|
|
|
|
|
|
NewDC->DMW.dmSize = sizeof(NewDC->DMW);
|
|
|
|
NewDC->DMW.dmFields = 0x000fc000;
|
|
|
|
|
|
|
|
/* FIXME: get mode selection information from somewhere */
|
|
|
|
|
|
|
|
NewDC->DMW.dmLogPixels = 96;
|
|
|
|
NewDC->DMW.dmBitsPerPel = 4;
|
|
|
|
NewDC->DMW.dmPelsWidth = 640;
|
|
|
|
NewDC->DMW.dmPelsHeight = 480;
|
|
|
|
NewDC->DMW.dmDisplayFlags = 0;
|
|
|
|
NewDC->DMW.dmDisplayFrequency = 0;
|
|
|
|
|
|
|
|
NewDC->w.bitsPerPixel = 4; // FIXME: set this here??
|
2002-10-01 06:41:57 +00:00
|
|
|
|
|
|
|
NewDC->w.hPalette = NewDC->DevInfo.hpalDefault;
|
2001-05-26 08:15:40 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
DPRINT("Bits per pel: %u\n", NewDC->w.bitsPerPixel);
|
1999-07-12 23:26:57 +00:00
|
|
|
|
2003-01-19 01:01:00 +00:00
|
|
|
NewDC->w.hVisRgn = W32kCreateRectRgn(0, 0, 640, 480);
|
|
|
|
DC_ReleasePtr( hNewDC );
|
|
|
|
|
1999-07-12 23:26:57 +00:00
|
|
|
/* Initialize the DC state */
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_InitDC(hNewDC);
|
2002-09-01 20:39:56 +00:00
|
|
|
W32kSetTextColor(hNewDC, RGB(0, 0, 0));
|
2002-09-19 22:41:57 +00:00
|
|
|
W32kSetTextAlign(hNewDC, TA_TOP);
|
2002-09-17 23:43:29 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
return hNewDC;
|
1999-07-12 23:26:57 +00:00
|
|
|
}
|
|
|
|
|
1999-07-23 19:57:18 +00:00
|
|
|
HDC STDCALL W32kCreateIC(LPCWSTR Driver,
|
|
|
|
LPCWSTR Device,
|
|
|
|
LPCWSTR Output,
|
|
|
|
CONST PDEVMODEW DevMode)
|
|
|
|
{
|
1999-09-08 04:50:50 +00:00
|
|
|
/* FIXME: this should probably do something else... */
|
1999-09-10 21:17:07 +00:00
|
|
|
return W32kCreateDC(Driver, Device, Output, DevMode);
|
1999-07-23 19:57:18 +00:00
|
|
|
}
|
|
|
|
|
1999-07-12 23:26:57 +00:00
|
|
|
BOOL STDCALL W32kDeleteDC(HDC DCHandle)
|
|
|
|
{
|
|
|
|
PDC DCToDelete;
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-07-12 23:26:57 +00:00
|
|
|
DCToDelete = DC_HandleToPtr(DCHandle);
|
1999-11-17 20:54:05 +00:00
|
|
|
if (DCToDelete == NULL)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-07-07 01:20:53 +00:00
|
|
|
DPRINT( "Deleting DC\n" );
|
2002-02-15 20:14:43 +00:00
|
|
|
if ((!(DCToDelete->w.flags & DC_MEMORY))) // Don't reset the display if its a memory DC
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
2002-02-15 20:14:43 +00:00
|
|
|
if (!DRIVER_UnreferenceDriver (DCToDelete->DriverName))
|
|
|
|
{
|
|
|
|
DPRINT( "No more references to driver, reseting display\n" );
|
|
|
|
DCToDelete->DriverFunctions.DisableSurface(DCToDelete->PDev);
|
|
|
|
CHECKPOINT;
|
|
|
|
DCToDelete->DriverFunctions.AssertMode( DCToDelete->PDev, FALSE );
|
|
|
|
CHECKPOINT;
|
|
|
|
DCToDelete->DriverFunctions.DisablePDev(DCToDelete->PDev);
|
2002-10-01 06:41:57 +00:00
|
|
|
PrimarySurfaceCreated = FALSE;
|
|
|
|
}
|
2001-03-31 15:35:08 +00:00
|
|
|
}
|
2000-07-07 01:20:53 +00:00
|
|
|
CHECKPOINT;
|
1999-11-17 20:54:05 +00:00
|
|
|
/* First delete all saved DCs */
|
|
|
|
while (DCToDelete->saveLevel)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
PDC savedDC;
|
|
|
|
HDC savedHDC;
|
2002-07-13 21:37:27 +00:00
|
|
|
|
2001-11-02 06:10:11 +00:00
|
|
|
savedHDC = DC_GetNextDC (DCToDelete);
|
2001-03-31 15:35:08 +00:00
|
|
|
savedDC = DC_HandleToPtr (savedHDC);
|
|
|
|
if (savedDC == NULL)
|
|
|
|
{
|
|
|
|
break;
|
1999-11-17 20:54:05 +00:00
|
|
|
}
|
2001-11-02 06:10:11 +00:00
|
|
|
DC_SetNextDC (DCToDelete, DC_GetNextDC (savedDC));
|
2001-03-31 15:35:08 +00:00
|
|
|
DCToDelete->saveLevel--;
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_ReleasePtr( savedHDC );
|
2001-03-31 15:35:08 +00:00
|
|
|
W32kDeleteDC (savedHDC);
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-11-17 20:54:05 +00:00
|
|
|
/* Free GDI resources allocated to this DC */
|
|
|
|
if (!(DCToDelete->w.flags & DC_SAVED))
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
2001-11-02 06:10:11 +00:00
|
|
|
/*
|
2001-03-31 15:35:08 +00:00
|
|
|
W32kSelectObject (DCHandle, STOCK_BLACK_PEN);
|
|
|
|
W32kSelectObject (DCHandle, STOCK_WHITE_BRUSH);
|
|
|
|
W32kSelectObject (DCHandle, STOCK_SYSTEM_FONT);
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_LockDC (DCHandle); W32kSelectObject does not recognize stock objects yet */
|
|
|
|
if (DCToDelete->w.flags & DC_MEMORY)
|
1999-11-17 20:54:05 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
W32kDeleteObject (DCToDelete->w.hFirstBitmap);
|
1999-11-17 20:54:05 +00:00
|
|
|
}
|
2001-03-31 15:35:08 +00:00
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
if (DCToDelete->w.hClipRgn)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
W32kDeleteObject (DCToDelete->w.hClipRgn);
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
if (DCToDelete->w.hVisRgn)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
W32kDeleteObject (DCToDelete->w.hVisRgn);
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
if (DCToDelete->w.hGCClipRgn)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
W32kDeleteObject (DCToDelete->w.hGCClipRgn);
|
|
|
|
}
|
1999-11-17 20:54:05 +00:00
|
|
|
#if 0 /* FIXME */
|
|
|
|
PATH_DestroyGdiPath (&DCToDelete->w.path);
|
|
|
|
#endif
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_ReleasePtr( DCToDelete );
|
1999-11-17 20:54:05 +00:00
|
|
|
DC_FreeDC (DCToDelete);
|
1999-07-12 23:26:57 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
return TRUE;
|
1999-07-23 19:57:18 +00:00
|
|
|
}
|
|
|
|
|
1999-09-08 04:40:56 +00:00
|
|
|
INT STDCALL W32kDrawEscape(HDC hDC,
|
1999-07-12 23:26:57 +00:00
|
|
|
INT nEscape,
|
|
|
|
INT cbInput,
|
|
|
|
LPCSTR lpszInData)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
1999-09-08 04:40:56 +00:00
|
|
|
INT STDCALL W32kEnumObjects(HDC hDC,
|
1999-07-12 23:26:57 +00:00
|
|
|
INT ObjectType,
|
|
|
|
GOBJENUMPROC ObjectFunc,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
DC_GET_VAL( COLORREF, W32kGetBkColor, w.backgroundColor )
|
|
|
|
DC_GET_VAL( INT, W32kGetBkMode, w.backgroundMode )
|
|
|
|
DC_GET_VAL_EX( W32kGetBrushOrgEx, w.brushOrgX, w.brushOrgY, POINT )
|
|
|
|
DC_GET_VAL( HRGN, W32kGetClipRgn, w.hClipRgn )
|
|
|
|
|
1999-09-08 04:40:56 +00:00
|
|
|
HGDIOBJ STDCALL W32kGetCurrentObject(HDC hDC,
|
1999-07-12 23:26:57 +00:00
|
|
|
UINT ObjectType)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
DC_GET_VAL_EX( W32kGetCurrentPositionEx, w.CursPosX, w.CursPosY, POINT )
|
|
|
|
|
1999-09-08 04:40:56 +00:00
|
|
|
BOOL STDCALL W32kGetDCOrgEx(HDC hDC,
|
1999-07-12 23:26:57 +00:00
|
|
|
LPPOINT Point)
|
|
|
|
{
|
2002-07-13 21:37:27 +00:00
|
|
|
PDC dc;
|
1999-10-28 23:37:14 +00:00
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
if (!Point)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
1999-10-28 23:37:14 +00:00
|
|
|
dc = DC_HandleToPtr(hDC);
|
2002-07-13 21:37:27 +00:00
|
|
|
if (dc == NULL)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
1999-10-28 23:37:14 +00:00
|
|
|
|
|
|
|
Point->x = Point->y = 0;
|
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
Point->x += dc->w.DCOrgX;
|
1999-10-28 23:37:14 +00:00
|
|
|
Point->y += dc->w.DCOrgY;
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_ReleasePtr( hDC );
|
1999-10-28 23:37:14 +00:00
|
|
|
return TRUE;
|
1999-07-12 23:26:57 +00:00
|
|
|
}
|
|
|
|
|
1999-10-31 22:43:40 +00:00
|
|
|
HDC STDCALL W32kGetDCState16(HDC hDC)
|
1999-09-08 04:50:50 +00:00
|
|
|
{
|
|
|
|
PDC newdc, dc;
|
2002-07-13 21:37:27 +00:00
|
|
|
HDC hnewdc;
|
|
|
|
|
1999-09-08 04:50:50 +00:00
|
|
|
dc = DC_HandleToPtr(hDC);
|
2002-07-13 21:37:27 +00:00
|
|
|
if (dc == NULL)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
|
|
|
|
hnewdc = DC_AllocDC(NULL);
|
|
|
|
if (hnewdc == NULL)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_ReleasePtr( hDC );
|
2001-03-31 15:35:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
newdc = DC_HandleToPtr( hnewdc );
|
|
|
|
ASSERT( newdc );
|
1999-09-08 04:50:50 +00:00
|
|
|
|
|
|
|
newdc->w.flags = dc->w.flags | DC_SAVED;
|
1999-09-10 21:17:07 +00:00
|
|
|
#if 0
|
1999-09-08 04:50:50 +00:00
|
|
|
newdc->w.devCaps = dc->w.devCaps;
|
1999-09-10 21:17:07 +00:00
|
|
|
#endif
|
2002-07-13 21:37:27 +00:00
|
|
|
newdc->w.hPen = dc->w.hPen;
|
|
|
|
newdc->w.hBrush = dc->w.hBrush;
|
|
|
|
newdc->w.hFont = dc->w.hFont;
|
|
|
|
newdc->w.hBitmap = dc->w.hBitmap;
|
1999-09-08 04:50:50 +00:00
|
|
|
newdc->w.hFirstBitmap = dc->w.hFirstBitmap;
|
1999-09-10 21:17:07 +00:00
|
|
|
#if 0
|
1999-09-08 04:50:50 +00:00
|
|
|
newdc->w.hDevice = dc->w.hDevice;
|
2002-07-13 21:37:27 +00:00
|
|
|
newdc->w.hPalette = dc->w.hPalette;
|
1999-09-10 21:17:07 +00:00
|
|
|
#endif
|
1999-09-08 04:50:50 +00:00
|
|
|
newdc->w.totalExtent = dc->w.totalExtent;
|
|
|
|
newdc->w.bitsPerPixel = dc->w.bitsPerPixel;
|
|
|
|
newdc->w.ROPmode = dc->w.ROPmode;
|
|
|
|
newdc->w.polyFillMode = dc->w.polyFillMode;
|
|
|
|
newdc->w.stretchBltMode = dc->w.stretchBltMode;
|
|
|
|
newdc->w.relAbsMode = dc->w.relAbsMode;
|
|
|
|
newdc->w.backgroundMode = dc->w.backgroundMode;
|
|
|
|
newdc->w.backgroundColor = dc->w.backgroundColor;
|
|
|
|
newdc->w.textColor = dc->w.textColor;
|
|
|
|
newdc->w.brushOrgX = dc->w.brushOrgX;
|
|
|
|
newdc->w.brushOrgY = dc->w.brushOrgY;
|
|
|
|
newdc->w.textAlign = dc->w.textAlign;
|
|
|
|
newdc->w.charExtra = dc->w.charExtra;
|
|
|
|
newdc->w.breakTotalExtra = dc->w.breakTotalExtra;
|
|
|
|
newdc->w.breakCount = dc->w.breakCount;
|
|
|
|
newdc->w.breakExtra = dc->w.breakExtra;
|
|
|
|
newdc->w.breakRem = dc->w.breakRem;
|
|
|
|
newdc->w.MapMode = dc->w.MapMode;
|
|
|
|
newdc->w.GraphicsMode = dc->w.GraphicsMode;
|
|
|
|
#if 0
|
|
|
|
/* Apparently, the DC origin is not changed by [GS]etDCState */
|
|
|
|
newdc->w.DCOrgX = dc->w.DCOrgX;
|
|
|
|
newdc->w.DCOrgY = dc->w.DCOrgY;
|
|
|
|
#endif
|
|
|
|
newdc->w.CursPosX = dc->w.CursPosX;
|
|
|
|
newdc->w.CursPosY = dc->w.CursPosY;
|
|
|
|
newdc->w.ArcDirection = dc->w.ArcDirection;
|
1999-09-10 21:17:07 +00:00
|
|
|
#if 0
|
1999-09-08 04:50:50 +00:00
|
|
|
newdc->w.xformWorld2Wnd = dc->w.xformWorld2Wnd;
|
|
|
|
newdc->w.xformWorld2Vport = dc->w.xformWorld2Vport;
|
|
|
|
newdc->w.xformVport2World = dc->w.xformVport2World;
|
|
|
|
newdc->w.vport2WorldValid = dc->w.vport2WorldValid;
|
1999-09-10 21:17:07 +00:00
|
|
|
#endif
|
1999-09-08 04:50:50 +00:00
|
|
|
newdc->wndOrgX = dc->wndOrgX;
|
|
|
|
newdc->wndOrgY = dc->wndOrgY;
|
|
|
|
newdc->wndExtX = dc->wndExtX;
|
|
|
|
newdc->wndExtY = dc->wndExtY;
|
|
|
|
newdc->vportOrgX = dc->vportOrgX;
|
|
|
|
newdc->vportOrgY = dc->vportOrgY;
|
|
|
|
newdc->vportExtX = dc->vportExtX;
|
|
|
|
newdc->vportExtY = dc->vportExtY;
|
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
newdc->hSelf = hnewdc;
|
1999-09-08 04:50:50 +00:00
|
|
|
newdc->saveLevel = 0;
|
|
|
|
|
1999-09-10 21:17:07 +00:00
|
|
|
#if 0
|
1999-09-08 04:50:50 +00:00
|
|
|
PATH_InitGdiPath( &newdc->w.path );
|
1999-09-10 21:17:07 +00:00
|
|
|
#endif
|
|
|
|
|
1999-09-08 04:50:50 +00:00
|
|
|
/* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */
|
|
|
|
|
1999-09-10 21:17:07 +00:00
|
|
|
#if 0
|
1999-09-08 04:50:50 +00:00
|
|
|
newdc->w.hGCClipRgn = newdc->w.hVisRgn = 0;
|
1999-09-10 21:17:07 +00:00
|
|
|
#endif
|
1999-09-08 04:50:50 +00:00
|
|
|
if (dc->w.hClipRgn)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
newdc->w.hClipRgn = W32kCreateRectRgn( 0, 0, 0, 0 );
|
|
|
|
W32kCombineRgn( newdc->w.hClipRgn, dc->w.hClipRgn, 0, RGN_COPY );
|
|
|
|
}
|
1999-09-08 04:50:50 +00:00
|
|
|
else
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
newdc->w.hClipRgn = 0;
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_ReleasePtr( hnewdc );
|
|
|
|
return hnewdc;
|
1999-09-08 04:50:50 +00:00
|
|
|
}
|
|
|
|
|
1999-09-08 04:40:56 +00:00
|
|
|
INT STDCALL W32kGetDeviceCaps(HDC hDC,
|
1999-07-12 23:26:57 +00:00
|
|
|
INT Index)
|
|
|
|
{
|
1999-10-28 23:37:14 +00:00
|
|
|
PDC dc;
|
|
|
|
INT ret;
|
|
|
|
POINT pt;
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-10-28 23:37:14 +00:00
|
|
|
dc = DC_HandleToPtr(hDC);
|
2002-07-13 21:37:27 +00:00
|
|
|
if (dc == NULL)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
1999-10-28 23:37:14 +00:00
|
|
|
|
|
|
|
/* Device capabilities for the printer */
|
|
|
|
switch (Index)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
1999-10-28 23:37:14 +00:00
|
|
|
case PHYSICALWIDTH:
|
|
|
|
if(W32kEscape(hDC, GETPHYSPAGESIZE, 0, NULL, (LPVOID)&pt) > 0)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return pt.x;
|
|
|
|
}
|
1999-10-28 23:37:14 +00:00
|
|
|
break;
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-10-28 23:37:14 +00:00
|
|
|
case PHYSICALHEIGHT:
|
|
|
|
if(W32kEscape(hDC, GETPHYSPAGESIZE, 0, NULL, (LPVOID)&pt) > 0)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return pt.y;
|
|
|
|
}
|
1999-10-28 23:37:14 +00:00
|
|
|
break;
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-10-28 23:37:14 +00:00
|
|
|
case PHYSICALOFFSETX:
|
|
|
|
if(W32kEscape(hDC, GETPRINTINGOFFSET, 0, NULL, (LPVOID)&pt) > 0)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return pt.x;
|
|
|
|
}
|
1999-10-28 23:37:14 +00:00
|
|
|
break;
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-10-28 23:37:14 +00:00
|
|
|
case PHYSICALOFFSETY:
|
|
|
|
if(W32kEscape(hDC, GETPRINTINGOFFSET, 0, NULL, (LPVOID)&pt) > 0)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return pt.y;
|
|
|
|
}
|
1999-10-28 23:37:14 +00:00
|
|
|
break;
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-10-28 23:37:14 +00:00
|
|
|
case SCALINGFACTORX:
|
|
|
|
if(W32kEscape(hDC, GETSCALINGFACTOR, 0, NULL, (LPVOID)&pt) > 0)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return pt.x;
|
|
|
|
}
|
1999-10-28 23:37:14 +00:00
|
|
|
break;
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-10-28 23:37:14 +00:00
|
|
|
case SCALINGFACTORY:
|
|
|
|
if(W32kEscape(hDC, GETSCALINGFACTOR, 0, NULL, (LPVOID)&pt) > 0)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return pt.y;
|
|
|
|
}
|
1999-10-28 23:37:14 +00:00
|
|
|
break;
|
2001-03-31 15:35:08 +00:00
|
|
|
}
|
1999-10-28 23:37:14 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
if ((Index < 0) || (Index > sizeof(DEVICECAPS) - sizeof(WORD)))
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
DPRINT("(%04x,%d): returning %d\n",
|
|
|
|
hDC, Index, *(WORD *)(((char *)dc->w.devCaps) + Index));
|
1999-10-28 23:37:14 +00:00
|
|
|
ret = *(WORD *)(((char *)dc->w.devCaps) + Index);
|
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_ReleasePtr( hDC );
|
1999-10-28 23:37:14 +00:00
|
|
|
return ret;
|
1999-07-12 23:26:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DC_GET_VAL( INT, W32kGetMapMode, w.MapMode )
|
|
|
|
DC_GET_VAL( INT, W32kGetPolyFillMode, w.polyFillMode )
|
1999-07-23 19:57:18 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
INT STDCALL W32kGetObjectA(HANDLE handle, INT count, LPVOID buffer)
|
1999-07-23 19:57:18 +00:00
|
|
|
{
|
2001-11-02 06:10:11 +00:00
|
|
|
PGDIOBJ gdiObject;
|
|
|
|
INT result = 0;
|
|
|
|
WORD magic;
|
2001-03-31 15:35:08 +00:00
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
if (!count)
|
2001-11-02 06:10:11 +00:00
|
|
|
return 0;
|
2002-07-13 21:37:27 +00:00
|
|
|
gdiObject = GDIOBJ_LockObj (handle, GO_MAGIC_DONTCARE);
|
|
|
|
if (gdiObject == 0)
|
2001-11-02 06:10:11 +00:00
|
|
|
return 0;
|
2001-03-31 15:35:08 +00:00
|
|
|
|
2001-11-02 06:10:11 +00:00
|
|
|
magic = GDIOBJ_GetHandleMagic (handle);
|
|
|
|
switch(magic)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
/* case GO_PEN_MAGIC:
|
2001-11-02 06:10:11 +00:00
|
|
|
result = PEN_GetObject((PENOBJ *)gdiObject, count, buffer);
|
2001-03-31 15:35:08 +00:00
|
|
|
break;
|
2002-07-13 21:37:27 +00:00
|
|
|
case GO_BRUSH_MAGIC:
|
2001-11-02 06:10:11 +00:00
|
|
|
result = BRUSH_GetObject((BRUSHOBJ *)gdiObject, count, buffer);
|
2001-03-31 15:35:08 +00:00
|
|
|
break; */
|
2002-07-13 21:37:27 +00:00
|
|
|
case GO_BITMAP_MAGIC:
|
2001-11-02 06:10:11 +00:00
|
|
|
result = BITMAP_GetObject((BITMAPOBJ *)gdiObject, count, buffer);
|
2001-03-31 15:35:08 +00:00
|
|
|
break;
|
|
|
|
/* case GO_FONT_MAGIC:
|
2001-11-02 06:10:11 +00:00
|
|
|
result = FONT_GetObjectA((FONTOBJ *)gdiObject, count, buffer);
|
2001-03-31 15:35:08 +00:00
|
|
|
|
|
|
|
// FIXME: Fix the LOGFONT structure for the stock fonts
|
|
|
|
|
|
|
|
if ( (handle >= FIRST_STOCK_HANDLE) && (handle <= LAST_STOCK_HANDLE) )
|
|
|
|
FixStockFontSizeA(handle, count, buffer);
|
|
|
|
break;
|
|
|
|
case GO_PALETTE_MAGIC:
|
2001-11-02 06:10:11 +00:00
|
|
|
result = PALETTE_GetObject((PALETTEOBJ *)gdiObject, count, buffer);
|
2001-03-31 15:35:08 +00:00
|
|
|
break; */
|
|
|
|
|
|
|
|
case GO_REGION_MAGIC:
|
|
|
|
case GO_DC_MAGIC:
|
|
|
|
case GO_DISABLED_DC_MAGIC:
|
|
|
|
case GO_META_DC_MAGIC:
|
|
|
|
case GO_METAFILE_MAGIC:
|
|
|
|
case GO_METAFILE_DC_MAGIC:
|
|
|
|
case GO_ENHMETAFILE_MAGIC:
|
|
|
|
case GO_ENHMETAFILE_DC_MAGIC:
|
2001-11-02 06:10:11 +00:00
|
|
|
// FIXME("Magic %04x not implemented\n", magic);
|
2001-03-31 15:35:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2001-11-02 06:10:11 +00:00
|
|
|
DbgPrint("Invalid GDI Magic %04x\n", magic);
|
2001-03-31 15:35:08 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
GDIOBJ_UnlockObj (handle, GO_MAGIC_DONTCARE);
|
2001-11-02 06:10:11 +00:00
|
|
|
return result;
|
2001-03-31 15:35:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
INT STDCALL W32kGetObjectW(HANDLE handle, INT count, LPVOID buffer)
|
|
|
|
{
|
2001-11-02 06:10:11 +00:00
|
|
|
PGDIOBJHDR gdiObject;
|
|
|
|
INT result = 0;
|
|
|
|
WORD magic;
|
2001-03-31 15:35:08 +00:00
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
if (!count)
|
2001-11-02 06:10:11 +00:00
|
|
|
return 0;
|
2002-07-13 21:37:27 +00:00
|
|
|
gdiObject = GDIOBJ_LockObj(handle, GO_MAGIC_DONTCARE);
|
|
|
|
if (gdiObject == 0)
|
2001-11-02 06:10:11 +00:00
|
|
|
return 0;
|
2001-03-31 15:35:08 +00:00
|
|
|
|
2001-11-02 06:10:11 +00:00
|
|
|
magic = GDIOBJ_GetHandleMagic (handle);
|
|
|
|
switch(magic)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
/* case GO_PEN_MAGIC:
|
2001-11-02 06:10:11 +00:00
|
|
|
result = PEN_GetObject((PENOBJ *)gdiObject, count, buffer);
|
2001-03-31 15:35:08 +00:00
|
|
|
break;
|
2002-07-13 21:37:27 +00:00
|
|
|
case GO_BRUSH_MAGIC:
|
2001-11-02 06:10:11 +00:00
|
|
|
result = BRUSH_GetObject((BRUSHOBJ *)gdiObject, count, buffer);
|
2001-03-31 15:35:08 +00:00
|
|
|
break; */
|
2002-07-13 21:37:27 +00:00
|
|
|
case GO_BITMAP_MAGIC:
|
2001-11-02 06:10:11 +00:00
|
|
|
result = BITMAP_GetObject((BITMAPOBJ *)gdiObject, count, buffer);
|
2001-03-31 15:35:08 +00:00
|
|
|
break;
|
|
|
|
/* case GO_FONT_MAGIC:
|
2001-11-02 06:10:11 +00:00
|
|
|
result = FONT_GetObjectW((FONTOBJ *)gdiObject, count, buffer);
|
2001-03-31 15:35:08 +00:00
|
|
|
|
|
|
|
// Fix the LOGFONT structure for the stock fonts
|
|
|
|
|
|
|
|
if ( (handle >= FIRST_STOCK_HANDLE) && (handle <= LAST_STOCK_HANDLE) )
|
|
|
|
FixStockFontSizeW(handle, count, buffer);
|
|
|
|
break;
|
|
|
|
case GO_PALETTE_MAGIC:
|
2001-11-02 06:10:11 +00:00
|
|
|
result = PALETTE_GetObject((PALETTEOBJ *)gdiObject, count, buffer);
|
2001-03-31 15:35:08 +00:00
|
|
|
break; */
|
|
|
|
default:
|
2001-11-02 06:10:11 +00:00
|
|
|
// FIXME("Magic %04x not implemented\n", gdiObject->magic);
|
2001-03-31 15:35:08 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
GDIOBJ_UnlockObj(handle, GO_MAGIC_DONTCARE);
|
2001-11-02 06:10:11 +00:00
|
|
|
return result;
|
1999-07-23 19:57:18 +00:00
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
INT STDCALL W32kGetObject(HANDLE handle, INT count, LPVOID buffer)
|
1999-07-23 19:57:18 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
return W32kGetObjectW(handle, count, buffer);
|
1999-07-23 19:57:18 +00:00
|
|
|
}
|
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
DWORD STDCALL W32kGetObjectType(HANDLE handle)
|
1999-07-23 19:57:18 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
GDIOBJHDR * ptr;
|
|
|
|
INT result = 0;
|
2001-11-02 06:10:11 +00:00
|
|
|
WORD magic;
|
2001-03-31 15:35:08 +00:00
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
ptr = GDIOBJ_LockObj(handle, GO_MAGIC_DONTCARE);
|
|
|
|
if (ptr == 0)
|
2001-11-02 06:10:11 +00:00
|
|
|
return 0;
|
2002-07-13 21:37:27 +00:00
|
|
|
|
2001-11-02 06:10:11 +00:00
|
|
|
magic = GDIOBJ_GetHandleMagic (handle);
|
|
|
|
switch(magic)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
case GO_PEN_MAGIC:
|
|
|
|
result = OBJ_PEN;
|
|
|
|
break;
|
2002-07-13 21:37:27 +00:00
|
|
|
case GO_BRUSH_MAGIC:
|
2001-03-31 15:35:08 +00:00
|
|
|
result = OBJ_BRUSH;
|
|
|
|
break;
|
2002-07-13 21:37:27 +00:00
|
|
|
case GO_BITMAP_MAGIC:
|
2001-03-31 15:35:08 +00:00
|
|
|
result = OBJ_BITMAP;
|
|
|
|
break;
|
|
|
|
case GO_FONT_MAGIC:
|
|
|
|
result = OBJ_FONT;
|
|
|
|
break;
|
|
|
|
case GO_PALETTE_MAGIC:
|
|
|
|
result = OBJ_PAL;
|
|
|
|
break;
|
|
|
|
case GO_REGION_MAGIC:
|
|
|
|
result = OBJ_REGION;
|
|
|
|
break;
|
|
|
|
case GO_DC_MAGIC:
|
|
|
|
result = OBJ_DC;
|
|
|
|
break;
|
|
|
|
case GO_META_DC_MAGIC:
|
|
|
|
result = OBJ_METADC;
|
|
|
|
break;
|
|
|
|
case GO_METAFILE_MAGIC:
|
|
|
|
result = OBJ_METAFILE;
|
|
|
|
break;
|
|
|
|
case GO_METAFILE_DC_MAGIC:
|
|
|
|
result = OBJ_METADC;
|
|
|
|
break;
|
|
|
|
case GO_ENHMETAFILE_MAGIC:
|
|
|
|
result = OBJ_ENHMETAFILE;
|
|
|
|
break;
|
|
|
|
case GO_ENHMETAFILE_DC_MAGIC:
|
|
|
|
result = OBJ_ENHMETADC;
|
|
|
|
break;
|
|
|
|
default:
|
2001-11-02 06:10:11 +00:00
|
|
|
// FIXME("Magic %04x not implemented\n", magic);
|
2001-03-31 15:35:08 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
GDIOBJ_UnlockObj(handle, GO_MAGIC_DONTCARE);
|
2001-03-31 15:35:08 +00:00
|
|
|
return result;
|
1999-07-23 19:57:18 +00:00
|
|
|
}
|
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
DC_GET_VAL( INT, W32kGetRelAbs, w.relAbsMode )
|
|
|
|
DC_GET_VAL( INT, W32kGetROP2, w.ROPmode )
|
|
|
|
DC_GET_VAL( INT, W32kGetStretchBltMode, w.stretchBltMode )
|
1999-07-12 23:26:57 +00:00
|
|
|
DC_GET_VAL( UINT, W32kGetTextAlign, w.textAlign )
|
|
|
|
DC_GET_VAL( COLORREF, W32kGetTextColor, w.textColor )
|
|
|
|
DC_GET_VAL_EX( W32kGetViewportExtEx, vportExtX, vportExtY, SIZE )
|
|
|
|
DC_GET_VAL_EX( W32kGetViewportOrgEx, vportOrgX, vportOrgY, POINT )
|
|
|
|
DC_GET_VAL_EX( W32kGetWindowExtEx, wndExtX, wndExtY, SIZE )
|
|
|
|
DC_GET_VAL_EX( W32kGetWindowOrgEx, wndOrgX, wndOrgY, POINT )
|
|
|
|
|
2001-06-29 19:34:35 +00:00
|
|
|
HDC STDCALL W32kResetDC(HDC hDC, CONST DEVMODEW *InitData)
|
1999-07-12 23:26:57 +00:00
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
1999-09-08 04:50:50 +00:00
|
|
|
BOOL STDCALL W32kRestoreDC(HDC hDC, INT SaveLevel)
|
1999-07-12 23:26:57 +00:00
|
|
|
{
|
1999-09-08 04:50:50 +00:00
|
|
|
PDC dc, dcs;
|
|
|
|
BOOL success;
|
|
|
|
|
|
|
|
dc = DC_HandleToPtr(hDC);
|
2002-07-13 21:37:27 +00:00
|
|
|
if(!dc)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
|
|
|
|
if (SaveLevel == -1)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
SaveLevel = dc->saveLevel;
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-09-08 04:50:50 +00:00
|
|
|
if ((SaveLevel < 1) || (SaveLevel > dc->saveLevel))
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-09-08 04:50:50 +00:00
|
|
|
success = TRUE;
|
|
|
|
while (dc->saveLevel >= SaveLevel)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
2001-11-02 06:10:11 +00:00
|
|
|
HDC hdcs = DC_GetNextDC (dc);
|
2002-07-13 21:37:27 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
dcs = DC_HandleToPtr (hdcs);
|
|
|
|
if (dcs == NULL)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-11-02 06:10:11 +00:00
|
|
|
DC_SetNextDC (dcs, DC_GetNextDC (dcs));
|
2001-03-31 15:35:08 +00:00
|
|
|
if (--dc->saveLevel < SaveLevel)
|
|
|
|
{
|
|
|
|
W32kSetDCState16 (hDC, hdcs);
|
|
|
|
#if 0
|
|
|
|
if (!PATH_AssignGdiPath( &dc->w.path, &dcs->w.path ))
|
1999-09-08 04:50:50 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
/* FIXME: This might not be quite right, since we're
|
|
|
|
* returning FALSE but still destroying the saved DC state */
|
|
|
|
success = FALSE;
|
1999-09-08 04:50:50 +00:00
|
|
|
}
|
1999-09-10 21:17:07 +00:00
|
|
|
#endif
|
2001-03-31 15:35:08 +00:00
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_ReleasePtr( hdcs );
|
2001-03-31 15:35:08 +00:00
|
|
|
W32kDeleteDC (hdcs);
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_ReleasePtr( hDC );
|
1999-09-08 04:50:50 +00:00
|
|
|
return success;
|
1999-07-12 23:26:57 +00:00
|
|
|
}
|
|
|
|
|
1999-09-08 04:40:56 +00:00
|
|
|
INT STDCALL W32kSaveDC(HDC hDC)
|
1999-07-12 23:26:57 +00:00
|
|
|
{
|
1999-09-08 04:50:50 +00:00
|
|
|
HDC hdcs;
|
1999-09-10 21:17:07 +00:00
|
|
|
PDC dc, dcs;
|
1999-09-08 04:50:50 +00:00
|
|
|
INT ret;
|
|
|
|
|
1999-11-17 20:54:05 +00:00
|
|
|
dc = DC_HandleToPtr (hDC);
|
1999-09-08 04:50:50 +00:00
|
|
|
if (dc == NULL)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
1999-09-08 04:50:50 +00:00
|
|
|
|
1999-11-17 20:54:05 +00:00
|
|
|
if (!(hdcs = W32kGetDCState16 (hDC)))
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
1999-11-17 20:54:05 +00:00
|
|
|
dcs = DC_HandleToPtr (hdcs);
|
1999-09-08 04:50:50 +00:00
|
|
|
|
1999-09-10 21:17:07 +00:00
|
|
|
#if 0
|
1999-09-08 04:50:50 +00:00
|
|
|
/* Copy path. The reason why path saving / restoring is in SaveDC/
|
|
|
|
* RestoreDC and not in GetDCState/SetDCState is that the ...DCState
|
|
|
|
* functions are only in Win16 (which doesn't have paths) and that
|
|
|
|
* SetDCState doesn't allow us to signal an error (which can happen
|
|
|
|
* when copying paths).
|
|
|
|
*/
|
1999-11-17 20:54:05 +00:00
|
|
|
if (!PATH_AssignGdiPath (&dcs->w.path, &dc->w.path))
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
W32kDeleteDC (hdcs);
|
|
|
|
return 0;
|
|
|
|
}
|
1999-09-10 21:17:07 +00:00
|
|
|
#endif
|
2002-07-13 21:37:27 +00:00
|
|
|
|
2001-11-02 06:10:11 +00:00
|
|
|
DC_SetNextDC (dcs, DC_GetNextDC (dc));
|
|
|
|
DC_SetNextDC (dc, hdcs);
|
1999-09-08 04:50:50 +00:00
|
|
|
ret = ++dc->saveLevel;
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_ReleasePtr( hdcs );
|
|
|
|
DC_ReleasePtr( hDC );
|
1999-09-08 04:50:50 +00:00
|
|
|
|
|
|
|
return ret;
|
1999-07-12 23:26:57 +00:00
|
|
|
}
|
|
|
|
|
2000-06-16 07:25:41 +00:00
|
|
|
HGDIOBJ STDCALL W32kSelectObject(HDC hDC, HGDIOBJ hGDIObj)
|
1999-07-12 23:26:57 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
HGDIOBJ objOrg;
|
|
|
|
BITMAPOBJ *pb;
|
2002-09-08 10:23:54 +00:00
|
|
|
PSURFOBJ surfobj;
|
2001-03-31 15:35:08 +00:00
|
|
|
PSURFGDI surfgdi;
|
|
|
|
PDC dc;
|
|
|
|
PPENOBJ pen;
|
2002-09-08 10:23:54 +00:00
|
|
|
PBRUSHOBJ brush;
|
|
|
|
PXLATEOBJ XlateObj;
|
2001-03-31 15:35:08 +00:00
|
|
|
PPALGDI PalGDI;
|
2001-11-02 06:10:11 +00:00
|
|
|
WORD objectMagic;
|
2002-09-24 20:22:10 +00:00
|
|
|
ULONG NumColors;
|
2001-03-31 15:35:08 +00:00
|
|
|
|
|
|
|
if(!hDC || !hGDIObj) return NULL;
|
|
|
|
|
|
|
|
dc = DC_HandleToPtr(hDC);
|
2001-11-02 06:10:11 +00:00
|
|
|
objectMagic = GDIOBJ_GetHandleMagic (hGDIObj);
|
|
|
|
// GdiObjHdr = hGDIObj;
|
2001-03-31 15:35:08 +00:00
|
|
|
|
|
|
|
// FIXME: Get object handle from GDIObj and use it instead of GDIObj below?
|
|
|
|
|
2001-11-02 06:10:11 +00:00
|
|
|
switch(objectMagic) {
|
2001-03-31 15:35:08 +00:00
|
|
|
case GO_PEN_MAGIC:
|
|
|
|
objOrg = (HGDIOBJ)dc->w.hPen;
|
|
|
|
dc->w.hPen = hGDIObj;
|
|
|
|
|
|
|
|
// Convert the color of the pen to the format of the DC
|
2001-06-25 09:30:45 +00:00
|
|
|
PalGDI = (PPALGDI)AccessInternalObject(dc->w.hPalette);
|
2002-08-19 21:49:45 +00:00
|
|
|
if( PalGDI ){
|
2002-09-08 10:23:54 +00:00
|
|
|
XlateObj = (PXLATEOBJ)EngCreateXlate(PalGDI->Mode, PAL_RGB, dc->w.hPalette, NULL);
|
2002-08-19 21:49:45 +00:00
|
|
|
pen = GDIOBJ_LockObj(dc->w.hPen, GO_PEN_MAGIC);
|
|
|
|
pen->logpen.lopnColor = XLATEOBJ_iXlate(XlateObj, pen->logpen.lopnColor);
|
|
|
|
GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC);
|
|
|
|
}
|
2001-03-31 15:35:08 +00:00
|
|
|
break;
|
|
|
|
case GO_BRUSH_MAGIC:
|
|
|
|
objOrg = (HGDIOBJ)dc->w.hBrush;
|
2001-11-02 06:10:11 +00:00
|
|
|
dc->w.hBrush = (HBRUSH) hGDIObj;
|
2002-08-19 21:49:45 +00:00
|
|
|
|
|
|
|
// Convert the color of the brush to the format of the DC
|
|
|
|
PalGDI = (PPALGDI)AccessInternalObject(dc->w.hPalette);
|
|
|
|
if( PalGDI ){
|
2002-09-08 10:23:54 +00:00
|
|
|
XlateObj = (PXLATEOBJ)EngCreateXlate(PalGDI->Mode, PAL_RGB, dc->w.hPalette, NULL);
|
|
|
|
brush = GDIOBJ_LockObj(dc->w.hBrush, GO_BRUSH_MAGIC);
|
2002-10-01 06:41:57 +00:00
|
|
|
brush->iSolidColor = XLATEOBJ_iXlate(XlateObj,
|
2002-09-01 20:39:56 +00:00
|
|
|
brush->logbrush.lbColor);
|
2002-08-19 21:49:45 +00:00
|
|
|
GDIOBJ_UnlockObj( dc->w.hBrush, GO_BRUSH_MAGIC);
|
|
|
|
}
|
2001-03-31 15:35:08 +00:00
|
|
|
break;
|
2000-06-16 07:25:41 +00:00
|
|
|
case GO_FONT_MAGIC:
|
2001-03-31 15:35:08 +00:00
|
|
|
objOrg = (HGDIOBJ)dc->w.hFont;
|
2001-11-02 06:10:11 +00:00
|
|
|
dc->w.hFont = (HFONT) hGDIObj;
|
2001-03-31 15:35:08 +00:00
|
|
|
break;
|
|
|
|
case GO_BITMAP_MAGIC:
|
|
|
|
// must be memory dc to select bitmap
|
|
|
|
if (!(dc->w.flags & DC_MEMORY)) return NULL;
|
|
|
|
objOrg = (HGDIOBJ)dc->w.hBitmap;
|
|
|
|
|
|
|
|
// setup mem dc for drawing into bitmap
|
2001-11-02 06:10:11 +00:00
|
|
|
pb = BITMAPOBJ_HandleToPtr (hGDIObj);
|
2002-08-04 09:55:11 +00:00
|
|
|
dc->w.hBitmap = CreateGDIHandle(sizeof( SURFGDI ), sizeof( SURFOBJ )); // Assign the DC's bitmap
|
2001-03-31 15:35:08 +00:00
|
|
|
|
2002-09-08 10:23:54 +00:00
|
|
|
surfobj = (PSURFOBJ) AccessUserObject( dc->w.hBitmap );
|
2002-08-04 09:55:11 +00:00
|
|
|
surfgdi = (PSURFGDI) AccessInternalObject( dc->w.hBitmap );
|
2001-03-31 15:35:08 +00:00
|
|
|
BitmapToSurf(hDC, surfgdi, surfobj, pb); // Put the bitmap in a surface
|
2002-08-04 09:55:11 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
dc->Surface = dc->w.hBitmap;
|
|
|
|
|
|
|
|
// if we're working with a DIB, get the palette [fixme: only create if the selected palette is null]
|
|
|
|
if(pb->dib)
|
|
|
|
{
|
2002-09-24 20:22:10 +00:00
|
|
|
dc->w.bitsPerPixel = pb->dib->dsBmih.biBitCount;
|
|
|
|
|
|
|
|
if(pb->dib->dsBmih.biBitCount <= 8)
|
|
|
|
{
|
|
|
|
if(pb->dib->dsBmih.biBitCount == 1) { NumColors = 2; } else
|
|
|
|
if(pb->dib->dsBmih.biBitCount == 4) { NumColors = 16; } else
|
|
|
|
if(pb->dib->dsBmih.biBitCount == 8) { NumColors = 256; }
|
|
|
|
|
|
|
|
dc->w.hPalette = EngCreatePalette(PAL_INDEXED, NumColors, pb->ColorMap, 0, 0, 0);
|
|
|
|
} else
|
2001-03-31 15:35:08 +00:00
|
|
|
if((pb->dib->dsBmih.biBitCount > 8) && (pb->dib->dsBmih.biBitCount < 24))
|
|
|
|
{
|
|
|
|
dc->w.hPalette = EngCreatePalette(PAL_BITFIELDS, pb->dib->dsBmih.biClrUsed, NULL, 0, 0, 0);
|
|
|
|
} else
|
|
|
|
if(pb->dib->dsBmih.biBitCount >= 24)
|
|
|
|
{
|
|
|
|
dc->w.hPalette = EngCreatePalette(PAL_RGB, pb->dib->dsBmih.biClrUsed, NULL, 0, 0, 0);
|
|
|
|
}
|
2002-09-24 20:22:10 +00:00
|
|
|
} else {
|
|
|
|
dc->w.bitsPerPixel = pb->bitmap.bmBitsPixel;
|
2001-03-31 15:35:08 +00:00
|
|
|
}
|
|
|
|
break;
|
2000-06-16 07:25:41 +00:00
|
|
|
#if UPDATEREGIONS
|
2001-03-31 15:35:08 +00:00
|
|
|
case GO_REGION_MAGIC:
|
|
|
|
/* objOrg = (HGDIOBJ)hDC->region; */
|
|
|
|
objOrg = NULL; /* FIXME? hDC->region is destroyed below */
|
2001-11-02 06:10:11 +00:00
|
|
|
SelectClipRgn(hDC, (HRGN)hGDIObj);
|
2001-03-31 15:35:08 +00:00
|
|
|
break;
|
2000-06-16 07:25:41 +00:00
|
|
|
#endif
|
2001-03-31 15:35:08 +00:00
|
|
|
default:
|
2000-06-16 07:25:41 +00:00
|
|
|
return NULL;
|
2001-03-31 15:35:08 +00:00
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_ReleasePtr( hDC );
|
2001-03-31 15:35:08 +00:00
|
|
|
return objOrg;
|
1999-07-12 23:26:57 +00:00
|
|
|
}
|
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_SET_MODE( W32kSetBkMode, w.backgroundMode, TRANSPARENT, OPAQUE )
|
1999-07-12 23:26:57 +00:00
|
|
|
DC_SET_MODE( W32kSetPolyFillMode, w.polyFillMode, ALTERNATE, WINDING )
|
|
|
|
// DC_SET_MODE( W32kSetRelAbs, w.relAbsMode, ABSOLUTE, RELATIVE )
|
|
|
|
DC_SET_MODE( W32kSetROP2, w.ROPmode, R2_BLACK, R2_WHITE )
|
|
|
|
DC_SET_MODE( W32kSetStretchBltMode, w.stretchBltMode, BLACKONWHITE, HALFTONE )
|
|
|
|
|
|
|
|
COLORREF STDCALL W32kSetBkColor(HDC hDC, COLORREF color)
|
|
|
|
{
|
|
|
|
COLORREF oldColor;
|
|
|
|
PDC dc = DC_HandleToPtr(hDC);
|
2002-07-13 21:37:27 +00:00
|
|
|
|
|
|
|
if (!dc)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return 0x80000000;
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-07-12 23:26:57 +00:00
|
|
|
oldColor = dc->w.backgroundColor;
|
|
|
|
dc->w.backgroundColor = color;
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_ReleasePtr( hDC );
|
1999-07-12 23:26:57 +00:00
|
|
|
return oldColor;
|
|
|
|
}
|
|
|
|
|
1999-09-10 21:17:07 +00:00
|
|
|
static void W32kSetDCState16(HDC hDC, HDC hDCSave)
|
1999-09-08 04:50:50 +00:00
|
|
|
{
|
|
|
|
PDC dc, dcs;
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-09-08 04:50:50 +00:00
|
|
|
dc = DC_HandleToPtr(hDC);
|
|
|
|
if (dc == NULL)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-09-08 04:50:50 +00:00
|
|
|
dcs = DC_HandleToPtr(hDCSave);
|
|
|
|
if (dcs == NULL)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
2002-07-13 21:37:27 +00:00
|
|
|
DC_ReleasePtr( hDC );
|
2001-03-31 15:35:08 +00:00
|
|
|
return;
|
|
|
|
}
|
1999-09-08 04:50:50 +00:00
|
|
|
if (!dcs->w.flags & DC_SAVED)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
1999-09-08 04:50:50 +00:00
|
|
|
|
|
|
|
dc->w.flags = dcs->w.flags & ~DC_SAVED;
|
1999-09-10 21:17:07 +00:00
|
|
|
|
|
|
|
#if 0
|
1999-09-08 04:50:50 +00:00
|
|
|
dc->w.devCaps = dcs->w.devCaps;
|
1999-09-10 21:17:07 +00:00
|
|
|
#endif
|
|
|
|
|
1999-09-08 04:50:50 +00:00
|
|
|
dc->w.hFirstBitmap = dcs->w.hFirstBitmap;
|
1999-09-10 21:17:07 +00:00
|
|
|
|
|
|
|
#if 0
|
1999-09-08 04:50:50 +00:00
|
|
|
dc->w.hDevice = dcs->w.hDevice;
|
1999-09-10 21:17:07 +00:00
|
|
|
#endif
|
|
|
|
|
1999-09-08 04:50:50 +00:00
|
|
|
dc->w.totalExtent = dcs->w.totalExtent;
|
|
|
|
dc->w.ROPmode = dcs->w.ROPmode;
|
|
|
|
dc->w.polyFillMode = dcs->w.polyFillMode;
|
|
|
|
dc->w.stretchBltMode = dcs->w.stretchBltMode;
|
|
|
|
dc->w.relAbsMode = dcs->w.relAbsMode;
|
|
|
|
dc->w.backgroundMode = dcs->w.backgroundMode;
|
|
|
|
dc->w.backgroundColor = dcs->w.backgroundColor;
|
|
|
|
dc->w.textColor = dcs->w.textColor;
|
|
|
|
dc->w.brushOrgX = dcs->w.brushOrgX;
|
|
|
|
dc->w.brushOrgY = dcs->w.brushOrgY;
|
|
|
|
dc->w.textAlign = dcs->w.textAlign;
|
|
|
|
dc->w.charExtra = dcs->w.charExtra;
|
|
|
|
dc->w.breakTotalExtra = dcs->w.breakTotalExtra;
|
|
|
|
dc->w.breakCount = dcs->w.breakCount;
|
|
|
|
dc->w.breakExtra = dcs->w.breakExtra;
|
|
|
|
dc->w.breakRem = dcs->w.breakRem;
|
|
|
|
dc->w.MapMode = dcs->w.MapMode;
|
|
|
|
dc->w.GraphicsMode = dcs->w.GraphicsMode;
|
|
|
|
#if 0
|
|
|
|
/* Apparently, the DC origin is not changed by [GS]etDCState */
|
|
|
|
dc->w.DCOrgX = dcs->w.DCOrgX;
|
|
|
|
dc->w.DCOrgY = dcs->w.DCOrgY;
|
|
|
|
#endif
|
|
|
|
dc->w.CursPosX = dcs->w.CursPosX;
|
|
|
|
dc->w.CursPosY = dcs->w.CursPosY;
|
|
|
|
dc->w.ArcDirection = dcs->w.ArcDirection;
|
1999-09-10 21:17:07 +00:00
|
|
|
|
|
|
|
#if 0
|
1999-09-08 04:50:50 +00:00
|
|
|
dc->w.xformWorld2Wnd = dcs->w.xformWorld2Wnd;
|
|
|
|
dc->w.xformWorld2Vport = dcs->w.xformWorld2Vport;
|
|
|
|
dc->w.xformVport2World = dcs->w.xformVport2World;
|
|
|
|
dc->w.vport2WorldValid = dcs->w.vport2WorldValid;
|
1999-09-10 21:17:07 +00:00
|
|
|
#endif
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-09-08 04:50:50 +00:00
|
|
|
dc->wndOrgX = dcs->wndOrgX;
|
|
|
|
dc->wndOrgY = dcs->wndOrgY;
|
|
|
|
dc->wndExtX = dcs->wndExtX;
|
|
|
|
dc->wndExtY = dcs->wndExtY;
|
|
|
|
dc->vportOrgX = dcs->vportOrgX;
|
|
|
|
dc->vportOrgY = dcs->vportOrgY;
|
|
|
|
dc->vportExtX = dcs->vportExtX;
|
|
|
|
dc->vportExtY = dcs->vportExtY;
|
2002-07-13 21:37:27 +00:00
|
|
|
|
|
|
|
if (!(dc->w.flags & DC_MEMORY))
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
dc->w.bitsPerPixel = dcs->w.bitsPerPixel;
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-09-10 21:17:07 +00:00
|
|
|
#if 0
|
1999-09-08 04:50:50 +00:00
|
|
|
if (dcs->w.hClipRgn)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
2002-07-13 21:37:27 +00:00
|
|
|
if (!dc->w.hClipRgn)
|
1999-09-08 04:50:50 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
dc->w.hClipRgn = W32kCreateRectRgn( 0, 0, 0, 0 );
|
1999-09-08 04:50:50 +00:00
|
|
|
}
|
2001-03-31 15:35:08 +00:00
|
|
|
W32kCombineRgn( dc->w.hClipRgn, dcs->w.hClipRgn, 0, RGN_COPY );
|
|
|
|
}
|
1999-09-08 04:50:50 +00:00
|
|
|
else
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
2002-07-13 21:37:27 +00:00
|
|
|
if (dc->w.hClipRgn)
|
1999-09-08 04:50:50 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
W32kDeleteObject( dc->w.hClipRgn );
|
1999-09-08 04:50:50 +00:00
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
dc->w.hClipRgn = 0;
|
|
|
|
}
|
1999-09-08 04:50:50 +00:00
|
|
|
CLIPPING_UpdateGCRegion( dc );
|
1999-09-10 21:17:07 +00:00
|
|
|
#endif
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-09-10 21:17:07 +00:00
|
|
|
W32kSelectObject( hDC, dcs->w.hBitmap );
|
|
|
|
W32kSelectObject( hDC, dcs->w.hBrush );
|
|
|
|
W32kSelectObject( hDC, dcs->w.hFont );
|
|
|
|
W32kSelectObject( hDC, dcs->w.hPen );
|
|
|
|
W32kSetBkColor( hDC, dcs->w.backgroundColor);
|
|
|
|
W32kSetTextColor( hDC, dcs->w.textColor);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
GDISelectPalette16( hDC, dcs->w.hPalette, FALSE );
|
|
|
|
#endif
|
2002-07-13 21:37:27 +00:00
|
|
|
|
|
|
|
DC_ReleasePtr( hDCSave );
|
|
|
|
DC_ReleasePtr( hDC );
|
1999-09-08 04:50:50 +00:00
|
|
|
}
|
|
|
|
|
1999-07-12 23:26:57 +00:00
|
|
|
// ---------------------------------------------------- Private Interface
|
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
HDC DC_AllocDC(LPCWSTR Driver)
|
1999-07-12 23:26:57 +00:00
|
|
|
{
|
2002-07-13 21:37:27 +00:00
|
|
|
PDC NewDC;
|
|
|
|
HDC hDC;
|
|
|
|
|
|
|
|
hDC = (HDC) GDIOBJ_AllocObj(sizeof(DC), GO_DC_MAGIC);
|
|
|
|
if (hDC == NULL)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
NewDC = (PDC) GDIOBJ_LockObj( hDC, GO_DC_MAGIC );
|
|
|
|
|
|
|
|
if (Driver != NULL)
|
|
|
|
{
|
|
|
|
NewDC->DriverName = ExAllocatePool(PagedPool, (wcslen(Driver) + 1) * sizeof(WCHAR));
|
|
|
|
wcscpy(NewDC->DriverName, Driver);
|
|
|
|
}
|
|
|
|
|
2002-09-01 20:39:56 +00:00
|
|
|
NewDC->w.xformWorld2Wnd.eM11 = 1.0f;
|
|
|
|
NewDC->w.xformWorld2Wnd.eM12 = 0.0f;
|
|
|
|
NewDC->w.xformWorld2Wnd.eM21 = 0.0f;
|
|
|
|
NewDC->w.xformWorld2Wnd.eM22 = 1.0f;
|
|
|
|
NewDC->w.xformWorld2Wnd.eDx = 0.0f;
|
|
|
|
NewDC->w.xformWorld2Wnd.eDy = 0.0f;
|
|
|
|
NewDC->w.xformWorld2Vport = NewDC->w.xformWorld2Wnd;
|
|
|
|
NewDC->w.xformVport2World = NewDC->w.xformWorld2Wnd;
|
|
|
|
NewDC->w.vport2WorldValid = TRUE;
|
|
|
|
|
2002-09-17 23:43:29 +00:00
|
|
|
NewDC->w.hFont = W32kGetStockObject(SYSTEM_FONT);
|
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
GDIOBJ_UnlockObj( hDC, GO_DC_MAGIC );
|
|
|
|
return hDC;
|
1999-07-12 23:26:57 +00:00
|
|
|
}
|
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
HDC DC_FindOpenDC(LPCWSTR Driver)
|
1999-09-10 21:17:07 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
return NULL;
|
1999-09-10 21:17:07 +00:00
|
|
|
}
|
|
|
|
|
2003-01-19 01:01:00 +00:00
|
|
|
/*!
|
|
|
|
* Initialize some common fields in the Device Context structure.
|
|
|
|
*/
|
2002-07-13 21:37:27 +00:00
|
|
|
void DC_InitDC(HDC DCHandle)
|
1999-07-12 23:26:57 +00:00
|
|
|
{
|
|
|
|
// W32kRealizeDefaultPalette(DCHandle);
|
2003-01-19 01:01:00 +00:00
|
|
|
|
|
|
|
W32kSelectObject(DCHandle, W32kGetStockObject( WHITE_BRUSH ));
|
|
|
|
//W32kSelectObject(DCHandle, hPen);
|
|
|
|
//W32kSelectObject(DCHandle, hFont);
|
|
|
|
|
1999-07-12 23:26:57 +00:00
|
|
|
// CLIPPING_UpdateGCRegion(DCToInit);
|
2003-01-19 01:01:00 +00:00
|
|
|
|
1999-07-12 23:26:57 +00:00
|
|
|
}
|
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
void DC_FreeDC(HDC DCToFree)
|
1999-07-12 23:26:57 +00:00
|
|
|
{
|
2002-10-01 06:41:57 +00:00
|
|
|
if (!GDIOBJ_FreeObj(DCToFree, GO_DC_MAGIC, GDIOBJFLAG_DEFAULT))
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
DPRINT("DC_FreeDC failed\n");
|
|
|
|
}
|
1999-07-12 23:26:57 +00:00
|
|
|
}
|
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
BOOL DC_InternalDeleteDC( PDC DCToDelete )
|
|
|
|
{
|
2002-10-01 06:41:57 +00:00
|
|
|
if( DCToDelete->DriverName )
|
|
|
|
ExFreePool(DCToDelete->DriverName);
|
2002-07-13 21:37:27 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-11-02 06:10:11 +00:00
|
|
|
HDC DC_GetNextDC (PDC pDC)
|
|
|
|
{
|
|
|
|
return pDC->hNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DC_SetNextDC (PDC pDC, HDC hNextDC)
|
|
|
|
{
|
|
|
|
pDC->hNext = hNextDC;
|
|
|
|
}
|
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
void
|
1999-10-28 23:37:14 +00:00
|
|
|
DC_UpdateXforms(PDC dc)
|
|
|
|
{
|
|
|
|
XFORM xformWnd2Vport;
|
|
|
|
FLOAT scaleX, scaleY;
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-10-28 23:37:14 +00:00
|
|
|
/* Construct a transformation to do the window-to-viewport conversion */
|
|
|
|
scaleX = (FLOAT)dc->vportExtX / (FLOAT)dc->wndExtX;
|
|
|
|
scaleY = (FLOAT)dc->vportExtY / (FLOAT)dc->wndExtY;
|
|
|
|
xformWnd2Vport.eM11 = scaleX;
|
|
|
|
xformWnd2Vport.eM12 = 0.0;
|
|
|
|
xformWnd2Vport.eM21 = 0.0;
|
|
|
|
xformWnd2Vport.eM22 = scaleY;
|
2001-03-31 15:35:08 +00:00
|
|
|
xformWnd2Vport.eDx = (FLOAT)dc->vportOrgX - scaleX * (FLOAT)dc->wndOrgX;
|
|
|
|
xformWnd2Vport.eDy = (FLOAT)dc->vportOrgY - scaleY * (FLOAT)dc->wndOrgY;
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-10-28 23:37:14 +00:00
|
|
|
/* Combine with the world transformation */
|
2001-03-31 15:35:08 +00:00
|
|
|
W32kCombineTransform(&dc->w.xformWorld2Vport, &dc->w.xformWorld2Wnd, &xformWnd2Vport);
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-10-28 23:37:14 +00:00
|
|
|
/* Create inverse of world-to-viewport transformation */
|
2001-03-31 15:35:08 +00:00
|
|
|
dc->w.vport2WorldValid = DC_InvertXform(&dc->w.xformWorld2Vport, &dc->w.xformVport2World);
|
1999-10-28 23:37:14 +00:00
|
|
|
}
|
|
|
|
|
2002-07-13 21:37:27 +00:00
|
|
|
BOOL
|
|
|
|
DC_InvertXform(const XFORM *xformSrc,
|
1999-10-28 23:37:14 +00:00
|
|
|
XFORM *xformDest)
|
|
|
|
{
|
|
|
|
FLOAT determinant;
|
2002-07-13 21:37:27 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
determinant = xformSrc->eM11*xformSrc->eM22 - xformSrc->eM12*xformSrc->eM21;
|
1999-10-28 23:37:14 +00:00
|
|
|
if (determinant > -1e-12 && determinant < 1e-12)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-10-28 23:37:14 +00:00
|
|
|
xformDest->eM11 = xformSrc->eM22 / determinant;
|
|
|
|
xformDest->eM12 = -xformSrc->eM12 / determinant;
|
|
|
|
xformDest->eM21 = -xformSrc->eM21 / determinant;
|
|
|
|
xformDest->eM22 = xformSrc->eM11 / determinant;
|
2001-03-31 15:35:08 +00:00
|
|
|
xformDest->eDx = -xformSrc->eDx * xformDest->eM11 - xformSrc->eDy * xformDest->eM21;
|
|
|
|
xformDest->eDy = -xformSrc->eDx * xformDest->eM12 - xformSrc->eDy * xformDest->eM22;
|
2002-07-13 21:37:27 +00:00
|
|
|
|
1999-10-28 23:37:14 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|