Author: tkreuzer
Date: Mon Dec 29 13:11:40 2014
New Revision: 65881
URL:
http://svn.reactos.org/svn/reactos?rev=65881&view=rev
Log:
[GDI32]
Improve GetROP2and SetROP2
Modified:
trunk/reactos/win32ss/gdi/gdi32/objects/dc.c
Modified: trunk/reactos/win32ss/gdi/gdi32/objects/dc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/objects/…
==============================================================================
--- trunk/reactos/win32ss/gdi/gdi32/objects/dc.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/gdi32/objects/dc.c [iso-8859-1] Mon Dec 29 13:11:40 2014
@@ -1152,11 +1152,20 @@
*/
int
WINAPI
-GetROP2(HDC hdc)
-{
- PDC_ATTR Dc_Attr;
- if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr))
return 0;
- return Dc_Attr->jROP2;
+GetROP2(
+ _In_ HDC hdc)
+{
+ PDC_ATTR pdcattr;
+
+ /* Get the DC attribute */
+ pdcattr = GdiGetDcAttr(hdc);
+ if (pdcattr == NULL)
+ {
+ /* Do not set LastError here! */
+ return 0;
+ }
+
+ return pdcattr->jROP2;
}
/*
@@ -1164,18 +1173,19 @@
*/
int
WINAPI
-SetROP2(HDC hdc,
- int fnDrawMode)
-{
- PDC_ATTR Dc_Attr;
- INT Old_ROP2;
+SetROP2(
+ _In_ HDC hdc,
+ _In_ int rop2)
+{
+ PDC_ATTR pdcattr;
+ INT rop2Old;
#if 0
// Handle something other than a normal dc object.
if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)
{
if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC)
- return MFDRV_SetROP2( hdc, fnDrawMode);
+ return MFDRV_SetROP2( hdc, rop2);
else
{
PLDC pLDC = GdiGetLDC(hdc);
@@ -1186,27 +1196,34 @@
}
if (pLDC->iType == LDC_EMFLDC)
{
- return EMFDRV_SetROP2(( hdc, fnDrawMode);
+ return EMFDRV_SetROP2(( hdc, rop2);
}
return FALSE;
}
}
#endif
- if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr))
return FALSE;
+
+ /* Get the DC attribute */
+ pdcattr = GdiGetDcAttr(hdc);
+ if (pdcattr == NULL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
if (NtCurrentTeb()->GdiTebBatch.HDC == hdc)
{
- if (Dc_Attr->ulDirty_ & DC_MODE_DIRTY)
+ if (pdcattr->ulDirty_ & DC_MODE_DIRTY)
{
NtGdiFlush();
- Dc_Attr->ulDirty_ &= ~DC_MODE_DIRTY;
- }
- }
-
- Old_ROP2 = Dc_Attr->jROP2;
- Dc_Attr->jROP2 = fnDrawMode;
-
- return Old_ROP2;
+ pdcattr->ulDirty_ &= ~DC_MODE_DIRTY;
+ }
+ }
+
+ rop2Old = pdcattr->jROP2;
+ pdcattr->jROP2 = (BYTE)rop2;
+
+ return rop2Old;
}