reformatted and fixed one of the gdi locking bugs

svn path=/trunk/; revision=5370
This commit is contained in:
Royce Mitchell III 2003-08-01 19:42:54 +00:00
parent 9b7ffc9f8a
commit 2f64211efe

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: dc.c,v 1.64 2003/07/17 07:49:15 gvg Exp $ /* $Id: dc.c,v 1.65 2003/08/01 19:42:54 royce Exp $
* *
* DC.C - Device context functions * DC.C - Device context functions
* *
@ -110,16 +110,19 @@ INT STDCALL func_name( HDC hdc, INT mode ) \
// --------------------------------------------------------- File Statics // --------------------------------------------------------- File Statics
static VOID FASTCALL W32kSetDCState16(HDC hDC, HDC hDCSave); static VOID FASTCALL
W32kSetDCState16(HDC hDC, HDC hDCSave);
// ----------------------------------------------------- Public Functions // ----------------------------------------------------- Public Functions
BOOL STDCALL W32kCancelDC(HDC hDC) BOOL STDCALL
W32kCancelDC(HDC hDC)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
} }
HDC STDCALL W32kCreateCompatableDC(HDC hDC) HDC STDCALL
W32kCreateCompatableDC(HDC hDC)
{ {
PDC NewDC, OrigDC = NULL; PDC NewDC, OrigDC = NULL;
HBITMAP hBitmap; HBITMAP hBitmap;
@ -206,7 +209,8 @@ HDC STDCALL W32kCreateCompatableDC(HDC hDC)
return hNewDC; return hNewDC;
} }
static BOOL STDCALL FindDriverFileNames(PUNICODE_STRING DriverFileNames) static BOOL STDCALL
FindDriverFileNames(PUNICODE_STRING DriverFileNames)
{ {
RTL_QUERY_REGISTRY_TABLE QueryTable[2]; RTL_QUERY_REGISTRY_TABLE QueryTable[2];
UNICODE_STRING RegistryPath; UNICODE_STRING RegistryPath;
@ -252,7 +256,8 @@ static BOOL STDCALL FindDriverFileNames(PUNICODE_STRING DriverFileNames)
} }
BOOL STDCALL W32kCreatePrimarySurface(LPCWSTR Driver, BOOL STDCALL
W32kCreatePrimarySurface(LPCWSTR Driver,
LPCWSTR Device) LPCWSTR Device)
{ {
PGD_ENABLEDRIVER GDEnableDriver; PGD_ENABLEDRIVER GDEnableDriver;
@ -389,7 +394,8 @@ BOOL STDCALL W32kCreatePrimarySurface(LPCWSTR Driver,
return TRUE; return TRUE;
} }
HDC STDCALL W32kCreateDC(LPCWSTR Driver, HDC STDCALL
W32kCreateDC(LPCWSTR Driver,
LPCWSTR Device, LPCWSTR Device,
LPCWSTR Output, LPCWSTR Output,
CONST PDEVMODEW InitData) CONST PDEVMODEW InitData)
@ -472,7 +478,8 @@ HDC STDCALL W32kCreateDC(LPCWSTR Driver,
return hNewDC; return hNewDC;
} }
HDC STDCALL W32kCreateIC(LPCWSTR Driver, HDC STDCALL
W32kCreateIC(LPCWSTR Driver,
LPCWSTR Device, LPCWSTR Device,
LPCWSTR Output, LPCWSTR Output,
CONST PDEVMODEW DevMode) CONST PDEVMODEW DevMode)
@ -481,7 +488,8 @@ HDC STDCALL W32kCreateIC(LPCWSTR Driver,
return W32kCreateDC(Driver, Device, Output, DevMode); return W32kCreateDC(Driver, Device, Output, DevMode);
} }
BOOL STDCALL W32kDeleteDC(HDC DCHandle) BOOL STDCALL
W32kDeleteDC(HDC DCHandle)
{ {
PDC DCToDelete; PDC DCToDelete;
@ -568,7 +576,8 @@ BOOL STDCALL W32kDeleteDC(HDC DCHandle)
return TRUE; return TRUE;
} }
INT STDCALL W32kDrawEscape(HDC hDC, INT STDCALL
W32kDrawEscape(HDC hDC,
INT nEscape, INT nEscape,
INT cbInput, INT cbInput,
LPCSTR lpszInData) LPCSTR lpszInData)
@ -576,7 +585,8 @@ INT STDCALL W32kDrawEscape(HDC hDC,
UNIMPLEMENTED; UNIMPLEMENTED;
} }
INT STDCALL W32kEnumObjects(HDC hDC, INT STDCALL
W32kEnumObjects(HDC hDC,
INT ObjectType, INT ObjectType,
GOBJENUMPROC ObjectFunc, GOBJENUMPROC ObjectFunc,
LPARAM lParam) LPARAM lParam)
@ -589,16 +599,16 @@ DC_GET_VAL( INT, W32kGetBkMode, w.backgroundMode )
DC_GET_VAL_EX( W32kGetBrushOrgEx, w.brushOrgX, w.brushOrgY, POINT ) DC_GET_VAL_EX( W32kGetBrushOrgEx, w.brushOrgX, w.brushOrgY, POINT )
DC_GET_VAL( HRGN, W32kGetClipRgn, w.hClipRgn ) DC_GET_VAL( HRGN, W32kGetClipRgn, w.hClipRgn )
HGDIOBJ STDCALL W32kGetCurrentObject(HDC hDC, HGDIOBJ STDCALL
UINT ObjectType) W32kGetCurrentObject(HDC hDC, UINT ObjectType)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
} }
DC_GET_VAL_EX( W32kGetCurrentPositionEx, w.CursPosX, w.CursPosY, POINT ) DC_GET_VAL_EX( W32kGetCurrentPositionEx, w.CursPosX, w.CursPosY, POINT )
BOOL STDCALL W32kGetDCOrgEx(HDC hDC, BOOL STDCALL
LPPOINT Point) W32kGetDCOrgEx(HDC hDC, LPPOINT Point)
{ {
PDC dc; PDC dc;
@ -620,7 +630,8 @@ BOOL STDCALL W32kGetDCOrgEx(HDC hDC,
return TRUE; return TRUE;
} }
HDC STDCALL W32kGetDCState16(HDC hDC) HDC STDCALL
W32kGetDCState16(HDC hDC)
{ {
PDC newdc, dc; PDC newdc, dc;
HDC hnewdc; HDC hnewdc;
@ -717,7 +728,8 @@ HDC STDCALL W32kGetDCState16(HDC hDC)
return hnewdc; return hnewdc;
} }
INT STDCALL W32kGetDeviceCaps(HDC hDC, INT STDCALL
W32kGetDeviceCaps(HDC hDC,
INT Index) INT Index)
{ {
PDC dc; PDC dc;
@ -925,7 +937,8 @@ INT STDCALL W32kGetDeviceCaps(HDC hDC,
DC_GET_VAL( INT, W32kGetMapMode, w.MapMode ) DC_GET_VAL( INT, W32kGetMapMode, w.MapMode )
DC_GET_VAL( INT, W32kGetPolyFillMode, w.polyFillMode ) DC_GET_VAL( INT, W32kGetPolyFillMode, w.polyFillMode )
INT STDCALL W32kGetObjectA(HANDLE handle, INT count, LPVOID buffer) INT STDCALL
W32kGetObjectA(HANDLE handle, INT count, LPVOID buffer)
{ {
PGDIOBJ gdiObject; PGDIOBJ gdiObject;
INT result = 0; INT result = 0;
@ -980,7 +993,8 @@ INT STDCALL W32kGetObjectA(HANDLE handle, INT count, LPVOID buffer)
return result; return result;
} }
INT STDCALL W32kGetObjectW(HANDLE handle, INT count, LPVOID buffer) INT STDCALL
W32kGetObjectW(HANDLE handle, INT count, LPVOID buffer)
{ {
PGDIOBJHDR gdiObject; PGDIOBJHDR gdiObject;
INT result = 0; INT result = 0;
@ -1023,12 +1037,14 @@ INT STDCALL W32kGetObjectW(HANDLE handle, INT count, LPVOID buffer)
return result; return result;
} }
INT STDCALL W32kGetObject(HANDLE handle, INT count, LPVOID buffer) INT STDCALL
W32kGetObject(HANDLE handle, INT count, LPVOID buffer)
{ {
return W32kGetObjectW(handle, count, buffer); return W32kGetObjectW(handle, count, buffer);
} }
DWORD STDCALL W32kGetObjectType(HANDLE handle) DWORD STDCALL
W32kGetObjectType(HANDLE handle)
{ {
GDIOBJHDR * ptr; GDIOBJHDR * ptr;
INT result = 0; INT result = 0;
@ -1095,12 +1111,14 @@ DC_GET_VAL_EX( W32kGetViewportOrgEx, vportOrgX, vportOrgY, POINT )
DC_GET_VAL_EX( W32kGetWindowExtEx, wndExtX, wndExtY, SIZE ) DC_GET_VAL_EX( W32kGetWindowExtEx, wndExtX, wndExtY, SIZE )
DC_GET_VAL_EX( W32kGetWindowOrgEx, wndOrgX, wndOrgY, POINT ) DC_GET_VAL_EX( W32kGetWindowOrgEx, wndOrgX, wndOrgY, POINT )
HDC STDCALL W32kResetDC(HDC hDC, CONST DEVMODEW *InitData) HDC STDCALL
W32kResetDC(HDC hDC, CONST DEVMODEW *InitData)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
} }
BOOL STDCALL W32kRestoreDC(HDC hDC, INT SaveLevel) BOOL STDCALL
W32kRestoreDC(HDC hDC, INT SaveLevel)
{ {
PDC dc, dcs; PDC dc, dcs;
BOOL success; BOOL success;
@ -1151,7 +1169,8 @@ BOOL STDCALL W32kRestoreDC(HDC hDC, INT SaveLevel)
return success; return success;
} }
INT STDCALL W32kSaveDC(HDC hDC) INT STDCALL
W32kSaveDC(HDC hDC)
{ {
HDC hdcs; HDC hdcs;
PDC dc, dcs; PDC dc, dcs;
@ -1192,7 +1211,8 @@ INT STDCALL W32kSaveDC(HDC hDC)
return ret; return ret;
} }
HGDIOBJ STDCALL W32kSelectObject(HDC hDC, HGDIOBJ hGDIObj) HGDIOBJ STDCALL
W32kSelectObject(HDC hDC, HGDIOBJ hGDIObj)
{ {
HGDIOBJ objOrg; HGDIOBJ objOrg;
BITMAPOBJ *pb; BITMAPOBJ *pb;
@ -1214,17 +1234,20 @@ HGDIOBJ STDCALL W32kSelectObject(HDC hDC, HGDIOBJ hGDIObj)
// FIXME: Get object handle from GDIObj and use it instead of GDIObj below? // FIXME: Get object handle from GDIObj and use it instead of GDIObj below?
switch(objectMagic) { switch(objectMagic)
{
case GO_PEN_MAGIC: case GO_PEN_MAGIC:
objOrg = (HGDIOBJ)dc->w.hPen; objOrg = (HGDIOBJ)dc->w.hPen;
dc->w.hPen = hGDIObj; dc->w.hPen = hGDIObj;
// Convert the color of the pen to the format of the DC // Convert the color of the pen to the format of the DC
PalGDI = (PPALGDI)AccessInternalObject((ULONG) dc->w.hPalette); PalGDI = (PPALGDI)AccessInternalObject((ULONG) dc->w.hPalette);
if( PalGDI ){ if( PalGDI )
{
XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalGDI->Mode, PAL_RGB, dc->w.hPalette, NULL); XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalGDI->Mode, PAL_RGB, dc->w.hPalette, NULL);
pen = GDIOBJ_LockObj(dc->w.hPen, GO_PEN_MAGIC); pen = GDIOBJ_LockObj(dc->w.hPen, GO_PEN_MAGIC);
if( pen ){ if( pen )
{
pen->logpen.lopnColor = XLATEOBJ_iXlate(XlateObj, pen->logpen.lopnColor); pen->logpen.lopnColor = XLATEOBJ_iXlate(XlateObj, pen->logpen.lopnColor);
} }
GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC); GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC);
@ -1238,10 +1261,12 @@ HGDIOBJ STDCALL W32kSelectObject(HDC hDC, HGDIOBJ hGDIObj)
// Convert the color of the brush to the format of the DC // Convert the color of the brush to the format of the DC
PalGDI = (PPALGDI)AccessInternalObject((ULONG) dc->w.hPalette); PalGDI = (PPALGDI)AccessInternalObject((ULONG) dc->w.hPalette);
if( PalGDI ){ if( PalGDI )
{
XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalGDI->Mode, PAL_RGB, dc->w.hPalette, NULL); XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalGDI->Mode, PAL_RGB, dc->w.hPalette, NULL);
brush = GDIOBJ_LockObj(dc->w.hBrush, GO_BRUSH_MAGIC); brush = GDIOBJ_LockObj(dc->w.hBrush, GO_BRUSH_MAGIC);
if( brush ){ if( brush )
{
brush->iSolidColor = XLATEOBJ_iXlate(XlateObj, brush->logbrush.lbColor); brush->iSolidColor = XLATEOBJ_iXlate(XlateObj, brush->logbrush.lbColor);
} }
GDIOBJ_UnlockObj( dc->w.hBrush, GO_BRUSH_MAGIC); GDIOBJ_UnlockObj( dc->w.hBrush, GO_BRUSH_MAGIC);
@ -1300,20 +1325,21 @@ HGDIOBJ STDCALL W32kSelectObject(HDC hDC, HGDIOBJ hGDIObj)
dc->w.bitsPerPixel = pb->bitmap.bmBitsPixel; dc->w.bitsPerPixel = pb->bitmap.bmBitsPixel;
} }
DC_ReleasePtr ( hDC );
hVisRgn = W32kCreateRectRgn(0, 0, pb->size.cx, pb->size.cy); hVisRgn = W32kCreateRectRgn(0, 0, pb->size.cx, pb->size.cy);
W32kSelectVisRgn(hDC, hVisRgn); W32kSelectVisRgn(hDC, hVisRgn);
W32kDeleteObject(hVisRgn); W32kDeleteObject(hVisRgn);
break; return objOrg;
#if UPDATEREGIONS #if UPDATEREGIONS
case GO_REGION_MAGIC: case GO_REGION_MAGIC:
/* objOrg = (HGDIOBJ)hDC->region; */ DC_ReleasePtr ( hDC );
objOrg = NULL; /* FIXME? hDC->region is destroyed below */
SelectClipRgn(hDC, (HRGN)hGDIObj); SelectClipRgn(hDC, (HRGN)hGDIObj);
break; return NULL;
#endif #endif
default: default:
DC_ReleasePtr ( hDC );
return NULL; return NULL;
} }
DC_ReleasePtr( hDC ); DC_ReleasePtr( hDC );
@ -1326,7 +1352,8 @@ DC_SET_MODE( W32kSetPolyFillMode, w.polyFillMode, ALTERNATE, WINDING )
DC_SET_MODE( W32kSetROP2, w.ROPmode, R2_BLACK, R2_WHITE ) DC_SET_MODE( W32kSetROP2, w.ROPmode, R2_BLACK, R2_WHITE )
DC_SET_MODE( W32kSetStretchBltMode, w.stretchBltMode, BLACKONWHITE, HALFTONE ) DC_SET_MODE( W32kSetStretchBltMode, w.stretchBltMode, BLACKONWHITE, HALFTONE )
COLORREF STDCALL W32kSetBkColor(HDC hDC, COLORREF color) COLORREF STDCALL
W32kSetBkColor(HDC hDC, COLORREF color)
{ {
COLORREF oldColor; COLORREF oldColor;
PDC dc = DC_HandleToPtr(hDC); PDC dc = DC_HandleToPtr(hDC);
@ -1342,7 +1369,8 @@ COLORREF STDCALL W32kSetBkColor(HDC hDC, COLORREF color)
return oldColor; return oldColor;
} }
STATIC VOID FASTCALL W32kSetDCState16(HDC hDC, HDC hDCSave) STATIC VOID FASTCALL
W32kSetDCState16(HDC hDC, HDC hDCSave)
{ {
PDC dc, dcs; PDC dc, dcs;
@ -1457,7 +1485,8 @@ STATIC VOID FASTCALL W32kSetDCState16(HDC hDC, HDC hDCSave)
// ---------------------------------------------------- Private Interface // ---------------------------------------------------- Private Interface
HDC FASTCALL DC_AllocDC(LPCWSTR Driver) HDC FASTCALL
DC_AllocDC(LPCWSTR Driver)
{ {
PDC NewDC; PDC NewDC;
HDC hDC; HDC hDC;
@ -1492,7 +1521,8 @@ HDC FASTCALL DC_AllocDC(LPCWSTR Driver)
return hDC; return hDC;
} }
HDC FASTCALL DC_FindOpenDC(LPCWSTR Driver) HDC FASTCALL
DC_FindOpenDC(LPCWSTR Driver)
{ {
return NULL; return NULL;
} }
@ -1500,7 +1530,8 @@ HDC FASTCALL DC_FindOpenDC(LPCWSTR Driver)
/*! /*!
* Initialize some common fields in the Device Context structure. * Initialize some common fields in the Device Context structure.
*/ */
VOID FASTCALL DC_InitDC(HDC DCHandle) VOID FASTCALL
DC_InitDC(HDC DCHandle)
{ {
// W32kRealizeDefaultPalette(DCHandle); // W32kRealizeDefaultPalette(DCHandle);
@ -1512,7 +1543,8 @@ VOID FASTCALL DC_InitDC(HDC DCHandle)
} }
VOID FASTCALL DC_FreeDC(HDC DCToFree) VOID FASTCALL
DC_FreeDC(HDC DCToFree)
{ {
if (!GDIOBJ_FreeObj(DCToFree, GO_DC_MAGIC, GDIOBJFLAG_DEFAULT)) if (!GDIOBJ_FreeObj(DCToFree, GO_DC_MAGIC, GDIOBJFLAG_DEFAULT))
{ {
@ -1520,19 +1552,22 @@ VOID FASTCALL DC_FreeDC(HDC DCToFree)
} }
} }
BOOL FASTCALL DC_InternalDeleteDC( PDC DCToDelete ) BOOL FASTCALL
DC_InternalDeleteDC( PDC DCToDelete )
{ {
if( DCToDelete->DriverName ) if( DCToDelete->DriverName )
ExFreePool(DCToDelete->DriverName); ExFreePool(DCToDelete->DriverName);
return TRUE; return TRUE;
} }
HDC FASTCALL DC_GetNextDC (PDC pDC) HDC FASTCALL
DC_GetNextDC (PDC pDC)
{ {
return pDC->hNext; return pDC->hNext;
} }
VOID FASTCALL DC_SetNextDC (PDC pDC, HDC hNextDC) VOID FASTCALL
DC_SetNextDC (PDC pDC, HDC hNextDC)
{ {
pDC->hNext = hNextDC; pDC->hNext = hNextDC;
} }