little GDI speed improvements

svn path=/trunk/; revision=9560
This commit is contained in:
Thomas Bluemel 2004-05-30 14:01:13 +00:00
parent 2e86c2a5bc
commit 56099c14d4
11 changed files with 63 additions and 90 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: clip.c,v 1.21 2004/05/14 22:56:18 gvg Exp $
/* $Id: clip.c,v 1.22 2004/05/30 14:01:12 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -45,18 +45,14 @@ IntEngCreateClipRegion(ULONG count, PRECTL pRect, PRECTL rcBounds)
if (1 < count)
{
hClip = (HCLIP) CreateGDIHandle(sizeof(CLIPGDI) + count * sizeof(RECTL),
sizeof(CLIPOBJ));
sizeof(CLIPOBJ), (PVOID*)&clipInt, (PVOID*)&clipUser);
if (hClip)
{
clipInt = (CLIPGDI *) AccessInternalObject(hClip);
RtlCopyMemory(clipInt->EnumRects.arcl, pRect, count * sizeof(RECTL));
clipInt->EnumRects.c = count;
clipInt->EnumOrder = CD_ANY;
clipUser = (CLIPOBJ *) AccessUserObject(hClip);
ASSERT(NULL != clipUser);
clipUser->iDComplexity = DC_COMPLEX;
clipUser->iFComplexity = (count <= 4) ? FC_RECT4: FC_COMPLEX;
clipUser->iMode = TC_RECTANGLES;
@ -68,17 +64,14 @@ IntEngCreateClipRegion(ULONG count, PRECTL pRect, PRECTL rcBounds)
else
{
hClip = (HCLIP) CreateGDIHandle(sizeof(CLIPGDI),
sizeof(CLIPOBJ));
sizeof(CLIPOBJ),
(PVOID)&clipInt, (PVOID)&clipUser);
if (hClip)
{
clipInt = (CLIPGDI *) AccessInternalObject(hClip);
RtlCopyMemory(clipInt->EnumRects.arcl, rcBounds, sizeof(RECTL));
clipInt->EnumRects.c = 1;
clipInt->EnumOrder = CD_ANY;
clipUser = (CLIPOBJ *) AccessUserObject(hClip);
ASSERT(NULL != clipUser);
clipUser->iDComplexity = ((rcBounds->top==rcBounds->bottom)
&& (rcBounds->left==rcBounds->right))
? DC_TRIVIAL : DC_RECT;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: handle.c,v 1.15 2004/05/10 17:07:17 weiden Exp $
/* $Id: handle.c,v 1.16 2004/05/30 14:01:12 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -29,28 +29,34 @@
#include <w32k.h>
static int LastHandle = MAX_GDI_HANDLES;
static GDI_HANDLE GDIHandles[MAX_GDI_HANDLES];
ULONG FASTCALL CreateGDIHandle(ULONG InternalSize, ULONG UserSize)
ULONG FASTCALL CreateGDIHandle(ULONG InternalSize, ULONG UserSize, PVOID *InternalObject, PVOID *UserObject)
{
ULONG size;
PENGOBJ pObj;
int i;
//size = sizeof( ENGOBJ ) + InternalSize + UserSize;
size = InternalSize; //internal size includes header and user portions
pObj = EngAllocMem( FL_ZERO_MEMORY, size, 0 );
/* internal size includes header and user portions */
pObj = EngAllocMem( FL_ZERO_MEMORY, InternalSize, 0 );
if( !pObj )
return 0;
#if 0
/* not used at the moment */
pObj->InternalSize = InternalSize;
pObj->UserSize = UserSize;
#endif
for( i = (MAX_GDI_HANDLES - 1 <= LastHandle ? 1 : LastHandle + 1); i != LastHandle;
i = (MAX_GDI_HANDLES - 1 <= i ? 1 : i + 1) ){
if( GDIHandles[ i ].pEngObj == NULL ){
pObj->hObj = i;
GDIHandles[ i ].pEngObj = pObj;
*InternalObject = pObj;
*UserObject = (PVOID)( (PCHAR)pObj + sizeof( ENGOBJ ) );
DPRINT("CreateGDIHandle: obj: %x, handle: %d, usersize: %d\n", pObj, i, UserSize );
LastHandle = i;
return i;
@ -77,13 +83,12 @@ PVOID FASTCALL AccessInternalObject(ULONG Handle)
PENGOBJ pEngObj;
if (Handle == 0 || Handle >= MAX_GDI_HANDLES
|| GDIHandles[Handle].pEngObj == NULL)
|| !(pEngObj = GDIHandles[Handle].pEngObj))
{
DPRINT1("AccessInternalObject: invalid handle: %d!!!!\n", Handle);
return NULL;
}
pEngObj = GDIHandles[Handle].pEngObj;
return (PVOID)pEngObj;
}
@ -92,13 +97,12 @@ PVOID FASTCALL AccessUserObject(ULONG Handle)
PENGOBJ pEngObj;
if (Handle == 0 || Handle >= MAX_GDI_HANDLES
|| GDIHandles[Handle].pEngObj == NULL)
|| !(pEngObj = GDIHandles[Handle].pEngObj))
{
DPRINT1("AccessUserObject: invalid handle: %d!!!!\n", Handle);
return NULL;
}
pEngObj = GDIHandles[Handle].pEngObj;
return (PVOID)( (PCHAR)pEngObj + sizeof( ENGOBJ ) );
}
@ -120,12 +124,6 @@ ULONG FASTCALL AccessHandleFromUserObject(PVOID UserObject)
return Handle;
}
PVOID FASTCALL AccessInternalObjectFromUserObject(PVOID UserObject)
{
return AccessInternalObject( AccessHandleFromUserObject( UserObject ) );
}
VOID FASTCALL InitEngHandleTable( void )
{
ULONG i;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: handle.h,v 1.5 2003/05/18 17:16:17 ea Exp $
/* $Id: handle.h,v 1.6 2004/05/30 14:01:12 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -39,8 +39,6 @@ typedef struct _GDI_HANDLE {
#define INVALID_HANDLE 0
#define MAX_GDI_HANDLES 4096
GDI_HANDLE GDIHandles[MAX_GDI_HANDLES];
#define ValidEngHandle( x ) (!( (x) == INVALID_HANDLE ))
#endif

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: mouse.c,v 1.70 2004/05/14 23:57:32 weiden Exp $
/* $Id: mouse.c,v 1.71 2004/05/30 14:01:12 weiden Exp $
*
* PROJECT: ReactOS kernel
* PURPOSE: Mouse
@ -51,9 +51,11 @@ EnableMouse(HDC hDisplayDC)
dc = DC_LockDc(hDisplayDC);
SurfObj = (SURFOBJ*)AccessUserObject((ULONG) dc->Surface);
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
DC_UnlockDc( hDisplayDC );
ASSERT(SurfObj);
SurfGDI = (PSURFGDI)AccessInternalObjectFromUserObject(SurfObj);
/* Move the cursor to the screen center */
DPRINT("Setting Cursor up at 0x%x, 0x%x\n", SurfObj->sizlBitmap.cx / 2, SurfObj->sizlBitmap.cy / 2);
ExAcquireFastMutex(&CurInfo->CursorMutex);

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: surface.c,v 1.39 2004/05/14 22:56:18 gvg Exp $
/* $Id: surface.c,v 1.40 2004/05/30 14:01:12 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -317,14 +317,10 @@ EngCreateBitmap(IN SIZEL Size,
PVOID UncompressedBits;
ULONG UncompressedFormat;
NewBitmap = (PVOID)CreateGDIHandle(sizeof(SURFGDI), sizeof(SURFOBJ));
NewBitmap = (PVOID)CreateGDIHandle(sizeof(SURFGDI), sizeof(SURFOBJ), (PVOID*)&SurfGDI, (PVOID*)&SurfObj);
if( !ValidEngHandle( NewBitmap ) )
return 0;
SurfObj = (SURFOBJ*) AccessUserObject( (ULONG) NewBitmap );
SurfGDI = (SURFGDI*) AccessInternalObject( (ULONG) NewBitmap );
ASSERT( SurfObj );
ASSERT( SurfGDI );
SurfGDI->BitsPerPixel = BitsPerFormat(Format);
if (Format == BMF_4RLE) {
SurfObj->lDelta = DIB_GetDIBWidthBytes(Size.cx, BitsPerFormat(BMF_4BPP));
@ -401,15 +397,10 @@ EngCreateDeviceSurface(IN DHSURF dhsurf,
SURFOBJ *SurfObj;
SURFGDI *SurfGDI;
NewSurface = (HSURF)CreateGDIHandle(sizeof( SURFGDI ), sizeof( SURFOBJ ));
NewSurface = (HSURF)CreateGDIHandle(sizeof( SURFGDI ), sizeof( SURFOBJ ), (PVOID*)&SurfGDI, (PVOID*)&SurfObj);
if( !ValidEngHandle( NewSurface ) )
return 0;
SurfObj = (SURFOBJ*) AccessUserObject( (ULONG) NewSurface );
SurfGDI = (SURFGDI*) AccessInternalObject( (ULONG) NewSurface );
ASSERT( SurfObj );
ASSERT( SurfGDI );
SurfGDI->BitsPerPixel = BitsPerFormat(Format);
SurfObj->dhsurf = dhsurf;
SurfObj->hsurf = (HSURF) dhsurf; // FIXME: Is this correct??
@ -450,8 +441,9 @@ EngAssociateSurface(IN HSURF Surface,
Device = (GDIDEVICE*)Dev;
SurfGDI = (PVOID)AccessInternalObject((ULONG)Surface);
SurfObj = (PVOID)AccessUserObject((ULONG)Surface);
SurfObj = (SURFOBJ*)AccessUserObject((ULONG)Surface);
ASSERT(SurfObj);
SurfGDI = (SURFGDI*)AccessInternalObjectFromUserObject(SurfObj);
// Associate the hdev
SurfObj->hdev = Dev;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: xlate.c,v 1.34 2004/05/10 17:07:17 weiden Exp $
/* $Id: xlate.c,v 1.35 2004/05/30 14:01:12 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -215,15 +215,10 @@ XLATEOBJ * STDCALL IntEngCreateXlate(USHORT DestPalType, USHORT SourcePalType,
ULONG DestRedMask, DestGreenMask, DestBlueMask;
UINT i;
NewXlate = (HPALETTE)CreateGDIHandle(sizeof( XLATEGDI ), sizeof( XLATEOBJ ));
NewXlate = (HPALETTE)CreateGDIHandle(sizeof( XLATEGDI ), sizeof( XLATEOBJ ), (PVOID*)&XlateGDI, (PVOID*)&XlateObj);
if ( !ValidEngHandle ( NewXlate ) )
return NULL;
XlateObj = (XLATEOBJ*) AccessUserObject( (ULONG) NewXlate );
XlateGDI = (XLATEGDI*) AccessInternalObject( (ULONG) NewXlate );
ASSERT( XlateObj );
ASSERT( XlateGDI );
if (NULL != PaletteSource)
{
SourcePalGDI = PALETTE_LockPalette(PaletteSource);
@ -396,15 +391,10 @@ XLATEOBJ * STDCALL IntEngCreateMonoXlate(
XLATEGDI *XlateGDI;
PALGDI *SourcePalGDI;
NewXlate = (HPALETTE)CreateGDIHandle(sizeof(XLATEGDI), sizeof(XLATEOBJ));
NewXlate = (HPALETTE)CreateGDIHandle(sizeof(XLATEGDI), sizeof(XLATEOBJ), (PVOID*)&XlateGDI, (PVOID*)&XlateObj);
if (!ValidEngHandle(NewXlate))
return NULL;
XlateObj = (XLATEOBJ *)AccessUserObject((ULONG)NewXlate);
XlateGDI = (XLATEGDI *)AccessInternalObject((ULONG)NewXlate);
ASSERT(XlateObj);
ASSERT(XlateGDI);
XlateObj->iSrcType = SourcePalType;
XlateObj->iDstType = PAL_INDEXED;

View file

@ -112,15 +112,17 @@ ObmCreateHandleTable(VOID);
VOID FASTCALL ObmDestroyHandleTable (PUSER_HANDLE_TABLE HandleTable);
ULONG FASTCALL CreateGDIHandle (ULONG InternalSize, ULONG UserSize);
ULONG FASTCALL CreateGDIHandle (ULONG InternalSize, ULONG UserSize, PVOID *InternalObject, PVOID *UserObject);
VOID FASTCALL FreeGDIHandle (ULONG Handle);
PVOID FASTCALL AccessUserObject (ULONG Handle);
PVOID FASTCALL AccessInternalObject (ULONG Handle);
PVOID FASTCALL AccessInternalObjectFromUserObject (PVOID UserObject);
ULONG FASTCALL AccessHandleFromUserObject (PVOID UserObject);
#define AccessInternalObjectFromUserObject(UserObj) \
((PVOID)( (PCHAR)(UserObj) - sizeof( ENGOBJ ) ) )
VOID FASTCALL InitEngHandleTable (VOID);
VOID FASTCALL InitGdiObjectHandleTable (VOID);

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: cursoricon.c,v 1.56 2004/05/14 23:57:32 weiden Exp $ */
/* $Id: cursoricon.c,v 1.57 2004/05/30 14:01:13 weiden Exp $ */
#include <w32k.h>
PCURICON_OBJECT FASTCALL
@ -99,7 +99,7 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor,
}
SurfObj = (SURFOBJ*)AccessUserObject((ULONG) dc->Surface);
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
SurfGDI = (PSURFGDI)AccessInternalObjectFromUserObject(SurfObj);
DevInfo = dc->DevInfo;
DC_UnlockDc(Screen);
}

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: dc.c,v 1.136 2004/05/26 18:49:06 weiden Exp $
/* $Id: dc.c,v 1.137 2004/05/30 14:01:13 weiden Exp $
*
* DC.C - Device context functions
*
@ -652,7 +652,7 @@ IntCreatePrimarySurface()
SurfObj = (SURFOBJ*)AccessUserObject((ULONG) PrimarySurface.Handle);
SurfObj->dhpdev = PrimarySurface.PDev;
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) PrimarySurface.Handle);
SurfGDI = (PSURFGDI)AccessInternalObjectFromUserObject(SurfObj);
IntShowDesktop(
IntGetActiveDesktop(),
SurfGDI->SurfObj.sizlBitmap.cx,
@ -676,7 +676,7 @@ IntDestroyPrimarySurface()
#if 0
DPRINT("Hiding mouse pointer\n" );
SurfObj = (SURFOBJ*)AccessUserObject((ULONG) PrimarySurface.Handle);
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) PrimarySurface.Handle);
SurfGDI = (PSURFGDI)AccessInternalObjectFromUserObject(SurfObj);
SurfGDI->SetPointerShape(SurfObj, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0);
#endif
DPRINT("Reseting display\n" );

View file

@ -1,5 +1,5 @@
/*
* $Id: dib.c,v 1.49 2004/05/15 15:04:43 navaraf Exp $
* $Id: dib.c,v 1.50 2004/05/30 14:01:13 weiden Exp $
*
* ReactOS W32 Subsystem
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
@ -152,7 +152,7 @@ IntSetDIBits(
DestBitmap = BitmapToSurf(bitmap, DC->GDIDevice);
DestSurf = (SURFOBJ*) AccessUserObject( (ULONG)DestBitmap );
DestGDI = (PSURFGDI) AccessInternalObject( (ULONG)DestBitmap );
DestGDI = (PSURFGDI) AccessInternalObjectFromUserObject( DestSurf );
// Create source surface
SourceSize.cx = bmi->bmiHeader.biWidth;

View file

@ -22,7 +22,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: text.c,v 1.93 2004/05/29 15:10:27 navaraf Exp $ */
/* $Id: text.c,v 1.94 2004/05/30 14:01:13 weiden Exp $ */
#include <w32k.h>
#include <ft2build.h>
@ -178,9 +178,12 @@ IntGdiAddFontResource(PUNICODE_STRING Filename, DWORD fl)
IO_STATUS_BLOCK Iosb;
PFONT_ENTRY entry;
NewFont = (HFONT)CreateGDIHandle(sizeof( FONTGDI ), sizeof( FONTOBJ ));
FontObj = (FONTOBJ*) AccessUserObject( (ULONG) NewFont );
FontGDI = (PFONTGDI) AccessInternalObject( (ULONG) NewFont );
NewFont = (HFONT)CreateGDIHandle(sizeof( FONTGDI ), sizeof( FONTOBJ ), (PVOID*)&FontGDI, (PVOID*)&FontObj);
if(NewFont == 0)
{
DPRINT1("Could not allocate a new GDI font object\n");
return 0;
}
// Open the Module
InitializeObjectAttributes(&ObjectAttributes, Filename, 0, NULL, NULL);
@ -399,18 +402,20 @@ BOOL FASTCALL InitFontSupport(VOID)
static NTSTATUS STDCALL
GetFontObjectsFromTextObj(PTEXTOBJ TextObj, HFONT *FontHandle, FONTOBJ **FontObj, PFONTGDI *FontGDI)
{
FONTOBJ *FntObj;
NTSTATUS Status = STATUS_SUCCESS;
ASSERT(NULL != TextObj && NULL != TextObj->GDIFontHandle);
if (NULL != TextObj && NULL != TextObj->GDIFontHandle)
{
if (NT_SUCCESS(Status) && NULL != FontHandle)
if (NULL != FontHandle)
{
*FontHandle = TextObj->GDIFontHandle;
}
if (NT_SUCCESS(Status) && NULL != FontObj)
FntObj = (FONTOBJ*)AccessUserObject((ULONG) TextObj->GDIFontHandle);
if (NULL != FontObj)
{
*FontObj = AccessUserObject((ULONG) TextObj->GDIFontHandle);
*FontObj = FntObj;
if (NULL == *FontObj)
{
ASSERT(FALSE);
@ -419,20 +424,13 @@ GetFontObjectsFromTextObj(PTEXTOBJ TextObj, HFONT *FontHandle, FONTOBJ **FontObj
}
if (NT_SUCCESS(Status) && NULL != FontGDI)
{
*FontGDI = AccessInternalObject((ULONG) TextObj->GDIFontHandle);
if (NULL == *FontGDI)
{
ASSERT(FALSE);
Status = STATUS_INVALID_HANDLE;
}
*FontGDI = AccessInternalObjectFromUserObject(FntObj);
}
return Status;
}
else
{
Status = STATUS_INVALID_HANDLE;
}
return Status;
return STATUS_INVALID_HANDLE;
}
int