📄 painting.c
字号:
#include "precomp.h"
#if 0 /* FIXME: enable this as soon as we have working usermode gdi */
// Will move to dc.c
HGDIOBJ
STDCALL
GetDCObject( HDC hDC, INT iType)
{
if((iType == GDI_OBJECT_TYPE_BRUSH) ||
(iType == GDI_OBJECT_TYPE_EXTPEN)||
(iType == GDI_OBJECT_TYPE_PEN) ||
(iType == GDI_OBJECT_TYPE_COLORSPACE))
{
HGDIOBJ hGO;
PDC_ATTR Dc_Attr;
if (!GdiGetHandleUserData((HGDIOBJ) hDC, (PVOID) &Dc_Attr)) return NULL;
switch (iType)
{
case GDI_OBJECT_TYPE_BRUSH:
hGO = Dc_Attr->hbrush;
break;
case GDI_OBJECT_TYPE_EXTPEN:
case GDI_OBJECT_TYPE_PEN:
hGO = Dc_Attr->hpen;
break;
case GDI_OBJECT_TYPE_COLORSPACE:
hGO = Dc_Attr->hColorSpace;
break;
}
return hGO;
}
return NtGdiGetDCObject( hDC, iType );
}
BOOL
STDCALL
LineTo( HDC hDC, INT x, INT y )
{
// 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_MetaParam2( hDC, META_LINETO, x, y);
else
{
PLDC pLDC = GdiGetLDC(hDC);
if ( !pLDC )
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (pLDC->iType == LDC_EMFLDC)
{
return MFDRV_LineTo( hDC, x, y )
}
return FALSE;
}
}
return NtGdiLineTo( hDC, x, y);
}
BOOL
STDCALL
MoveToEx( HDC hDC, INT x, INT y, LPPOINT Point )
{
PDC_ATTR Dc_Attr;
if (!GdiGetHandleUserData((HGDIOBJ) hDC, (PVOID) &Dc_Attr)) return FALSE;
if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC)
{
if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC)
return MFDRV_MetaParam2( hDC, META_MOVETO, x, y);
else
{
PLDC pLDC = Dc_Attr->pvLDC;
if ( !pLDC )
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (pLDC->iType == LDC_EMFLDC)
{
if (!EMFDRV_MoveTo( hDC, x, y)) return FALSE;
}
}
}
if ( Point )
{
if ( Dc_Attr->ulDirty_ & DIRTY_PTLCURRENT ) // Double hit!
{
Point->x = Dc_Attr->ptfxCurrent.x; // ret prev before change.
Point->y = Dc_Attr->ptfxCurrent.y;
DPtoLP ( hDC, Point, 1); // reconvert back.
}
else
{
Point->x = Dc_Attr->ptlCurrent.x;
Point->y = Dc_Attr->ptlCurrent.y;
}
}
Dc_Attr->ptlCurrent.x = x;
Dc_Attr->ptlCurrent.y = y;
Dc_Attr->ulDirty_ |= ( DIRTY_PTLCURRENT|DIRTY_STYLESTATE); // Set dirty
return TRUE;
}
BOOL
STDCALL
Ellipse(HDC hDC, INT Left, INT Top, INT Right, INT Bottom)
{
// 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_MetaParam4(hDC, META_ELLIPSE, Left, Top, Right, Bottom );
else
{
PLDC pLDC = GdiGetLDC(hDC);
if ( !pLDC )
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (pLDC->iType == LDC_EMFLDC)
{
return EMFDRV_Ellipse( hDC, Left, Top, Right, Bottom );
}
return FALSE;
}
}
return NtGdiEllipse( hDC, Left, Top, Right, Bottom);
}
BOOL
STDCALL
Rectangle(HDC, INT Left, INT Top, INT Right, INT Bottom)
{
// 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_MetaParam4(hDC, META_RECTANGLE, Left, Top, Right, Bottom );
else
{
PLDC pLDC = GdiGetLDC(hDC);
if ( !pLDC )
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (pLDC->iType == LDC_EMFLDC)
{
return EMFDRV_Rectangle( hDC, Left, Top, Right, Bottom );
}
return FALSE;
}
}
return NtGdiRectangle( hDC, Left, Top, Right, Bottom);
}
BOOL
STDCALL
RoundRect(HDC, INT Left, INT Top, INT Right, INT Bottom,
INT ell_Width, INT ell_Height)
{
// 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_MetaParam6( hDC, META_ROUNDRECT, Left, Top, Right, Bottom,
ell_Width, ell_Height );
else
{
PLDC pLDC = GdiGetLDC(hDC);
if ( !pLDC )
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (pLDC->iType == LDC_EMFLDC)
{
return EMFDRV_RoundRect( hDC, Left, Top, Right, Bottom,
ell_Width, ell_Height );
}
return FALSE;
}
}
return NtGdiRoundRect( hDc, Left, Top, Right, Bottom, ell_Width, ell_Height);
}
COLORREF
STDCALL
GetPixel( HDC hDC, INT x, INT y )
{
if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) return CLR_INVALID;
if (!GdiIsHandleValid((HGDIOBJ) hDC)) return CLR_INVALID;
return NtGdiGetPixel( hDC, x, y);
}
COLORREF
STDCALL
SetPixel( HDC hDC, INT x, INT y, COLORREF Color )
{
// 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_MetaParam4(hDC, META_SETPIXEL, x, y, HIWORD(Color),
LOWORD(Color));
else
{
PLDC pLDC = GdiGetLDC(hDC);
if ( !pLDC )
{
SetLastError(ERROR_INVALID_HANDLE);
return 0;
}
if (pLDC->iType == LDC_EMFLDC)
{
return EMFDRV_SetPixel( hDC, x, y, Color );
}
return 0;
}
}
return NtGdiSetPixel( hDC, x, y, Color);
}
BOOL
STDCALL
SetPixelV( HDC hDC, INT x, INT y, COLORREF Color )
{
COLORREF Cr = SetPixel( hDC, x, y, Color );
if (Cr) return TRUE;
return FALSE;
}
BOOL
STDCALL
FillRgn( HDC hDC, HRGN hRgn, HBRUSH hBrush )
{
if ( (!hRgn) || (!hBrush) ) return FALSE;
// 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_FillRgn( hDC, hRgn, hBrush);
else
{
PLDC pLDC = GdiGetLDC(hDC);
if ( !pLDC )
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (pLDC->iType == LDC_EMFLDC)
{
return EMFDRV_FillRgn(( hDC, hRgn, hBrush);
}
return FALSE;
}
}
return NtGdiFillRgn( hDC, hRgn, hBrush);
}
BOOL
STDCALL
FrameRgn( HDC hDC, HRGN hRgn, HBRUSH hBrush, INT nWidth, INT nHeight )
{
if ( (!hRgn) || (!hBrush) ) return FALSE;
// 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_FrameRgn( hDC, hRgn, hBrush, nWidth, nHeight );
else
{
PLDC pLDC = GdiGetLDC(hDC);
if ( !pLDC )
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (pLDC->iType == LDC_EMFLDC)
{
return EMFDRV_FrameRgn( hDC, hRgn, hBrush, nWidth, nHeight );
}
return FALSE;
}
}
return NtGdiFrameRgn( hDC, hRgn, hBrush, nWidth, nHeight);
}
BOOL
STDCALL
InvertRgn( HDC hDC, HRGN hRgn )
{
if ( !hRgn ) return FALSE;
// 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_InvertRgn( hDC, HRGN hRgn ); // Use this instead of MFDRV_MetaParam.
else
{
PLDC pLDC = GdiGetLDC(hDC);
if ( !pLDC )
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (pLDC->iType == LDC_EMFLDC)
{
return EMFDRV_PaintInvertRgn( hDC, hRgn, EMR_INVERTRGN );
}
return FALSE;
}
}
return NtGdiInvertRgn( hDC, hRgn);
}
BOOL
STDCALL
PaintRgn( HDC hDC, HRGN hRgn )
{
// 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_PaintRgn( hDC, HRGN hRgn ); // Use this instead of MFDRV_MetaParam.
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -