Author: jimtabor
Date: Mon Dec 28 08:02:32 2009
New Revision: 44792
URL:
http://svn.reactos.org/svn/reactos?rev=44792&view=rev
Log:
[Win32k]
- Added two new function's to support thread and process information free attribute
list support.
Modified:
trunk/reactos/subsystems/win32/win32k/main/dllmain.c
trunk/reactos/subsystems/win32/win32k/objects/dcattr.c
Modified: trunk/reactos/subsystems/win32/win32k/main/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ma…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/main/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/main/dllmain.c [iso-8859-1] Mon Dec 28 08:02:32
2009
@@ -113,6 +113,9 @@
InitializeListHead(&Win32Process->ClassList);
InitializeListHead(&Win32Process->MenuListHead);
+
+ InitializeListHead(&Win32Process->GDIBrushAttrFreeList);
+ InitializeListHead(&Win32Process->GDIDcAttrFreeList);
InitializeListHead(&Win32Process->PrivateFontListHead);
ExInitializeFastMutex(&Win32Process->PrivateFontListLock);
Modified: trunk/reactos/subsystems/win32/win32k/objects/dcattr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dcattr.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dcattr.c [iso-8859-1] Mon Dec 28
08:02:32 2009
@@ -11,6 +11,147 @@
#define NDEBUG
#include <debug.h>
+
+#define GDIDCATTRFREE 8
+
+typedef struct _GDI_DC_ATTR_FREELIST
+{
+ LIST_ENTRY Entry;
+ DWORD nEntries;
+ PVOID AttrList[GDIDCATTRFREE];
+} GDI_DC_ATTR_FREELIST, *PGDI_DC_ATTR_FREELIST;
+
+typedef struct _GDI_DC_ATTR_ENTRY
+{
+ DC_ATTR Attr[GDIDCATTRFREE];
+} GDI_DC_ATTR_ENTRY, *PGDI_DC_ATTR_ENTRY;
+
+
+PDC_ATTR
+FASTCALL
+AllocateDcAttr(VOID)
+{
+ PTHREADINFO pti;
+ PPROCESSINFO ppi;
+ PDC_ATTR pDc_Attr;
+ PGDI_DC_ATTR_FREELIST pGdiDcAttrFreeList;
+ PGDI_DC_ATTR_ENTRY pGdiDcAttrEntry;
+ int i;
+
+ pti = PsGetCurrentThreadWin32Thread();
+ if (pti->pgdiDcattr)
+ {
+ pDc_Attr = pti->pgdiDcattr; // Get the free one.
+ pti->pgdiDcattr = NULL;
+ return pDc_Attr;
+ }
+
+ ppi = PsGetCurrentProcessWin32Process();
+
+ if (!ppi->pDCAttrList) // If set point is null, allocate new group.
+ {
+ pGdiDcAttrEntry = EngAllocUserMem(sizeof(GDI_DC_ATTR_ENTRY), 0);
+
+ if (!pGdiDcAttrEntry)
+ {
+ DPRINT1("DcAttr Failed User Allocation!\n");
+ return NULL;
+ }
+
+ DPRINT("AllocDcAttr User 0x%x\n",pGdiDcAttrEntry);
+
+ pGdiDcAttrFreeList = ExAllocatePoolWithTag( PagedPool,
+ sizeof(GDI_DC_ATTR_FREELIST),
+ GDITAG_DC_FREELIST);
+ if ( !pGdiDcAttrFreeList )
+ {
+ EngFreeUserMem(pGdiDcAttrEntry);
+ return NULL;
+ }
+
+ RtlZeroMemory(pGdiDcAttrFreeList, sizeof(GDI_DC_ATTR_FREELIST));
+
+ DPRINT("AllocDcAttr Ex 0x%x\n",pGdiDcAttrFreeList);
+
+ InsertHeadList( &ppi->GDIDcAttrFreeList, &pGdiDcAttrFreeList->Entry);
+
+ pGdiDcAttrFreeList->nEntries = GDIDCATTRFREE;
+ // Start at the bottom up and set end of free list point.
+ ppi->pDCAttrList = &pGdiDcAttrEntry->Attr[GDIDCATTRFREE-1];
+ // Build the free attr list.
+ for ( i = 0; i < GDIDCATTRFREE; i++)
+ {
+ pGdiDcAttrFreeList->AttrList[i] = &pGdiDcAttrEntry->Attr[i];
+ }
+ }
+
+ pDc_Attr = ppi->pDCAttrList;
+ pGdiDcAttrFreeList = (PGDI_DC_ATTR_FREELIST)ppi->GDIDcAttrFreeList.Flink;
+
+ // Free the list when it is full!
+ if ( pGdiDcAttrFreeList->nEntries-- == 1)
+ { // No more free entries, so yank the list.
+ RemoveEntryList( &pGdiDcAttrFreeList->Entry );
+
+ ExFreePoolWithTag( pGdiDcAttrFreeList, GDITAG_DC_FREELIST );
+
+ if ( IsListEmpty( &ppi->GDIDcAttrFreeList ) )
+ {
+ ppi->pDCAttrList = NULL;
+ return pDc_Attr;
+ }
+
+ pGdiDcAttrFreeList = (PGDI_DC_ATTR_FREELIST)ppi->GDIDcAttrFreeList.Flink;
+ }
+
+ ppi->pDCAttrList =
pGdiDcAttrFreeList->AttrList[pGdiDcAttrFreeList->nEntries-1];
+
+ return pDc_Attr;
+}
+
+VOID
+FASTCALL
+FreeDcAttr(PDC_ATTR pDc_Attr)
+{
+ PTHREADINFO pti;
+ PPROCESSINFO ppi;
+ PGDI_DC_ATTR_FREELIST pGdiDcAttrFreeList;
+
+ pti = PsGetCurrentThreadWin32Thread();
+
+ if (!pti) return;
+
+ if (!pti->pgdiDcattr)
+ { // If it is null, just cache it for the next time.
+ pti->pgdiDcattr = pDc_Attr;
+ return;
+ }
+
+ ppi = PsGetCurrentProcessWin32Process();
+
+ pGdiDcAttrFreeList = (PGDI_DC_ATTR_FREELIST)ppi->GDIDcAttrFreeList.Flink;
+
+ // We add to the list of free entries, so this will grows!
+ if ( IsListEmpty(&ppi->GDIDcAttrFreeList) ||
+ pGdiDcAttrFreeList->nEntries == GDIDCATTRFREE )
+ {
+ pGdiDcAttrFreeList = ExAllocatePoolWithTag( PagedPool,
+ sizeof(GDI_DC_ATTR_FREELIST),
+ GDITAG_DC_FREELIST);
+ if ( !pGdiDcAttrFreeList )
+ {
+ return;
+ }
+ InsertHeadList( &ppi->GDIDcAttrFreeList, &pGdiDcAttrFreeList->Entry);
+ pGdiDcAttrFreeList->nEntries = 0;
+ }
+ // Up count, save the entry and set end of free list point.
+ ++pGdiDcAttrFreeList->nEntries; // Top Down...
+ pGdiDcAttrFreeList->AttrList[pGdiDcAttrFreeList->nEntries-1] = pDc_Attr;
+ ppi->pDCAttrList = pDc_Attr;
+
+ return;
+}
VOID
FASTCALL