ReactOS  0.4.13-dev-92-gf251225
dcattr.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS kernel
4  * PURPOSE: Functions for creation and destruction of DCs
5  * FILE: win32ss/gdi/ntgdi/dcattr.c
6  * PROGRAMER: Timo Kreuzer (timo.kreuzer@rectos.org)
7  */
8 
9 #include <win32k.h>
10 
11 #define NDEBUG
12 #include <debug.h>
13 
14 #define GDIDCATTRFREE 8
15 
16 typedef struct _GDI_DC_ATTR_FREELIST
17 {
22 
23 typedef struct _GDI_DC_ATTR_ENTRY
24 {
27 
28 
29 BOOL
30 NTAPI
32 {
33  PPROCESSINFO ppi;
34  PDC_ATTR pdcattr;
35 
37  ASSERT(ppi);
38 
39  pdcattr = GdiPoolAllocate(ppi->pPoolDcAttr);
40  if (!pdcattr)
41  {
42  DPRINT1("Could not allocate DC attr\n");
43  return FALSE;
44  }
45 
46  /* Copy the content from the kernel mode dc attr */
47  pdc->pdcattr = pdcattr;
48  *pdc->pdcattr = pdc->dcattr;
49 
50  /* Set the object attribute in the handle table */
51  GDIOBJ_vSetObjectAttr(&pdc->BaseObject, pdcattr);
52 
53  DPRINT("DC_AllocDcAttr: pdc=%p, pdc->pdcattr=%p\n", pdc, pdc->pdcattr);
54  return TRUE;
55 }
56 
57 VOID
58 NTAPI
60 {
61  PPROCESSINFO ppi;
62 
63  if (pdc->pdcattr == &pdc->dcattr)
64  {
65  // Internal DC object!
66  return;
67  }
68 
69  /* Reset the object attribute in the handle table */
70  GDIOBJ_vSetObjectAttr(&pdc->BaseObject, NULL);
71 
73  ASSERT(ppi);
74  GdiPoolFree(ppi->pPoolDcAttr, pdc->pdcattr);
75 
76  /* Reset to kmode dcattr */
77  pdc->pdcattr = &pdc->dcattr;
78 }
#define TRUE
Definition: types.h:120
struct _GDI_DC_ATTR_ENTRY * PGDI_DC_ATTR_ENTRY
VOID NTAPI GdiPoolFree(PGDI_POOL pPool, PVOID pvAlloc)
Definition: gdipool.c:233
LIST_ENTRY Entry
Definition: dcattr.c:18
VOID NTAPI DC_vFreeDcAttr(PDC pdc)
Definition: dcattr.c:59
struct _GDI_DC_ATTR_ENTRY GDI_DC_ATTR_ENTRY
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
struct _GDI_POOL * pPoolDcAttr
Definition: win32.h:282
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _GDI_DC_ATTR_FREELIST * PGDI_DC_ATTR_FREELIST
DC_ATTR Attr[GDIDCATTRFREE]
Definition: dcattr.c:25
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
PVOID NTAPI GdiPoolAllocate(PGDI_POOL pPool)
Definition: gdipool.c:122
Definition: dcattr.c:23
Definition: polytest.cpp:40
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID NTAPI GDIOBJ_vSetObjectAttr(POBJ pobj, PVOID pvObjAttr)
Definition: gdiobj.c:1091
BOOL NTAPI DC_bAllocDcAttr(PDC pdc)
Definition: dcattr.c:31
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: typedefs.h:117
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
#define DPRINT1
Definition: precomp.h:8
struct _GDI_DC_ATTR_FREELIST GDI_DC_ATTR_FREELIST
PVOID AttrList[GDIDCATTRFREE]
Definition: dcattr.c:20
#define GDIDCATTRFREE
Definition: dcattr.c:14