3 * Copyright (C) 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * PROJECT: ReactOS gdi32.dll
22 * FILE: lib/gdi32/misc/misc.c
23 * PURPOSE: Miscellaneous functions
24 * PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
31 PGDI_TABLE_ENTRY GdiHandleTable
= NULL
;
32 HANDLE CurrentProcessId
= NULL
;
33 DWORD GDI_BatchLimit
= 1;
49 BLENDFUNCTION BlendFunction
52 if ( hDCSrc
== NULL
) return FALSE
;
54 if (GDI_HANDLE_GET_TYPE(hDCSrc
) == GDI_OBJECT_TYPE_METADC
) return FALSE
;
56 return NtGdiAlphaBlend(
76 GdiFixUpHandle(HGDIOBJ hGdiObj
)
78 PGDI_TABLE_ENTRY Entry
;
80 if (((ULONG_PTR
)(hGdiObj
)) & GDI_HANDLE_UPPER_MASK
)
85 /* FIXME is this right ?? */
87 Entry
= GdiHandleTable
+ GDI_HANDLE_GET_INDEX(hGdiObj
);
89 /* Rebuild handle for Object */
90 return hGdiObj
= (HGDIOBJ
)(((LONG_PTR
)(hGdiObj
)) | (Entry
->Type
<< GDI_ENTRY_UPPER_SHIFT
));
100 return (PVOID
)GdiHandleTable
;
103 BOOL
GdiIsHandleValid(HGDIOBJ hGdiObj
)
105 PGDI_TABLE_ENTRY Entry
= GdiHandleTable
+ GDI_HANDLE_GET_INDEX(hGdiObj
);
106 if((Entry
->Type
& GDI_ENTRY_BASETYPE_MASK
) != 0 &&
107 (Entry
->Type
<< GDI_ENTRY_UPPER_SHIFT
) == GDI_HANDLE_GET_UPPER(hGdiObj
))
109 HANDLE pid
= (HANDLE
)((ULONG_PTR
)Entry
->ProcessId
& ~0x1);
110 if(pid
== NULL
|| pid
== CurrentProcessId
)
118 BOOL
GdiGetHandleUserData(HGDIOBJ hGdiObj
, PVOID
*UserData
)
120 PGDI_TABLE_ENTRY Entry
= GdiHandleTable
+ GDI_HANDLE_GET_INDEX(hGdiObj
);
121 if((Entry
->Type
& GDI_ENTRY_BASETYPE_MASK
) != 0 &&
122 (Entry
->Type
<< GDI_ENTRY_UPPER_SHIFT
) == GDI_HANDLE_GET_UPPER(hGdiObj
))
124 HANDLE pid
= (HANDLE
)((ULONG_PTR
)Entry
->ProcessId
& ~0x1);
125 if(pid
== NULL
|| pid
== CurrentProcessId
)
127 *UserData
= Entry
->UserData
;
131 SetLastError(ERROR_INVALID_PARAMETER
);
135 PLDC
GdiGetLDC(HDC hDC
)
138 if (!GdiGetHandleUserData((HGDIOBJ
) hDC
, (PVOID
) &Dc_Attr
))
140 return Dc_Attr
->pvLDC
;
148 GdiSetBatchLimit(DWORD Limit
)
150 DWORD OldLimit
= GDI_BatchLimit
;
153 (Limit
>= GDI_BATCH_LIMIT
))
159 GDI_BatchLimit
= Limit
;
171 return GDI_BatchLimit
;
179 GdiReleaseDC(HDC hdc
)
193 return NtGdiExtEscape(hDC
, NULL
, 0, nEscape
, cbInput
, (LPSTR
)lpszInData
, cbOutput
, lpszOutData
);
201 GdiSetLastError(DWORD dwErrCode
)
203 NtCurrentTeb ()->LastErrorValue
= (ULONG
) dwErrCode
;