mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 19:42:57 +00:00
[WIN32SS][NTGDI] Refactoring PATH_WidenPath (#888)
Preparation to support pen width. Split IntGdiWidenPath function from PATH_WidenPath function. IntGdiWidenPath is independent from DC. CORE-2527, CORE-13534
This commit is contained in:
parent
7af2f717bc
commit
43c78d4b75
2 changed files with 98 additions and 83 deletions
|
@ -6,6 +6,7 @@
|
||||||
* PROGRAMMER: Copyright 1997, 1998 Martin Boehme
|
* PROGRAMMER: Copyright 1997, 1998 Martin Boehme
|
||||||
* 1999 Huw D M Davies
|
* 1999 Huw D M Davies
|
||||||
* 2005 Dmitry Timoshkov
|
* 2005 Dmitry Timoshkov
|
||||||
|
* 2018 Katayama Hirofumi MZ
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <win32k.h>
|
#include <win32k.h>
|
||||||
|
@ -1719,93 +1720,22 @@ end:
|
||||||
|
|
||||||
#define round(x) ((int)((x)>0?(x)+0.5:(x)-0.5))
|
#define round(x) ((int)((x)>0?(x)+0.5:(x)-0.5))
|
||||||
|
|
||||||
static
|
PPATH FASTCALL
|
||||||
PPATH
|
IntGdiWidenPath(PPATH pPath, UINT penWidth, UINT penStyle, FLOAT eMiterLimit)
|
||||||
FASTCALL
|
|
||||||
PATH_WidenPath(DC *dc)
|
|
||||||
{
|
{
|
||||||
INT i, j, numStrokes, numOldStrokes, penWidth, penWidthIn, penWidthOut, size, penStyle;
|
INT i, j, numStrokes, numOldStrokes, penWidthIn, penWidthOut;
|
||||||
PPATH pPath, flat_path, pNewPath, *pStrokes = NULL, *pOldStrokes, pUpPath, pDownPath;
|
PPATH flat_path, pNewPath, *pStrokes = NULL, *pOldStrokes, pUpPath, pDownPath;
|
||||||
EXTLOGPEN *elp;
|
|
||||||
BYTE *type;
|
BYTE *type;
|
||||||
DWORD obj_type, joint, endcap, penType;
|
DWORD joint, endcap;
|
||||||
PDC_ATTR pdcattr = dc->pdcattr;
|
|
||||||
|
|
||||||
pPath = PATH_LockPath(dc->dclevel.hPath);
|
|
||||||
if (!pPath)
|
|
||||||
{
|
|
||||||
EngSetLastError( ERROR_CAN_NOT_COMPLETE );
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pPath->state != PATH_Closed)
|
|
||||||
{
|
|
||||||
DPRINT("PWP 1\n");
|
|
||||||
PATH_UnlockPath(pPath);
|
|
||||||
EngSetLastError(ERROR_CAN_NOT_COMPLETE);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
size = GreGetObject(pdcattr->hpen, 0, NULL);
|
|
||||||
if (!size)
|
|
||||||
{
|
|
||||||
DPRINT("PWP 2\n");
|
|
||||||
PATH_UnlockPath(pPath);
|
|
||||||
EngSetLastError(ERROR_CAN_NOT_COMPLETE);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
elp = ExAllocatePoolWithTag(PagedPool, size, TAG_PATH);
|
|
||||||
if (elp == NULL)
|
|
||||||
{
|
|
||||||
DPRINT("PWP 3\n");
|
|
||||||
PATH_UnlockPath(pPath);
|
|
||||||
EngSetLastError(ERROR_OUTOFMEMORY);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GreGetObject(pdcattr->hpen, size, elp);
|
|
||||||
|
|
||||||
obj_type = GDI_HANDLE_GET_TYPE(pdcattr->hpen);
|
|
||||||
if (obj_type == GDI_OBJECT_TYPE_PEN)
|
|
||||||
{
|
|
||||||
penStyle = ((LOGPEN*)elp)->lopnStyle;
|
|
||||||
}
|
|
||||||
else if (obj_type == GDI_OBJECT_TYPE_EXTPEN)
|
|
||||||
{
|
|
||||||
penStyle = elp->elpPenStyle;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DPRINT("PWP 4\n");
|
|
||||||
EngSetLastError(ERROR_CAN_NOT_COMPLETE);
|
|
||||||
ExFreePoolWithTag(elp, TAG_PATH);
|
|
||||||
PATH_UnlockPath(pPath);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
penWidth = elp->elpWidth;
|
|
||||||
ExFreePoolWithTag(elp, TAG_PATH);
|
|
||||||
|
|
||||||
endcap = (PS_ENDCAP_MASK & penStyle);
|
endcap = (PS_ENDCAP_MASK & penStyle);
|
||||||
joint = (PS_JOIN_MASK & penStyle);
|
joint = (PS_JOIN_MASK & penStyle);
|
||||||
penType = (PS_TYPE_MASK & penStyle);
|
|
||||||
|
|
||||||
/* The function cannot apply to cosmetic pens */
|
|
||||||
if (obj_type == GDI_OBJECT_TYPE_EXTPEN && penType == PS_COSMETIC)
|
|
||||||
{
|
|
||||||
DPRINT("PWP 5\n");
|
|
||||||
PATH_UnlockPath(pPath);
|
|
||||||
EngSetLastError(ERROR_CAN_NOT_COMPLETE);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(flat_path = PATH_FlattenPath(pPath)))
|
if (!(flat_path = PATH_FlattenPath(pPath)))
|
||||||
{
|
{
|
||||||
PATH_UnlockPath(pPath);
|
DPRINT1("PATH_FlattenPath\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
PATH_UnlockPath(pPath);
|
|
||||||
|
|
||||||
penWidthIn = penWidth / 2;
|
penWidthIn = penWidth / 2;
|
||||||
penWidthOut = penWidth / 2;
|
penWidthOut = penWidth / 2;
|
||||||
|
@ -1827,7 +1757,7 @@ PATH_WidenPath(DC *dc)
|
||||||
ExFreePoolWithTag(pStrokes, TAG_PATH);
|
ExFreePoolWithTag(pStrokes, TAG_PATH);
|
||||||
PATH_UnlockPath(flat_path);
|
PATH_UnlockPath(flat_path);
|
||||||
PATH_Delete(flat_path->BaseObject.hHmgr);
|
PATH_Delete(flat_path->BaseObject.hHmgr);
|
||||||
return FALSE;
|
return NULL;
|
||||||
}
|
}
|
||||||
switch(flat_path->pFlags[i])
|
switch(flat_path->pFlags[i])
|
||||||
{
|
{
|
||||||
|
@ -1849,7 +1779,7 @@ PATH_WidenPath(DC *dc)
|
||||||
{
|
{
|
||||||
PATH_UnlockPath(flat_path);
|
PATH_UnlockPath(flat_path);
|
||||||
PATH_Delete(flat_path->BaseObject.hHmgr);
|
PATH_Delete(flat_path->BaseObject.hHmgr);
|
||||||
return FALSE;
|
return NULL;
|
||||||
}
|
}
|
||||||
RtlCopyMemory(pStrokes, pOldStrokes, numOldStrokes * sizeof(PPATH));
|
RtlCopyMemory(pStrokes, pOldStrokes, numOldStrokes * sizeof(PPATH));
|
||||||
ExFreePoolWithTag(pOldStrokes, TAG_PATH); // Free old pointer.
|
ExFreePoolWithTag(pOldStrokes, TAG_PATH); // Free old pointer.
|
||||||
|
@ -1858,7 +1788,7 @@ PATH_WidenPath(DC *dc)
|
||||||
{
|
{
|
||||||
PATH_UnlockPath(flat_path);
|
PATH_UnlockPath(flat_path);
|
||||||
PATH_Delete(flat_path->BaseObject.hHmgr);
|
PATH_Delete(flat_path->BaseObject.hHmgr);
|
||||||
return FALSE;
|
return NULL;
|
||||||
}
|
}
|
||||||
pStrokes[numStrokes - 1] = ExAllocatePoolWithTag(PagedPool, sizeof(PATH), TAG_PATH);
|
pStrokes[numStrokes - 1] = ExAllocatePoolWithTag(PagedPool, sizeof(PATH), TAG_PATH);
|
||||||
if (!pStrokes[numStrokes - 1])
|
if (!pStrokes[numStrokes - 1])
|
||||||
|
@ -1883,7 +1813,7 @@ PATH_WidenPath(DC *dc)
|
||||||
ExFreePoolWithTag(pStrokes, TAG_PATH);
|
ExFreePoolWithTag(pStrokes, TAG_PATH);
|
||||||
PATH_UnlockPath(flat_path);
|
PATH_UnlockPath(flat_path);
|
||||||
PATH_Delete(flat_path->BaseObject.hHmgr);
|
PATH_Delete(flat_path->BaseObject.hHmgr);
|
||||||
return FALSE;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1988,7 +1918,7 @@ PATH_WidenPath(DC *dc)
|
||||||
alpha = atan2(yb - yo, xb - xo) - theta;
|
alpha = atan2(yb - yo, xb - xo) - theta;
|
||||||
if (alpha > 0) alpha -= M_PI;
|
if (alpha > 0) alpha -= M_PI;
|
||||||
else alpha += M_PI;
|
else alpha += M_PI;
|
||||||
if (_joint == PS_JOIN_MITER && dc->dclevel.laPath.eMiterLimit < fabs(1 / sin(alpha / 2)))
|
if (_joint == PS_JOIN_MITER && eMiterLimit < fabs(1 / sin(alpha / 2)))
|
||||||
{
|
{
|
||||||
_joint = PS_JOIN_BEVEL;
|
_joint = PS_JOIN_BEVEL;
|
||||||
}
|
}
|
||||||
|
@ -2115,6 +2045,89 @@ PATH_WidenPath(DC *dc)
|
||||||
return pNewPath;
|
return pNewPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
PPATH
|
||||||
|
FASTCALL
|
||||||
|
PATH_WidenPath(DC *dc)
|
||||||
|
{
|
||||||
|
INT size;
|
||||||
|
UINT penWidth, penStyle;
|
||||||
|
DWORD obj_type;
|
||||||
|
PPATH pPath, pNewPath;
|
||||||
|
LPEXTLOGPEN elp;
|
||||||
|
PDC_ATTR pdcattr = dc->pdcattr;
|
||||||
|
|
||||||
|
pPath = PATH_LockPath(dc->dclevel.hPath);
|
||||||
|
if (!pPath)
|
||||||
|
{
|
||||||
|
EngSetLastError( ERROR_CAN_NOT_COMPLETE );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pPath->state != PATH_Closed)
|
||||||
|
{
|
||||||
|
DPRINT("PWP 1\n");
|
||||||
|
PATH_UnlockPath(pPath);
|
||||||
|
EngSetLastError(ERROR_CAN_NOT_COMPLETE);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
size = GreGetObject(pdcattr->hpen, 0, NULL);
|
||||||
|
if (!size)
|
||||||
|
{
|
||||||
|
DPRINT("PWP 2\n");
|
||||||
|
PATH_UnlockPath(pPath);
|
||||||
|
EngSetLastError(ERROR_CAN_NOT_COMPLETE);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
elp = ExAllocatePoolWithTag(PagedPool, size, TAG_PATH);
|
||||||
|
if (elp == NULL)
|
||||||
|
{
|
||||||
|
DPRINT("PWP 3\n");
|
||||||
|
PATH_UnlockPath(pPath);
|
||||||
|
EngSetLastError(ERROR_OUTOFMEMORY);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GreGetObject(pdcattr->hpen, size, elp);
|
||||||
|
|
||||||
|
obj_type = GDI_HANDLE_GET_TYPE(pdcattr->hpen);
|
||||||
|
if (obj_type == GDI_OBJECT_TYPE_PEN)
|
||||||
|
{
|
||||||
|
penStyle = ((LOGPEN*)elp)->lopnStyle;
|
||||||
|
}
|
||||||
|
else if (obj_type == GDI_OBJECT_TYPE_EXTPEN)
|
||||||
|
{
|
||||||
|
penStyle = elp->elpPenStyle;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DPRINT("PWP 4\n");
|
||||||
|
EngSetLastError(ERROR_CAN_NOT_COMPLETE);
|
||||||
|
ExFreePoolWithTag(elp, TAG_PATH);
|
||||||
|
PATH_UnlockPath(pPath);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
penWidth = elp->elpWidth;
|
||||||
|
ExFreePoolWithTag(elp, TAG_PATH);
|
||||||
|
|
||||||
|
/* The function cannot apply to cosmetic pens */
|
||||||
|
if (obj_type == GDI_OBJECT_TYPE_EXTPEN &&
|
||||||
|
(PS_TYPE_MASK & penStyle) == PS_COSMETIC)
|
||||||
|
{
|
||||||
|
DPRINT("PWP 5\n");
|
||||||
|
PATH_UnlockPath(pPath);
|
||||||
|
EngSetLastError(ERROR_CAN_NOT_COMPLETE);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
pNewPath = IntGdiWidenPath(pPath, penWidth, penStyle, dc->dclevel.laPath.eMiterLimit);
|
||||||
|
PATH_UnlockPath(pPath);
|
||||||
|
return pNewPath;
|
||||||
|
}
|
||||||
|
|
||||||
static inline INT int_from_fixed(FIXED f)
|
static inline INT int_from_fixed(FIXED f)
|
||||||
{
|
{
|
||||||
return (f.fract >= 0x8000) ? (f.value + 1) : f.value;
|
return (f.fract >= 0x8000) ? (f.value + 1) : f.value;
|
||||||
|
|
|
@ -109,3 +109,5 @@ VOID FASTCALL IntGetCurrentPositionEx(PDC dc, LPPOINT pt);
|
||||||
BOOL PATH_RestorePath( DC *, DC *);
|
BOOL PATH_RestorePath( DC *, DC *);
|
||||||
BOOL PATH_SavePath( DC *, DC *);
|
BOOL PATH_SavePath( DC *, DC *);
|
||||||
BOOL IntGdiFillRgn(PDC pdc, PREGION prgn, PBRUSH pbrFill);
|
BOOL IntGdiFillRgn(PDC pdc, PREGION prgn, PBRUSH pbrFill);
|
||||||
|
PPATH FASTCALL
|
||||||
|
IntGdiWidenPath(PPATH pPath, UINT penWidth, UINT penStyle, FLOAT eMiterLimit);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue