https://git.reactos.org/?p=reactos.git;a=commitdiff;h=43c78d4b752b860649773…
commit 43c78d4b752b86064977325110e72bc9071738bd
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Sun Oct 28 05:13:08 2018 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Sun Oct 28 05:13:08 2018 +0900
[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
---
win32ss/gdi/ntgdi/path.c | 179 +++++++++++++++++++++++++----------------------
win32ss/gdi/ntgdi/path.h | 2 +
2 files changed, 98 insertions(+), 83 deletions(-)
diff --git a/win32ss/gdi/ntgdi/path.c b/win32ss/gdi/ntgdi/path.c
index 1bc5e2fb5f..a3e2ea0cdd 100644
--- a/win32ss/gdi/ntgdi/path.c
+++ b/win32ss/gdi/ntgdi/path.c
@@ -6,6 +6,7 @@
* PROGRAMMER: Copyright 1997, 1998 Martin Boehme
* 1999 Huw D M Davies
* 2005 Dmitry Timoshkov
+ * 2018 Katayama Hirofumi MZ
*/
#include <win32k.h>
@@ -1719,93 +1720,22 @@ end:
#define round(x) ((int)((x)>0?(x)+0.5:(x)-0.5))
-static
-PPATH
-FASTCALL
-PATH_WidenPath(DC *dc)
+PPATH FASTCALL
+IntGdiWidenPath(PPATH pPath, UINT penWidth, UINT penStyle, FLOAT eMiterLimit)
{
- INT i, j, numStrokes, numOldStrokes, penWidth, penWidthIn, penWidthOut, size,
penStyle;
- PPATH pPath, flat_path, pNewPath, *pStrokes = NULL, *pOldStrokes, pUpPath,
pDownPath;
- EXTLOGPEN *elp;
+ INT i, j, numStrokes, numOldStrokes, penWidthIn, penWidthOut;
+ PPATH flat_path, pNewPath, *pStrokes = NULL, *pOldStrokes, pUpPath, pDownPath;
BYTE *type;
- DWORD obj_type, joint, endcap, penType;
- 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);
+ DWORD joint, endcap;
endcap = (PS_ENDCAP_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)))
{
- PATH_UnlockPath(pPath);
- return NULL;
+ DPRINT1("PATH_FlattenPath\n");
+ return NULL;
}
- PATH_UnlockPath(pPath);
penWidthIn = penWidth / 2;
penWidthOut = penWidth / 2;
@@ -1827,7 +1757,7 @@ PATH_WidenPath(DC *dc)
ExFreePoolWithTag(pStrokes, TAG_PATH);
PATH_UnlockPath(flat_path);
PATH_Delete(flat_path->BaseObject.hHmgr);
- return FALSE;
+ return NULL;
}
switch(flat_path->pFlags[i])
{
@@ -1849,7 +1779,7 @@ PATH_WidenPath(DC *dc)
{
PATH_UnlockPath(flat_path);
PATH_Delete(flat_path->BaseObject.hHmgr);
- return FALSE;
+ return NULL;
}
RtlCopyMemory(pStrokes, pOldStrokes, numOldStrokes * sizeof(PPATH));
ExFreePoolWithTag(pOldStrokes, TAG_PATH); // Free old pointer.
@@ -1858,7 +1788,7 @@ PATH_WidenPath(DC *dc)
{
PATH_UnlockPath(flat_path);
PATH_Delete(flat_path->BaseObject.hHmgr);
- return FALSE;
+ return NULL;
}
pStrokes[numStrokes - 1] = ExAllocatePoolWithTag(PagedPool, sizeof(PATH),
TAG_PATH);
if (!pStrokes[numStrokes - 1])
@@ -1883,7 +1813,7 @@ PATH_WidenPath(DC *dc)
ExFreePoolWithTag(pStrokes, TAG_PATH);
PATH_UnlockPath(flat_path);
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;
if (alpha > 0) 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;
}
@@ -2115,6 +2045,89 @@ PATH_WidenPath(DC *dc)
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)
{
return (f.fract >= 0x8000) ? (f.value + 1) : f.value;
diff --git a/win32ss/gdi/ntgdi/path.h b/win32ss/gdi/ntgdi/path.h
index 9c5f63dabe..021045ee5f 100644
--- a/win32ss/gdi/ntgdi/path.h
+++ b/win32ss/gdi/ntgdi/path.h
@@ -109,3 +109,5 @@ VOID FASTCALL IntGetCurrentPositionEx(PDC dc, LPPOINT pt);
BOOL PATH_RestorePath( DC *, DC *);
BOOL PATH_SavePath( DC *, DC *);
BOOL IntGdiFillRgn(PDC pdc, PREGION prgn, PBRUSH pbrFill);
+PPATH FASTCALL
+IntGdiWidenPath(PPATH pPath, UINT penWidth, UINT penStyle, FLOAT eMiterLimit);