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

@ -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

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

@ -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

@ -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);

View file

@ -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

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

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,4 +1,4 @@
/* $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;
}
@ -120,12 +123,15 @@ HBITMAP STDCALL W32kCreateBitmap(INT 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)
@ -186,7 +201,7 @@ HBITMAP STDCALL W32kCreateCompatibleBitmap(HDC hDC,
}
}
DPRINT ("\t\t%04x\n", hbmpRet);
DC_ReleasePtr( hDC );
return hbmpRet;
}

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 = BRUSHOBJ_LockBrush (hBrush);
ASSERT( brushPtr ); //I want to know if this ever occurs
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,
@ -108,13 +113,15 @@ HBRUSH STDCALL W32kCreateDIBPatternBrushPt(CONST VOID *PackedDIB,
}
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);
}

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

@ -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;
@ -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;

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
@ -75,6 +75,7 @@ W32kDPtoLP(HDC hDC,
{
CoordDPtoLP(Dc, &Points[i]);
}
DC_ReleasePtr( hDC );
return(TRUE);
}
@ -92,7 +93,7 @@ W32kGetGraphicsMode(HDC hDC)
}
GraphicsMode = dc->w.GraphicsMode;
DC_ReleasePtr( hDC );
return GraphicsMode;
}
@ -113,7 +114,7 @@ W32kGetWorldTransform(HDC hDC,
return FALSE;
}
*XForm = dc->w.xformWorld2Wnd;
DC_ReleasePtr( hDC );
return TRUE;
}
@ -145,6 +146,7 @@ W32kLPtoDP(HDC hDC, LPPOINT Points, INT Count)
{
CoordLPtoDP(Dc, &Points[i]);
}
DC_ReleasePtr( hDC );
return(TRUE);
}
@ -192,10 +194,11 @@ W32kModifyWorldTransform(HDC hDC,
break;
default:
DC_ReleasePtr( hDC );
return FALSE;
}
DC_UpdateXforms (dc);
DC_ReleasePtr( hDC );
return TRUE;
}
@ -265,11 +268,12 @@ W32kSetGraphicsMode(HDC hDC,
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;
}
@ -331,22 +335,23 @@ W32kSetWorldTransform(HDC hDC,
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,4 +1,4 @@
/* $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
*
@ -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,6 +40,7 @@ func_type STDCALL func_name( HDC hdc ) \
return 0; \
} \
ft = dc->dc_field; \
DC_ReleasePtr( hdc ); \
return ft; \
}
@ -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,14 +99,20 @@ 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)
@ -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)
{
@ -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;
}
@ -347,6 +364,7 @@ BOOL STDCALL W32kDeleteDC(HDC DCHandle)
}
DC_SetNextDC (DCToDelete, DC_GetNextDC (savedDC));
DCToDelete->saveLevel--;
DC_ReleasePtr( savedHDC );
W32kDeleteDC (savedHDC);
}
@ -378,39 +396,12 @@ BOOL STDCALL W32kDeleteDC(HDC DCHandle)
#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;
}
INT STDCALL W32kDrawEscape(HDC hDC,
INT nEscape,
INT cbInput,
@ -443,7 +434,7 @@ DC_GET_VAL_EX( W32kGetCurrentPositionEx, w.CursPosX, w.CursPosY, POINT )
BOOL STDCALL W32kGetDCOrgEx(HDC hDC,
LPPOINT Point)
{
DC * dc;
PDC dc;
if (!Point)
{
@ -459,13 +450,14 @@ BOOL STDCALL W32kGetDCOrgEx(HDC hDC,
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)
@ -473,11 +465,14 @@ HDC STDCALL W32kGetDCState16(HDC hDC)
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
@ -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,
@ -627,6 +622,7 @@ INT STDCALL W32kGetDeviceCaps(HDC hDC,
hDC, Index, *(WORD *)(((char *)dc->w.devCaps) + Index));
ret = *(WORD *)(((char *)dc->w.devCaps) + Index);
DC_ReleasePtr( hDC );
return ret;
}
@ -641,7 +637,7 @@ INT STDCALL W32kGetObjectA(HANDLE handle, INT count, LPVOID buffer)
if (!count)
return 0;
gdiObject = GDIOBJ_HandleToPtr (handle, GO_MAGIC_DONTCARE);
gdiObject = GDIOBJ_LockObj (handle, GO_MAGIC_DONTCARE);
if (gdiObject == 0)
return 0;
@ -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;
}
@ -696,7 +692,7 @@ INT STDCALL W32kGetObjectW(HANDLE handle, INT count, LPVOID buffer)
if (!count)
return 0;
gdiObject = GDIOBJ_HandleToPtr(handle, GO_MAGIC_DONTCARE);
gdiObject = GDIOBJ_LockObj(handle, GO_MAGIC_DONTCARE);
if (gdiObject == 0)
return 0;
@ -727,7 +723,7 @@ 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;
}
@ -742,7 +738,7 @@ DWORD STDCALL W32kGetObjectType(HANDLE handle)
INT result = 0;
WORD magic;
ptr = GDIOBJ_HandleToPtr(handle, GO_MAGIC_DONTCARE);
ptr = GDIOBJ_LockObj(handle, GO_MAGIC_DONTCARE);
if (ptr == 0)
return 0;
@ -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;
}
@ -852,9 +848,10 @@ BOOL STDCALL W32kRestoreDC(HDC hDC, INT SaveLevel)
}
#endif
}
DC_ReleasePtr( hdcs );
W32kDeleteDC (hdcs);
}
DC_ReleasePtr( hDC );
return success;
}
@ -893,6 +890,8 @@ INT STDCALL W32kSaveDC(HDC hDC)
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,7 +973,7 @@ HGDIOBJ STDCALL W32kSelectObject(HDC hDC, HGDIOBJ hGDIObj)
default:
return NULL;
}
DC_ReleasePtr( hDC );
return objOrg;
}
@ -995,7 +995,7 @@ COLORREF STDCALL W32kSetBkColor(HDC hDC, COLORREF color)
oldColor = dc->w.backgroundColor;
dc->w.backgroundColor = color;
DC_ReleasePtr( hDC );
return oldColor;
}
@ -1012,6 +1012,7 @@ static void W32kSetDCState16(HDC hDC, HDC hDCSave)
dcs = DC_HandleToPtr(hDCSave);
if (dcs == NULL)
{
DC_ReleasePtr( hDC );
return;
}
if (!dcs->w.flags & DC_SAVED)
@ -1111,56 +1112,69 @@ static void W32kSetDCState16(HDC hDC, HDC hDCSave)
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;
HDC hDC;
NewDC = (PDC) GDIOBJ_AllocObject(sizeof(DC), GO_DC_MAGIC);
if (NewDC == NULL)
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);
}
return NewDC;
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);
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;

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,11 +80,12 @@ 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;
}
@ -136,7 +139,8 @@ INT STDCALL W32kSetDIBits(HDC hDC,
// WinFree((LPSTR)lpRGB);
// GDI_ReleaseObj(hBitmap); unlock?
// GDI_ReleaseObj(hDC);
GDIOBJ_UnlockObj(hBitmap, GO_BITMAP_MAGIC);
DC_ReleasePtr(hDC);
return result;
}
@ -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)
@ -504,7 +509,7 @@ HBITMAP DIB_CreateDIBSection(
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;
@ -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;
}

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);
ExAcquireFastMutexUnsafe (&HandleTableMutex);
handleTable = ExAllocatePool(PagedPool,
sizeof (GDI_HANDLE_TABLE) +
sizeof (GDI_HANDLE_ENTRY) * Size);
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,11 +150,155 @@ GDIOBJ_iGetNextOpenHandleIndex (void)
break;
}
}
// ExReleaseFastMutexUnsafe (&HandleTableMutex);
ExReleaseFastMutexUnsafe (&HandleTableMutex);
return (tableIndex < HandleTable->wTableSize) ? tableIndex : 0;
}
/*-----------------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;
@ -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));
@ -194,7 +349,7 @@ HGDIOBJ GDIOBJ_PtrToHandle (PGDIOBJ Obj, WORD Magic)
handleEntry = GDIOBJ_iGetHandleEntryForIndex (objectHeader->wTableIndex);
if (handleEntry == 0 ||
handleEntry->wMagic != Magic ||
handleEntry->hProcessId != 0 /* PsGetCurrentProcess () */)
handleEntry->hProcessId != PsGetCurrentProcessId () )
return NULL;
return (HGDIOBJ) objectHeader->wTableIndex;
@ -210,11 +365,12 @@ PGDIOBJ GDIOBJ_HandleToPtr (HGDIOBJ ObjectHandle, WORD Magic)
handleEntry = GDIOBJ_iGetHandleEntryForIndex ((WORD)ObjectHandle & 0xffff);
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)
{
@ -225,7 +381,7 @@ WORD GDIOBJ_GetHandleMagic (HGDIOBJ ObjectHandle)
handleEntry = GDIOBJ_iGetHandleEntryForIndex ((WORD)ObjectHandle & 0xffff);
if (handleEntry == 0 ||
handleEntry->hProcessId != 0 /* PsGetCurrentProcess () */)
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

@ -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;
}
@ -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,6 +30,8 @@ PBRUSHOBJ PenToBrushObj(PDC dc, PENOBJ *pen)
VOID BitmapToSurf(HDC hdc, PSURFGDI SurfGDI, PSURFOBJ SurfObj, PBITMAPOBJ Bitmap)
{
ASSERT( SurfGDI );
if( Bitmap ){
if(Bitmap->dib)
{
SurfGDI->BitsPerPixel = Bitmap->dib->dsBm.bmBitsPixel;
@ -38,13 +44,14 @@ VOID BitmapToSurf(HDC hdc, PSURFGDI SurfGDI, PSURFOBJ SurfObj, PBITMAPOBJ Bitmap
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;
SurfObj->hsurf = NULL;
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

@ -381,19 +381,25 @@ BOOL PATH_Arc(HDC hdc, INT x1, INT y1, INT x2, INT y2,
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;
@ -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;
}
@ -927,8 +934,9 @@ static BOOL PATH_GetPathFromHDC(HDC hdc, GdiPath **ppPath)
if(pDC)
{
*ppPath=&pDC->w.path;
DC_ReleasePtr( hdc );
return TRUE;
} else
}
return FALSE;
}

View file

@ -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

@ -195,15 +195,19 @@ W32kCreateFontIndirect(CONST LPLOGFONT lf)
if (lf)
{
if(fontPtr = TEXTOBJ_AllocText())
if(hFont = TEXTOBJ_AllocText())
{
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);
TEXTOBJ_UnlockText( hFont );
}
}
}
@ -529,7 +533,7 @@ W32kSetTextAlign(HDC hDC,
}
prevAlign = dc->w.textAlign;
dc->w.textAlign = Mode;
DC_ReleasePtr( hDC );
return prevAlign;
}
@ -548,7 +552,7 @@ W32kSetTextColor(HDC hDC,
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,6 +729,20 @@ 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