Commit in reactos/subsys/win32k on MAIN
eng/clip.c+4-111.21 -> 1.22
   /handle.c+17-191.15 -> 1.16
   /handle.h+1-31.5 -> 1.6
   /mouse.c+4-21.70 -> 1.71
   /surface.c+6-141.39 -> 1.40
   /xlate.c+3-131.34 -> 1.35
include/object.h+4-21.22 -> 1.23
objects/cursoricon.c+2-21.56 -> 1.57
       /dc.c+3-31.136 -> 1.137
       /dib.c+2-21.49 -> 1.50
       /text.c+17-191.93 -> 1.94
+63-90
11 modified files
little GDI speed improvements

reactos/subsys/win32k/eng
clip.c 1.21 -> 1.22
diff -u -r1.21 -r1.22
--- clip.c	14 May 2004 22:56:18 -0000	1.21
+++ clip.c	30 May 2004 14:01:12 -0000	1.22
@@ -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 @@
   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 @@
   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;

reactos/subsys/win32k/eng
handle.c 1.15 -> 1.16
diff -u -r1.15 -r1.16
--- handle.c	10 May 2004 17:07:17 -0000	1.15
+++ handle.c	30 May 2004 14:01:12 -0000	1.16
@@ -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 @@
   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 @@
   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 @@
   return Handle;
 }
 
-PVOID FASTCALL AccessInternalObjectFromUserObject(PVOID UserObject)
-{
-
-  return AccessInternalObject( AccessHandleFromUserObject( UserObject ) );
-}
-
 VOID FASTCALL InitEngHandleTable( void )
 {
 	ULONG i;

reactos/subsys/win32k/eng
handle.h 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- handle.h	18 May 2003 17:16:17 -0000	1.5
+++ handle.h	30 May 2004 14:01:12 -0000	1.6
@@ -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 @@
 #define INVALID_HANDLE  0
 #define MAX_GDI_HANDLES 4096
 
-GDI_HANDLE GDIHandles[MAX_GDI_HANDLES];
-
 #define ValidEngHandle( x )  (!( (x) == INVALID_HANDLE ))
 
 #endif

reactos/subsys/win32k/eng
mouse.c 1.70 -> 1.71
diff -u -r1.70 -r1.71
--- mouse.c	14 May 2004 23:57:32 -0000	1.70
+++ mouse.c	30 May 2004 14:01:12 -0000	1.71
@@ -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 @@
     
     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);

reactos/subsys/win32k/eng
surface.c 1.39 -> 1.40
diff -u -r1.39 -r1.40
--- surface.c	14 May 2004 22:56:18 -0000	1.39
+++ surface.c	30 May 2004 14:01:12 -0000	1.40
@@ -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 @@
   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 @@
   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 @@
 
   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;

reactos/subsys/win32k/eng
xlate.c 1.34 -> 1.35
diff -u -r1.34 -r1.35
--- xlate.c	10 May 2004 17:07:17 -0000	1.34
+++ xlate.c	30 May 2004 14:01:12 -0000	1.35
@@ -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 @@
   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 @@
    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;
 

reactos/subsys/win32k/include
object.h 1.22 -> 1.23
diff -u -r1.22 -r1.23
--- object.h	5 Apr 2004 21:26:25 -0000	1.22
+++ object.h	30 May 2004 14:01:12 -0000	1.23
@@ -112,15 +112,17 @@
 
 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);
 

reactos/subsys/win32k/objects
cursoricon.c 1.56 -> 1.57
diff -u -r1.56 -r1.57
--- cursoricon.c	14 May 2004 23:57:32 -0000	1.56
+++ cursoricon.c	30 May 2004 14:01:13 -0000	1.57
@@ -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 @@
       }
   
       SurfObj = (SURFOBJ*)AccessUserObject((ULONG) dc->Surface);
-      SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
+      SurfGDI = (PSURFGDI)AccessInternalObjectFromUserObject(SurfObj);
       DevInfo = dc->DevInfo;
       DC_UnlockDc(Screen);
    }

reactos/subsys/win32k/objects
dc.c 1.136 -> 1.137
diff -u -r1.136 -r1.137
--- dc.c	26 May 2004 18:49:06 -0000	1.136
+++ dc.c	30 May 2004 14:01:13 -0000	1.137
@@ -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 @@
 
       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 @@
 #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" );

reactos/subsys/win32k/objects
dib.c 1.49 -> 1.50
diff -u -r1.49 -r1.50
--- dib.c	15 May 2004 15:04:43 -0000	1.49
+++ dib.c	30 May 2004 14:01:13 -0000	1.50
@@ -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 @@
   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;

reactos/subsys/win32k/objects
text.c 1.93 -> 1.94
diff -u -r1.93 -r1.94
--- text.c	29 May 2004 15:10:27 -0000	1.93
+++ text.c	30 May 2004 14:01:13 -0000	1.94
@@ -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 @@
   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 @@
 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 @@
     }
     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
CVSspam 0.2.8