-#include <w32k.h>
+#include <win32k.h>
#define NDEBUG
#include <debug.h>
-/*
- * DC device-independent Get/SetXXX functions
- * (RJJ) swiped from WINE
- */
-
-#define DC_GET_VAL( func_type, func_name, dc_field ) \
-func_type APIENTRY func_name( HDC hdc ) \
-{ \
- func_type ft; \
- PDC dc = DC_LockDc( hdc ); \
- PDC_ATTR pdcattr; \
- if (!dc) \
- { \
- SetLastWin32Error(ERROR_INVALID_HANDLE); \
- return 0; \
- } \
- pdcattr = dc->pdcattr; \
- ft = pdcattr->dc_field; \
- DC_UnlockDc(dc); \
- return ft; \
-}
-
-/* DC_GET_VAL_EX is used to define functions returning a POINT or a SIZE. It is
- * important that the function has the right signature, for the implementation
- * we can do whatever we want.
- */
-#define DC_GET_VAL_EX( FuncName, ret_x, ret_y, type, ax, ay ) \
-VOID FASTCALL Int##FuncName ( PDC dc, LP##type pt) \
-{ \
- PDC_ATTR pdcattr; \
- ASSERT(dc); \
- ASSERT(pt); \
- pdcattr = dc->pdcattr; \
- pt->ax = pdcattr->ret_x; \
- pt->ay = pdcattr->ret_y; \
-}
-
-#if 0
-BOOL APIENTRY NtGdi##FuncName ( HDC hdc, LP##type pt ) \
-{ \
- NTSTATUS Status = STATUS_SUCCESS; \
- type Safept; \
- PDC dc; \
- if(!pt) \
- { \
- SetLastWin32Error(ERROR_INVALID_PARAMETER); \
- return FALSE; \
- } \
- if(!(dc = DC_LockDc(hdc))) \
- { \
- SetLastWin32Error(ERROR_INVALID_HANDLE); \
- return FALSE; \
- } \
- Int##FuncName( dc, &Safept); \
- DC_UnlockDc(dc); \
- _SEH2_TRY \
- { \
- ProbeForWrite(pt, \
- sizeof( type ), \
- 1); \
- *pt = Safept; \
- } \
- _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) \
- { \
- Status = _SEH2_GetExceptionCode(); \
- } \
- _SEH2_END; \
- if(!NT_SUCCESS(Status)) \
- { \
- SetLastNtError(Status); \
- return FALSE; \
- } \
- return TRUE; \
-}
-#endif
-
-#define DC_SET_MODE( func_name, dc_field, min_val, max_val ) \
-INT APIENTRY func_name( HDC hdc, INT mode ) \
-{ \
- INT prevMode; \
- PDC dc; \
- PDC_ATTR pdcattr; \
- if ((mode < min_val) || (mode > max_val)) \
- { \
- SetLastWin32Error(ERROR_INVALID_PARAMETER); \
- return 0; \
- } \
- dc = DC_LockDc ( hdc ); \
- if ( !dc ) \
- { \
- SetLastWin32Error(ERROR_INVALID_HANDLE); \
- return 0; \
- } \
- pdcattr = dc->pdcattr; \
- prevMode = pdcattr->dc_field; \
- pdcattr->dc_field = mode; \
- DC_UnlockDc ( dc ); \
- return prevMode; \
-}
-
-
-DC_GET_VAL( INT, IntGdiGetMapMode, iMapMode )
-DC_GET_VAL( INT, IntGdiGetPolyFillMode, jFillMode )
-DC_GET_VAL( COLORREF, IntGdiGetBkColor, crBackgroundClr )
-DC_GET_VAL( INT, IntGdiGetBkMode, jBkMode )
-DC_GET_VAL( INT, IntGdiGetROP2, jROP2 )
-DC_GET_VAL( INT, IntGdiGetStretchBltMode, jStretchBltMode )
-DC_GET_VAL( UINT, IntGdiGetTextAlign, lTextAlign )
-DC_GET_VAL( COLORREF, IntGdiGetTextColor, crForegroundClr )
-
-DC_GET_VAL_EX( GetViewportOrgEx, ptlViewportOrg.x, ptlViewportOrg.y, POINT, x, y )
-DC_GET_VAL_EX( GetWindowExtEx, szlWindowExt.cx, szlWindowExt.cy, SIZE, cx, cy )
-DC_GET_VAL_EX( GetWindowOrgEx, ptlWindowOrg.x, ptlWindowOrg.y, POINT, x, y )
-
-DC_SET_MODE( IntGdiSetPolyFillMode, jFillMode, ALTERNATE, WINDING )
-DC_SET_MODE( IntGdiSetROP2, jROP2, R2_BLACK, R2_WHITE )
-DC_SET_MODE( IntGdiSetStretchBltMode, jStretchBltMode, BLACKONWHITE, HALFTONE )
-
-
-
COLORREF FASTCALL
IntGdiSetBkColor(HDC hDC, COLORREF color)
{
IntGdiSetTextColor(HDC hDC,
COLORREF color)
{
- COLORREF oldColor;
- PDC dc = DC_LockDc(hDC);
+ COLORREF crOldColor;
+ PDC pdc;
PDC_ATTR pdcattr;
- HBRUSH hBrush;
- if (!dc)
+ pdc = DC_LockDc(hDC);
+ if (!pdc)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
return CLR_INVALID;
}
- pdcattr = dc->pdcattr;
+ pdcattr = pdc->pdcattr;
- oldColor = pdcattr->crForegroundClr;
+ // What about ulForegroundClr, like in gdi32?
+ crOldColor = pdcattr->crForegroundClr;
pdcattr->crForegroundClr = color;
- hBrush = pdcattr->hbrush;
- pdcattr->ulDirty_ &= ~(DIRTY_TEXT|DIRTY_LINE|DIRTY_FILL);
- DC_UnlockDc(dc);
- NtGdiSelectBrush(hDC, hBrush);
- return oldColor;
+ DC_vUpdateTextBrush(pdc);
+
+ DC_UnlockDc(pdc);
+
+ return crOldColor;
}
VOID
}
#endif
-// FIXME: remove me
-HDC FASTCALL
-DC_GetNextDC (PDC pDC)
+BOOL
+FASTCALL
+IntSetDefaultRegion(PDC pdc)
{
- return pDC->hdcNext;
-}
+ PSURFACE pSurface;
+ PROSRGNDATA prgn;
+ RECTL rclWnd, rclClip;
-VOID FASTCALL
-DC_SetNextDC (PDC pDC, HDC hNextDC)
-{
- pDC->hdcNext = hNextDC;
+ IntGdiReleaseRaoRgn(pdc);
+
+ rclWnd.left = 0;
+ rclWnd.top = 0;
+ rclWnd.right = pdc->dclevel.sizl.cx;
+ rclWnd.bottom = pdc->dclevel.sizl.cy;
+ rclClip = rclWnd;
+
+// EngAcquireSemaphoreShared(pdc->ppdev->hsemDevLock);
+ if (pdc->ppdev->flFlags & PDEV_META_DEVICE)
+ {
+ pSurface = pdc->dclevel.pSurface;
+ if (pSurface && pSurface->flags & PDEV_SURFACE)
+ {
+ rclClip.left += pdc->ppdev->ptlOrigion.x;
+ rclClip.top += pdc->ppdev->ptlOrigion.y;
+ rclClip.right += pdc->ppdev->ptlOrigion.x;
+ rclClip.bottom += pdc->ppdev->ptlOrigion.y;
+ }
+ }
+// EngReleaseSemaphore(pdc->ppdev->hsemDevLock);
+
+ prgn = pdc->prgnVis;
+
+ if (prgn && prgn != prgnDefault)
+ {
+ REGION_SetRectRgn( prgn,
+ rclClip.left,
+ rclClip.top,
+ rclClip.right ,
+ rclClip.bottom );
+ }
+ else
+ {
+ prgn = IntSysCreateRectpRgn( rclClip.left,
+ rclClip.top,
+ rclClip.right ,
+ rclClip.bottom );
+ pdc->prgnVis = prgn;
+ }
+
+ if (prgn)
+ {
+ pdc->ptlDCOrig.x = 0;
+ pdc->ptlDCOrig.y = 0;
+ pdc->erclWindow = rclWnd;
+ pdc->erclClip = rclClip;
+ /* Might be an InitDC or DCE....*/
+ pdc->ptlFillOrigin.x = pdc->dcattr.VisRectRegion.Rect.right;
+ pdc->ptlFillOrigin.y = pdc->dcattr.VisRectRegion.Rect.bottom;
+ return TRUE;
+ }
+
+ pdc->prgnVis = prgnDefault;
+ return FALSE;
}
}
-
-
WORD APIENTRY
IntGdiSetHookFlags(HDC hDC, WORD Flags)
{
DWORD *Result)
{
BOOL Ret = TRUE;
- PDC dc;
+ PDC pdc;
PDC_ATTR pdcattr;
DWORD SafeResult = 0;
return FALSE;
}
- dc = DC_LockDc(hDC);
- if (!dc)
+ pdc = DC_LockDc(hDC);
+ if (!pdc)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
}
- pdcattr = dc->pdcattr;
+ pdcattr = pdc->pdcattr;
switch (u)
{
case GdiGetArcDirection:
if (pdcattr->dwLayout & LAYOUT_RTL)
- SafeResult = AD_CLOCKWISE - ((dc->dclevel.flPath & DCPATH_CLOCKWISE) != 0);
+ SafeResult = AD_CLOCKWISE - ((pdc->dclevel.flPath & DCPATH_CLOCKWISE) != 0);
else
- SafeResult = ((dc->dclevel.flPath & DCPATH_CLOCKWISE) != 0) + AD_COUNTERCLOCKWISE;
+ SafeResult = ((pdc->dclevel.flPath & DCPATH_CLOCKWISE) != 0) + AD_COUNTERCLOCKWISE;
break;
case GdiGetEMFRestorDc:
break;
case GdiGetFontLanguageInfo:
- SafeResult = IntGetFontLanguageInfo(dc);
+ SafeResult = IntGetFontLanguageInfo(pdc);
break;
case GdiGetIsMemDc:
- SafeResult = dc->dctype;
+ SafeResult = pdc->dctype;
break;
case GdiGetMapMode:
{
_SEH2_TRY
{
- ProbeForWrite(Result,
- sizeof(DWORD),
- 1);
+ ProbeForWrite(Result, sizeof(DWORD), 1);
*Result = SafeResult;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
- }
- if (!NT_SUCCESS(Status))
- {
- SetLastNtError(Status);
- DC_UnlockDc(dc);
- return FALSE;
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastNtError(Status);
+ Ret = FALSE;
+ }
}
- DC_UnlockDc(dc);
+ DC_UnlockDc(pdc);
return Ret;
}
DWORD *Result)
{
BOOL Ret = TRUE;
- PDC dc;
+ PDC pdc;
PDC_ATTR pdcattr;
DWORD SafeResult = 0;
return FALSE;
}
- dc = DC_LockDc(hDC);
- if (!dc)
+ pdc = DC_LockDc(hDC);
+ if (!pdc)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
}
- pdcattr = dc->pdcattr;
+ pdcattr = pdc->pdcattr;
switch (u)
{
case GdiGetSetCopyCount:
- SafeResult = dc->ulCopyCount;
- dc->ulCopyCount = dwIn;
+ SafeResult = pdc->ulCopyCount;
+ pdc->ulCopyCount = dwIn;
break;
case GdiGetSetTextAlign:
break;
case GdiGetSetMapMode:
- SafeResult = IntGdiSetMapMode(dc, dwIn);
+ SafeResult = IntGdiSetMapMode(pdc, dwIn);
break;
case GdiGetSetArcDirection:
}
if (pdcattr->dwLayout & LAYOUT_RTL) // Right to Left
{
- SafeResult = AD_CLOCKWISE - ((dc->dclevel.flPath & DCPATH_CLOCKWISE) != 0);
+ SafeResult = AD_CLOCKWISE - ((pdc->dclevel.flPath & DCPATH_CLOCKWISE) != 0);
if (dwIn == AD_CLOCKWISE)
{
- dc->dclevel.flPath &= ~DCPATH_CLOCKWISE;
+ pdc->dclevel.flPath &= ~DCPATH_CLOCKWISE;
break;
}
- dc->dclevel.flPath |= DCPATH_CLOCKWISE;
+ pdc->dclevel.flPath |= DCPATH_CLOCKWISE;
}
else // Left to Right
{
- SafeResult = ((dc->dclevel.flPath & DCPATH_CLOCKWISE) != 0) + AD_COUNTERCLOCKWISE;
+ SafeResult = ((pdc->dclevel.flPath & DCPATH_CLOCKWISE) != 0) +
+ AD_COUNTERCLOCKWISE;
if (dwIn == AD_COUNTERCLOCKWISE)
{
- dc->dclevel.flPath &= ~DCPATH_CLOCKWISE;
+ pdc->dclevel.flPath &= ~DCPATH_CLOCKWISE;
break;
}
- dc->dclevel.flPath |= DCPATH_CLOCKWISE;
+ pdc->dclevel.flPath |= DCPATH_CLOCKWISE;
}
break;
{
_SEH2_TRY
{
- ProbeForWrite(Result,
- sizeof(DWORD),
- 1);
+ ProbeForWrite(Result, sizeof(DWORD), 1);
*Result = SafeResult;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
- }
- if (!NT_SUCCESS(Status))
- {
- SetLastNtError(Status);
- DC_UnlockDc(dc);
- return FALSE;
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastNtError(Status);
+ Ret = FALSE;
+ }
}
- DC_UnlockDc(dc);
+ DC_UnlockDc(pdc);
return Ret;
}