mirror of
https://github.com/reactos/reactos.git
synced 2024-11-20 14:30:57 +00:00
[NTGDI] Strictly check pen style (#4164)
- Check the pen style and elegantly fail if the style was wrong. CORE-13819
This commit is contained in:
parent
545e1190f2
commit
e3622ebe4e
1 changed files with 46 additions and 11 deletions
|
@ -115,11 +115,54 @@ IntGdiExtCreatePen(
|
|||
DPRINT("Can't allocate pen\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
hPen = pbrushPen->BaseObject.hHmgr;
|
||||
|
||||
// If nWidth is zero, the pen is a single pixel wide, regardless of the current transformation.
|
||||
if ((bOldStylePen) && (!dwWidth) && ((dwPenStyle & PS_STYLE_MASK) != PS_SOLID))
|
||||
dwWidth = 1;
|
||||
if (bOldStylePen)
|
||||
{
|
||||
// If nWidth is zero, the pen is a single pixel wide, regardless of the current transformation.
|
||||
if (!dwWidth && (dwPenStyle & PS_STYLE_MASK) != PS_SOLID)
|
||||
dwWidth = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (dwPenStyle & PS_ENDCAP_MASK)
|
||||
{
|
||||
case PS_ENDCAP_ROUND:
|
||||
case PS_ENDCAP_SQUARE:
|
||||
case PS_ENDCAP_FLAT:
|
||||
break;
|
||||
|
||||
default:
|
||||
goto ExitCleanup;
|
||||
}
|
||||
|
||||
switch (dwPenStyle & PS_JOIN_MASK)
|
||||
{
|
||||
case PS_JOIN_ROUND:
|
||||
case PS_JOIN_BEVEL:
|
||||
case PS_JOIN_MITER:
|
||||
break;
|
||||
|
||||
default:
|
||||
goto ExitCleanup;
|
||||
}
|
||||
|
||||
switch (dwPenStyle & PS_TYPE_MASK)
|
||||
{
|
||||
case PS_COSMETIC:
|
||||
if (dwWidth != 1 || ulBrushStyle != BS_SOLID)
|
||||
goto ExitCleanup;
|
||||
|
||||
break;
|
||||
|
||||
case PS_GEOMETRIC:
|
||||
break;
|
||||
|
||||
default:
|
||||
goto ExitCleanup;
|
||||
}
|
||||
}
|
||||
|
||||
pbrushPen->lWidth = dwWidth;
|
||||
FLOATOBJ_SetLong(&pbrushPen->eWidth, pbrushPen->lWidth);
|
||||
|
@ -131,16 +174,8 @@ IntGdiExtCreatePen(
|
|||
pbrushPen->dwStyleCount = 0;
|
||||
pbrushPen->pStyle = NULL;
|
||||
pbrushPen->ulStyleSize = 0;
|
||||
|
||||
pbrushPen->flAttrs = bOldStylePen ? BR_IS_OLDSTYLEPEN : BR_IS_PEN;
|
||||
|
||||
// If dwPenStyle is PS_COSMETIC, the width must be set to 1.
|
||||
if ( !(bOldStylePen) && ((dwPenStyle & PS_TYPE_MASK) == PS_COSMETIC) && ( dwWidth != 1) )
|
||||
goto ExitCleanup;
|
||||
// If dwPenStyle is PS_COSMETIC, the brush style must be BS_SOLID.
|
||||
if ( !(bOldStylePen) && ((dwPenStyle & PS_TYPE_MASK) == PS_COSMETIC) && (ulBrushStyle != BS_SOLID) )
|
||||
goto ExitCleanup;
|
||||
|
||||
switch (dwPenStyle & PS_STYLE_MASK)
|
||||
{
|
||||
case PS_NULL:
|
||||
|
|
Loading…
Reference in a new issue