Added reference counting and deferred deletion for GDI objects.

svn path=/trunk/; revision=3215
This commit is contained in:
Eugene Ingerman 2002-07-13 21:37:27 +00:00
parent e39975e5f1
commit a0e70e46a2
26 changed files with 957 additions and 517 deletions

View file

@ -17,7 +17,7 @@ typedef struct _BITMAPOBJ
{
BITMAP bitmap;
SIZE size; /* For SetBitmapDimension() */
DDBITMAP *DDBitmap;
/* For device-independent bitmaps: */
@ -27,12 +27,16 @@ typedef struct _BITMAPOBJ
/* Internal interface */
#define BITMAPOBJ_AllocBitmap() \
((PBITMAPOBJ) GDIOBJ_AllocObject (sizeof (BITMAPOBJ), GO_BITMAP_MAGIC))
#define BITMAPOBJ_FreeBitmap(hBMObj) GDIOBJ_FreeObject((HGDIOBJ) hBMObj, GO_BITMAP_MAGIC)
((HBITMAP) GDIOBJ_AllocObj (sizeof (BITMAPOBJ), GO_BITMAP_MAGIC))
#define BITMAPOBJ_FreeBitmap(hBMObj) \
GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GO_BITMAP_MAGIC)
#define BITMAPOBJ_HandleToPtr(hBMObj) \
((PBITMAPOBJ) GDIOBJ_HandleToPtr ((HGDIOBJ) hBMObj, GO_BITMAP_MAGIC))
#define BITMAPOBJ_PtrToHandle(hBMObj) \
((HBITMAP) GDIOBJ_PtrToHandle ((PGDIOBJ) hBMObj, GO_BITMAP_MAGIC))
((PBITMAPOBJ) GDIOBJ_LockObj ((HGDIOBJ) hBMObj, GO_BITMAP_MAGIC))
#define BITMAPOBJ_ReleasePtr(hBMObj) \
GDIOBJ_UnlockObj ((HGDIOBJ) hBMObj, GO_BITMAP_MAGIC)
/*#define BITMAPOBJ_PtrToHandle(hBMObj) \
((HBITMAP) GDIOBJ_PtrToHandle ((PGDIOBJ) hBMObj, GO_BITMAP_MAGIC))*/
#define BITMAPOBJ_LockBitmap(hBMObj) GDIOBJ_LockObject ((HGDIOBJ) hBMObj)
#define BITMAPOBJ_UnlockBitmap(hBMObj) GDIOBJ_UnlockObject ((HGDIOBJ) hBMObj)
@ -41,6 +45,8 @@ HBITMAP BITMAPOBJ_CopyBitmap (HBITMAP hBitmap);
int DIB_GetDIBWidthBytes (int width, int depth);
int DIB_GetDIBImageBytes (int width, int height, int depth);
int DIB_BitmapInfoSize (const BITMAPINFO * info, WORD coloruse);
INT BITMAP_GetObject(BITMAPOBJ * bmp, INT count, LPVOID buffer);
BOOL Bitmap_InternalDelete( PBITMAPOBJ pBmp );
/* User Entry Points */
BOOL
@ -110,7 +116,7 @@ W32kExtFloodFill (
HDC hDC,
INT XStart,
INT YStart,
COLORREF Color,
COLORREF Color,
UINT FillType
);
BOOL
@ -169,7 +175,7 @@ W32kMaskBlt (
INT Width,
INT Height,
HDC hDCSrc,
INT XSrc,
INT XSrc,
INT YSrc,
HBITMAP hMaskBitmap,
INT xMask,
@ -181,13 +187,13 @@ STDCALL
W32kPlgBlt (
HDC hDCDest,
CONST POINT * Point,
HDC hDCSrc,
INT XSrc,
INT YSrc,
INT Width,
HDC hDCSrc,
INT XSrc,
INT YSrc,
INT Width,
INT Height,
HBITMAP hMaskBitmap,
INT xMask,
INT xMask,
INT yMask
);
LONG
@ -267,8 +273,8 @@ W32kStretchBlt (
HDC hDCSrc,
INT XOriginSrc,
INT YOriginSrc,
INT WidthSrc,
INT HeightSrc,
INT WidthSrc,
INT HeightSrc,
DWORD ROP
);
INT
@ -279,13 +285,13 @@ W32kStretchDIBits (
INT YDest,
INT DestWidth,
INT DestHeight,
INT XSrc,
INT YSrc,
INT SrcWidth,
INT SrcHeight,
INT XSrc,
INT YSrc,
INT SrcWidth,
INT SrcHeight,
CONST VOID * Bits,
CONST BITMAPINFO * BitsInfo,
UINT Usage,
UINT Usage,
DWORD ROP
);
#endif

View file

@ -8,14 +8,15 @@
#define NB_HATCH_STYLES 6
#define BRUSHOBJ_AllocBrush() \
((PBRUSHOBJ) GDIOBJ_AllocObject (sizeof (BRUSHOBJ), GO_BRUSH_MAGIC))
#define BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObject((HGDIOBJ)hBrush)
#define BRUSHOBJ_HandleToPtr(hBrush) \
((HBRUSH) GDIOBJ_AllocObj (sizeof (BRUSHOBJ), GO_BRUSH_MAGIC))
#define BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObj((HGDIOBJ)hBrush, GO_BRUSH_MAGIC)
/*#define BRUSHOBJ_HandleToPtr(hBrush) \
((PBRUSHOBJ) GDIOBJ_HandleToPtr ((HGDIOBJ) hBrush, GO_BRUSH_MAGIC))
#define BRUSHOBJ_PtrToHandle(pBrushObj) \
((HBRUSH) GDIOBJ_PtrToHandle ((PGDIOBJ) pBrushObj, GO_BRUSH_MAGIC))
#define BRUSHOBJ_LockBrush(hBrush) GDIOBJ_LockObject((HGDIOBJ)hBrush)
#define BRUSHOBJ_UnlockBrush(hBrush) GDIOBJ_UnlockObject((HGDIOBJ)hBrush)
*/
#define BRUSHOBJ_LockBrush(hBrush) GDIOBJ_LockObj((HGDIOBJ)hBrush, GO_BRUSH_MAGIC)
#define BRUSHOBJ_UnlockBrush(hBrush) GDIOBJ_UnlockObj((HGDIOBJ)hBrush, GO_BRUSH_MAGIC)
HBRUSH
STDCALL

View file

@ -39,7 +39,7 @@ typedef struct _DEVICECAPS
WORD pad2[6]; /* 92-102: reserved */
WORD sizePalette; /* 104: entries in system palette */
WORD numReserved; /* 106: reserved entries */
WORD colorRes; /* 108: color resolution */
WORD colorRes; /* 108: color resolution */
} DEVICECAPS, *PDEVICECAPS;
typedef struct _WIN_DC_INFO
@ -58,7 +58,7 @@ typedef struct _WIN_DC_INFO
// #if 0
HANDLE hDevice;
HPALETTE hPalette;
GdiPath path;
// #endif
@ -69,44 +69,44 @@ typedef struct _WIN_DC_INFO
WORD backgroundMode;
COLORREF backgroundColor;
COLORREF textColor;
short brushOrgX;
short brushOrgY;
WORD textAlign; /* Text alignment from SetTextAlign() */
short charExtra; /* Spacing from SetTextCharacterExtra() */
short breakTotalExtra; /* Total extra space for justification */
short breakCount; /* Break char. count */
short breakExtra; /* breakTotalExtra / breakCount */
short breakRem; /* breakTotalExtra % breakCount */
RECT totalExtent;
BYTE bitsPerPixel;
INT MapMode;
INT GraphicsMode; /* Graphics mode */
INT DCOrgX; /* DC origin */
INT DCOrgY;
#if 0
FARPROC lpfnPrint; /* AbortProc for Printing */
#endif
INT CursPosX; /* Current position */
INT CursPosY;
INT ArcDirection;
XFORM xformWorld2Wnd; /* World-to-window transformation */
XFORM xformWorld2Vport; /* World-to-viewport transformation */
XFORM xformVport2World; /* Inverse of the above transformation */
BOOL vport2WorldValid; /* Is xformVport2World valid? */
BOOL vport2WorldValid; /* Is xformVport2World valid? */
} WIN_DC_INFO;
/* DC flags */
#define DC_MEMORY 0x0001 /* It is a memory DC */
#define DC_SAVED 0x0002 /* It is a saved DC */
#define DC_DIRTY 0x0004 /* hVisRgn has to be updated */
#define DC_THUNKHOOK 0x0008 /* DC hook is in the 16-bit code */
#define DC_THUNKHOOK 0x0008 /* DC hook is in the 16-bit code */
#define GDI_DC_TYPE (1)
@ -114,7 +114,7 @@ typedef struct _DC
{
HDC hSelf;
HDC hNext;
DHPDEV PDev;
DHPDEV PDev;
DEVMODEW DMW;
HSURF FillPatternSurfaces[HS_DDI_MAX];
GDIINFO GDIInfo;
@ -124,7 +124,7 @@ typedef struct _DC
DRIVER_FUNCTIONS DriverFunctions;
PWSTR DriverName;
HANDLE DeviceDriver;
INT wndOrgX; /* Window origin */
INT wndOrgY;
INT wndExtX; /* Window extent */
@ -141,17 +141,24 @@ typedef struct _DC
/* Internal functions */
/*
#define DC_PtrToHandle(pDC) \
((HDC) GDIOBJ_PtrToHandle ((PGDIOBJ) pDC, GO_DC_MAGIC))
*/
#define DC_HandleToPtr(hDC) \
((PDC) GDIOBJ_HandleToPtr ((HGDIOBJ) hDC, GO_DC_MAGIC))
((PDC) GDIOBJ_LockObj ((HGDIOBJ) hDC, GO_DC_MAGIC))
#define DC_ReleasePtr(hDC) \
GDIOBJ_UnlockObj ((HGDIOBJ) hDC, GO_DC_MAGIC)
HDC RetrieveDisplayHDC(VOID);
PDC DC_AllocDC(LPCWSTR Driver);
void DC_InitDC(PDC DCToInit);
PDC DC_FindOpenDC(LPCWSTR Driver);
void DC_FreeDC(PDC DCToFree);
HDC DC_AllocDC(LPCWSTR Driver);
void DC_InitDC(HDC DCToInit);
HDC DC_FindOpenDC(LPCWSTR Driver);
void DC_FreeDC(HDC DCToFree);
HDC DC_GetNextDC (PDC pDC);
void DC_SetNextDC (PDC pDC, HDC hNextDC);
BOOL DC_InternalDeleteDC( PDC DCToDelete );
void DC_UpdateXforms(PDC dc);
BOOL DC_InvertXform(const XFORM *xformSrc, XFORM *xformDest);

View file

@ -4,7 +4,7 @@
* FILE: include/internal/debug.h
* PURPOSE: Useful debugging macros
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* UPDATE HISTORY:
* 28/05/98: Created
*/
@ -25,8 +25,10 @@
#ifndef NASSERT
#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); KeBugCheck(0); }
#define ASSERT(x) assert(x)
#else
#define assert(x)
#define ASSERT(x)
#endif
#define DPRINT1(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); ExAllocatePool(NonPagedPool,0); } while(0);
@ -81,16 +83,16 @@ extern unsigned int old_idt_valid;
* NOTES:
* The variable to watch must be aligned to its length (i.e. a dword
* breakpoint must be aligned to a dword boundary)
*
*
* A fatal exception will be generated on the access to the variable.
* It is (at the moment) only really useful for catching undefined
* pointers if you know the variable effected but not the buggy
* routine.
*
* routine.
*
* FIXME: Extend to call out to kernel debugger on breakpoint
* Add support for I/O breakpoints
* REFERENCES: See the i386 programmer manual for more details
*/
*/
void set_breakpoint(unsigned int i, unsigned int addr, unsigned int type,
unsigned int len);

View file

@ -1,6 +1,6 @@
/*
* GDI object common header definition
*
*
* (RJJ) taken from WINE
*/
@ -56,6 +56,7 @@
typedef struct _GDIOBJHDR
{
WORD wTableIndex;
DWORD dwCount; //reference count.
} GDIOBJHDR, *PGDIOBJHDR;
typedef PVOID PGDIOBJ;
@ -70,14 +71,15 @@ typedef struct _GDI_HANDLE_ENTRY
typedef struct _GDI_HANDLE_TABLE
{
WORD wTableSize;
GDI_HANDLE_ENTRY Handles [0];
GDI_HANDLE_ENTRY Handles [1];
} GDI_HANDLE_TABLE, *PGDI_HANDLE_TABLE;
PGDIOBJ GDIOBJ_AllocObject(WORD Size, WORD Magic);
BOOL GDIOBJ_FreeObject (PGDIOBJ Obj, WORD Magic);
HGDIOBJ GDIOBJ_PtrToHandle (PGDIOBJ Obj, WORD Magic);
PGDIOBJ GDIOBJ_HandleToPtr (HGDIOBJ Obj, WORD Magic);
HGDIOBJ GDIOBJ_AllocObj(WORD Size, WORD Magic);
BOOL GDIOBJ_FreeObj (HGDIOBJ Obj, WORD Magic);
PGDIOBJ GDIOBJ_LockObj (HGDIOBJ Obj, WORD Magic);
BOOL GDIOBJ_UnlockObj (HGDIOBJ Obj, WORD Magic);
WORD GDIOBJ_GetHandleMagic (HGDIOBJ ObjectHandle);
VOID STDCALL W32kDumpGdiObjects( INT Process );
#endif

View file

@ -13,14 +13,16 @@ typedef struct
/* Internal interface */
#define PENOBJ_AllocPen() \
((PPENOBJ) GDIOBJ_AllocObject (sizeof (PENOBJ), GO_PEN_MAGIC))
#define PENOBJ_FreePen(hBMObj) GDIOBJ_FreeObject((HGDIOBJ) hBMObj)
((HPEN) GDIOBJ_AllocObj (sizeof (PENOBJ), GO_PEN_MAGIC))
#define PENOBJ_FreePen(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj)
/*
#define PENOBJ_HandleToPtr(hBMObj) \
((PPENOBJ) GDIOBJ_HandleToPtr ((HGDIOBJ) hBMObj, GO_PEN_MAGIC))
#define PENOBJ_PtrToHandle(hBMObj) \
((HPEN) GDIOBJ_PtrToHandle ((PGDIOBJ) hBMObj, GO_PEN_MAGIC))
#define PENOBJ_LockPen(hBMObj) GDIOBJ_LockObject ((HGDIOBJ) hBMObj)
#define PENOBJ_UnlockPen(hBMObj) GDIOBJ_UnlockObject ((HGDIOBJ) hBMObj)
*/
#define PENOBJ_LockPen(hBMObj) ((PPENOBJ)GDIOBJ_LockObj ((HGDIOBJ) hBMObj, GO_PEN_MAGIC))
#define PENOBJ_UnlockPen(hBMObj) GDIOBJ_UnlockObj ((HGDIOBJ) hBMObj, GO_PEN_MAGIC)
HPEN STDCALL W32kCreatePen(INT PenStyle,
INT Width,

View file

@ -2,6 +2,28 @@
#ifndef __WIN32K_REGION_H
#define __WIN32K_REGION_H
#include <structs.h>
#include <win32k/gdiobj.h>
/* Internal functions */
/*
#define RGNDATA_PtrToHandle(pRgn) \
((HRGN) GDIOBJ_PtrToHandle ((PGDIOBJ) pRgn, GO_REGION_MAGIC))
*/
#define RGNDATA_HandleToPtr(hRgn) \
((RGNDATA *) GDIOBJ_LockObj ((HGDIOBJ) hRgn, GO_REGION_MAGIC))
/* call GDIOBJ_ReleaseObj when reference counting is added */
#define RGNDATA_Release(hRgn) {}
/* GDI logical region object */
typedef struct tagRGNOBJ
{
GDIOBJHDR header;
RGNDATA* rgn;
} RGNOBJ;
/* User entry points */
INT STDCALL
W32kGetBoxRgn(HRGN hRgn, PRECT Rect);
HRGN STDCALL
@ -124,4 +146,4 @@ W32kSetRectRgn(HRGN hRgn,
INT BottomRect);
#endif

View file

@ -11,14 +11,16 @@ typedef struct
/* Internal interface */
#define TEXTOBJ_AllocText() \
((PTEXTOBJ) GDIOBJ_AllocObject (sizeof (TEXTOBJ), GO_FONT_MAGIC))
#define TEXTOBJ_FreeText(hBMObj) GDIOBJ_FreeObject((HGDIOBJ) hBMObj)
((HFONT) GDIOBJ_AllocObj (sizeof (TEXTOBJ), GO_FONT_MAGIC))
#define TEXTOBJ_FreeText(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GO_FONT_MAGIC)
/*
#define TEXTOBJ_HandleToPtr(hBMObj) \
((PTEXTOBJ) GDIOBJ_HandleToPtr ((HGDIOBJ) hBMObj, GO_FONT_MAGIC))
#define TEXTOBJ_PtrToHandle(hBMObj) \
((HFONT) GDIOBJ_PtrToHandle ((PGDIOBJ) hBMObj, GO_FONT_MAGIC))
#define TEXTOBJ_LockText(hBMObj) GDIOBJ_LockObject ((HGDIOBJ) hBMObj)
#define TEXTOBJ_UnlockText(hBMObj) GDIOBJ_UnlockObject ((HGDIOBJ) hBMObj)
*/
#define TEXTOBJ_LockText(hBMObj) ((PTEXTOBJ) GDIOBJ_LockObj ((HGDIOBJ) hBMObj, GO_FONT_MAGIC))
#define TEXTOBJ_UnlockText(hBMObj) GDIOBJ_UnlockObj ((HGDIOBJ) hBMObj, GO_FONT_MAGIC)
int
STDCALL
@ -252,7 +254,7 @@ W32kTextOut(HDC hDC,
UINT
STDCALL
W32kTranslateCharsetInfo(PDWORD Src,
LPCHARSETINFO CSI,
LPCHARSETINFO CSI,
DWORD Flags);
#endif

View file

@ -20,3 +20,10 @@ CreatePenIndirect(CONST LOGPEN *lgpn)
{
return W32kCreatePenIndirect((CONST PLOGPEN)lgpn);
}
/*
VOID STDCALL
DumpGdiObjects( INT process )
{
W32kDumpGdiObjects( process );
}
*/

View file

@ -7,6 +7,9 @@
#include <win32k/bitmaps.h>
#include "../eng/objects.h"
//#define NDEBUG
#include <win32k/debug1.h>
// #include "grfont.h"
// #include <string.h>
@ -275,6 +278,8 @@ const unsigned char font_8x8[2048] =
static PSURFOBJ CharCellSurfObj;
static HBITMAP hCharCellBitmap;
VOID BitmapToSurf(HDC hdc, PSURFGDI SurfGDI, PSURFOBJ SurfObj, PBITMAPOBJ Bitmap);
// Set things up for a character cell surface
void CreateCellCharSurface()
{
@ -287,9 +292,10 @@ void CreateCellCharSurface()
hCharCellBitmap = W32kCreateBitmap(8, 8, 1, 8, NULL); // 8x8, 1 plane, 8 bits per pel
pbo = BITMAPOBJ_HandleToPtr(hCharCellBitmap);
ASSERT( pbo );
// VOID BitmapToSurf(HDC hdc, PSURFGDI SurfGDI, PSURFOBJ SurfObj, PBITMAPOBJ Bitmap)
BitmapToSurf(0, surfgdi, CharCellSurfObj, pbo); // Make the bitmap a surface
BITMAPOBJ_ReleasePtr( hCharCellBitmap );
}
void grWriteCellChar(PSURFOBJ target,

View file

@ -1,5 +1,5 @@
/* $Id: dllmain.c,v 1.26 2002/07/04 19:56:37 dwelch Exp $
*
/* $Id: dllmain.c,v 1.27 2002/07/13 21:37:26 ei Exp $
*
* Entry Point for win32k.sys
*/
@ -17,6 +17,9 @@
#include <include/class.h>
#include <include/window.h>
//#define NDEBUG
#include <win32k/debug1.h>
extern SSDT Win32kSSDT[];
extern SSPT Win32kSSPT[];
extern ULONG Win32kNumberOfSysCalls;
@ -94,6 +97,7 @@ BOOLEAN
STDCALL
W32kInitialize (VOID)
{
DPRINT("in W32kInitialize\n");
InitGdiObjectHandleTable ();
// Create surface used to draw the internal font onto

View file

@ -5,8 +5,8 @@
//#include <win32k/debug.h>
#include "../eng/objects.h"
#define NDEBUG
#include <debug.h>
//#define NDEBUG
#include <win32k/debug1.h>
BOOL STDCALL W32kBitBlt(HDC hDCDest,
INT XDest,
@ -85,6 +85,9 @@ BOOL STDCALL W32kBitBlt(HDC hDCDest,
if(SurfDestAlloc == TRUE) ExFreePool(SurfDest);
if(SurfSrcAlloc == TRUE) ExFreePool(SurfSrc);
DC_ReleasePtr(hDCDest);
DC_ReleasePtr(hDCSrc);
return Status;
}
@ -101,31 +104,34 @@ HBITMAP STDCALL W32kCreateBitmap(INT Width,
BitsPerPel = (BYTE) BitsPerPel;
/* Check parameters */
if (!Height || !Width)
if (!Height || !Width)
{
return 0;
}
if (Planes != 1)
if (Planes != 1)
{
UNIMPLEMENTED;
return 0;
}
if (Height < 0)
if (Height < 0)
{
Height = -Height;
}
if (Width < 0)
if (Width < 0)
{
Width = -Width;
}
/* Create the BITMAPOBJ */
bmp = BITMAPOBJ_AllocBitmap ();
if (!bmp)
hBitmap = BITMAPOBJ_AllocBitmap ();
if (!hBitmap)
{
DPRINT("W32kCreateBitmap: BITMAPOBJ_AllocBitmap returned 0\n");
return 0;
}
bmp = BITMAPOBJ_HandleToPtr( hBitmap );
DPRINT("W32kCreateBitmap:%dx%d, %d (%d BPP) colors returning %08x\n", Width, Height,
1 << (Planes * BitsPerPel), BitsPerPel, bmp);
@ -140,7 +146,6 @@ HBITMAP STDCALL W32kCreateBitmap(INT Width,
bmp->bitmap.bmBits = NULL;
bmp->DDBitmap = NULL;
bmp->dib = NULL;
hBitmap = BITMAPOBJ_PtrToHandle (bmp);
// Allocate memory for bitmap bits
bmp->bitmap.bmBits = ExAllocatePool(PagedPool, bmp->bitmap.bmWidthBytes * bmp->bitmap.bmHeight);
@ -150,9 +155,19 @@ HBITMAP STDCALL W32kCreateBitmap(INT Width,
W32kSetBitmapBits(hBitmap, Height * bmp->bitmap.bmWidthBytes, Bits);
}
BITMAPOBJ_ReleasePtr( hBitmap );
return hBitmap;
}
BOOL Bitmap_InternalDelete( PBITMAPOBJ pBmp )
{
ASSERT( pBmp );
ExFreePool(pBmp->bitmap.bmBits);
return TRUE;
}
HBITMAP STDCALL W32kCreateCompatibleBitmap(HDC hDC,
INT Width,
INT Height)
@ -169,33 +184,33 @@ HBITMAP STDCALL W32kCreateCompatibleBitmap(HDC hDC,
{
return 0;
}
if ((Width >= 0x10000) || (Height >= 0x10000))
if ((Width >= 0x10000) || (Height >= 0x10000))
{
DPRINT("got bad width %d or height %d, please look for reason\n", Width, Height);
}
else
else
{
/* MS doc says if width or height is 0, return 1-by-1 pixel, monochrome bitmap */
if (!Width || !Height)
{
hbmpRet = W32kCreateBitmap (1, 1, 1, 1, NULL);
}
else
else
{
hbmpRet = W32kCreateBitmap(Width, Height, 1, dc->w.bitsPerPixel, NULL);
}
}
DPRINT ("\t\t%04x\n", hbmpRet);
DC_ReleasePtr( hDC );
return hbmpRet;
}
HBITMAP STDCALL W32kCreateBitmapIndirect(CONST BITMAP *BM)
{
return W32kCreateBitmap (BM->bmWidth,
BM->bmHeight,
return W32kCreateBitmap (BM->bmWidth,
BM->bmHeight,
BM->bmPlanes,
BM->bmBitsPixel,
BM->bmBitsPixel,
BM->bmBits);
}
@ -210,7 +225,7 @@ HBITMAP STDCALL W32kCreateDiscardableBitmap(HDC hDC,
BOOL STDCALL W32kExtFloodFill(HDC hDC,
INT XStart,
INT YStart,
COLORREF Color,
COLORREF Color,
UINT FillType)
{
UNIMPLEMENTED;
@ -228,13 +243,13 @@ BOOL STDCALL W32kGetBitmapDimensionEx(HBITMAP hBitmap,
LPSIZE Dimension)
{
PBITMAPOBJ bmp;
bmp = BITMAPOBJ_HandleToPtr (hBitmap);
if (bmp == NULL)
if (bmp == NULL)
{
return FALSE;
}
*Dimension = bmp->size;
return TRUE;
@ -253,7 +268,7 @@ BOOL STDCALL W32kMaskBlt(HDC hDCDest,
INT Width,
INT Height,
HDC hDCSrc,
INT XSrc,
INT XSrc,
INT YSrc,
HBITMAP hMaskBitmap,
INT xMask,
@ -265,13 +280,13 @@ BOOL STDCALL W32kMaskBlt(HDC hDCDest,
BOOL STDCALL W32kPlgBlt(HDC hDCDest,
CONST POINT *Point,
HDC hDCSrc,
INT XSrc,
INT YSrc,
INT Width,
HDC hDCSrc,
INT XSrc,
INT YSrc,
INT Width,
INT Height,
HBITMAP hMaskBitmap,
INT xMask,
INT xMask,
INT yMask)
{
UNIMPLEMENTED;
@ -283,14 +298,14 @@ LONG STDCALL W32kSetBitmapBits(HBITMAP hBitmap,
{
DWORD height, ret;
PBITMAPOBJ bmp;
bmp = BITMAPOBJ_HandleToPtr (hBitmap);
if (bmp == NULL || Bits == NULL)
{
return 0;
}
if (Bytes < 0)
if (Bytes < 0)
{
DPRINT ("(%ld): Negative number of bytes passed???\n", Bytes );
Bytes = -Bytes;
@ -298,35 +313,35 @@ LONG STDCALL W32kSetBitmapBits(HBITMAP hBitmap,
/* Only get entire lines */
height = Bytes / bmp->bitmap.bmWidthBytes;
if (height > bmp->bitmap.bmHeight)
if (height > bmp->bitmap.bmHeight)
{
height = bmp->bitmap.bmHeight;
}
Bytes = height * bmp->bitmap.bmWidthBytes;
DPRINT ("(%08x, bytes:%ld, bits:%p) %dx%d %d colors fetched height: %ld\n",
hBitmap,
Bytes,
Bits,
bmp->bitmap.bmWidth,
hBitmap,
Bytes,
Bits,
bmp->bitmap.bmWidth,
bmp->bitmap.bmHeight,
1 << bmp->bitmap.bmBitsPixel,
1 << bmp->bitmap.bmBitsPixel,
height);
#if 0
/* FIXME: call DDI specific function here if available */
if(bmp->DDBitmap)
if(bmp->DDBitmap)
{
DPRINT ("Calling device specific BitmapBits\n");
if (bmp->DDBitmap->funcs->pBitmapBits)
{
ret = bmp->DDBitmap->funcs->pBitmapBits(hBitmap, (void *) Bits, Bytes, DDB_SET);
}
else
}
else
{
DPRINT ("BitmapBits == NULL??\n");
ret = 0;
}
}
}
else
#endif
{
@ -335,12 +350,12 @@ LONG STDCALL W32kSetBitmapBits(HBITMAP hBitmap,
{
bmp->bitmap.bmBits = ExAllocatePool (PagedPool, Bytes);
}
if(!bmp->bitmap.bmBits)
if(!bmp->bitmap.bmBits)
{
DPRINT ("Unable to allocate bit buffer\n");
ret = 0;
}
else
}
else
{
memcpy(bmp->bitmap.bmBits, Bits, Bytes);
ret = Bytes;
@ -356,14 +371,14 @@ BOOL STDCALL W32kSetBitmapDimensionEx(HBITMAP hBitmap,
LPSIZE Size)
{
PBITMAPOBJ bmp;
bmp = BITMAPOBJ_HandleToPtr (hBitmap);
if (bmp == NULL)
if (bmp == NULL)
{
return FALSE;
}
if (Size)
if (Size)
{
*Size = bmp->size;
}
@ -397,8 +412,8 @@ BOOL STDCALL W32kStretchBlt(HDC hDCDest,
HDC hDCSrc,
INT XOriginSrc,
INT YOriginSrc,
INT WidthSrc,
INT HeightSrc,
INT WidthSrc,
INT HeightSrc,
DWORD ROP)
{
UNIMPLEMENTED;
@ -406,29 +421,29 @@ BOOL STDCALL W32kStretchBlt(HDC hDCDest,
/* Internal Functions */
INT
INT
BITMAPOBJ_GetWidthBytes (INT bmWidth, INT bpp)
{
switch(bpp)
{
case 1:
return 2 * ((bmWidth+15) >> 4);
case 24:
bmWidth *= 3; /* fall through */
case 8:
return bmWidth + (bmWidth & 1);
case 32:
return bmWidth * 4;
case 16:
case 15:
return bmWidth * 2;
case 4:
return 2 * ((bmWidth+3) >> 2);
default:
DPRINT ("stub");
}
@ -443,19 +458,19 @@ HBITMAP BITMAPOBJ_CopyBitmap(HBITMAP hBitmap)
BITMAP bm;
bmp = BITMAPOBJ_HandleToPtr (hBitmap);
if (bmp == NULL)
if (bmp == NULL)
{
return 0;
}
res = 0;
bm = bmp->bitmap;
bm.bmBits = NULL;
res = W32kCreateBitmapIndirect(&bm);
if(res)
if(res)
{
char *buf;
buf = ExAllocatePool (NonPagedPool, bm.bmWidthBytes * bm.bmHeight);
W32kGetBitmapBits (hBitmap, bm.bmWidthBytes * bm.bmHeight, buf);
W32kSetBitmapBits (res, bm.bmWidthBytes * bm.bmHeight, buf);

View file

@ -1,4 +1,4 @@
/* $Id: brush.c,v 1.13 2001/11/02 06:10:11 rex Exp $
/* $Id: brush.c,v 1.14 2002/07/13 21:37:26 ei Exp $
*/
@ -17,20 +17,25 @@ HBRUSH STDCALL W32kCreateBrushIndirect(CONST LOGBRUSH *lb)
PBRUSHOBJ brushPtr;
HBRUSH hBrush;
brushPtr = BRUSHOBJ_AllocBrush();
hBrush = BRUSHOBJ_PtrToHandle (brushPtr);
hBrush = BRUSHOBJ_AllocBrush();
if (hBrush == NULL)
{
return 0;
}
brushPtr->iSolidColor = lb->lbColor;
brushPtr->logbrush.lbStyle = lb->lbStyle;
brushPtr->logbrush.lbColor = lb->lbColor;
brushPtr->logbrush.lbHatch = lb->lbHatch;
brushPtr = BRUSHOBJ_LockBrush (hBrush);
ASSERT( brushPtr ); //I want to know if this ever occurs
return hBrush;
if( brushPtr ){
brushPtr->iSolidColor = lb->lbColor;
brushPtr->logbrush.lbStyle = lb->lbStyle;
brushPtr->logbrush.lbColor = lb->lbColor;
brushPtr->logbrush.lbHatch = lb->lbHatch;
BRUSHOBJ_UnlockBrush( hBrush );
return hBrush;
}
return NULL;
}
HBRUSH STDCALL W32kCreateDIBPatternBrush(HGLOBAL hDIBPacked,
@ -41,7 +46,7 @@ HBRUSH STDCALL W32kCreateDIBPatternBrush(HGLOBAL hDIBPacked,
LOGBRUSH logbrush;
PBITMAPINFO info, newInfo;
INT size;
DPRINT("%04x\n", hbitmap );
logbrush.lbStyle = BS_DIBPATTERN;
@ -49,11 +54,11 @@ HBRUSH STDCALL W32kCreateDIBPatternBrush(HGLOBAL hDIBPacked,
logbrush.lbHatch = 0;
/* Make a copy of the bitmap */
if (!(info = (BITMAPINFO *)GlobalLock( hbitmap )))
if (!(info = (BITMAPINFO *)GlobalLock( hbitmap )))
{
return 0;
}
if (info->bmiHeader.biCompression) size = info->bmiHeader.biSizeImage;
else
@ -80,16 +85,16 @@ HBRUSH STDCALL W32kCreateDIBPatternBrushPt(CONST VOID *PackedDIB,
LOGBRUSH logbrush;
PBITMAPINFO info;
PBITMAPINFO newInfo;
info = (BITMAPINFO *) PackedDIB;
if (info == NULL)
{
return 0;
}
DPRINT ("%p %ldx%ld %dbpp\n",
info,
DPRINT ("%p %ldx%ld %dbpp\n",
info,
info->bmiHeader.biWidth,
info->bmiHeader.biHeight,
info->bmiHeader.biHeight,
info->bmiHeader.biBitCount);
logbrush.lbStyle = BS_DIBPATTERN;
@ -107,15 +112,17 @@ HBRUSH STDCALL W32kCreateDIBPatternBrushPt(CONST VOID *PackedDIB,
size = DIB_GetDIBImageBytes (info->bmiHeader.biWidth, info->bmiHeader.biHeight, info->bmiHeader.biBitCount);
}
size += DIB_BitmapInfoSize (info, Usage);
logbrush.lbHatch = (INT)GDIOBJ_PtrToHandle (GDIOBJ_AllocObject (size, GO_MAGIC_DONTCARE), GO_MAGIC_DONTCARE);
logbrush.lbHatch = (LONG) GDIOBJ_AllocObj(size, GO_MAGIC_DONTCARE);
if (logbrush.lbHatch == 0)
{
return 0;
}
newInfo = (PBITMAPINFO) GDIOBJ_HandleToPtr ((HGDIOBJ) logbrush.lbHatch, GO_MAGIC_DONTCARE);
newInfo = (PBITMAPINFO) GDIOBJ_LockObj ((HGDIOBJ) logbrush.lbHatch, GO_MAGIC_DONTCARE);
ASSERT(newInfo);
memcpy(newInfo, info, size);
GDIOBJ_UnlockObj( (HGDIOBJ) logbrush.lbHatch, GO_MAGIC_DONTCARE );
return W32kCreateBrushIndirect (&logbrush);
}
@ -133,7 +140,7 @@ HBRUSH STDCALL W32kCreateHatchBrush(INT Style,
logbrush.lbStyle = BS_HATCHED;
logbrush.lbColor = Color;
logbrush.lbHatch = Style;
return W32kCreateBrushIndirect (&logbrush);
}

View file

@ -3,11 +3,56 @@
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ddk/ntddk.h>
#include <win32k/dc.h>
#include <win32k/cliprgn.h>
// #define NDEBUG
#include <win32k/debug1.h>
HRGN WINAPI SaveVisRgn(HDC hdc)
{
HRGN copy;
PRGNDATA obj, copyObj;
PDC dc = DC_HandleToPtr(hdc);
/*ei
if (!dc) return 0;
obj = RGNDATA_HandleToPtr(dc->w.hVisRgn);
if(!(copy = CreateRectRgn(0, 0, 0, 0)))
{
GDI_ReleaseObj(dc->w.hVisRgn);
GDI_ReleaseObj(hdc);
return 0;
}
CombineRgn(copy, dc->w.hVisRgn, 0, RGN_COPY);
copyObj = RGNDATA_HandleToPtr(copy);
*/
/* copyObj->header.hNext = obj->header.hNext;
header.hNext = copy; */
DC_ReleasePtr( hdc );
return copy;
}
INT16 WINAPI SelectVisRgn(HDC hdc, HRGN hrgn)
{
return ERROR;
/*ei
int retval;
DC *dc;
if (!hrgn) return ERROR;
if (!(dc = DC_HandleToPtr(hdc))) return ERROR;
dc->flags &= ~DC_DIRTY;
retval = CombineRgn(dc->hVisRgn, hrgn, 0, RGN_COPY);
CLIPPING_UpdateGCRegion(dc);
return retval;
*/
}
int STDCALL W32kExcludeClipRect(HDC hDC,
int LeftRect,
int TopRect,

View file

@ -19,7 +19,7 @@ int COLOR_max = 256;
static HPALETTE hPrimaryPalette = 0; // used for WM_PALETTECHANGED
static HPALETTE hLastRealizedPalette = 0; // UnrealizeObject() needs it
const PALETTEENTRY COLOR_sysPalTemplate[NB_RESERVED_COLORS] =
const PALETTEENTRY COLOR_sysPalTemplate[NB_RESERVED_COLORS] =
{
// first 10 entries in the system palette
// red green blue flags
@ -50,6 +50,10 @@ const PALETTEENTRY COLOR_sysPalTemplate[NB_RESERVED_COLORS] =
{ 0xff, 0xff, 0xff, PC_SYS_USED } // last 10
};
//forward declarations
COLORREF COLOR_LookupNearestColor( PALETTEENTRY* palPalEntry, int size, COLORREF color );
const PALETTEENTRY* COLOR_GetSystemPaletteTemplate(void)
{
return (const PALETTEENTRY*)&COLOR_sysPalTemplate;
@ -102,7 +106,7 @@ HPALETTE STDCALL W32kCreateHalftonePalette(HDC hDC)
Palette.aEntries[i].peRed = r * 51;
Palette.aEntries[i].peGreen = g * 51;
Palette.aEntries[i].peBlue = b * 51;
}
}
}
}
@ -120,7 +124,7 @@ HPALETTE STDCALL W32kCreatePalette(CONST PLOGPALETTE palette)
{
PPALOBJ PalObj;
HPALETTE NewPalette = (HPALETTE)EngCreatePalette(PAL_INDEXED, palette->palNumEntries, palette->palPalEntry, 0, 0, 0);
HPALETTE NewPalette = (HPALETTE)EngCreatePalette(PAL_INDEXED, palette->palNumEntries, (PULONG*) palette->palPalEntry, 0, 0, 0);
ULONG size;
PalObj = (PPALOBJ)AccessUserObject(NewPalette);
@ -147,7 +151,7 @@ COLORREF STDCALL W32kGetNearestColor(HDC hDC,
PDC dc;
PPALOBJ palObj;
if(DC_HandleToPtr(hDC))
if( (dc = DC_HandleToPtr(hDC) ) )
{
HPALETTE hpal = (dc->w.hPalette)? dc->w.hPalette : W32kGetStockObject(DEFAULT_PALETTE);
palObj = (PPALOBJ)AccessUserObject(hpal);
@ -158,9 +162,9 @@ COLORREF STDCALL W32kGetNearestColor(HDC hDC,
nearest = COLOR_LookupNearestColor(palObj->logpalette->palPalEntry,
palObj->logpalette->palNumEntries, Color);
// FIXME: release hpal!!
// GDI_ReleaseObj( hpal );
// GDI_ReleaseObj( hdc );
DC_ReleasePtr( hDC );
}
return nearest;
@ -196,8 +200,8 @@ UINT STDCALL W32kGetPaletteEntries(HPALETTE hpal,
numEntries = palPtr->logpalette->palNumEntries;
if (StartIndex + Entries > numEntries) Entries = numEntries - StartIndex;
if (pe)
{
if (StartIndex >= numEntries)
{
if (StartIndex >= numEntries)
{
// GDI_ReleaseObj( hpalette );
return 0;
@ -253,7 +257,7 @@ UINT STDCALL W32kGetSystemPaletteUse(HDC hDC)
UINT STDCALL W32kRealizePalette(HDC hDC)
/*
The RealizePalette function modifies the palette for the device associated with the specified device context. If the device context is a memory DC, the color table for the bitmap selected into the DC is modified. If the device context is a display DC, the physical palette for that device is modified.
The RealizePalette function modifies the palette for the device associated with the specified device context. If the device context is a memory DC, the color table for the bitmap selected into the DC is modified. If the device context is a display DC, the physical palette for that device is modified.
A logical palette is a buffer between color-intensive applications and the system, allowing these applications to use as many colors as needed without interfering with colors displayed by other windows.
@ -332,13 +336,13 @@ BOOL STDCALL W32kResizePalette(HPALETTE hpal,
prevsize = sizeof(LOGPALETTE) + (cPrevEnt - 1) * sizeof(PALETTEENTRY) + sizeof(int*) + sizeof(GDIOBJHDR);
size += sizeof(int*) + sizeof(GDIOBJHDR);
XlateObj = palPtr->logicalToSystem;
if (!(palPtr = GDI_ReallocObject(size, hPal, palPtr))) return FALSE;
if(XlateObj)
{
PXLATEOBJ NewXlateObj = (int*) HeapReAlloc(GetProcessHeap(), 0, XlateObj, cEntries * sizeof(int));
if(NewXlateObj == NULL)
if(NewXlateObj == NULL)
{
ERR("Can not resize logicalToSystem -- out of memory!");
GDI_ReleaseObj( hPal );
@ -475,7 +479,7 @@ COLORREF COLOR_LookupNearestColor( PALETTEENTRY* palPalEntry, int size, COLORREF
else if( spec_type == 1 ) /* PALETTEINDEX */
{
if( (i = color & 0x0000ffff) >= size )
if( (i = color & 0x0000ffff) >= size )
{
DbgPrint("RGB(%lx) : idx %d is out of bounds, assuming NULL\n", color, i);
color = *(COLORREF*)palPalEntry;

View file

@ -1,4 +1,4 @@
/* $Id: coord.c,v 1.7 2002/07/04 19:56:37 dwelch Exp $
/* $Id: coord.c,v 1.8 2002/07/13 21:37:26 ei Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -24,7 +24,7 @@ BOOL STDCALL W32kCombineTransform(LPXFORM XFormResult,
CONST LPXFORM xform2)
{
XFORM xformTemp;
/* Check for illegal parameters */
if (!XFormResult || !xform1 || !xform2)
{
@ -47,34 +47,35 @@ BOOL STDCALL W32kCombineTransform(LPXFORM XFormResult,
VOID STATIC
CoordDPtoLP(PDC Dc, LPPOINT Point)
{
{
FLOAT x, y;
x = (FLOAT)Point->x;
y = (FLOAT)Point->y;
Point->x = x * Dc->w.xformVport2World.eM11 +
y * Dc->w.xformVport2World.eM21 + Dc->w.xformVport2World.eDx;
Point->y = x * Dc->w.xformVport2World.eM12 +
y * Dc->w.xformVport2World.eM22 + Dc->w.xformVport2World.eDy;
y * Dc->w.xformVport2World.eM22 + Dc->w.xformVport2World.eDy;
}
BOOL STDCALL
BOOL STDCALL
W32kDPtoLP(HDC hDC,
LPPOINT Points,
int Count)
{
PDC Dc;
PDC Dc;
ULONG i;
Dc = DC_HandleToPtr (hDC);
if (Dc == NULL || !Dc->w.vport2WorldValid)
if (Dc == NULL || !Dc->w.vport2WorldValid)
{
return(FALSE);
}
for (i = 0; i < Count; i++)
{
CoordDPtoLP(Dc, &Points[i]);
}
DC_ReleasePtr( hDC );
return(TRUE);
}
@ -84,15 +85,15 @@ W32kGetGraphicsMode(HDC hDC)
{
PDC dc;
int GraphicsMode;
dc = DC_HandleToPtr (hDC);
if (!dc)
if (!dc)
{
return 0;
}
GraphicsMode = dc->w.GraphicsMode;
DC_ReleasePtr( hDC );
return GraphicsMode;
}
@ -102,7 +103,7 @@ W32kGetWorldTransform(HDC hDC,
LPXFORM XForm)
{
PDC dc;
dc = DC_HandleToPtr (hDC);
if (!dc)
{
@ -113,7 +114,7 @@ W32kGetWorldTransform(HDC hDC,
return FALSE;
}
*XForm = dc->w.xformWorld2Wnd;
DC_ReleasePtr( hDC );
return TRUE;
}
@ -132,19 +133,20 @@ CoordLPtoDP(PDC Dc, LPPOINT Point)
BOOL STDCALL
W32kLPtoDP(HDC hDC, LPPOINT Points, INT Count)
{
PDC Dc;
PDC Dc;
ULONG i;
Dc = DC_HandleToPtr (hDC);
if (Dc == NULL)
if (Dc == NULL)
{
return(FALSE);
}
for (i = 0; i < Count; i++)
{
CoordLPtoDP(Dc, &Points[i]);
}
DC_ReleasePtr( hDC );
return(TRUE);
}
@ -155,7 +157,7 @@ W32kModifyWorldTransform(HDC hDC,
DWORD Mode)
{
PDC dc;
dc = DC_HandleToPtr (hDC);
if (!dc)
{
@ -166,7 +168,7 @@ W32kModifyWorldTransform(HDC hDC,
{
return FALSE;
}
/* Check that graphics mode is GM_ADVANCED */
if (dc->w.GraphicsMode!=GM_ADVANCED)
{
@ -178,24 +180,25 @@ W32kModifyWorldTransform(HDC hDC,
dc->w.xformWorld2Wnd.eM11 = 1.0f;
dc->w.xformWorld2Wnd.eM12 = 0.0f;
dc->w.xformWorld2Wnd.eM21 = 0.0f;
dc->w.xformWorld2Wnd.eM22 = 1.0f;
dc->w.xformWorld2Wnd.eM22 = 1.0f;
dc->w.xformWorld2Wnd.eDx = 0.0f;
dc->w.xformWorld2Wnd.eDy = 0.0f;
break;
case MWT_LEFTMULTIPLY:
W32kCombineTransform(&dc->w.xformWorld2Wnd, XForm, &dc->w.xformWorld2Wnd );
break;
case MWT_RIGHTMULTIPLY:
W32kCombineTransform(&dc->w.xformWorld2Wnd, &dc->w.xformWorld2Wnd, XForm);
break;
default:
DC_ReleasePtr( hDC );
return FALSE;
}
DC_UpdateXforms (dc);
DC_ReleasePtr( hDC );
return TRUE;
}
@ -250,7 +253,7 @@ W32kSetGraphicsMode(HDC hDC,
{
INT ret;
DC *dc;
dc = DC_HandleToPtr (hDC);
if (!dc)
{
@ -262,14 +265,15 @@ W32kSetGraphicsMode(HDC hDC,
* matrix. However, in Windows, this is not the case. This doesn't
* make a lot of sense to me, but that's the way it is.
*/
if ((Mode != GM_COMPATIBLE) && (Mode != GM_ADVANCED))
if ((Mode != GM_COMPATIBLE) && (Mode != GM_ADVANCED))
{
DC_ReleasePtr( hDC );
return 0;
}
ret = dc->w.GraphicsMode;
dc->w.GraphicsMode = Mode;
DC_ReleasePtr( hDC );
return ret;
}
@ -327,26 +331,27 @@ W32kSetWorldTransform(HDC hDC,
CONST LPXFORM XForm)
{
PDC dc;
dc = DC_HandleToPtr (hDC);
if (!dc)
{
// SetLastError( ERROR_INVALID_HANDLE );
return FALSE;
}
if (!XForm)
{
DC_ReleasePtr( hDC );
return FALSE;
}
/* Check that graphics mode is GM_ADVANCED */
if (dc->w.GraphicsMode != GM_ADVANCED)
{
DC_ReleasePtr( hDC );
return FALSE;
}
dc->w.xformWorld2Wnd = *XForm;
DC_UpdateXforms (dc);
DC_ReleasePtr( hDC );
return TRUE;
}

View file

@ -1,7 +1,7 @@
/* $Id: dc.c,v 1.31 2002/02/16 00:51:02 jfilby Exp $
/* $Id: dc.c,v 1.32 2002/07/13 21:37:26 ei Exp $
*
* DC.C - Device context functions
*
*
*/
#undef WIN32_LEAN_AND_MEAN
@ -19,9 +19,10 @@
#include <win32k/text.h>
#include "../eng/objects.h"
#define NDEBUG
//#define NDEBUG
#include <win32k/debug1.h>
/* FIXME: DCs should probably be thread safe */
/*
@ -39,11 +40,12 @@ func_type STDCALL func_name( HDC hdc ) \
return 0; \
} \
ft = dc->dc_field; \
DC_ReleasePtr( hdc ); \
return ft; \
}
/* 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
/* 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
* we can do whatever we want.
*/
#define DC_GET_VAL_EX( func_name, ret_x, ret_y, type ) \
@ -56,6 +58,7 @@ BOOL STDCALL func_name( HDC hdc, LP##type pt ) \
} \
((LPPOINT)pt)->x = dc->ret_x; \
((LPPOINT)pt)->y = dc->ret_y; \
DC_ReleasePtr( hdc ); \
return TRUE; \
}
@ -74,9 +77,12 @@ INT STDCALL func_name( HDC hdc, INT mode ) \
} \
prevMode = dc->dc_field; \
dc->dc_field = mode; \
DC_ReleasePtr( hdc ); \
return prevMode; \
}
VOID BitmapToSurf(HDC hdc, PSURFGDI SurfGDI, PSURFOBJ SurfObj, PBITMAPOBJ Bitmap);
// --------------------------------------------------------- File Statics
static void W32kSetDCState16(HDC hDC, HDC hDCSave);
@ -93,17 +99,23 @@ HDC STDCALL W32kCreateCompatableDC(HDC hDC)
PDC NewDC, OrigDC = NULL;
HBITMAP hBitmap;
SIZEL onebyone;
HDC hNewDC;
OrigDC = DC_HandleToPtr(hDC);
if (OrigDC == NULL)
{
NewDC = DC_AllocDC(L"DISPLAY");
} else {
hNewDC = DC_AllocDC(L"DISPLAY");
if( hNewDC )
NewDC = DC_HandleToPtr( hNewDC );
}
else {
/* Allocate a new DC based on the original DC's device */
NewDC = DC_AllocDC(OrigDC->DriverName);
hNewDC = DC_AllocDC(OrigDC->DriverName);
if( hNewDC )
NewDC = DC_HandleToPtr( hNewDC );
}
if (NewDC == NULL)
if (NewDC == NULL)
{
return NULL;
}
@ -116,7 +128,7 @@ HDC STDCALL W32kCreateCompatableDC(HDC hDC)
} else {
NewDC->PDev = OrigDC->PDev;
NewDC->DMW = OrigDC->DMW;
memcpy(NewDC->FillPatternSurfaces,
memcpy(NewDC->FillPatternSurfaces,
OrigDC->FillPatternSurfaces,
sizeof OrigDC->FillPatternSurfaces);
NewDC->GDIInfo = OrigDC->GDIInfo;
@ -143,13 +155,13 @@ HDC STDCALL W32kCreateCompatableDC(HDC hDC)
NewDC->vportExtY = OrigDC->vportExtY;
}
DC_InitDC(NewDC);
DC_InitDC(hNewDC);
/* Create default bitmap */
if (!(hBitmap = W32kCreateBitmap( 1, 1, 1, 1, NULL )))
{
DC_FreeDC(NewDC);
DC_ReleasePtr( hNewDC );
DC_FreeDC( hNewDC );
return NULL;
}
NewDC->w.flags = DC_MEMORY;
@ -163,8 +175,10 @@ HDC STDCALL W32kCreateCompatableDC(HDC hDC)
NewDC->w.textColor = OrigDC->w.textColor;
NewDC->w.textAlign = OrigDC->w.textAlign;
}
DC_ReleasePtr( hDC );
DC_ReleasePtr( hNewDC );
return DC_PtrToHandle(NewDC);
return hNewDC;
}
#include <ddk/ntddvid.h>
@ -175,27 +189,30 @@ HDC STDCALL W32kCreateDC(LPCWSTR Driver,
CONST PDEVMODEW InitData)
{
PGD_ENABLEDRIVER GDEnableDriver;
HDC hNewDC;
PDC NewDC;
HDC hDC = NULL;
DRVENABLEDATA DED;
HDC hNewDC;
PSURFOBJ SurfObj;
/* Check for existing DC object */
if ((NewDC = DC_FindOpenDC(Driver)) != NULL)
if ((hNewDC = DC_FindOpenDC(Driver)) != NULL)
{
hDC = DC_PtrToHandle(NewDC);
hDC = hNewDC;
return W32kCreateCompatableDC(hDC);
}
DPRINT("NAME: %S\n", Driver); // FIXME: Should not crash if NULL
/* Allocate a DC object */
if ((NewDC = DC_AllocDC(Driver)) == NULL)
if ((hNewDC = DC_AllocDC(Driver)) == NULL)
{
return NULL;
}
NewDC = DC_HandleToPtr( hNewDC );
ASSERT( NewDC );
/* Open the miniport driver */
if ((NewDC->DeviceDriver = DRIVER_FindMPDriver(Driver)) == NULL)
{
@ -238,7 +255,7 @@ HDC STDCALL W32kCreateDC(LPCWSTR Driver,
NewDC->DMW.dmFields = 0x000fc000;
/* FIXME: get mode selection information from somewhere */
NewDC->DMW.dmLogPixels = 96;
NewDC->DMW.dmBitsPerPel = 4;
NewDC->DMW.dmPelsWidth = 640;
@ -288,16 +305,16 @@ HDC STDCALL W32kCreateDC(LPCWSTR Driver,
DPRINT("Bits per pel: %u\n", NewDC->w.bitsPerPixel);
/* Initialize the DC state */
DC_InitDC(NewDC);
hNewDC = DC_PtrToHandle(NewDC);
DC_InitDC(hNewDC);
W32kSetTextColor(hNewDC, RGB(0xff, 0xff, 0xff));
W32kSetTextAlign(hNewDC, TA_BASELINE);
DC_ReleasePtr( hNewDC );
return hNewDC;
Failure:
DC_FreeDC(NewDC);
DC_ReleasePtr( hNewDC );
DC_FreeDC(hNewDC);
return NULL;
}
@ -313,7 +330,7 @@ HDC STDCALL W32kCreateIC(LPCWSTR Driver,
BOOL STDCALL W32kDeleteDC(HDC DCHandle)
{
PDC DCToDelete;
DCToDelete = DC_HandleToPtr(DCHandle);
if (DCToDelete == NULL)
{
@ -338,7 +355,7 @@ BOOL STDCALL W32kDeleteDC(HDC DCHandle)
{
PDC savedDC;
HDC savedHDC;
savedHDC = DC_GetNextDC (DCToDelete);
savedDC = DC_HandleToPtr (savedHDC);
if (savedDC == NULL)
@ -347,9 +364,10 @@ BOOL STDCALL W32kDeleteDC(HDC DCHandle)
}
DC_SetNextDC (DCToDelete, DC_GetNextDC (savedDC));
DCToDelete->saveLevel--;
DC_ReleasePtr( savedHDC );
W32kDeleteDC (savedHDC);
}
/* Free GDI resources allocated to this DC */
if (!(DCToDelete->w.flags & DC_SAVED))
{
@ -357,57 +375,30 @@ BOOL STDCALL W32kDeleteDC(HDC DCHandle)
W32kSelectObject (DCHandle, STOCK_BLACK_PEN);
W32kSelectObject (DCHandle, STOCK_WHITE_BRUSH);
W32kSelectObject (DCHandle, STOCK_SYSTEM_FONT);
DC_LockDC (DCHandle); W32kSelectObject does not recognize stock objects yet */
if (DCToDelete->w.flags & DC_MEMORY)
DC_LockDC (DCHandle); W32kSelectObject does not recognize stock objects yet */
if (DCToDelete->w.flags & DC_MEMORY)
{
W32kDeleteObject (DCToDelete->w.hFirstBitmap);
}
}
if (DCToDelete->w.hClipRgn)
if (DCToDelete->w.hClipRgn)
{
W32kDeleteObject (DCToDelete->w.hClipRgn);
}
if (DCToDelete->w.hVisRgn)
if (DCToDelete->w.hVisRgn)
{
W32kDeleteObject (DCToDelete->w.hVisRgn);
}
if (DCToDelete->w.hGCClipRgn)
if (DCToDelete->w.hGCClipRgn)
{
W32kDeleteObject (DCToDelete->w.hGCClipRgn);
}
#if 0 /* FIXME */
PATH_DestroyGdiPath (&DCToDelete->w.path);
#endif
DC_ReleasePtr( DCToDelete );
DC_FreeDC (DCToDelete);
return TRUE;
}
BOOL STDCALL W32kDeleteObject(HGDIOBJ hObject)
{
PGDIOBJ Obj;
PGDIOBJHDR ObjHdr;
WORD magic;
magic = GDIOBJ_GetHandleMagic (hObject);
Obj = GDIOBJ_HandleToPtr( hObject, GO_MAGIC_DONTCARE );
if( !Obj )
return FALSE;
ObjHdr = (PGDIOBJHDR)(((PCHAR)Obj) - sizeof (GDIOBJHDR));
switch( magic )
{
case GO_BITMAP_MAGIC: {
DPRINT( "Deleting bitmap\n" );
ExFreePool( ((PBITMAPOBJ)Obj)->bitmap.bmBits );
BITMAPOBJ_FreeBitmap( Obj );
break;
}
default: {
DPRINT( "W32kDeleteObject: Deleting object of unknown type %x\n", magic );
return FALSE;
}
}
return TRUE;
}
@ -443,54 +434,58 @@ DC_GET_VAL_EX( W32kGetCurrentPositionEx, w.CursPosX, w.CursPosY, POINT )
BOOL STDCALL W32kGetDCOrgEx(HDC hDC,
LPPOINT Point)
{
DC * dc;
PDC dc;
if (!Point)
if (!Point)
{
return FALSE;
}
dc = DC_HandleToPtr(hDC);
if (dc == NULL)
if (dc == NULL)
{
return FALSE;
}
Point->x = Point->y = 0;
Point->x += dc->w.DCOrgX;
Point->x += dc->w.DCOrgX;
Point->y += dc->w.DCOrgY;
DC_ReleasePtr( hDC );
return TRUE;
}
HDC STDCALL W32kGetDCState16(HDC hDC)
{
PDC newdc, dc;
HDC hnewdc;
dc = DC_HandleToPtr(hDC);
if (dc == NULL)
if (dc == NULL)
{
return 0;
}
newdc = DC_AllocDC(NULL);
if (newdc == NULL)
hnewdc = DC_AllocDC(NULL);
if (hnewdc == NULL)
{
DC_ReleasePtr( hDC );
return 0;
}
newdc = DC_HandleToPtr( hnewdc );
ASSERT( newdc );
newdc->w.flags = dc->w.flags | DC_SAVED;
#if 0
newdc->w.devCaps = dc->w.devCaps;
#endif
newdc->w.hPen = dc->w.hPen;
newdc->w.hBrush = dc->w.hBrush;
newdc->w.hFont = dc->w.hFont;
newdc->w.hBitmap = dc->w.hBitmap;
newdc->w.hPen = dc->w.hPen;
newdc->w.hBrush = dc->w.hBrush;
newdc->w.hFont = dc->w.hFont;
newdc->w.hBitmap = dc->w.hBitmap;
newdc->w.hFirstBitmap = dc->w.hFirstBitmap;
#if 0
newdc->w.hDevice = dc->w.hDevice;
newdc->w.hPalette = dc->w.hPalette;
newdc->w.hPalette = dc->w.hPalette;
#endif
newdc->w.totalExtent = dc->w.totalExtent;
newdc->w.bitsPerPixel = dc->w.bitsPerPixel;
@ -534,7 +529,7 @@ HDC STDCALL W32kGetDCState16(HDC hDC)
newdc->vportExtX = dc->vportExtX;
newdc->vportExtY = dc->vportExtY;
newdc->hSelf = DC_PtrToHandle(newdc);
newdc->hSelf = hnewdc;
newdc->saveLevel = 0;
#if 0
@ -555,8 +550,8 @@ HDC STDCALL W32kGetDCState16(HDC hDC)
{
newdc->w.hClipRgn = 0;
}
return newdc->hSelf;
DC_ReleasePtr( hnewdc );
return hnewdc;
}
INT STDCALL W32kGetDeviceCaps(HDC hDC,
@ -565,9 +560,9 @@ INT STDCALL W32kGetDeviceCaps(HDC hDC,
PDC dc;
INT ret;
POINT pt;
dc = DC_HandleToPtr(hDC);
if (dc == NULL)
if (dc == NULL)
{
return 0;
}
@ -581,35 +576,35 @@ INT STDCALL W32kGetDeviceCaps(HDC hDC,
return pt.x;
}
break;
case PHYSICALHEIGHT:
if(W32kEscape(hDC, GETPHYSPAGESIZE, 0, NULL, (LPVOID)&pt) > 0)
{
return pt.y;
}
break;
case PHYSICALOFFSETX:
if(W32kEscape(hDC, GETPRINTINGOFFSET, 0, NULL, (LPVOID)&pt) > 0)
{
return pt.x;
}
break;
case PHYSICALOFFSETY:
if(W32kEscape(hDC, GETPRINTINGOFFSET, 0, NULL, (LPVOID)&pt) > 0)
{
return pt.y;
}
break;
case SCALINGFACTORX:
if(W32kEscape(hDC, GETSCALINGFACTOR, 0, NULL, (LPVOID)&pt) > 0)
{
return pt.x;
}
break;
case SCALINGFACTORY:
if(W32kEscape(hDC, GETSCALINGFACTOR, 0, NULL, (LPVOID)&pt) > 0)
{
@ -622,11 +617,12 @@ INT STDCALL W32kGetDeviceCaps(HDC hDC,
{
return 0;
}
DPRINT("(%04x,%d): returning %d\n",
hDC, Index, *(WORD *)(((char *)dc->w.devCaps) + Index));
ret = *(WORD *)(((char *)dc->w.devCaps) + Index);
DC_ReleasePtr( hDC );
return ret;
}
@ -639,10 +635,10 @@ INT STDCALL W32kGetObjectA(HANDLE handle, INT count, LPVOID buffer)
INT result = 0;
WORD magic;
if (!count)
if (!count)
return 0;
gdiObject = GDIOBJ_HandleToPtr (handle, GO_MAGIC_DONTCARE);
if (gdiObject == 0)
gdiObject = GDIOBJ_LockObj (handle, GO_MAGIC_DONTCARE);
if (gdiObject == 0)
return 0;
magic = GDIOBJ_GetHandleMagic (handle);
@ -651,10 +647,10 @@ INT STDCALL W32kGetObjectA(HANDLE handle, INT count, LPVOID buffer)
/* case GO_PEN_MAGIC:
result = PEN_GetObject((PENOBJ *)gdiObject, count, buffer);
break;
case GO_BRUSH_MAGIC:
case GO_BRUSH_MAGIC:
result = BRUSH_GetObject((BRUSHOBJ *)gdiObject, count, buffer);
break; */
case GO_BITMAP_MAGIC:
case GO_BITMAP_MAGIC:
result = BITMAP_GetObject((BITMAPOBJ *)gdiObject, count, buffer);
break;
/* case GO_FONT_MAGIC:
@ -684,7 +680,7 @@ INT STDCALL W32kGetObjectA(HANDLE handle, INT count, LPVOID buffer)
DbgPrint("Invalid GDI Magic %04x\n", magic);
break;
}
GDIOBJ_UnlockObj (handle, GO_MAGIC_DONTCARE);
return result;
}
@ -694,10 +690,10 @@ INT STDCALL W32kGetObjectW(HANDLE handle, INT count, LPVOID buffer)
INT result = 0;
WORD magic;
if (!count)
if (!count)
return 0;
gdiObject = GDIOBJ_HandleToPtr(handle, GO_MAGIC_DONTCARE);
if (gdiObject == 0)
gdiObject = GDIOBJ_LockObj(handle, GO_MAGIC_DONTCARE);
if (gdiObject == 0)
return 0;
magic = GDIOBJ_GetHandleMagic (handle);
@ -706,10 +702,10 @@ INT STDCALL W32kGetObjectW(HANDLE handle, INT count, LPVOID buffer)
/* case GO_PEN_MAGIC:
result = PEN_GetObject((PENOBJ *)gdiObject, count, buffer);
break;
case GO_BRUSH_MAGIC:
case GO_BRUSH_MAGIC:
result = BRUSH_GetObject((BRUSHOBJ *)gdiObject, count, buffer);
break; */
case GO_BITMAP_MAGIC:
case GO_BITMAP_MAGIC:
result = BITMAP_GetObject((BITMAPOBJ *)gdiObject, count, buffer);
break;
/* case GO_FONT_MAGIC:
@ -727,10 +723,10 @@ INT STDCALL W32kGetObjectW(HANDLE handle, INT count, LPVOID buffer)
// FIXME("Magic %04x not implemented\n", gdiObject->magic);
break;
}
GDIOBJ_UnlockObj(handle, GO_MAGIC_DONTCARE);
return result;
}
INT STDCALL W32kGetObject(HANDLE handle, INT count, LPVOID buffer)
{
return W32kGetObjectW(handle, count, buffer);
@ -742,20 +738,20 @@ DWORD STDCALL W32kGetObjectType(HANDLE handle)
INT result = 0;
WORD magic;
ptr = GDIOBJ_HandleToPtr(handle, GO_MAGIC_DONTCARE);
if (ptr == 0)
ptr = GDIOBJ_LockObj(handle, GO_MAGIC_DONTCARE);
if (ptr == 0)
return 0;
magic = GDIOBJ_GetHandleMagic (handle);
switch(magic)
{
case GO_PEN_MAGIC:
result = OBJ_PEN;
break;
case GO_BRUSH_MAGIC:
case GO_BRUSH_MAGIC:
result = OBJ_BRUSH;
break;
case GO_BITMAP_MAGIC:
case GO_BITMAP_MAGIC:
result = OBJ_BITMAP;
break;
case GO_FONT_MAGIC:
@ -789,7 +785,7 @@ DWORD STDCALL W32kGetObjectType(HANDLE handle)
// FIXME("Magic %04x not implemented\n", magic);
break;
}
GDIOBJ_UnlockObj(handle, GO_MAGIC_DONTCARE);
return result;
}
@ -814,26 +810,26 @@ BOOL STDCALL W32kRestoreDC(HDC hDC, INT SaveLevel)
BOOL success;
dc = DC_HandleToPtr(hDC);
if(!dc)
if(!dc)
{
return FALSE;
}
if (SaveLevel == -1)
if (SaveLevel == -1)
{
SaveLevel = dc->saveLevel;
}
if ((SaveLevel < 1) || (SaveLevel > dc->saveLevel))
{
return FALSE;
}
success = TRUE;
while (dc->saveLevel >= SaveLevel)
{
HDC hdcs = DC_GetNextDC (dc);
dcs = DC_HandleToPtr (hdcs);
if (dcs == NULL)
{
@ -852,9 +848,10 @@ BOOL STDCALL W32kRestoreDC(HDC hDC, INT SaveLevel)
}
#endif
}
DC_ReleasePtr( hdcs );
W32kDeleteDC (hdcs);
}
DC_ReleasePtr( hDC );
return success;
}
@ -889,10 +886,12 @@ INT STDCALL W32kSaveDC(HDC hDC)
return 0;
}
#endif
DC_SetNextDC (dcs, DC_GetNextDC (dc));
DC_SetNextDC (dc, hdcs);
ret = ++dc->saveLevel;
DC_ReleasePtr( hdcs );
DC_ReleasePtr( hDC );
return ret;
}
@ -925,8 +924,9 @@ HGDIOBJ STDCALL W32kSelectObject(HDC hDC, HGDIOBJ hGDIObj)
// Convert the color of the pen to the format of the DC
PalGDI = (PPALGDI)AccessInternalObject(dc->w.hPalette);
XlateObj = (PXLATEOBJ)EngCreateXlate(PalGDI->Mode, PAL_RGB, dc->w.hPalette, NULL);
pen = GDIOBJ_HandleToPtr(dc->w.hPen, GO_PEN_MAGIC);
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);
break;
case GO_BRUSH_MAGIC:
objOrg = (HGDIOBJ)dc->w.hBrush;
@ -973,11 +973,11 @@ HGDIOBJ STDCALL W32kSelectObject(HDC hDC, HGDIOBJ hGDIObj)
default:
return NULL;
}
DC_ReleasePtr( hDC );
return objOrg;
}
DC_SET_MODE( W32kSetBkMode, w.backgroundMode, TRANSPARENT, OPAQUE )
DC_SET_MODE( W32kSetBkMode, w.backgroundMode, TRANSPARENT, OPAQUE )
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 )
@ -987,31 +987,32 @@ COLORREF STDCALL W32kSetBkColor(HDC hDC, COLORREF color)
{
COLORREF oldColor;
PDC dc = DC_HandleToPtr(hDC);
if (!dc)
if (!dc)
{
return 0x80000000;
}
oldColor = dc->w.backgroundColor;
dc->w.backgroundColor = color;
DC_ReleasePtr( hDC );
return oldColor;
}
static void W32kSetDCState16(HDC hDC, HDC hDCSave)
{
PDC dc, dcs;
dc = DC_HandleToPtr(hDC);
if (dc == NULL)
{
return;
}
dcs = DC_HandleToPtr(hDCSave);
if (dcs == NULL)
{
DC_ReleasePtr( hDC );
return;
}
if (!dcs->w.flags & DC_SAVED)
@ -1064,7 +1065,7 @@ static void W32kSetDCState16(HDC hDC, HDC hDCSave)
dc->w.xformVport2World = dcs->w.xformVport2World;
dc->w.vport2WorldValid = dcs->w.vport2WorldValid;
#endif
dc->wndOrgX = dcs->wndOrgX;
dc->wndOrgY = dcs->wndOrgY;
dc->wndExtX = dcs->wndExtX;
@ -1073,16 +1074,16 @@ static void W32kSetDCState16(HDC hDC, HDC hDCSave)
dc->vportOrgY = dcs->vportOrgY;
dc->vportExtX = dcs->vportExtX;
dc->vportExtY = dcs->vportExtY;
if (!(dc->w.flags & DC_MEMORY))
if (!(dc->w.flags & DC_MEMORY))
{
dc->w.bitsPerPixel = dcs->w.bitsPerPixel;
}
#if 0
if (dcs->w.hClipRgn)
{
if (!dc->w.hClipRgn)
if (!dc->w.hClipRgn)
{
dc->w.hClipRgn = W32kCreateRectRgn( 0, 0, 0, 0 );
}
@ -1090,16 +1091,16 @@ static void W32kSetDCState16(HDC hDC, HDC hDCSave)
}
else
{
if (dc->w.hClipRgn)
if (dc->w.hClipRgn)
{
W32kDeleteObject( dc->w.hClipRgn );
}
dc->w.hClipRgn = 0;
}
CLIPPING_UpdateGCRegion( dc );
#endif
W32kSelectObject( hDC, dcs->w.hBitmap );
W32kSelectObject( hDC, dcs->w.hBrush );
W32kSelectObject( hDC, dcs->w.hFont );
@ -1110,57 +1111,70 @@ static void W32kSetDCState16(HDC hDC, HDC hDCSave)
#if 0
GDISelectPalette16( hDC, dcs->w.hPalette, FALSE );
#endif
DC_ReleasePtr( hDCSave );
DC_ReleasePtr( hDC );
}
// ---------------------------------------------------- Private Interface
PDC DC_AllocDC(LPCWSTR Driver)
HDC DC_AllocDC(LPCWSTR Driver)
{
PDC NewDC;
NewDC = (PDC) GDIOBJ_AllocObject(sizeof(DC), GO_DC_MAGIC);
if (NewDC == NULL)
{
return NULL;
}
if (Driver != NULL)
{
NewDC->DriverName = ExAllocatePool(PagedPool, (wcslen(Driver) + 1) * sizeof(WCHAR));
wcscpy(NewDC->DriverName, Driver);
}
return NewDC;
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);
}
GDIOBJ_UnlockObj( hDC, GO_DC_MAGIC );
return hDC;
}
PDC DC_FindOpenDC(LPCWSTR Driver)
HDC DC_FindOpenDC(LPCWSTR Driver)
{
return NULL;
}
void DC_InitDC(PDC DCToInit)
void DC_InitDC(HDC DCHandle)
{
HDC DCHandle;
DCHandle = DC_PtrToHandle(DCToInit);
// W32kRealizeDefaultPalette(DCHandle);
W32kSetTextColor(DCHandle, DCToInit->w.textColor);
W32kSetBkColor(DCHandle, DCToInit->w.backgroundColor);
W32kSelectObject(DCHandle, DCToInit->w.hPen);
W32kSelectObject(DCHandle, DCToInit->w.hBrush);
W32kSelectObject(DCHandle, DCToInit->w.hFont);
PDC DCToInit;
if( (DCToInit = DC_HandleToPtr( DCHandle ) ) ){
W32kSetTextColor(DCHandle, DCToInit->w.textColor);
W32kSetBkColor(DCHandle, DCToInit->w.backgroundColor);
W32kSelectObject(DCHandle, DCToInit->w.hPen);
W32kSelectObject(DCHandle, DCToInit->w.hBrush);
W32kSelectObject(DCHandle, DCToInit->w.hFont);
}
DPRINT("DC_InitDC: can't get dc for handle %d\n", DCHandle );
// CLIPPING_UpdateGCRegion(DCToInit);
}
void DC_FreeDC(PDC DCToFree)
void DC_FreeDC(HDC DCToFree)
{
ExFreePool(DCToFree->DriverName);
if (!GDIOBJ_FreeObject((PGDIOBJ)DCToFree, GO_DC_MAGIC))
if (!GDIOBJ_FreeObj(DCToFree, GO_DC_MAGIC))
{
DPRINT("DC_FreeDC failed\n");
}
}
BOOL DC_InternalDeleteDC( PDC DCToDelete )
{
ExFreePool(DCToDelete->DriverName);
return TRUE;
}
HDC DC_GetNextDC (PDC pDC)
{
return pDC->hNext;
@ -1171,12 +1185,12 @@ void DC_SetNextDC (PDC pDC, HDC hNextDC)
pDC->hNext = hNextDC;
}
void
void
DC_UpdateXforms(PDC dc)
{
XFORM xformWnd2Vport;
FLOAT scaleX, scaleY;
/* Construct a transformation to do the window-to-viewport conversion */
scaleX = (FLOAT)dc->vportExtX / (FLOAT)dc->wndExtX;
scaleY = (FLOAT)dc->vportExtY / (FLOAT)dc->wndExtY;
@ -1186,32 +1200,32 @@ DC_UpdateXforms(PDC dc)
xformWnd2Vport.eM22 = scaleY;
xformWnd2Vport.eDx = (FLOAT)dc->vportOrgX - scaleX * (FLOAT)dc->wndOrgX;
xformWnd2Vport.eDy = (FLOAT)dc->vportOrgY - scaleY * (FLOAT)dc->wndOrgY;
/* Combine with the world transformation */
W32kCombineTransform(&dc->w.xformWorld2Vport, &dc->w.xformWorld2Wnd, &xformWnd2Vport);
/* Create inverse of world-to-viewport transformation */
dc->w.vport2WorldValid = DC_InvertXform(&dc->w.xformWorld2Vport, &dc->w.xformVport2World);
}
BOOL
DC_InvertXform(const XFORM *xformSrc,
BOOL
DC_InvertXform(const XFORM *xformSrc,
XFORM *xformDest)
{
FLOAT determinant;
determinant = xformSrc->eM11*xformSrc->eM22 - xformSrc->eM12*xformSrc->eM21;
if (determinant > -1e-12 && determinant < 1e-12)
{
return FALSE;
}
xformDest->eM11 = xformSrc->eM22 / determinant;
xformDest->eM12 = -xformSrc->eM12 / determinant;
xformDest->eM21 = -xformSrc->eM21 / determinant;
xformDest->eM22 = xformSrc->eM11 / determinant;
xformDest->eDx = -xformSrc->eDx * xformDest->eM11 - xformSrc->eDy * xformDest->eM21;
xformDest->eDy = -xformSrc->eDx * xformDest->eM12 - xformSrc->eDy * xformDest->eM22;
return TRUE;
}

View file

@ -7,6 +7,8 @@
#include "../eng/objects.h"
#include <ntos/minmax.h>
VOID BitmapToSurf(HDC hdc, PSURFGDI SurfGDI, PSURFOBJ SurfObj, PBITMAPOBJ Bitmap);
UINT STDCALL W32kSetDIBColorTable(HDC hDC,
UINT StartIndex,
UINT Entries,
@ -78,16 +80,17 @@ INT STDCALL W32kSetDIBits(HDC hDC,
// Check parameters
if (!(dc = DC_HandleToPtr(hDC))) return 0;
if (!(dc = DC_HandleToPtr(hDC)))
return 0;
if (!(bitmap = (BITMAPOBJ *)GDIOBJ_HandleToPtr(hBitmap, GO_BITMAP_MAGIC)))
if (!(bitmap = (BITMAPOBJ *)GDIOBJ_LockObj(hBitmap, GO_BITMAP_MAGIC)))
{
// GDI_ReleaseObj(hDC);
DC_ReleasePtr(hDC);
return 0;
}
// Get RGB values
if (ColorUse == DIB_PAL_COLORS)
if (ColorUse == DIB_PAL_COLORS)
lpRGB = DIB_MapPaletteColors(hDC, bmi);
else
lpRGB = &bmi->bmiColors[0];
@ -132,11 +135,12 @@ INT STDCALL W32kSetDIBits(HDC hDC,
EngDeleteSurface(SourceBitmap);
EngDeleteSurface(DestBitmap);
// if (ColorUse == DIB_PAL_COLORS)
// if (ColorUse == DIB_PAL_COLORS)
// WinFree((LPSTR)lpRGB);
// GDI_ReleaseObj(hBitmap); unlock?
// GDI_ReleaseObj(hDC);
GDIOBJ_UnlockObj(hBitmap, GO_BITMAP_MAGIC);
DC_ReleasePtr(hDC);
return result;
}
@ -182,13 +186,13 @@ INT STDCALL W32kStretchDIBits(HDC hDC,
INT YDest,
INT DestWidth,
INT DestHeight,
INT XSrc,
INT YSrc,
INT SrcWidth,
INT SrcHeight,
INT XSrc,
INT YSrc,
INT SrcWidth,
INT SrcHeight,
CONST VOID *Bits,
CONST BITMAPINFO *BitsInfo,
UINT Usage,
UINT Usage,
DWORD ROP)
{
UNIMPLEMENTED;
@ -200,20 +204,20 @@ LONG STDCALL W32kGetBitmapBits(HBITMAP hBitmap,
{
PBITMAPOBJ bmp;
LONG height, ret;
bmp = BITMAPOBJ_HandleToPtr (hBitmap);
if (!bmp)
if (!bmp)
{
return 0;
}
/* If the bits vector is null, the function should return the read size */
if (Bits == NULL)
{
return bmp->bitmap.bmWidthBytes * bmp->bitmap.bmHeight;
}
if (Count < 0)
if (Count < 0)
{
DPRINT ("(%ld): Negative number of bytes passed???\n", Count);
Count = -Count;
@ -221,7 +225,7 @@ LONG STDCALL W32kGetBitmapBits(HBITMAP hBitmap,
/* Only get entire lines */
height = Count / bmp->bitmap.bmWidthBytes;
if (height > bmp->bitmap.bmHeight)
if (height > bmp->bitmap.bmHeight)
{
height = bmp->bitmap.bmHeight;
}
@ -237,7 +241,7 @@ LONG STDCALL W32kGetBitmapBits(HBITMAP hBitmap,
1 << bmp->bitmap.bmBitsPixel, height );
#if 0
/* FIXME: Call DDI CopyBits here if available */
if(bmp->DDBitmap)
if(bmp->DDBitmap)
{
DPRINT("Calling device specific BitmapBits\n");
if(bmp->DDBitmap->funcs->pBitmapBits)
@ -245,21 +249,21 @@ LONG STDCALL W32kGetBitmapBits(HBITMAP hBitmap,
ret = bmp->DDBitmap->funcs->pBitmapBits(hbitmap, bits, count,
DDB_GET);
}
else
else
{
ERR_(bitmap)("BitmapBits == NULL??\n");
ret = 0;
}
}
else
}
else
#endif
{
if(!bmp->bitmap.bmBits)
if(!bmp->bitmap.bmBits)
{
DPRINT ("Bitmap is empty\n");
ret = 0;
}
else
}
else
{
memcpy(Bits, bmp->bitmap.bmBits, Count);
ret = Count;
@ -375,6 +379,7 @@ HBITMAP STDCALL W32kCreateDIBSection(HDC hDC,
if ((dc = DC_HandleToPtr(hDC)))
{
hbitmap = DIB_CreateDIBSection(dc, bmi, Usage, Bits, hSection, dwOffset, 0);
DC_ReleasePtr( hDC );
}
if (bDesktopDC)
@ -393,16 +398,16 @@ HBITMAP DIB_CreateDIBSection(
DIBSECTION *dib = NULL;
int *colorMap = NULL;
int nColorMap;
// Fill BITMAP32 structure with DIB data
BITMAPINFOHEADER *bi = &bmi->bmiHeader;
INT effHeight, totalSize;
BITMAP bm;
DbgPrint("format (%ld,%ld), planes %d, bpp %d, size %ld, colors %ld (%s)\n",
bi->biWidth, bi->biHeight, bi->biPlanes, bi->biBitCount,
bi->biSizeImage, bi->biClrUsed, usage == DIB_PAL_COLORS? "PAL" : "RGB");
effHeight = bi->biHeight >= 0 ? bi->biHeight : -bi->biHeight;
bm.bmType = 0;
bm.bmWidth = bi->biWidth;
@ -412,7 +417,7 @@ HBITMAP DIB_CreateDIBSection(
bm.bmPlanes = bi->biPlanes;
bm.bmBitsPixel = bi->biBitCount;
bm.bmBits = NULL;
// Get storage location for DIB bits. Only use biSizeImage if it's valid and
// we're dealing with a compressed bitmap. Otherwise, use width * height.
totalSize = bi->biSizeImage && bi->biCompression != BI_RGB
@ -420,13 +425,13 @@ HBITMAP DIB_CreateDIBSection(
/*
if (section)
bm.bmBits = MapViewOfFile(section, FILE_MAP_ALL_ACCESS,
bm.bmBits = MapViewOfFile(section, FILE_MAP_ALL_ACCESS,
0L, offset, totalSize);
else if (ovr_pitch && offset)
bm.bmBits = (LPVOID) offset;
else { */
offset = 0;
/* bm.bmBits = VirtualAlloc(NULL, totalSize,
/* bm.bmBits = VirtualAlloc(NULL, totalSize,
MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); */
bm.bmBits = ExAllocatePool(NonPagedPool, totalSize);
@ -476,7 +481,7 @@ HBITMAP DIB_CreateDIBSection(
}
// Create Device Dependent Bitmap and add DIB pointer
if (dib)
if (dib)
{
res = W32kCreateDIBitmap(dc->hSelf, bi, 0, NULL, bmi, usage);
if (res)
@ -500,11 +505,11 @@ HBITMAP DIB_CreateDIBSection(
else if (!offset)
VirtualFree(bm.bmBits, 0L, MEM_RELEASE), bm.bmBits = NULL;
} */
if (colorMap) { ExFreePool(colorMap); colorMap = NULL; }
if (dib) { ExFreePool(dib); dib = NULL; }
if (bmp) { bmp = NULL; }
if (res) { GDIOBJ_FreeObject(res, GO_BITMAP_MAGIC); res = 0; }
if (res) { GDIOBJ_FreeObj(res, GO_BITMAP_MAGIC); res = 0; }
}
// Install fault handler, if possible
@ -525,6 +530,9 @@ HBITMAP DIB_CreateDIBSection(
}
} */
if( bmp )
BITMAPOBJ_ReleasePtr(res);
// Return BITMAP handle and storage location
if (bm.bmBits && bits) *bits = bm.bmBits;
return res;
@ -540,7 +548,7 @@ HBITMAP DIB_CreateDIBSection(
int DIB_GetDIBWidthBytes(int width, int depth)
{
int words;
switch(depth)
{
case 1: words = (width + 31) / 32; break;
@ -549,7 +557,7 @@ int DIB_GetDIBWidthBytes(int width, int depth)
case 15:
case 16: words = (width + 1) / 2; break;
case 24: words = (width * 3 + 3)/4; break;
default:
DPRINT("(%d): Unsupported depth\n", depth );
/* fall through */
@ -642,7 +650,7 @@ PBITMAPOBJ DIBtoDDB(HGLOBAL hPackedDIB, HDC hdc) // FIXME: This should be remove
// GlobalUnlock(hPackedDIB);
// Retrieve the internal Pixmap from the DDB
pBmp = (BITMAPOBJ *)GDIOBJ_HandleToPtr(hBmp, GO_BITMAP_MAGIC);
pBmp = (BITMAPOBJ *)GDIOBJ_LockObj(hBmp, GO_BITMAP_MAGIC);
return pBmp;
}

View file

@ -81,15 +81,23 @@ W32kRectangle(HDC hDC,
SURFOBJ *SurfObj = (SURFOBJ*)AccessUserObject(dc->Surface);
PBRUSHOBJ BrushObj;
BOOL ret;
PRECTL RectBounds = GDIOBJ_HandleToPtr(dc->w.hGCClipRgn, GO_REGION_MAGIC);
PRECTL RectBounds;
PENOBJ * pen;
if(!dc) return FALSE;
if(!dc)
return FALSE;
RectBounds = GDIOBJ_LockObj(dc->w.hGCClipRgn, GO_REGION_MAGIC);
//ei not yet implemented ASSERT(RectBounds);
if(PATH_IsPathOpen(dc->w.path)) {
ret = PATH_Rectangle(hDC, LeftRect, TopRect, RightRect, BottomRect);
} else {
// Draw the rectangle with the current pen
BrushObj = (PBRUSHOBJ)PenToBrushObj(dc, GDIOBJ_HandleToPtr(dc->w.hPen, GO_PEN_MAGIC));
pen = (PENOBJ*) GDIOBJ_LockObj(dc->w.hPen, GO_PEN_MAGIC);
ASSERT(pen);
BrushObj = (PBRUSHOBJ)PenToBrushObj(dc, pen);
GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC );
ret = EngLineTo(SurfObj,
NULL, // ClipObj,
@ -123,7 +131,8 @@ W32kRectangle(HDC hDC,
}
// FIXME: Move current position in DC?
GDIOBJ_UnlockObj(dc->w.hGCClipRgn, GO_REGION_MAGIC);
DC_ReleasePtr( hDC );
return TRUE;
}
@ -131,8 +140,8 @@ BOOL
STDCALL
W32kRoundRect(HDC hDC,
int LeftRect,
int TopRect,
int RightRect,
int TopRect,
int RightRect,
int BottomRect,
int Width,
int Height)

View file

@ -1,7 +1,7 @@
/*
* GDIOBJ.C - GDI object manipulation routines
*
* $Id: gdiobj.c,v 1.11 2001/11/02 06:10:11 rex Exp $
* $Id: gdiobj.c,v 1.12 2002/07/13 21:37:27 ei Exp $
*
*/
@ -12,6 +12,10 @@
#include <win32k/brush.h>
#include <win32k/pen.h>
#include <win32k/text.h>
#include <win32k/dc.h>
#include <win32k/bitmaps.h>
//#define NDEBUG
#include <win32k/debug1.h>
// GDI stock objects
@ -100,21 +104,25 @@ HBITMAP hPseudoStockBitmap; /* 1x1 bitmap for memory DCs */
static PGDI_HANDLE_TABLE HandleTable = 0;
static FAST_MUTEX HandleTableMutex;
static FAST_MUTEX RefCountHandling;
#define GDI_HANDLE_NUMBER 0x4000
static PGDI_HANDLE_TABLE
GDIOBJ_iAllocHandleTable (WORD Size)
{
PGDI_HANDLE_TABLE handleTable;
// ExAcquireFastMutexUnsafe (&HandleTableMutex);
handleTable = ExAllocatePool(PagedPool,
sizeof (GDI_HANDLE_TABLE) +
ExAcquireFastMutexUnsafe (&HandleTableMutex);
handleTable = ExAllocatePool(PagedPool,
sizeof (GDI_HANDLE_TABLE) +
sizeof (GDI_HANDLE_ENTRY) * Size);
memset (handleTable,
0,
ASSERT( handleTable );
memset (handleTable,
0,
sizeof (GDI_HANDLE_TABLE) + sizeof (GDI_HANDLE_ENTRY) * Size);
handleTable->wTableSize = Size;
// ExReleaseFastMutexUnsafe (&HandleTableMutex);
ExReleaseFastMutexUnsafe (&HandleTableMutex);
return handleTable;
}
@ -122,7 +130,10 @@ GDIOBJ_iAllocHandleTable (WORD Size)
static PGDI_HANDLE_ENTRY
GDIOBJ_iGetHandleEntryForIndex (WORD TableIndex)
{
return &HandleTable->Handles [TableIndex];
//DPRINT("GDIOBJ_iGetHandleEntryForIndex: TableIndex: %d,\n handle: %x, ptr: %x\n", TableIndex, HandleTable->Handles [TableIndex], &(HandleTable->Handles [TableIndex]) );
//DPRINT("GIG: HandleTable: %x, Handles: %x, \n TableIndex: %x, pt: %x\n", HandleTable, HandleTable->Handles, TableIndex, ((PGDI_HANDLE_ENTRY)HandleTable->Handles+TableIndex));
DPRINT("GIG: Hndl: %x, mag: %x\n", ((PGDI_HANDLE_ENTRY)HandleTable->Handles+TableIndex), ((PGDI_HANDLE_ENTRY)HandleTable->Handles+TableIndex)->wMagic);
return ((PGDI_HANDLE_ENTRY)HandleTable->Handles+TableIndex);
}
static WORD
@ -130,7 +141,7 @@ GDIOBJ_iGetNextOpenHandleIndex (void)
{
WORD tableIndex;
// ExAcquireFastMutexUnsafe (&HandleTableMutex);
ExAcquireFastMutexUnsafe (&HandleTableMutex);
for (tableIndex = 1; tableIndex < HandleTable->wTableSize; tableIndex++)
{
if (HandleTable->Handles [tableIndex].wMagic == 0)
@ -139,12 +150,156 @@ GDIOBJ_iGetNextOpenHandleIndex (void)
break;
}
}
// ExReleaseFastMutexUnsafe (&HandleTableMutex);
ExReleaseFastMutexUnsafe (&HandleTableMutex);
return (tableIndex < HandleTable->wTableSize) ? tableIndex : 0;
}
PGDIOBJ GDIOBJ_AllocObject(WORD Size, WORD Magic)
/*-----------------7/12/2002 11:38AM----------------
* Allocate memory for GDI object and return handle to it
* Use GDIOBJ_Lock to obtain pointer to the new object.
* --------------------------------------------------*/
HGDIOBJ GDIOBJ_AllocObj(WORD Size, WORD Magic)
{
PGDIOBJHDR newObject;
PGDI_HANDLE_ENTRY handleEntry;
DPRINT("GDIOBJ_AllocObj: size: %d, magic: %x\n", Size, Magic);
newObject = ExAllocatePool (PagedPool, Size + sizeof (GDIOBJHDR));
if (newObject == NULL)
{
return NULL;
}
RtlZeroMemory (newObject, Size + sizeof (GDIOBJHDR));
newObject->wTableIndex = GDIOBJ_iGetNextOpenHandleIndex ();
newObject->dwCount = 0;
handleEntry = GDIOBJ_iGetHandleEntryForIndex (newObject->wTableIndex);
handleEntry->wMagic = Magic;
handleEntry->hProcessId = PsGetCurrentProcessId ();
handleEntry->pObject = newObject;
DPRINT("GDIOBJ_AllocObj: object handle %d\n", newObject->wTableIndex );
return (HGDIOBJ) newObject->wTableIndex;
}
BOOL GDIOBJ_FreeObj(HGDIOBJ hObj, WORD Magic)
{
PGDIOBJHDR objectHeader;
PGDI_HANDLE_ENTRY handleEntry;
PGDIOBJ Obj;
BOOL bRet = TRUE;
handleEntry = GDIOBJ_iGetHandleEntryForIndex ((WORD)hObj & 0xffff);
DPRINT("GDIOBJ_FreeObj: hObj: %d, magic: %x, handleEntry: %x\n", hObj, Magic, handleEntry );
if (handleEntry == 0 || (handleEntry->wMagic != Magic && handleEntry->wMagic != GO_MAGIC_DONTCARE )
|| handleEntry->hProcessId != PsGetCurrentProcessId ())
return FALSE;
objectHeader = (PGDIOBJHDR) handleEntry->pObject;
ASSERT(objectHeader);
// check that the reference count is zero. if not then set flag
// and delete object when releaseobj is called
ExAcquireFastMutex(&RefCountHandling);
if( ( objectHeader->dwCount & ~0x80000000 ) > 0 ){
objectHeader->dwCount |= 0x80000000;
DPRINT("GDIOBJ_FreeObj: delayed object deletion");
ExReleaseFastMutex(&RefCountHandling);
return TRUE;
}
ExReleaseFastMutex(&RefCountHandling);
//allow object to delete internal data
Obj = (PGDIOBJ)((PCHAR)handleEntry->pObject + sizeof(GDIOBJHDR));
switch( handleEntry->wMagic ){
case GO_REGION_MAGIC:
case GO_PEN_MAGIC:
case GO_PALETTE_MAGIC:
case GO_BITMAP_MAGIC:
bRet = Bitmap_InternalDelete( (PBITMAPOBJ) Obj );
break;
case GO_DC_MAGIC:
bRet = DC_InternalDeleteDC( (PDC) Obj );
break;
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:
case GO_BRUSH_MAGIC:
case GO_FONT_MAGIC:
break;
}
handleEntry->hProcessId = 0;
ExFreePool (handleEntry->pObject);
handleEntry->pObject = 0;
// (RJJ) set wMagic last to avoid race condition
handleEntry->wMagic = 0;
return TRUE;
}
PGDIOBJ GDIOBJ_LockObj( HGDIOBJ hObj, WORD Magic )
{
PGDI_HANDLE_ENTRY handleEntry = GDIOBJ_iGetHandleEntryForIndex ((WORD) hObj & 0xffff);
PGDIOBJHDR objectHeader;
DPRINT("GDIOBJ_LockObj: hObj: %d, magic: %x, \n handleEntry: %x, mag %x\n", hObj, Magic, handleEntry, handleEntry->wMagic);
if (handleEntry == 0 || (handleEntry->wMagic != Magic && handleEntry->wMagic != GO_MAGIC_DONTCARE )
|| handleEntry->hProcessId != PsGetCurrentProcessId () )
return NULL;
objectHeader = (PGDIOBJHDR) handleEntry->pObject;
ASSERT(objectHeader);
ExAcquireFastMutex(&RefCountHandling);
objectHeader->dwCount++;
ExReleaseFastMutex(&RefCountHandling);
DPRINT("GDIOBJ_LockObj: PGDIOBJ %x\n", ((PCHAR)objectHeader + sizeof(GDIOBJHDR)) );
return (PGDIOBJ)((PCHAR)objectHeader + sizeof(GDIOBJHDR));
}
BOOL GDIOBJ_UnlockObj( HGDIOBJ hObj, WORD Magic )
{
PGDI_HANDLE_ENTRY handleEntry = GDIOBJ_iGetHandleEntryForIndex ((WORD) hObj & 0xffff);
PGDIOBJHDR objectHeader;
DPRINT("GDIOBJ_UnlockObj: hObj: %d, magic: %x, \n handleEntry: %x\n", hObj, Magic, handleEntry);
if (handleEntry == 0 || (handleEntry->wMagic != Magic && handleEntry->wMagic != GO_MAGIC_DONTCARE )
|| handleEntry->hProcessId != PsGetCurrentProcessId ())
return FALSE;
objectHeader = (PGDIOBJHDR) handleEntry->pObject;
ASSERT(objectHeader);
ExAcquireFastMutex(&RefCountHandling);
if( ( objectHeader->dwCount & ~0x80000000 ) == 0 ){
ExReleaseFastMutex(&RefCountHandling);
DPRINT( "GDIOBJ_UnLockObj: unlock object that is not locked\n" );
return FALSE;
}
objectHeader = (PGDIOBJHDR) handleEntry->pObject;
ASSERT(objectHeader);
objectHeader->dwCount--;
if( objectHeader->dwCount == 0x80000000 ){
//delayed object release
ExReleaseFastMutex(&RefCountHandling);
DPRINT("GDIOBJ_UnlockObj: delayed delete\n");
return GDIOBJ_FreeObj( hObj, Magic );
}
ExReleaseFastMutex(&RefCountHandling);
return TRUE;
}
/*
PGDIOBJ GDIOBJ_AllocObject(WORD Size, WORD Magic)
{
PGDIOBJHDR newObject;
PGDI_HANDLE_ENTRY handleEntry;
@ -159,7 +314,7 @@ PGDIOBJ GDIOBJ_AllocObject(WORD Size, WORD Magic)
newObject->wTableIndex = GDIOBJ_iGetNextOpenHandleIndex ();
handleEntry = GDIOBJ_iGetHandleEntryForIndex (newObject->wTableIndex);
handleEntry->wMagic = Magic;
handleEntry->hProcessId = 0; // PsGetCurrentProcessId ();
handleEntry->hProcessId = PsGetCurrentProcessId ();
handleEntry->pObject = newObject;
return (PGDIOBJ)(((PCHAR) newObject) + sizeof (GDIOBJHDR));
@ -187,16 +342,16 @@ HGDIOBJ GDIOBJ_PtrToHandle (PGDIOBJ Obj, WORD Magic)
{
PGDIOBJHDR objectHeader;
PGDI_HANDLE_ENTRY handleEntry;
if (Obj == NULL)
if (Obj == NULL)
return NULL;
objectHeader = (PGDIOBJHDR) (((PCHAR)Obj) - sizeof (GDIOBJHDR));
handleEntry = GDIOBJ_iGetHandleEntryForIndex (objectHeader->wTableIndex);
if (handleEntry == 0 ||
if (handleEntry == 0 ||
handleEntry->wMagic != Magic ||
handleEntry->hProcessId != 0 /* PsGetCurrentProcess () */)
handleEntry->hProcessId != PsGetCurrentProcessId () )
return NULL;
return (HGDIOBJ) objectHeader->wTableIndex;
}
@ -208,13 +363,14 @@ PGDIOBJ GDIOBJ_HandleToPtr (HGDIOBJ ObjectHandle, WORD Magic)
return NULL;
handleEntry = GDIOBJ_iGetHandleEntryForIndex ((WORD)ObjectHandle & 0xffff);
if (handleEntry == 0 ||
if (handleEntry == 0 ||
(Magic != GO_MAGIC_DONTCARE && handleEntry->wMagic != Magic) ||
handleEntry->hProcessId != 0 /* PsGetCurrentProcess () */)
handleEntry->hProcessId != PsGetCurrentProcessId () )
return NULL;
return (PGDIOBJ) (((PCHAR)handleEntry->pObject) + sizeof (GDIOBJHDR));
}
*/
WORD GDIOBJ_GetHandleMagic (HGDIOBJ ObjectHandle)
{
@ -224,8 +380,8 @@ WORD GDIOBJ_GetHandleMagic (HGDIOBJ ObjectHandle)
return 0;
handleEntry = GDIOBJ_iGetHandleEntryForIndex ((WORD)ObjectHandle & 0xffff);
if (handleEntry == 0 ||
handleEntry->hProcessId != 0 /* PsGetCurrentProcess () */)
if (handleEntry == 0 ||
handleEntry->hProcessId != PsGetCurrentProcessId ())
return 0;
return handleEntry->wMagic;
@ -234,9 +390,13 @@ WORD GDIOBJ_GetHandleMagic (HGDIOBJ ObjectHandle)
VOID
InitGdiObjectHandleTable (void)
{
DbgPrint ("InitGdiObjectHandleTable\n");
// ExInitializeFastMutex (&HandleTableMutex);
HandleTable = GDIOBJ_iAllocHandleTable (0x1000);
DPRINT ("InitGdiObjectHandleTable\n");
ExInitializeFastMutex (&HandleTableMutex);
ExInitializeFastMutex (&RefCountHandling);
//per http://www.wd-mag.com/articles/1999/9902/9902b/9902b.htm?topic=articles
//gdi handle table can hold 0x4000 handles
HandleTable = GDIOBJ_iAllocHandleTable (GDI_HANDLE_NUMBER);
DPRINT("HandleTable: %x\n", HandleTable );
}
VOID CreateStockObjects(void)
@ -276,3 +436,50 @@ HGDIOBJ STDCALL W32kGetStockObject(INT Object)
return StockObjects[Object]; // FIXME........
}
BOOL STDCALL W32kDeleteObject(HGDIOBJ hObject)
{
/* ei: Now this is handled in gdiobj.c
PGDIOBJ Obj;
PGDIOBJHDR ObjHdr;
WORD magic;
magic = GDIOBJ_GetHandleMagic (hObject);
Obj = GDIOBJ_HandleToPtr( hObject, GO_MAGIC_DONTCARE );
if( !Obj )
return FALSE;
ObjHdr = (PGDIOBJHDR)(((PCHAR)Obj) - sizeof (GDIOBJHDR));
switch( magic )
{
case GO_BITMAP_MAGIC: {
DPRINT( "Deleting bitmap\n" );
ExFreePool( ((PBITMAPOBJ)Obj)->bitmap.bmBits );
BITMAPOBJ_FreeBitmap( Obj );
break;
}
default: {
DPRINT( "W32kDeleteObject: Deleting object of unknown type %x\n", magic );
return FALSE;
}
}
return TRUE;
*/
return GDIOBJ_FreeObj( hObject, GO_MAGIC_DONTCARE );
}
// dump all the objects for process. if process == 0 dump all the objects
VOID STDCALL W32kDumpGdiObjects( INT Process )
{
DWORD i;
PGDI_HANDLE_ENTRY handleEntry;
PGDIOBJHDR objectHeader;
for( i=1; i < GDI_HANDLE_NUMBER; i++ ){
handleEntry = GDIOBJ_iGetHandleEntryForIndex ((WORD) i & 0xffff);
if( handleEntry && handleEntry->wMagic != 0 ){
objectHeader = (PGDIOBJHDR) handleEntry->pObject;
DPRINT("\nHandle: %d, magic: %x \n process: %d, locks: %d", i, handleEntry->wMagic, handleEntry->hProcessId, objectHeader->dwCount);
}
}
}

View file

@ -28,11 +28,11 @@ STDCALL
W32kArc(HDC hDC,
int LeftRect,
int TopRect,
int RightRect,
int RightRect,
int BottomRect,
int XStartArc,
int YStartArc,
int XEndArc,
int XEndArc,
int YEndArc)
{
DC *dc = DC_HandleToPtr(hDC);
@ -42,6 +42,7 @@ W32kArc(HDC hDC,
return PATH_Arc(hDC, LeftRect, TopRect, RightRect, BottomRect,
XStartArc, YStartArc, XEndArc, YEndArc);
DC_ReleasePtr( hDC );
// EngArc(dc, LeftRect, TopRect, RightRect, BottomRect, UNIMPLEMENTED
// XStartArc, YStartArc, XEndArc, YEndArc);
}
@ -74,7 +75,7 @@ W32kArcTo(HDC hDC,
{
W32kMoveToEx(hDC, XRadial2, YRadial2, NULL);
}
DC_ReleasePtr( hDC );
return result;
}
@ -84,7 +85,7 @@ W32kGetArcDirection(HDC hDC)
{
PDC dc;
int ret;
dc = DC_HandleToPtr (hDC);
if (!dc)
{
@ -92,7 +93,7 @@ W32kGetArcDirection(HDC hDC)
}
ret = dc->w.ArcDirection;
DC_ReleasePtr( hDC );
return ret;
}
@ -105,24 +106,35 @@ W32kLineTo(HDC hDC,
DC *dc = DC_HandleToPtr(hDC);
SURFOBJ *SurfObj = (SURFOBJ*)AccessUserObject(dc->Surface);
BOOL ret;
PPENOBJ pen;
PRGNDATA reg;
if(!dc) return FALSE;
if(PATH_IsPathOpen(dc->w.path)) {
ret = PATH_LineTo(hDC, XEnd, YEnd);
} else {
pen = (PPENOBJ) GDIOBJ_LockObj(dc->w.hPen, GO_PEN_MAGIC);
reg = (PRGNDATA)GDIOBJ_LockObj(dc->w.hGCClipRgn, GO_REGION_MAGIC);
ASSERT( pen );
// not yet implemented ASSERT( reg );
ret = EngLineTo(SurfObj,
NULL, // ClipObj
PenToBrushObj(dc, GDIOBJ_HandleToPtr(dc->w.hPen, GO_PEN_MAGIC)),
PenToBrushObj(dc, pen),
dc->w.CursPosX, dc->w.CursPosY, XEnd, YEnd,
GDIOBJ_HandleToPtr(dc->w.hGCClipRgn, GO_REGION_MAGIC), // Bounding rectangle
reg, // Bounding rectangle
dc->w.ROPmode); // MIX
GDIOBJ_UnlockObj( dc->w.hGCClipRgn, GO_REGION_MAGIC );
GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC);
}
if(ret) {
dc->w.CursPosX = XEnd;
dc->w.CursPosY = YEnd;
}
DC_ReleasePtr( hDC );
return ret;
}
@ -144,9 +156,11 @@ W32kMoveToEx(HDC hDC,
dc->w.CursPosX = X;
dc->w.CursPosY = Y;
if(PATH_IsPathOpen(dc->w.path))
if(PATH_IsPathOpen(dc->w.path)){
DC_ReleasePtr( hDC );
return PATH_MoveTo(hDC);
}
DC_ReleasePtr( hDC );
return FALSE;
}
@ -159,8 +173,10 @@ W32kPolyBezier(HDC hDC,
DC *dc = DC_HandleToPtr(hDC);
if(!dc) return FALSE;
if(PATH_IsPathOpen(dc->w.path))
if(PATH_IsPathOpen(dc->w.path)){
DC_ReleasePtr( hDC );
return PATH_PolyBezier(hDC, pt, Count);
}
/* We'll convert it into line segments and draw them using Polyline */
{
@ -173,6 +189,7 @@ W32kPolyBezier(HDC hDC,
DbgPrint("Pts = %p, no = %d\n", Pts, nOut);
ret = W32kPolyline(dc->hSelf, Pts, nOut);
ExFreePool(Pts);
DC_ReleasePtr( hDC );
return ret;
}
}
@ -204,6 +221,7 @@ W32kPolyBezierTo(HDC hDC,
dc->w.CursPosX = pt[Count-1].x;
dc->w.CursPosY = pt[Count-1].y;
}
DC_ReleasePtr( hDC );
return ret;
}
@ -255,6 +273,7 @@ W32kPolylineTo(HDC hDC,
dc->w.CursPosX = pt[Count-1].x;
dc->w.CursPosY = pt[Count-1].y;
}
DC_ReleasePtr( hDC );
return ret;
}
@ -284,11 +303,12 @@ W32kSetArcDirection(HDC hDC,
if (ArcDirection != AD_COUNTERCLOCKWISE && ArcDirection != AD_CLOCKWISE)
{
// SetLastError(ERROR_INVALID_PARAMETER);
DC_ReleasePtr( hDC );
return 0;
}
nOldDirection = dc->w.ArcDirection;
dc->w.ArcDirection = ArcDirection;
DC_ReleasePtr( hDC );
return nOldDirection;
}

View file

@ -13,6 +13,10 @@
#include <win32k/pen.h>
#include "../eng/objects.h"
//#define NDEBUG
#include <win32k/debug1.h>
PBRUSHOBJ PenToBrushObj(PDC dc, PENOBJ *pen)
{
BRUSHOBJ *BrushObj;
@ -26,17 +30,21 @@ PBRUSHOBJ PenToBrushObj(PDC dc, PENOBJ *pen)
VOID BitmapToSurf(HDC hdc, PSURFGDI SurfGDI, PSURFOBJ SurfObj, PBITMAPOBJ Bitmap)
{
if(Bitmap->dib)
{
SurfGDI->BitsPerPixel = Bitmap->dib->dsBm.bmBitsPixel;
SurfObj->lDelta = Bitmap->dib->dsBm.bmWidthBytes;
SurfObj->pvBits = Bitmap->dib->dsBm.bmBits;
SurfObj->cjBits = Bitmap->dib->dsBm.bmHeight * Bitmap->dib->dsBm.bmWidthBytes;
} else {
SurfGDI->BitsPerPixel = Bitmap->bitmap.bmBitsPixel;
SurfObj->lDelta = Bitmap->bitmap.bmWidthBytes;
SurfObj->pvBits = Bitmap->bitmap.bmBits;
SurfObj->cjBits = Bitmap->bitmap.bmHeight * Bitmap->bitmap.bmWidthBytes;
ASSERT( SurfGDI );
if( Bitmap ){
if(Bitmap->dib)
{
SurfGDI->BitsPerPixel = Bitmap->dib->dsBm.bmBitsPixel;
SurfObj->lDelta = Bitmap->dib->dsBm.bmWidthBytes;
SurfObj->pvBits = Bitmap->dib->dsBm.bmBits;
SurfObj->cjBits = Bitmap->dib->dsBm.bmHeight * Bitmap->dib->dsBm.bmWidthBytes;
} else {
SurfGDI->BitsPerPixel = Bitmap->bitmap.bmBitsPixel;
SurfObj->lDelta = Bitmap->bitmap.bmWidthBytes;
SurfObj->pvBits = Bitmap->bitmap.bmBits;
SurfObj->cjBits = Bitmap->bitmap.bmHeight * Bitmap->bitmap.bmWidthBytes;
}
SurfObj->sizlBitmap = Bitmap->size; // FIXME: alloc memory for our own struct?
}
SurfObj->dhsurf = NULL;
@ -44,7 +52,6 @@ VOID BitmapToSurf(HDC hdc, PSURFGDI SurfGDI, PSURFOBJ SurfObj, PBITMAPOBJ Bitmap
SurfObj->dhpdev = NULL;
SurfObj->hdev = NULL;
SurfObj->pvScan0 = SurfObj->pvBits; // start of bitmap
SurfObj->sizlBitmap = Bitmap->size; // FIXME: alloc memory for our own struct?
SurfObj->iUniq = 0; // not sure..
SurfObj->iBitmapFormat = BitmapFormat(SurfGDI->BitsPerPixel, BI_RGB);
SurfObj->iType = STYPE_BITMAP;

View file

@ -203,11 +203,11 @@ BOOL PATH_AssignGdiPath(GdiPath *pPathDest, const GdiPath *pPathSrc)
BOOL PATH_MoveTo(HDC hdc)
{
GdiPath *pPath;
/* Get pointer to path */
if(!PATH_GetPathFromHDC(hdc, &pPath))
return FALSE;
/* Check that path is open */
if(pPath->state!=PATH_Open)
/* FIXME: Do we have to call SetLastError? */
@ -230,11 +230,11 @@ BOOL PATH_LineTo(HDC hdc, INT x, INT y)
{
GdiPath *pPath;
POINT point, pointCurPos;
/* Get pointer to path */
if(!PATH_GetPathFromHDC(hdc, &pPath))
return FALSE;
/* Check that path is open */
if(pPath->state!=PATH_Open)
return FALSE;
@ -244,7 +244,7 @@ BOOL PATH_LineTo(HDC hdc, INT x, INT y)
point.y=y;
if(!W32kLPtoDP(hdc, &point, 1))
return FALSE;
/* Add a PT_MOVETO if necessary */
if(pPath->newStroke)
{
@ -255,7 +255,7 @@ BOOL PATH_LineTo(HDC hdc, INT x, INT y)
if(!PATH_AddEntry(pPath, &pointCurPos, PT_MOVETO))
return FALSE;
}
/* Add a PT_LINETO entry */
return PATH_AddEntry(pPath, &point, PT_LINETO);
}
@ -274,7 +274,7 @@ BOOL PATH_Rectangle(HDC hdc, INT x1, INT y1, INT x2, INT y2)
/* Get pointer to path */
if(!PATH_GetPathFromHDC(hdc, &pPath))
return FALSE;
/* Check that path is open */
if(pPath->state!=PATH_Open)
return FALSE;
@ -286,7 +286,7 @@ BOOL PATH_Rectangle(HDC hdc, INT x1, INT y1, INT x2, INT y2)
corners[1].y=y2;
if(!W32kLPtoDP(hdc, corners, 2))
return FALSE;
/* Make sure first corner is top left and second corner is bottom right */
if(corners[0].x>corners[1].x)
{
@ -300,7 +300,7 @@ BOOL PATH_Rectangle(HDC hdc, INT x1, INT y1, INT x2, INT y2)
corners[0].y=corners[1].y;
corners[1].y=temp;
}
/* In GM_COMPATIBLE, don't include bottom and right edges */
if(W32kGetGraphicsMode(hdc)==GM_COMPATIBLE)
{
@ -342,7 +342,7 @@ BOOL PATH_Rectangle(HDC hdc, INT x1, INT y1, INT x2, INT y2)
}
/* PATH_Ellipse
*
*
* Should be called when a call to Ellipse is performed on a DC that has
* an open path. This adds four Bezier splines representing the ellipse
* to the path. Returns TRUE if successful, else FALSE.
@ -374,27 +374,33 @@ BOOL PATH_Arc(HDC hdc, INT x1, INT y1, INT x2, INT y2,
/* FIXME: This function should check for all possible error returns */
/* FIXME: Do we have to respect newStroke? */
/* Get pointer to DC */
pDC=DC_HandleToPtr(hdc);
if(pDC==NULL)
return FALSE;
/* Get pointer to path */
if(!PATH_GetPathFromHDC(hdc, &pPath))
if(!PATH_GetPathFromHDC(hdc, &pPath)){
DC_ReleasePtr( hdc );
return FALSE;
}
/* Check that path is open */
if(pPath->state!=PATH_Open)
if(pPath->state!=PATH_Open){
DC_ReleasePtr( hdc );
return FALSE;
}
/* FIXME: Do we have to close the current figure? */
/* Check for zero height / width */
/* FIXME: Only in GM_COMPATIBLE? */
if(x1==x2 || y1==y2)
if(x1==x2 || y1==y2){
DC_ReleasePtr( hdc );
return TRUE;
}
/* Convert points to device coordinates */
corners[0].x=(FLOAT)x1;
corners[0].y=(FLOAT)y1;
@ -453,7 +459,7 @@ BOOL PATH_Arc(HDC hdc, INT x1, INT y1, INT x2, INT y2,
corners[1].x--;
corners[1].y--;
}
/* Add the arc to the path with one Bezier spline per quadrant that the
* arc spans */
start=TRUE;
@ -494,6 +500,7 @@ BOOL PATH_Arc(HDC hdc, INT x1, INT y1, INT x2, INT y2,
start=FALSE;
} while(!end);
DC_ReleasePtr( hdc );
return TRUE;
}
@ -505,7 +512,7 @@ BOOL PATH_PolyBezierTo(HDC hdc, const POINT *pts, DWORD cbPoints)
if(!PATH_GetPathFromHDC(hdc, &pPath))
return FALSE;
/* Check that path is open */
if(pPath->state!=PATH_Open)
return FALSE;
@ -529,7 +536,7 @@ BOOL PATH_PolyBezierTo(HDC hdc, const POINT *pts, DWORD cbPoints)
}
return TRUE;
}
BOOL PATH_PolyBezier(HDC hdc, const POINT *pts, DWORD cbPoints)
{
GdiPath *pPath;
@ -538,7 +545,7 @@ BOOL PATH_PolyBezier(HDC hdc, const POINT *pts, DWORD cbPoints)
if(!PATH_GetPathFromHDC(hdc, &pPath))
return FALSE;
/* Check that path is open */
if(pPath->state!=PATH_Open)
return FALSE;
@ -560,7 +567,7 @@ BOOL PATH_Polyline(HDC hdc, const POINT *pts, DWORD cbPoints)
if(!PATH_GetPathFromHDC(hdc, &pPath))
return FALSE;
/* Check that path is open */
if(pPath->state!=PATH_Open)
return FALSE;
@ -573,7 +580,7 @@ BOOL PATH_Polyline(HDC hdc, const POINT *pts, DWORD cbPoints)
}
return TRUE;
}
BOOL PATH_PolylineTo(HDC hdc, const POINT *pts, DWORD cbPoints)
{
GdiPath *pPath;
@ -582,7 +589,7 @@ BOOL PATH_PolylineTo(HDC hdc, const POINT *pts, DWORD cbPoints)
if(!PATH_GetPathFromHDC(hdc, &pPath))
return FALSE;
/* Check that path is open */
if(pPath->state!=PATH_Open)
return FALSE;
@ -617,7 +624,7 @@ BOOL PATH_Polygon(HDC hdc, const POINT *pts, DWORD cbPoints)
if(!PATH_GetPathFromHDC(hdc, &pPath))
return FALSE;
/* Check that path is open */
if(pPath->state!=PATH_Open)
return FALSE;
@ -642,7 +649,7 @@ BOOL PATH_PolyPolygon( HDC hdc, const POINT* pts, const INT* counts,
if(!PATH_GetPathFromHDC(hdc, &pPath))
return FALSE;
/* Check that path is open */
if(pPath->state!=PATH_Open)
return FALSE;
@ -670,7 +677,7 @@ BOOL PATH_PolyPolyline( HDC hdc, const POINT* pts, const DWORD* counts,
if(!PATH_GetPathFromHDC(hdc, &pPath))
return FALSE;
/* Check that path is open */
if(pPath->state!=PATH_Open)
return FALSE;
@ -685,7 +692,7 @@ BOOL PATH_PolyPolyline( HDC hdc, const POINT* pts, const DWORD* counts,
}
return TRUE;
}
/***********************************************************************
* Internal functions
*/
@ -738,7 +745,7 @@ static BOOL PATH_FlattenPath(GdiPath *pPath)
PATH_EmptyPath(&newPath);
return TRUE;
}
/* PATH_PathToRegion
*
* Creates a region from the specified path using the specified polygon
@ -760,7 +767,7 @@ static BOOL PATH_PathToRegion(const GdiPath *pPath, INT nPolyFillMode,
PATH_FlattenPath(pPath);
/* FIXME: What happens when number of points is zero? */
/* First pass: Find out how many strokes there are in the path */
/* FIXME: We could eliminate this with some bookkeeping in GdiPath */
numStrokes=0;
@ -775,7 +782,7 @@ static BOOL PATH_PathToRegion(const GdiPath *pPath, INT nPolyFillMode,
// SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
/* Second pass: remember number of points in each polygon */
iStroke=-1; /* Will get incremented to 0 at beginning of first stroke */
for(i=0; i<pPath->numEntriesUsed; i++)
@ -828,7 +835,7 @@ static void PATH_EmptyPath(GdiPath *pPath)
BOOL PATH_AddEntry(GdiPath *pPath, const POINT *pPoint, BYTE flags)
{
assert(pPath!=NULL);
/* FIXME: If newStroke is true, perhaps we want to check that we're
* getting a PT_MOVETO
*/
@ -836,7 +843,7 @@ BOOL PATH_AddEntry(GdiPath *pPath, const POINT *pPoint, BYTE flags)
/* Check that path is open */
if(pPath->state!=PATH_Open)
return FALSE;
/* Reserve enough memory for an extra path entry */
if(!PATH_ReserveEntries(pPath, pPath->numEntriesUsed+1))
return FALSE;
@ -866,7 +873,7 @@ static BOOL PATH_ReserveEntries(GdiPath *pPath, INT numEntries)
INT numEntriesToAllocate;
POINT *pPointsNew;
BYTE *pFlagsNew;
assert(pPath!=NULL);
assert(numEntries>=0);
@ -927,9 +934,10 @@ static BOOL PATH_GetPathFromHDC(HDC hdc, GdiPath **ppPath)
if(pDC)
{
*ppPath=&pDC->w.path;
DC_ReleasePtr( hdc );
return TRUE;
} else
return FALSE;
}
return FALSE;
}
/* PATH_DoArcPart
@ -972,7 +980,7 @@ static BOOL PATH_DoArcPart(GdiPath *pPath, FLOAT_POINT corners[],
xNorm[i]=cos(angleStart);
yNorm[i]=sin(angleStart);
}
/* Add starting point to path if desired */
if(addMoveTo)
{

View file

@ -12,7 +12,7 @@ W32kCreatePen(INT PenStyle, INT Width, COLORREF Color)
{
LOGPEN logpen;
logpen.lopnStyle = PenStyle;
logpen.lopnStyle = PenStyle;
logpen.lopnWidth.x = Width;
logpen.lopnWidth.y = 0;
logpen.lopnColor = Color;
@ -29,14 +29,16 @@ W32kCreatePenIndirect(CONST PLOGPEN lgpn)
if (lgpn->lopnStyle > PS_INSIDEFRAME) return 0;
penPtr = PENOBJ_AllocPen();
hpen = PENOBJ_PtrToHandle(penPtr);
hpen = PENOBJ_AllocPen();
if (!hpen) return 0;
penPtr = PENOBJ_LockPen( hpen );
ASSERT( penPtr );
penPtr->logpen.lopnStyle = lgpn->lopnStyle;
penPtr->logpen.lopnWidth = lgpn->lopnWidth;
penPtr->logpen.lopnColor = lgpn->lopnColor;
PENOBJ_UnlockPen( hpen );
return hpen;
}

View file

@ -11,11 +11,13 @@
INT STDCALL
W32kGetBoxRgn(HRGN hRgn, PRECT Rect)
{
return 0;
}
HRGN STDCALL
W32kCropRgn(HRGN hDest, HRGN hSrc, const RECT* Rect, const POINT* Point)
{
return NULL;
}
INT STDCALL
@ -67,7 +69,7 @@ W32kCreateRectRgn(INT LeftRect,
{
RGNDATA* Region;
PRECT Rect;
/*
DPRINT("W32kCreateRectRgn(LeftRect %d, TopRect %d, RightRect %d, "
"BottomRect %d)\n", LeftRect, TopRect, RightRect, BottomRect);
@ -83,6 +85,8 @@ W32kCreateRectRgn(INT LeftRect,
Region->rdh.rcBound = *Rect;
return(GDIOBJ_PtrToHandle((PGDIOBJ)Region, 0));
*/
return NULL;
}
HRGN STDCALL

View file

@ -95,7 +95,7 @@ W32kAddFontResource(LPCWSTR Filename)
DbgPrint("could not allocate memory for module");
return 0;
}
// Load driver into memory chunk
Status = NtReadFile(FileHandle, 0, 0, 0, &Iosb, buffer, FileStdInfo.EndOfFile.u.LowPart, 0, 0);
if (!NT_SUCCESS(Status))
@ -177,10 +177,10 @@ W32kCreateFont(int Height,
logfont.lfClipPrecision = ClipPrecision;
logfont.lfQuality = Quality;
logfont.lfPitchAndFamily = PitchAndFamily;
if(Face)
memcpy(logfont.lfFaceName, Face, sizeof(logfont.lfFaceName));
else
else
logfont.lfFaceName[0] = '\0';
return W32kCreateFontIndirect(&logfont);
@ -195,15 +195,19 @@ W32kCreateFontIndirect(CONST LPLOGFONT lf)
if (lf)
{
if(fontPtr = TEXTOBJ_AllocText())
if(hFont = TEXTOBJ_AllocText())
{
memcpy(&fontPtr->logfont, lf, sizeof(LOGFONT));
fontPtr = TEXTOBJ_LockText( hFont );
ASSERT( fontPtr ); //I want to know when this happens
if( fontPtr ){
memcpy(&fontPtr->logfont, lf, sizeof(LOGFONT));
if (lf->lfEscapement != lf->lfOrientation) {
/* this should really depend on whether GM_ADVANCED is set */
fontPtr->logfont.lfOrientation = fontPtr->logfont.lfEscapement;
}
hFont = TEXTOBJ_PtrToHandle(fontPtr);
if (lf->lfEscapement != lf->lfOrientation) {
/* this should really depend on whether GM_ADVANCED is set */
fontPtr->logfont.lfOrientation = fontPtr->logfont.lfEscapement;
}
TEXTOBJ_UnlockText( hFont );
}
}
}
@ -521,34 +525,34 @@ W32kSetTextAlign(HDC hDC,
{
UINT prevAlign;
DC *dc;
dc = DC_HandleToPtr(hDC);
if (!dc)
if (!dc)
{
return 0;
}
prevAlign = dc->w.textAlign;
dc->w.textAlign = Mode;
DC_ReleasePtr( hDC );
return prevAlign;
}
COLORREF
STDCALL
W32kSetTextColor(HDC hDC,
W32kSetTextColor(HDC hDC,
COLORREF color)
{
COLORREF oldColor;
PDC dc = DC_HandleToPtr(hDC);
if (!dc)
if (!dc)
{
return 0x80000000;
}
oldColor = dc->w.textColor;
dc->w.textColor = color;
DC_ReleasePtr( hDC );
return oldColor;
}
@ -580,8 +584,8 @@ W32kTextOut(HDC hDC,
FT_Bool use_kerning;
RECTL DestRect, MaskRect;
POINTL SourcePoint, BrushOrigin;
HBRUSH hBrush;
PBRUSHOBJ Brush;
HBRUSH hBrush = NULL;
PBRUSHOBJ Brush = NULL;
HBITMAP HSourceGlyph;
PSURFOBJ SourceGlyphSurf;
SIZEL bitSize;
@ -594,7 +598,10 @@ W32kTextOut(HDC hDC,
PPALGDI PalDestGDI;
PXLATEOBJ XlateObj;
TextObj = TEXTOBJ_HandleToPtr(dc->w.hFont);
if( !dc )
return FALSE;
TextObj = TEXTOBJ_LockText(dc->w.hFont);
for(i=0; i<FontsLoaded; i++)
{
@ -605,7 +612,7 @@ W32kTextOut(HDC hDC,
if(hFont == 0)
{
DbgPrint("Specified font %s is not loaded\n", TextObj->logfont.lfFaceName);
return FALSE;
goto fail;
}
FontObj = (PFONTOBJ)AccessUserObject(hFont);
@ -635,14 +642,14 @@ W32kTextOut(HDC hDC,
error = FT_Set_Pixel_Sizes(face, TextObj->logfont.lfHeight, TextObj->logfont.lfWidth);
if(error) {
DbgPrint("Error in setting pixel sizes: %u\n", error);
return FALSE;
goto fail;
}
// Create the brush
PalDestGDI = (PPALGDI)AccessInternalObject(dc->w.hPalette);
XlateObj = (PXLATEOBJ)EngCreateXlate(PalDestGDI->Mode, PAL_RGB, dc->w.hPalette, NULL);
hBrush = W32kCreateSolidBrush(XLATEOBJ_iXlate(XlateObj, dc->w.textColor));
Brush = BRUSHOBJ_HandleToPtr(hBrush);
Brush = BRUSHOBJ_LockBrush(hBrush);
EngDeleteXlate(XlateObj);
SourcePoint.x = 0;
@ -655,9 +662,12 @@ W32kTextOut(HDC hDC,
// Do we use the current TEXTOBJ's logfont.lfOrientation or the DC's textAlign?
if (dc->w.textAlign & TA_BASELINE) {
yoff = 0;
} else if (dc->w.textAlign & TA_BOTTOM) {
}
else
if (dc->w.textAlign & TA_BOTTOM) {
yoff = -face->size->metrics.descender / 64;
} else { // TA_TOP
}
else { // TA_TOP
yoff = face->size->metrics.ascender / 64;
}
@ -670,7 +680,7 @@ W32kTextOut(HDC hDC,
error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
if(error) {
DbgPrint("WARNING: Failed to load and render glyph! [index: %u]\n", glyph_index);
return FALSE;
goto fail;
}
glyph = face->glyph;
@ -687,7 +697,7 @@ W32kTextOut(HDC hDC,
error = FT_Render_Glyph(glyph, ft_render_mode_mono);
if(error) {
DbgPrint("WARNING: Failed to render glyph!\n");
return FALSE;
goto fail;
}
pitch = glyph->bitmap.pitch;
} else {
@ -719,12 +729,26 @@ W32kTextOut(HDC hDC,
String++;
}
TEXTOBJ_UnlockText( dc->w.hFont );
BRUSHOBJ_UnlockBrush(hBrush);
W32kDeleteObject( hBrush );
DC_ReleasePtr( hDC );
return TRUE;
fail:
TEXTOBJ_UnlockText( dc->w.hFont );
if( hBrush ){
BRUSHOBJ_UnlockBrush(hBrush);
W32kDeleteObject( hBrush );
}
DC_ReleasePtr( hDC );
return FALSE;
}
UINT
STDCALL
W32kTranslateCharsetInfo(PDWORD Src,
LPCHARSETINFO CSI,
LPCHARSETINFO CSI,
DWORD Flags)
{
UNIMPLEMENTED;