ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
March 2021
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
15 participants
161 discussions
Start a n
N
ew thread
[reactos] 01/01: [COMDLG32] Enable auto-completion on comdlg32 (#3564)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7e6550b35e306b3914896…
commit 7e6550b35e306b39148965632d60d3509c352d02 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Thu Apr 1 06:41:24 2021 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Thu Apr 1 06:41:24 2021 +0900 [COMDLG32] Enable auto-completion on comdlg32 (#3564) Auto-completion will be enabled when the user opens "Open" or "Save As" dialog of the common dialogs. CORE-9281 NOTE: The relative pathes, "..\" and "\" are not working. Those are bugs in CLSID_ACListISF. --- dll/win32/comdlg32/CMakeLists.txt | 1 + dll/win32/comdlg32/autocomp.cpp | 115 ++++++++++++++++++++++++++++++++++++ dll/win32/comdlg32/filedlg.c | 6 ++ dll/win32/comdlg32/filedlgbrowser.c | 6 ++ dll/win32/comdlg32/filedlgbrowser.h | 5 ++ 5 files changed, 133 insertions(+) diff --git a/dll/win32/comdlg32/CMakeLists.txt b/dll/win32/comdlg32/CMakeLists.txt index bb87894e2c8..a0f2d69ca75 100644 --- a/dll/win32/comdlg32/CMakeLists.txt +++ b/dll/win32/comdlg32/CMakeLists.txt @@ -7,6 +7,7 @@ include_directories(BEFORE ${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine) spec2def(comdlg32.dll comdlg32.spec ADD_IMPORTLIB) list(APPEND SOURCE + autocomp.cpp cdlg32.c colordlg.c filedlg.c diff --git a/dll/win32/comdlg32/autocomp.cpp b/dll/win32/comdlg32/autocomp.cpp new file mode 100644 index 00000000000..f5762a23246 --- /dev/null +++ b/dll/win32/comdlg32/autocomp.cpp @@ -0,0 +1,115 @@ +/* + * PROJECT: ReactOS Common Dialogs + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) + * PURPOSE: Implement auto-completion for comdlg32 + * COPYRIGHT: Copyright 2021 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ +#include "precomp.h" + +WINE_DEFAULT_DEBUG_CHANNEL(commdlg); + +EXTERN_C HRESULT +DoInitAutoCompleteWithCWD(FileOpenDlgInfos *pInfo, HWND hwndEdit) +{ + pInfo->pvCWD = pInfo->pvDropDown = pInfo->pvACList = NULL; + + WCHAR szClass[32]; + GetClassNameW(hwndEdit, szClass, _countof(szClass)); + if (lstrcmpiW(szClass, WC_COMBOBOXW) == 0) + { + COMBOBOXINFO info = { sizeof(info) }; + GetComboBoxInfo(hwndEdit, &info); + hwndEdit = info.hwndItem; + } + else if (lstrcmpiW(szClass, WC_COMBOBOXEXW) == 0) + { + hwndEdit = (HWND)SendMessageW(hwndEdit, CBEM_GETEDITCONTROL, 0, 0); + } + + IACList2 *pACList = NULL; + HRESULT hr = CoCreateInstance(CLSID_ACListISF, NULL, CLSCTX_INPROC_SERVER, + IID_IACList2, reinterpret_cast<LPVOID *>(&pACList)); + if (FAILED(hr)) + { + TRACE("CoCreateInstance(CLSID_ACListISF): 0x%08lX\n", hr); + return hr; + } + pInfo->pvACList = static_cast<LPVOID>(pACList); + + IAutoComplete2 *pAC = NULL; + hr = CoCreateInstance(CLSID_AutoComplete, NULL, CLSCTX_INPROC_SERVER, + IID_IAutoComplete2, reinterpret_cast<LPVOID *>(&pAC)); + if (SUCCEEDED(hr)) + { + pAC->Init(hwndEdit, pACList, NULL, NULL); + pAC->SetOptions(ACO_AUTOSUGGEST); + pAC->QueryInterface(IID_IAutoCompleteDropDown, &pInfo->pvDropDown); + pAC->Release(); + } + else + { + TRACE("CoCreateInstance(CLSID_AutoComplete): 0x%08lX\n", hr); + pACList->Release(); + pInfo->pvACList = NULL; + return hr; + } + + pACList->QueryInterface(IID_ICurrentWorkingDirectory, &pInfo->pvCWD); + + return hr; +} + +EXTERN_C HRESULT +DoUpdateAutoCompleteWithCWD(const FileOpenDlgInfos *info, LPCITEMIDLIST pidl) +{ + FileOpenDlgInfos *pInfo = const_cast<FileOpenDlgInfos*>(info); + if (!pInfo) + return E_POINTER; + + ICurrentWorkingDirectory* pCWD = + reinterpret_cast<ICurrentWorkingDirectory*>(pInfo->pvCWD); + + IAutoCompleteDropDown* pDropDown = + reinterpret_cast<IAutoCompleteDropDown*>(pInfo->pvDropDown); + + IACList2* pACList = static_cast<IACList2*>(pInfo->pvACList); + + WCHAR szPath[MAX_PATH]; + if (!pidl || !SHGetPathFromIDListW(pidl, szPath)) + { + GetCurrentDirectoryW(_countof(szPath), szPath); + } + + if (pCWD) + pCWD->SetDirectory(szPath); + if (pDropDown) + pDropDown->ResetEnumerator(); + if (pACList) + pACList->Expand(L""); + + return S_OK; +} + +EXTERN_C HRESULT +DoReleaseAutoCompleteWithCWD(FileOpenDlgInfos *pInfo) +{ + if (!pInfo) + return E_POINTER; + + ICurrentWorkingDirectory* pCWD = + reinterpret_cast<ICurrentWorkingDirectory*>(pInfo->pvCWD); + if (pCWD) + pCWD->Release(); + + IAutoCompleteDropDown* pDropDown = + reinterpret_cast<IAutoCompleteDropDown*>(pInfo->pvDropDown); + if (pDropDown) + pDropDown->Release(); + + IACList2 *pACList = static_cast<IACList2*>(pInfo->pvACList); + if (pACList) + pACList->Release(); + + pInfo->pvCWD = pInfo->pvDropDown = pInfo->pvACList = NULL; + return S_OK; +} diff --git a/dll/win32/comdlg32/filedlg.c b/dll/win32/comdlg32/filedlg.c index 49bd1d006b1..cf1d2bc34c2 100644 --- a/dll/win32/comdlg32/filedlg.c +++ b/dll/win32/comdlg32/filedlg.c @@ -79,6 +79,8 @@ #include "wine/heap.h" #ifdef __REACTOS__ #include "wine/unicode.h" +EXTERN_C HRESULT DoInitAutoCompleteWithCWD(FileOpenDlgInfos *pInfo, HWND hwndEdit); +EXTERN_C HRESULT DoReleaseAutoCompleteWithCWD(FileOpenDlgInfos *pInfo); #endif WINE_DEFAULT_DEBUG_CHANNEL(commdlg); @@ -1558,6 +1560,7 @@ INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l s_hFileDialogHook = NULL; } LeaveCriticalSection(&COMDLG32_OpenFileLock); + DoReleaseAutoCompleteWithCWD(fodInfos); #endif return FALSE; } @@ -2030,6 +2033,9 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd) /* Initialize the filter combo box */ FILEDLG95_FILETYPE_Init(hwnd); +#ifdef __REACTOS__ + DoInitAutoCompleteWithCWD(fodInfos, fodInfos->DlgInfos.hwndFileName); +#endif return 0; } diff --git a/dll/win32/comdlg32/filedlgbrowser.c b/dll/win32/comdlg32/filedlgbrowser.c index 83d5f5e9e09..feaa5557ea7 100644 --- a/dll/win32/comdlg32/filedlgbrowser.c +++ b/dll/win32/comdlg32/filedlgbrowser.c @@ -41,6 +41,9 @@ #include "servprov.h" #include "wine/debug.h" #include "wine/heap.h" +#ifdef __REACTOS__ +EXTERN_C HRESULT DoUpdateAutoCompleteWithCWD(const FileOpenDlgInfos *info, LPCITEMIDLIST pidl); +#endif WINE_DEFAULT_DEBUG_CHANNEL(commdlg); @@ -143,6 +146,9 @@ static void COMDLG32_UpdateCurrentDir(const FileOpenDlgInfos *fodInfos) if (SUCCEEDED(res)) SetCurrentDirectoryW(wszCurrentDir); } +#ifdef __REACTOS__ + DoUpdateAutoCompleteWithCWD(fodInfos, fodInfos->ShellInfos.pidlAbsCurrent); +#endif IShellFolder_Release(psfDesktop); } diff --git a/dll/win32/comdlg32/filedlgbrowser.h b/dll/win32/comdlg32/filedlgbrowser.h index 21eb3d56dfe..67c07a8793c 100644 --- a/dll/win32/comdlg32/filedlgbrowser.h +++ b/dll/win32/comdlg32/filedlgbrowser.h @@ -94,6 +94,11 @@ typedef struct BOOL ole_initialized; LPITEMIDLIST places[5]; +#ifdef __REACTOS__ + LPVOID pvCWD; /* ICurrentWorkingDirectory */ + LPVOID pvDropDown; /* IAutoCompleteDropDown */ + LPVOID pvACList; /* IACList2 */ +#endif } FileOpenDlgInfos; /***********************************************************************
3 years, 8 months
1
0
0
0
[reactos] 05/05: [WIN32K] Fix getting long value from float object
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=12dfa8ce390917db814d0…
commit 12dfa8ce390917db814d0ace0c40ffc376fa6c04 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Mon Mar 22 12:39:08 2021 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Mar 31 18:35:31 2021 +0200 [WIN32K] Fix getting long value from float object Most importantly, do not shift 32-bit integers by 32 or more. --- win32ss/CMakeLists.txt | 1 + win32ss/gdi/eng/floatobj.h | 23 ++++++++++------------- win32ss/gdi/eng/i386/floatobj.S | 34 +--------------------------------- win32ss/gdi/eng/i386/floatobj.c | 22 ++++++++++++++++++++++ 4 files changed, 34 insertions(+), 46 deletions(-) diff --git a/win32ss/CMakeLists.txt b/win32ss/CMakeLists.txt index 44dc77cd381..727461031cd 100644 --- a/win32ss/CMakeLists.txt +++ b/win32ss/CMakeLists.txt @@ -213,6 +213,7 @@ list(APPEND ASM_SOURCE gdi/dib/i386/dib32bpp_hline.s gdi/dib/i386/dib32bpp_colorfill.s gdi/eng/i386/floatobj.S) +list(APPEND SOURCE gdi/eng/i386/floatobj.c) else() list(APPEND SOURCE gdi/dib/dib24bppc.c diff --git a/win32ss/gdi/eng/floatobj.h b/win32ss/gdi/eng/floatobj.h index aa85a4e80b5..5cad6830af6 100644 --- a/win32ss/gdi/eng/floatobj.h +++ b/win32ss/gdi/eng/floatobj.h @@ -16,15 +16,6 @@ _FLOATOBJ_Equal(FLOATOBJ *pf1, FLOATOBJ *pf2) } #define FLOATOBJ_Equal _FLOATOBJ_Equal -FORCEINLINE -LONG -_FLOATOBJ_GetLong(FLOATOBJ *pf) -{ - EFLOAT_S *pef = (EFLOAT_S*)pf; - return pef->lMant >> (32 - pef->lExp); -} -#define FLOATOBJ_GetLong _FLOATOBJ_GetLong - /*! * \brief Converts a FLOATOBJ into a LONG by truncating the value to integer * @@ -37,16 +28,22 @@ _FLOATOBJ_GetLong(FLOATOBJ *pf) */ FORCEINLINE BOOL -FASTCALL FLOATOBJ_bConvertToLong(FLOATOBJ *pf, PLONG pl) { EFLOAT_S *pef = (EFLOAT_S*)pf; - LONG lShift = 32 - pef->lExp; - if (lShift < 0) + + if (pef->lExp > 32) { return FALSE; } - *pl = pef->lMant >> lShift; + + if (pef->lExp < 2) + { + *pl = 0; + return TRUE; + } + + *pl = EngMulDiv(pef->lMant, 1 << (pef->lExp - 2), 0x40000000); return TRUE; } diff --git a/win32ss/gdi/eng/i386/floatobj.S b/win32ss/gdi/eng/i386/floatobj.S index 7eb9f64cb76..0b36e1b4559 100644 --- a/win32ss/gdi/eng/i386/floatobj.S +++ b/win32ss/gdi/eng/i386/floatobj.S @@ -52,7 +52,7 @@ * FLOATOBJ_SetFloat - implemented, tested * FLOATOBJ_SetLong - implemented, tested * FLOATOBJ_GetFloat - implemented, tested - * FLOATOBJ_GetLong - implemented, tested + * FLOATOBJ_GetLong - implemented in C * FLOATOBJ_Equal - implemented, tested * FLOATOBJ_EqualLong - implemented * FLOATOBJ_GreaterThan - implemented @@ -249,34 +249,6 @@ SetLong0: ret 8 -/******************************************************************************* - * LONG - * APIENTRY - * FLOATOBJ_GetLong(IN PFLOATOBJ pf); - * - */ -_FLOATOBJ_GetLong@4: -PUBLIC _FLOATOBJ_GetLong@4 - push ebp - mov ebp, esp - - mov edx, [ebp + PARAM1] /* Load pf into edx */ - mov ecx, 32 /* Load (32 - lExp) into ecx */ - sub ecx, [edx + lExp] - jle short GetLong2 /* Check for Overflow */ - - mov eax, [edx + lMant] /* Load mantissa into eax */ - sar eax, cl /* Signed shift mantissa according to exponent */ - - pop ebp /* Return */ - ret 4 - -GetLong2: - xor eax, eax /* Overflow, return 0 */ - pop ebp - ret 4 - - /****************************************************************************** * BOOL * APIENTRY @@ -842,7 +814,6 @@ PUBLIC _FLOATOBJ_DivLong@8 pop ebp ret 8 - /******************************************************************************* * VOID * APIENTRY @@ -940,7 +911,6 @@ AddIs0: pop ebp ret 8 - /****************************************************************************** * VOID * APIENTRY @@ -998,7 +968,6 @@ PUBLIC _FLOATOBJ_AddLong@8 pop ebp ret 8 - /******************************************************************************* * VOID * APIENTRY @@ -1095,7 +1064,6 @@ SubIs0: mov dword ptr [eax + lExp], 0 pop ebp ret 8 - /****************************************************************************** * VOID * APIENTRY diff --git a/win32ss/gdi/eng/i386/floatobj.c b/win32ss/gdi/eng/i386/floatobj.c new file mode 100644 index 00000000000..d5b623d164f --- /dev/null +++ b/win32ss/gdi/eng/i386/floatobj.c @@ -0,0 +1,22 @@ +/* + * PROJECT: ReactOS win32 kernel mode subsystem + * LICENSE: GPL - See COPYING in the top level directory + * FILE: win32ss/gdi/eng/i386/floatobj.c + * PURPOSE: FLOATOBJ API + * PROGRAMMERS: Jérôme Gardou + */ + +/** Includes ******************************************************************/ + +#include <win32k.h> +#define NDEBUG +#include <debug.h> + +LONG +APIENTRY +FLOATOBJ_GetLong(FLOATOBJ* pf) +{ + LONG val = 0; + (void)FLOATOBJ_bConvertToLong(pf, &val); + return val; +}
3 years, 8 months
1
0
0
0
[reactos] 04/05: [WIN32K] More cleanup & improvements
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=405ce532118f5c5d7dd20…
commit 405ce532118f5c5d7dd2094aea8b65cb89c7b83f Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Wed Mar 17 18:43:59 2021 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Mar 31 18:35:31 2021 +0200 [WIN32K] More cleanup & improvements Use FLOATOBJs to perform device<->world transformations, avoiding use of XFORMOBJ all the time Remove unused macros & functions --- win32ss/gdi/ntgdi/coord.c | 37 +++++++------ win32ss/gdi/ntgdi/coord.h | 123 ++++++++++++++++++++++++++----------------- win32ss/gdi/ntgdi/dcutil.c | 4 +- win32ss/gdi/ntgdi/gdifloat.h | 75 -------------------------- win32ss/win32kp.h | 1 - 5 files changed, 96 insertions(+), 144 deletions(-) diff --git a/win32ss/gdi/ntgdi/coord.c b/win32ss/gdi/ntgdi/coord.c index bea04e28aa0..e0d05971697 100644 --- a/win32ss/gdi/ntgdi/coord.c +++ b/win32ss/gdi/ntgdi/coord.c @@ -416,11 +416,11 @@ NtGdiTransformPoints( switch (iMode) { case GdiDpToLp: - DC_vXformDeviceToWorld(pdc, Count, Points, Points); + ret = INTERNAL_APPLY_MATRIX(DC_pmxDeviceToWorld(pdc), Points, Count); break; case GdiLpToDp: - DC_vXformWorldToDevice(pdc, Count, Points, Points); + ret = INTERNAL_APPLY_MATRIX(DC_pmxWorldToDevice(pdc), Points, Count); break; case 2: // Not supported yet. Need testing. @@ -432,17 +432,20 @@ NtGdiTransformPoints( } } - _SEH2_TRY - { - /* Pointer was already probed! */ - RtlCopyMemory(UnsafePtOut, Points, Size); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + if (ret) { - /* Do not set last error */ - ret = 0; + _SEH2_TRY + { + /* Pointer was already probed! */ + RtlCopyMemory(UnsafePtOut, Points, Size); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + /* Do not set last error */ + ret = FALSE; + } + _SEH2_END; } - _SEH2_END; // // If we are getting called that means User XForms is a mess! @@ -866,22 +869,22 @@ IntGdiSetMapMode( break; case MM_LOENGLISH: - pdcattr->szlWindowExt.cx = MulDiv(1000, pdcattr->szlVirtualDeviceMm.cx, 254); - pdcattr->szlWindowExt.cy = MulDiv(1000, pdcattr->szlVirtualDeviceMm.cy, 254); + pdcattr->szlWindowExt.cx = EngMulDiv(1000, pdcattr->szlVirtualDeviceMm.cx, 254); + pdcattr->szlWindowExt.cy = EngMulDiv(1000, pdcattr->szlVirtualDeviceMm.cy, 254); pdcattr->szlViewportExt.cx = pdcattr->szlVirtualDevicePixel.cx; pdcattr->szlViewportExt.cy = -pdcattr->szlVirtualDevicePixel.cy; break; case MM_HIENGLISH: - pdcattr->szlWindowExt.cx = MulDiv(10000, pdcattr->szlVirtualDeviceMm.cx, 254); - pdcattr->szlWindowExt.cy = MulDiv(10000, pdcattr->szlVirtualDeviceMm.cy, 254); + pdcattr->szlWindowExt.cx = EngMulDiv(10000, pdcattr->szlVirtualDeviceMm.cx, 254); + pdcattr->szlWindowExt.cy = EngMulDiv(10000, pdcattr->szlVirtualDeviceMm.cy, 254); pdcattr->szlViewportExt.cx = pdcattr->szlVirtualDevicePixel.cx; pdcattr->szlViewportExt.cy = -pdcattr->szlVirtualDevicePixel.cy; break; case MM_TWIPS: - pdcattr->szlWindowExt.cx = MulDiv(14400, pdcattr->szlVirtualDeviceMm.cx, 254); - pdcattr->szlWindowExt.cy = MulDiv(14400, pdcattr->szlVirtualDeviceMm.cy, 254); + pdcattr->szlWindowExt.cx = EngMulDiv(14400, pdcattr->szlVirtualDeviceMm.cx, 254); + pdcattr->szlWindowExt.cy = EngMulDiv(14400, pdcattr->szlVirtualDeviceMm.cy, 254); pdcattr->szlViewportExt.cx = pdcattr->szlVirtualDevicePixel.cx; pdcattr->szlViewportExt.cy = -pdcattr->szlVirtualDevicePixel.cy; break; diff --git a/win32ss/gdi/ntgdi/coord.h b/win32ss/gdi/ntgdi/coord.h index a62abadabbe..e8d159926d1 100644 --- a/win32ss/gdi/ntgdi/coord.h +++ b/win32ss/gdi/ntgdi/coord.h @@ -4,21 +4,58 @@ #define MIN_COORD (INT_MIN / 16) #define MAX_COORD (INT_MAX / 16) -#define IntLPtoDP(pdc, ppt, count) do { \ - DC_vUpdateWorldToDevice(pdc); \ - INTERNAL_LPTODP(pdc, ppt, count); \ - } while (0) -#define CoordLPtoDP(pdc, ppt) \ - DC_vXformWorldToDevice(pdc, 1, (PPOINTL)(ppt), (PPOINTL)(ppt)); -#define IntDPtoLP(pdc, ppt, count) do { \ - DC_vUpdateDeviceToWorld(pdc); \ - DC_vXformDeviceToWorld(pdc, count, (PPOINTL)(ppt), (PPOINTL)(ppt)); \ - } while (0) -#define CoordDPtoLP(pdc, ppt) \ - DC_vXformDeviceToWorld(pdc, 1, (PPOINTL)(ppt), (PPOINTL)(ppt)); +/* + * Applies matrix (which is made of FLOATOBJs) to the points array, which are made of integers. + */ +static +inline +BOOLEAN +INTERNAL_APPLY_MATRIX(PMATRIX matrix, LPPOINT points, UINT count) +{ + while (count--) + { + FLOATOBJ x, y; + FLOATOBJ tmp; + + /* x = x * matrix->efM11 + y * matrix->efM21 + matrix->efDx; */ + FLOATOBJ_SetLong(&x, points[count].x); + FLOATOBJ_Mul(&x, &matrix->efM11); + tmp = matrix->efM21; + FLOATOBJ_MulLong(&tmp, points[count].y); + FLOATOBJ_Add(&x, &tmp); + FLOATOBJ_Add(&x, &matrix->efDx); + + /* y = x * matrix->efM12 + y * matrix->efM22 + matrix->efDy; */ + FLOATOBJ_SetLong(&y, points[count].y); + FLOATOBJ_Mul(&y, &matrix->efM22); + tmp = matrix->efM12; + FLOATOBJ_MulLong(&tmp, points[count].x); + FLOATOBJ_Add(&y, &tmp); + FLOATOBJ_Add(&y, &matrix->efDy); + + if (!FLOATOBJ_bConvertToLong(&x, &points[count].x)) + return FALSE; + if (!FLOATOBJ_bConvertToLong(&y, &points[count].y)) + return FALSE; + } + return TRUE; +} -#define XForm2MatrixS(m, x) XFormToMatrix(m, (XFORML*)x) -#define MatrixS2XForm(x, m) MatrixToXForm((XFORML*)x, m) +static +inline +BOOLEAN +INTERNAL_LPTODP(DC *dc, LPPOINT points, UINT count) +{ + return INTERNAL_APPLY_MATRIX(&dc->pdcattr->mxWorldToDevice, points, count); +} + +static +inline +BOOLEAN +INTERNAL_DPTOLP(DC *dc, LPPOINT points, UINT count) +{ + return INTERNAL_APPLY_MATRIX(&dc->pdcattr->mxDeviceToWorld, points, count); +} FORCEINLINE void @@ -121,41 +158,6 @@ DC_pmxDeviceToWorld(PDC pdc) return &pdc->pdcattr->mxDeviceToWorld; } -FORCEINLINE -VOID -DC_vXformDeviceToWorld( - IN PDC pdc, - IN ULONG cNumPoints, - OUT PPOINTL pptlDest, - IN PPOINTL pptlSource) -{ - XFORMOBJ xo; - PMATRIX pmx; - - pmx = DC_pmxDeviceToWorld(pdc); - if (!MX_IsInvertible(pmx)) - return; - - XFORMOBJ_vInit(&xo, pmx); - XFORMOBJ_bApplyXform(&xo, XF_LTOL, cNumPoints, pptlDest, pptlSource); -} - -FORCEINLINE -VOID -DC_vXformWorldToDevice( - IN PDC pdc, - IN ULONG cNumPoints, - OUT PPOINTL pptlDest, - IN PPOINTL pptlSource) -{ - XFORMOBJ xo; - PMATRIX pmx; - - pmx = DC_pmxWorldToDevice(pdc); - XFORMOBJ_vInit(&xo, pmx); - XFORMOBJ_bApplyXform(&xo, XF_LTOL, cNumPoints, pptlDest, pptlSource); -} - BOOL NTAPI GreModifyWorldTransform( @@ -173,3 +175,26 @@ BOOL WINAPI GreGetViewportExtEx( _In_ HDC hdc, _Out_ LPSIZE lpSize); BOOL FASTCALL GreSetViewportOrgEx(HDC,int,int,LPPOINT); BOOL WINAPI GreGetDCOrgEx(_In_ HDC, _Out_ PPOINTL, _Out_ PRECTL); BOOL WINAPI GreSetDCOrg(_In_ HDC, _In_ LONG, _In_ LONG, _In_opt_ PRECTL); + +static +inline +BOOLEAN +IntLPtoDP(DC* pdc, PPOINTL ppt, UINT count) +{ + DC_vUpdateWorldToDevice(pdc); + return INTERNAL_LPTODP(pdc, (LPPOINT)ppt, count); +} +#define CoordLPtoDP(pdc, ppt) INTERNAL_LPTODP(pdc, ppt, 1) + +static +inline +BOOLEAN +IntDPtoLP(DC* pdc, PPOINTL ppt, UINT count) +{ + DC_vUpdateDeviceToWorld(pdc); + return INTERNAL_DPTOLP(pdc, (LPPOINT)ppt, count); +} +#define CoordDPtoLP(pdc, ppt) INTERNAL_DPTOLP(pdc, ppt, 1) + +#define XForm2MatrixS(m, x) XFormToMatrix(m, (XFORML*)x) +#define MatrixS2XForm(x, m) MatrixToXForm((XFORML*)x, m) diff --git a/win32ss/gdi/ntgdi/dcutil.c b/win32ss/gdi/ntgdi/dcutil.c index 056fd7f2140..cb41e6cfcd5 100644 --- a/win32ss/gdi/ntgdi/dcutil.c +++ b/win32ss/gdi/ntgdi/dcutil.c @@ -743,7 +743,7 @@ NtGdiGetBoundsRect( DPRINT(" r %d b %d\n",rc.right,rc.bottom); ret = DCB_SET; } - IntDPtoLP( pdc, &rc, 2 ); + IntDPtoLP(pdc, (PPOINTL)&rc, 2); DPRINT("rc1 l %d t %d\n",rc.left,rc.top); DPRINT(" r %d b %d\n",rc.right,rc.bottom); } @@ -838,7 +838,7 @@ NtGdiSetBoundsRect( RECTL_vMakeWellOrdered(&rcl); if (!(flags & DCB_WINDOWMGR)) - { + { IntLPtoDP( pdc, (POINT *)&rcl, 2 ); RECTL_bUnionRect(&pdc->erclBoundsApp, &pdc->erclBoundsApp, &rcl); } diff --git a/win32ss/gdi/ntgdi/gdifloat.h b/win32ss/gdi/ntgdi/gdifloat.h deleted file mode 100644 index 86962ece449..00000000000 --- a/win32ss/gdi/ntgdi/gdifloat.h +++ /dev/null @@ -1,75 +0,0 @@ -#pragma once - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:28110) // disable "Drivers must protect floating point hardware state" warning -#endif - -static __inline INT GDI_ROUND(FLOAT val) -{ - return (int)floor(val + 0.5); -} - - -/* - * Performs a world-to-viewport transformation on the specified point, - * which is in integer format. - */ -static -inline -VOID -INTERNAL_LPTODP(DC *dc, LPPOINT point, UINT Count) -{ - MATRIX* WorldToDevice = &dc->pdcattr->mxWorldToDevice; - - while (Count--) - { - FLOATOBJ x, y; - FLOATOBJ tmp; - - /* x = x * mxWorldToDevice.efM11 + y * mxWorldToDevice.efM21 + mxWorldToDevice.efDx; */ - FLOATOBJ_SetLong(&x, point[Count].x); - FLOATOBJ_Mul(&x, &WorldToDevice->efM11); - tmp = WorldToDevice->efM21; - FLOATOBJ_MulLong(&tmp, point[Count].y); - FLOATOBJ_Add(&x, &tmp); - FLOATOBJ_Add(&x, &WorldToDevice->efDx); - - /* y = x * mxWorldToDevice.efM12 + y * mxWorldToDevice.efM22 + mxWorldToDevice.efDy; */ - FLOATOBJ_SetLong(&y, point[Count].y); - FLOATOBJ_Mul(&y, &WorldToDevice->efM22); - tmp = WorldToDevice->efM12; - FLOATOBJ_MulLong(&tmp, point[Count].x); - FLOATOBJ_Add(&y, &tmp); - FLOATOBJ_Add(&y, &WorldToDevice->efDy); - - point[Count].x = FLOATOBJ_GetLong(&x); - point[Count].y = FLOATOBJ_GetLong(&y); - } -} - -#define MulDiv( x, y, z ) EngMulDiv( x, y, z ) - -#define XDPTOLP(pdcattr,tx) \ - (MulDiv(((tx)-(pdcattr)->ptlViewportOrg.x), (pdcattr)->szlWindowExt.cx, (pdcattr)->szlViewportExt.cx) + (pdcattr)->ptlWindowOrg.x) -#define YDPTOLP(pdcattr,ty) \ - (MulDiv(((ty)-(pdcattr)->ptlViewportOrg.y), (pdcattr)->szlWindowExt.cy, (pdcattr)->szlViewportExt.cy) + (pdcattr)->ptlWindowOrg.y) -#define XLPTODP(pdcattr,tx) \ - (MulDiv(((tx)-(pdcattr)->ptlWindowOrg.x), (pdcattr)->szlViewportExt.cx, (pdcattr)->szlWindowExt.cx) + (pdcattr)->ptlViewportOrg.x) -#define YLPTODP(pdcattr,ty) \ - (MulDiv(((ty)-(pdcattr)->ptlWindowOrg.y), (pdcattr)->szlViewportExt.cy, (pdcattr)->szlWindowExt.cy) + (pdcattr)->ptlViewportOrg.y) - - /* Device <-> logical size conversion */ - -#define XDSTOLS(pdcattr,tx) \ - MulDiv((tx), (pdcattr)->szlWindowExt.cx, (pdcattr)->szlViewportExt.cx) -#define YDSTOLS(DC_Attr,ty) \ - MulDiv((ty), (pdcattr)->szlWindowExt.cy, (pdcattr)->szlViewportExt.cy) -#define XLSTODS(pdcattr,tx) \ - MulDiv((tx), (pdcattr)->szlViewportExt.cx, (pdcattr)->szlWindowExt.cx) -#define YLSTODS(pdcattr,ty) \ - MulDiv((ty), (pdcattr)->szlViewportExt.cy, (pdcattr)->szlWindowExt.cy) - -#ifdef _MSC_VER -#pragma warning(pop) -#endif diff --git a/win32ss/win32kp.h b/win32ss/win32kp.h index 2d0f358597c..06ff74638ff 100644 --- a/win32ss/win32kp.h +++ b/win32ss/win32kp.h @@ -49,7 +49,6 @@ typedef struct _DC *PDC; #include "gdi/ntgdi/pen.h" #include "gdi/ntgdi/cliprgn.h" #include "gdi/ntgdi/coord.h" -#include "gdi/ntgdi/gdifloat.h" #include "gdi/ntgdi/path.h" #include "gdi/dib/dib.h" #include "reactx/ntddraw/intddraw.h"
3 years, 8 months
1
0
0
0
[reactos] 03/05: [WIN32K] Use INTERNAL_LPTODP in IntLPtoDP
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3bad3c49e1f378a829d30…
commit 3bad3c49e1f378a829d306783a8172a1089a0a9a Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Wed Mar 17 16:21:58 2021 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Mar 31 18:35:31 2021 +0200 [WIN32K] Use INTERNAL_LPTODP in IntLPtoDP Instead of initializing a XFORMOBJ and whatnot --- win32ss/gdi/ntgdi/cliprgn.c | 2 +- win32ss/gdi/ntgdi/coord.h | 2 +- win32ss/gdi/ntgdi/line.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/win32ss/gdi/ntgdi/cliprgn.c b/win32ss/gdi/ntgdi/cliprgn.c index 0964f5559da..3084416a331 100644 --- a/win32ss/gdi/ntgdi/cliprgn.c +++ b/win32ss/gdi/ntgdi/cliprgn.c @@ -560,7 +560,7 @@ NtGdiOffsetClipRgn( apt[0].y = 0; apt[1].x = xOffset; apt[1].y = yOffset; - IntLPtoDP(pdc, &apt, 2); + IntLPtoDP(pdc, apt, 2); /* Offset the clip region */ if (!REGION_bOffsetRgn(pdc->dclevel.prgnClip, diff --git a/win32ss/gdi/ntgdi/coord.h b/win32ss/gdi/ntgdi/coord.h index 6dcf58fc982..a62abadabbe 100644 --- a/win32ss/gdi/ntgdi/coord.h +++ b/win32ss/gdi/ntgdi/coord.h @@ -6,7 +6,7 @@ #define IntLPtoDP(pdc, ppt, count) do { \ DC_vUpdateWorldToDevice(pdc); \ - DC_vXformWorldToDevice(pdc, count, (PPOINTL)(ppt), (PPOINTL)(ppt)); \ + INTERNAL_LPTODP(pdc, ppt, count); \ } while (0) #define CoordLPtoDP(pdc, ppt) \ DC_vXformWorldToDevice(pdc, 1, (PPOINTL)(ppt), (PPOINTL)(ppt)); diff --git a/win32ss/gdi/ntgdi/line.c b/win32ss/gdi/ntgdi/line.c index c922995925d..aeebebc58a1 100644 --- a/win32ss/gdi/ntgdi/line.c +++ b/win32ss/gdi/ntgdi/line.c @@ -24,7 +24,7 @@ AddPenLinesBounds(PDC dc, int count, POINT *points) /* Get BRUSH from current pen. */ pbrLine = dc->dclevel.pbrLine; ASSERT(pbrLine); - + lWidth = 0; // Setup bounds @@ -55,7 +55,7 @@ AddPenLinesBounds(PDC dc, int count, POINT *points) rect.top = points->y - lWidth; rect.right = points->x + lWidth + 1; rect.bottom = points->y + lWidth + 1; - RECTL_bUnionRect(&bounds, &bounds, &rect); + RECTL_bUnionRect(&bounds, &bounds, &rect); points++; } @@ -444,7 +444,7 @@ NtGdiLineTo(HDC hDC, rcLockRect.right = XEnd; rcLockRect.bottom = YEnd; - IntLPtoDP(dc, &rcLockRect, 2); + IntLPtoDP(dc, (PPOINT)&rcLockRect, 2); /* The DCOrg is in device coordinates */ rcLockRect.left += dc->ptlDCOrig.x;
3 years, 8 months
1
0
0
0
[reactos] 02/05: [WIN32K] Rewrite PATH_Ellipse & PATH_RoundRect using integer arithmetics
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=26b5596a111c60b3675df…
commit 26b5596a111c60b3675df11ba7a03729c42a60c3 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Wed Mar 31 16:17:02 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Mar 31 18:35:31 2021 +0200 [WIN32K] Rewrite PATH_Ellipse & PATH_RoundRect using integer arithmetics --- win32ss/gdi/ntgdi/path.c | 263 +++++++++++++++++++++++++---------------------- win32ss/gdi/ntgdi/path.h | 5 +- 2 files changed, 144 insertions(+), 124 deletions(-) diff --git a/win32ss/gdi/ntgdi/path.c b/win32ss/gdi/ntgdi/path.c index 92be0058e03..717fe9568b9 100644 --- a/win32ss/gdi/ntgdi/path.c +++ b/win32ss/gdi/ntgdi/path.c @@ -396,8 +396,8 @@ PATH_ScaleNormalizedPoint( * Normalizes a point with respect to the box whose corners are passed in * corners. The normalized coordinates are stored in *pX and *pY. */ +static VOID -FASTCALL PATH_NormalizePoint( POINTL corners[], const POINTL *pPoint, @@ -428,47 +428,32 @@ PATH_NormalizePoint( * * Helper function for PATH_RoundRect() and PATH_Rectangle() */ +static BOOL -PATH_CheckCorners( +PATH_CheckRect( DC *dc, - POINT corners[], + RECTL* rect, INT x1, INT y1, INT x2, INT y2) { - INT temp; PDC_ATTR pdcattr = dc->pdcattr; /* Convert points to device coordinates */ - corners[0].x = x1; - corners[0].y = y1; - corners[1].x = x2; - corners[1].y = y2; - IntLPtoDP(dc, corners, 2); + RECTL_vSetRect(rect, x1, y1, x2, y2); + IntLPtoDP(dc, (PPOINT)rect, 2); /* Make sure first corner is top left and second corner is bottom right */ - if (corners[0].x > corners[1].x) - { - temp = corners[0].x; - corners[0].x = corners[1].x; - corners[1].x = temp; - } - - if (corners[0].y > corners[1].y) - { - temp = corners[0].y; - corners[0].y = corners[1].y; - corners[1].y = temp; - } + RECTL_vMakeWellOrdered(rect); /* In GM_COMPATIBLE, don't include bottom and right edges */ if (pdcattr->iGraphicsMode == GM_COMPATIBLE) { - if (corners[0].x == corners[1].x) return FALSE; - if (corners[0].y == corners[1].y) return FALSE; - corners[1].x--; - corners[1].y--; + if (rect->left == rect->right) return FALSE; + if (rect->top == rect->bottom) return FALSE; + rect->right--; + rect->bottom--; } return TRUE; } @@ -647,26 +632,25 @@ PATH_Rectangle( INT y2) { PPATH pPath; - POINT corners[2], points[4]; + RECTL rect; + POINTL points[4]; BYTE *type; pPath = PATH_LockPath(dc->dclevel.hPath); if (!pPath) return FALSE; - if (!PATH_CheckCorners(dc, corners, x1, y1, x2, y2)) + if (!PATH_CheckRect(dc, &rect, x1, y1, x2, y2)) { PATH_UnlockPath(pPath); return TRUE; } - points[0].x = corners[1].x; - points[0].y = corners[0].y; - points[1] = corners[0]; - points[2].x = corners[0].x; - points[2].y = corners[1].y; - points[3] = corners[1]; + points[0].x = rect.right; points[0].y = rect.top; + points[1].x = rect.left; points[1].y = rect.top; + points[2].x = rect.left; points[2].y = rect.bottom; + points[3].x = rect.right; points[3].y = rect.bottom; - if (dc->dclevel.flPath & DCPATH_CLOCKWISE) reverse_points( points, 4 ); + if (dc->dclevel.flPath & DCPATH_CLOCKWISE) reverse_points(points, 4 ); if (!(type = add_points( pPath, points, 4, PT_LINETO ))) { @@ -688,7 +672,6 @@ PATH_Rectangle( * */ BOOL -FASTCALL PATH_RoundRect( DC *dc, INT x1, @@ -698,72 +681,85 @@ PATH_RoundRect( INT ell_width, INT ell_height) { - const double factor = 0.55428475; /* 4 / 3 * (sqrt(2) - 1) */ PPATH pPath; - POINT corners[2], ellipse[2], points[16]; + RECTL rect, ellipse; + POINT points[16]; BYTE *type; - double width, height; + INT xOffset, yOffset; if (!ell_width || !ell_height) return PATH_Rectangle( dc, x1, y1, x2, y2 ); pPath = PATH_LockPath(dc->dclevel.hPath); if (!pPath) return FALSE; - if (!PATH_CheckCorners(dc, corners, x1, y1, x2, y2)) + if (!PATH_CheckRect(dc, &rect, x1, y1, x2, y2)) { PATH_UnlockPath(pPath); return TRUE; } - ellipse[0].x = ellipse[0].y = 0; - ellipse[1].x = ell_width; - ellipse[1].y = ell_height; - IntLPtoDP( dc, &ellipse, 2 ); - ell_width = min( abs( ellipse[1].x - ellipse[0].x ), corners[1].x - corners[0].x ); - ell_height = min( abs( ellipse[1].y - ellipse[0].y ), corners[1].y - corners[0].y ); - width = ell_width / 2.0; - height = ell_height / 2.0; + RECTL_vSetRect(&ellipse, 0, 0, ell_width, ell_height); + IntLPtoDP( dc, (PPOINT)&ellipse, 2 ); + RECTL_vMakeWellOrdered(&ellipse); + ell_width = min(RECTL_lGetWidth(&ellipse), RECTL_lGetWidth(&rect)); + ell_height = min(RECTL_lGetHeight(&ellipse), RECTL_lGetHeight(&rect)); + + /* + * See here to understand what's happening + *
https://stackoverflow.com/questions/1734745/how-to-create-circle-with-b%C3%…
+ */ + xOffset = EngMulDiv(ell_width, 44771525, 200000000); /* w * (1 - 0.5522847) / 2 */ + yOffset = EngMulDiv(ell_height, 44771525, 200000000); /* h * (1 - 0.5522847) / 2 */ + TRACE("xOffset %d, yOffset %d, Rect WxH: %dx%d.\n", + xOffset, yOffset, RECTL_lGetWidth(&rect), RECTL_lGetHeight(&rect)); + + /* + * Get half width & height. + * Do not use integer division, we need the rounding made by EngMulDiv. + */ + ell_width = EngMulDiv(ell_width, 1, 2); + ell_height = EngMulDiv(ell_height, 1, 2); /* starting point */ - points[0].x = corners[1].x; - points[0].y = corners[0].y + GDI_ROUND( height ); + points[0].x = rect.right; + points[0].y = rect.top + ell_height; /* first curve */ - points[1].x = corners[1].x; - points[1].y = corners[0].y + GDI_ROUND( height * (1 - factor) ); - points[2].x = corners[1].x - GDI_ROUND( width * (1 - factor) ); - points[2].y = corners[0].y; - points[3].x = corners[1].x - GDI_ROUND( width ); - points[3].y = corners[0].y; + points[1].x = rect.right; + points[1].y = rect.top + yOffset; + points[2].x = rect.right - xOffset; + points[2].y = rect.top; + points[3].x = rect.right - ell_width; + points[3].y = rect.top; /* horizontal line */ - points[4].x = corners[0].x + GDI_ROUND( width ); - points[4].y = corners[0].y; + points[4].x = rect.left + ell_width; + points[4].y = rect.top; /* second curve */ - points[5].x = corners[0].x + GDI_ROUND( width * (1 - factor) ); - points[5].y = corners[0].y; - points[6].x = corners[0].x; - points[6].y = corners[0].y + GDI_ROUND( height * (1 - factor) ); - points[7].x = corners[0].x; - points[7].y = corners[0].y + GDI_ROUND( height ); + points[5].x = rect.left + xOffset; + points[5].y = rect.top; + points[6].x = rect.left; + points[6].y = rect.top + yOffset; + points[7].x = rect.left; + points[7].y = rect.top + ell_height; /* vertical line */ - points[8].x = corners[0].x; - points[8].y = corners[1].y - GDI_ROUND( height ); + points[8].x = rect.left; + points[8].y = rect.bottom - ell_height; /* third curve */ - points[9].x = corners[0].x; - points[9].y = corners[1].y - GDI_ROUND( height * (1 - factor) ); - points[10].x = corners[0].x + GDI_ROUND( width * (1 - factor) ); - points[10].y = corners[1].y; - points[11].x = corners[0].x + GDI_ROUND( width ); - points[11].y = corners[1].y; + points[9].x = rect.left; + points[9].y = rect.bottom - yOffset; + points[10].x = rect.left + xOffset; + points[10].y = rect.bottom; + points[11].x = rect.left + ell_width; + points[11].y = rect.bottom; /* horizontal line */ - points[12].x = corners[1].x - GDI_ROUND( width ); - points[12].y = corners[1].y; + points[12].x = rect.right - ell_width; + points[12].y = rect.bottom; /* fourth curve */ - points[13].x = corners[1].x - GDI_ROUND( width * (1 - factor) ); - points[13].y = corners[1].y; - points[14].x = corners[1].x; - points[14].y = corners[1].y - GDI_ROUND( height * (1 - factor) ); - points[15].x = corners[1].x; - points[15].y = corners[1].y - GDI_ROUND( height ); + points[13].x = rect.right - xOffset; + points[13].y = rect.bottom; + points[14].x = rect.right; + points[14].y = rect.bottom - yOffset; + points[15].x = rect.right; + points[15].y = rect.bottom - ell_height; if (dc->dclevel.flPath & DCPATH_CLOCKWISE) reverse_points( points, 16 ); if (!(type = add_points( pPath, points, 16, PT_BEZIERTO ))) @@ -783,7 +779,6 @@ PATH_RoundRect( * */ BOOL -FASTCALL PATH_Ellipse( PDC dc, INT x1, @@ -791,55 +786,81 @@ PATH_Ellipse( INT x2, INT y2) { - const double factor = 0.55428475; /* 4 / 3 * (sqrt(2) - 1) */ PPATH pPath; - POINT corners[2], points[13]; + POINT points[13]; + RECTL rect; BYTE *type; - double width, height; + LONG xRadius, yRadius, xOffset, yOffset; + POINT left, top, right, bottom; - pPath = PATH_LockPath(dc->dclevel.hPath); - if (!pPath) return FALSE; + TRACE("PATH_Ellipse: %p -> (%d, %d) - (%d, %d)\n", + dc, x1, y1, x2, y2); - if (!PATH_CheckCorners(dc, corners, x1, y1, x2, y2)) + if (!PATH_CheckRect(dc, &rect, x1, y1, x2, y2)) { - PATH_UnlockPath(pPath); return TRUE; } - width = (corners[1].x - corners[0].x) / 2.0; - height = (corners[1].y - corners[0].y) / 2.0; + xRadius = RECTL_lGetWidth(&rect) / 2; + yRadius = RECTL_lGetHeight(&rect) / 2; - /* starting point */ - points[0].x = corners[1].x; - points[0].y = corners[0].y + GDI_ROUND( height ); - /* first curve */ - points[1].x = corners[1].x; - points[1].y = corners[0].y + GDI_ROUND( height * (1 - factor) ); - points[2].x = corners[1].x - GDI_ROUND( width * (1 - factor) ); - points[2].y = corners[0].y; - points[3].x = corners[0].x + GDI_ROUND( width ); - points[3].y = corners[0].y; - /* second curve */ - points[4].x = corners[0].x + GDI_ROUND( width * (1 - factor) ); - points[4].y = corners[0].y; - points[5].x = corners[0].x; - points[5].y = corners[0].y + GDI_ROUND( height * (1 - factor) ); - points[6].x = corners[0].x; - points[6].y = corners[0].y + GDI_ROUND( height ); - /* third curve */ - points[7].x = corners[0].x; - points[7].y = corners[1].y - GDI_ROUND( height * (1 - factor) ); - points[8].x = corners[0].x + GDI_ROUND( width * (1 - factor) ); - points[8].y = corners[1].y; - points[9].x = corners[0].x + GDI_ROUND( width ); - points[9].y = corners[1].y; - /* fourth curve */ - points[10].x = corners[1].x - GDI_ROUND( width * (1 - factor) ); - points[10].y = corners[1].y; - points[11].x = corners[1].x; - points[11].y = corners[1].y - GDI_ROUND( height * (1 - factor) ); - points[12].x = corners[1].x; - points[12].y = corners[1].y - GDI_ROUND( height ); + /* Get the four points which box our ellipse */ + left.x = rect.left; left.y = rect.top + yRadius; + top.x = rect.left + xRadius; top.y = rect.top; + right.x = rect.right; right.y = rect.bottom - yRadius; + bottom.x = rect.right - xRadius; bottom.y = rect.bottom; + + /* + * See here to understand what's happening + *
https://stackoverflow.com/questions/1734745/how-to-create-circle-with-b%C3%…
+ */ + xOffset = EngMulDiv(RECTL_lGetWidth(&rect), 55428475, 200000000); /* w * 0.55428475 / 2 */ + yOffset = EngMulDiv(RECTL_lGetHeight(&rect), 55428475, 200000000); /* h * 0.55428475 / 2 */ + TRACE("xOffset %d, yOffset %d, Rect WxH: %dx%d.\n", + xOffset, yOffset, RECTL_lGetWidth(&rect), RECTL_lGetHeight(&rect)); + + pPath = PATH_LockPath(dc->dclevel.hPath); + if (!pPath) + return FALSE; + + /* Starting point: Right */ + points[0] = right; + + /* first curve - going up, left */ + points[1] = right; + points[1].y -= yOffset; + points[2] = top; + points[2].x += xOffset; + + /* top */ + points[3] = top; + + /* second curve - going left, down*/ + points[4] = top; + points[4].x -= xOffset; + points[5] = left; + points[5].y -= yOffset; + + /* Left */ + points[6] = left; + + /* Third curve - going down, right */ + points[7] = left; + points[7].y += yOffset; + points[8] = bottom; + points[8].x -= xOffset; + + /* bottom */ + points[9] = bottom; + + /* Fourth curve - Going right, up */ + points[10] = bottom; + points[10].x += xOffset; + points[11] = right; + points[11].y += yOffset; + + /* Back to starting point */ + points[12] = right; if (dc->dclevel.flPath & DCPATH_CLOCKWISE) reverse_points( points, 13 ); if (!(type = add_points( pPath, points, 13, PT_BEZIERTO ))) diff --git a/win32ss/gdi/ntgdi/path.h b/win32ss/gdi/ntgdi/path.h index fc8144644a1..038e58195dc 100644 --- a/win32ss/gdi/ntgdi/path.h +++ b/win32ss/gdi/ntgdi/path.h @@ -74,7 +74,7 @@ typedef struct _EPATHOBJ #define PATH_IsPathOpen(dclevel) ( ((dclevel).hPath) && ((dclevel).flPath & DCPATH_ACTIVE) ) BOOL FASTCALL PATH_Arc (PDC dc, INT x1, INT y1, INT x2, INT y2, INT xStart, INT yStart, INT xEnd, INT yEnd, INT direction, INT lines); -BOOL FASTCALL PATH_Ellipse (PDC dc, INT x1, INT y1, INT x2, INT y2); +BOOL PATH_Ellipse (PDC dc, INT x1, INT y1, INT x2, INT y2); VOID FASTCALL PATH_EmptyPath (PPATH pPath); BOOL FASTCALL PATH_LineTo (PDC dc, INT x, INT y); BOOL FASTCALL PATH_PolyBezier (PDC dc, const POINT *pts, DWORD cbPoints); @@ -84,7 +84,7 @@ BOOL FASTCALL PATH_PolylineTo (PDC dc, const POINT *pts, DWORD cbPoints); BOOL FASTCALL PATH_PolyPolygon ( PDC dc, const POINT* pts, const INT* counts, UINT polygons); BOOL FASTCALL PATH_PolyPolyline( PDC dc, const POINT* pts, const DWORD* counts, DWORD polylines); BOOL FASTCALL PATH_Rectangle (PDC dc, INT x1, INT y1, INT x2, INT y2); -BOOL FASTCALL PATH_RoundRect(DC *dc, INT x1, INT y1, INT x2, INT y2, INT ell_width, INT ell_height); +BOOL PATH_RoundRect(DC *dc, INT x1, INT y1, INT x2, INT y2, INT ell_width, INT ell_height); BOOL FASTCALL PATH_PathToRegion (PPATH pPath, INT nPolyFillMode, PREGION Rgn); BOOL FASTCALL PATH_ExtTextOut(PDC dc,INT x,INT y,UINT flags,const RECTL *lprc,LPCWSTR str,UINT count,const INT *dx); @@ -96,7 +96,6 @@ PPATH FASTCALL PATH_FlattenPath (PPATH pPath); BOOL FASTCALL PATH_ReserveEntries (PPATH pPath, INT numEntries); BOOL FASTCALL PATH_StrokePath(DC *dc, PPATH pPath); -BOOL PATH_CheckCorners(DC *dc, POINT corners[], INT x1, INT y1, INT x2, INT y2); VOID FASTCALL IntGdiCloseFigure(PPATH pPath); BOOL FASTCALL PATH_Delete(HPATH hPath);
3 years, 8 months
1
0
0
0
[reactos] 01/05: [WIN32K] Reduce use of FPU in path implementation with use of FLOATOBJs
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f9c068685fc68240c44c3…
commit f9c068685fc68240c44c35b86fa987ad42aec371 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Wed Mar 31 16:13:59 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Mar 31 18:35:31 2021 +0200 [WIN32K] Reduce use of FPU in path implementation with use of FLOATOBJs --- win32ss/gdi/eng/floatobj.h | 2 + win32ss/gdi/eng/i386/floatobj.S | 6 +- win32ss/gdi/ntgdi/gdifloat.h | 103 ++++++----------- win32ss/gdi/ntgdi/path.c | 238 ++++++++++++++++++++++------------------ win32ss/gdi/ntgdi/path.h | 3 - 5 files changed, 174 insertions(+), 178 deletions(-) diff --git a/win32ss/gdi/eng/floatobj.h b/win32ss/gdi/eng/floatobj.h index c8341482cd7..aa85a4e80b5 100644 --- a/win32ss/gdi/eng/floatobj.h +++ b/win32ss/gdi/eng/floatobj.h @@ -89,6 +89,7 @@ FLOATOBJ_Equal1(FLOATOBJ *pf) extern const FLOATOBJ gef0; extern const FLOATOBJ gef1; +extern const FLOATOBJ gef2; extern const FLOATOBJ gef16; #define FLOATOBJ_0 {0x00000000, 0x00000000} @@ -114,6 +115,7 @@ extern const FLOATOBJ gef16; static const FLOATOBJ gef0 = 0.; static const FLOATOBJ gef1 = 1.; +static const FLOATOBJ gef2 = 2.; static const FLOATOBJ gef16 = 16.; #define FLOATOBJ_Set0(fo) *(fo) = 0; diff --git a/win32ss/gdi/eng/i386/floatobj.S b/win32ss/gdi/eng/i386/floatobj.S index 2f84a7358b2..7eb9f64cb76 100644 --- a/win32ss/gdi/eng/i386/floatobj.S +++ b/win32ss/gdi/eng/i386/floatobj.S @@ -9,7 +9,6 @@ #include <asm.inc> .code - /******************************************************************************* * IEEE 754-1985 single precision floating point * @@ -92,6 +91,11 @@ PUBLIC _gef1 _gef1: .long HEX(40000000), HEX(00000002) +/* extern const FLOATOBJ gef2; */ +PUBLIC _gef2 +_gef2: + .long HEX(40000000), HEX(00000003) + /* extern const FLOATOBJ gef16; */ PUBLIC _gef16 _gef16: diff --git a/win32ss/gdi/ntgdi/gdifloat.h b/win32ss/gdi/ntgdi/gdifloat.h index 94c590f47dc..86962ece449 100644 --- a/win32ss/gdi/ntgdi/gdifloat.h +++ b/win32ss/gdi/ntgdi/gdifloat.h @@ -5,84 +5,49 @@ #pragma warning(disable:28110) // disable "Drivers must protect floating point hardware state" warning #endif -typedef struct tagFLOAT_POINT -{ - FLOAT x, y; -} FLOAT_POINT; - -/* Rounds a floating point number to integer. The world-to-viewport - * transformation process is done in floating point internally. This function - * is then used to round these coordinates to integer values. - */ static __inline INT GDI_ROUND(FLOAT val) { - return (int)floor(val + 0.5); + return (int)floor(val + 0.5); } -/* FIXME: Do not use the fpu in kernel on x86, use FLOATOBJ_Xxx api instead - * Performs a world-to-viewport transformation on the specified point (which - * is in floating point format). +/* + * Performs a world-to-viewport transformation on the specified point, + * which is in integer format. */ -static __inline void INTERNAL_LPTODP_FLOAT(DC *dc, FLOAT_POINT *point) +static +inline +VOID +INTERNAL_LPTODP(DC *dc, LPPOINT point, UINT Count) { - FLOAT x, y; - XFORM xformWorld2Vport; - - MatrixS2XForm(&xformWorld2Vport, &dc->pdcattr->mxWorldToDevice); - - /* Perform the transformation */ - x = point->x; - y = point->y; - point->x = x * xformWorld2Vport.eM11 + - y * xformWorld2Vport.eM21 + - xformWorld2Vport.eDx; - - point->y = x * xformWorld2Vport.eM12 + - y * xformWorld2Vport.eM22 + - xformWorld2Vport.eDy; + MATRIX* WorldToDevice = &dc->pdcattr->mxWorldToDevice; + + while (Count--) + { + FLOATOBJ x, y; + FLOATOBJ tmp; + + /* x = x * mxWorldToDevice.efM11 + y * mxWorldToDevice.efM21 + mxWorldToDevice.efDx; */ + FLOATOBJ_SetLong(&x, point[Count].x); + FLOATOBJ_Mul(&x, &WorldToDevice->efM11); + tmp = WorldToDevice->efM21; + FLOATOBJ_MulLong(&tmp, point[Count].y); + FLOATOBJ_Add(&x, &tmp); + FLOATOBJ_Add(&x, &WorldToDevice->efDx); + + /* y = x * mxWorldToDevice.efM12 + y * mxWorldToDevice.efM22 + mxWorldToDevice.efDy; */ + FLOATOBJ_SetLong(&y, point[Count].y); + FLOATOBJ_Mul(&y, &WorldToDevice->efM22); + tmp = WorldToDevice->efM12; + FLOATOBJ_MulLong(&tmp, point[Count].x); + FLOATOBJ_Add(&y, &tmp); + FLOATOBJ_Add(&y, &WorldToDevice->efDy); + + point[Count].x = FLOATOBJ_GetLong(&x); + point[Count].y = FLOATOBJ_GetLong(&y); + } } -/* Performs a viewport-to-world transformation on the specified point (which - * is in integer format). Returns TRUE if successful, else FALSE. - */ -#if 0 -static __inline BOOL INTERNAL_DPTOLP(DC *dc, LPPOINT point) -{ - FLOAT_POINT floatPoint; - - /* Perform operation with floating point */ - floatPoint.x=(FLOAT)point->x; - floatPoint.y=(FLOAT)point->y; - if (!INTERNAL_DPTOLP_FLOAT(dc, &floatPoint)) - return FALSE; - - /* Round to integers */ - point->x = GDI_ROUND(floatPoint.x); - point->y = GDI_ROUND(floatPoint.y); - - return TRUE; -} - -/* Performs a world-to-viewport transformation on the specified point (which - * is in integer format). - */ -static __inline void INTERNAL_LPTODP(DC *dc, LPPOINT point) -{ - FLOAT_POINT floatPoint; - - /* Perform operation with floating point */ - floatPoint.x=(FLOAT)point->x; - floatPoint.y=(FLOAT)point->y; - INTERNAL_LPTODP_FLOAT(dc, &floatPoint); - - /* Round to integers */ - point->x = GDI_ROUND(floatPoint.x); - point->y = GDI_ROUND(floatPoint.y); -} - -#endif - #define MulDiv( x, y, z ) EngMulDiv( x, y, z ) #define XDPTOLP(pdcattr,tx) \ diff --git a/win32ss/gdi/ntgdi/path.c b/win32ss/gdi/ntgdi/path.c index 552bc9c4f54..92be0058e03 100644 --- a/win32ss/gdi/ntgdi/path.c +++ b/win32ss/gdi/ntgdi/path.c @@ -12,8 +12,7 @@ #include <win32k.h> #include <suppress.h> -#define NDEBUG -#include <debug.h> +DBG_DEFAULT_CHANNEL(GdiPath); #ifdef _MSC_VER #pragma warning(disable:4244) @@ -43,7 +42,7 @@ PATH_CreatePath(int count) return NULL; } - DPRINT("CreatePath p 0x%p\n", pPath); + TRACE("CreatePath p 0x%p\n", pPath); // Path handles are shared. Also due to recursion with in the same thread. GDIOBJ_vUnlockObject((POBJ)pPath); // Unlock pPath = PATH_LockPath(pPath->BaseObject.hHmgr); // Share Lock. @@ -67,7 +66,7 @@ PATH_CreatePath(int count) pPath->pos.x = pPath->pos.y = 0; #if DBG PathCount++; - DPRINT("Create Path %d\n",PathCount); + TRACE("Create Path %d\n",PathCount); #endif return pPath; } @@ -98,7 +97,7 @@ PATH_Delete(HPATH hPath) GDIOBJ_vDeleteObject(&pPath->BaseObject); #if DBG PathCount--; - DPRINT("Delete Path %d\n",PathCount); + TRACE("Delete Path %d\n",PathCount); #endif return TRUE; } @@ -188,10 +187,10 @@ PATH_AssignGdiPath( BOOL PATH_SavePath( DC *dst, DC *src ) { PPATH pdstPath, psrcPath = PATH_LockPath(src->dclevel.hPath); - DPRINT("PATH_SavePath\n"); + TRACE("PATH_SavePath\n"); if (psrcPath) { - DPRINT("PATH_SavePath 1\n"); + TRACE("PATH_SavePath 1\n"); pdstPath = PATH_CreatePath(psrcPath->numEntriesAllocated); @@ -209,12 +208,12 @@ BOOL PATH_SavePath( DC *dst, DC *src ) BOOL PATH_RestorePath( DC *dst, DC *src ) { - DPRINT("PATH_RestorePath\n"); + TRACE("PATH_RestorePath\n"); if (dst->dclevel.hPath == NULL) { PPATH pdstPath, psrcPath = PATH_LockPath(src->dclevel.hPath); - DPRINT("PATH_RestorePath 1\n"); + TRACE("PATH_RestorePath 1\n"); pdstPath = PATH_CreatePath(psrcPath->numEntriesAllocated); dst->dclevel.flPath = src->dclevel.flPath; dst->dclevel.hPath = pdstPath->BaseObject.hHmgr; @@ -228,7 +227,7 @@ BOOL PATH_RestorePath( DC *dst, DC *src ) { PPATH pdstPath, psrcPath = PATH_LockPath(src->dclevel.hPath); pdstPath = PATH_LockPath(dst->dclevel.hPath); - DPRINT("PATH_RestorePath 2\n"); + TRACE("PATH_RestorePath 2\n"); dst->dclevel.flPath = src->dclevel.flPath & (DCPATH_CLOCKWISE|DCPATH_ACTIVE); PATH_AssignGdiPath(pdstPath, psrcPath); @@ -270,7 +269,7 @@ PATH_AddEntry( /* FIXME: If newStroke is true, perhaps we want to check that we're * getting a PT_MOVETO */ - DPRINT("(%d,%d) - %d\n", pPoint->x, pPoint->y, flags); + TRACE("(%d,%d) - %d\n", pPoint->x, pPoint->y, flags); /* Reserve enough memory for an extra path entry */ if (!PATH_ReserveEntries(pPath, pPath->numEntriesUsed + 1)) @@ -359,19 +358,37 @@ PATH_ReserveEntries( * coordinates (-1.0, -1.0) correspond to corners[0], the coordinates * (1.0, 1.0) correspond to corners[1]. */ -VOID -FASTCALL +static +BOOLEAN PATH_ScaleNormalizedPoint( - FLOAT_POINT corners[], - double x, - double y, + POINT corners[], + FLOATL x, + FLOATL y, POINT *pPoint) { + FLOATOBJ tmp; + ASSERT(corners); ASSERT(pPoint); - pPoint->x = GDI_ROUND((double)corners[0].x + (double)(corners[1].x - corners[0].x) * 0.5 * (x + 1.0)); - pPoint->y = GDI_ROUND((double)corners[0].y + (double)(corners[1].y - corners[0].y) * 0.5 * (y + 1.0)); + /* pPoint->x = (double)corners[0].x + (double)(corners[1].x - corners[0].x) * 0.5 * (x + 1.0); */ + FLOATOBJ_SetFloat(&tmp, x); + FLOATOBJ_Add(&tmp, (FLOATOBJ*)&gef1); + FLOATOBJ_Div(&tmp, (FLOATOBJ*)&gef2); + FLOATOBJ_MulLong(&tmp, corners[1].x - corners[0].x); + FLOATOBJ_AddLong(&tmp, corners[0].x); + if (!FLOATOBJ_bConvertToLong(&tmp, &pPoint->x)) + return FALSE; + + /* pPoint->y = (double)corners[0].y + (double)(corners[1].y - corners[0].y) * 0.5 * (y + 1.0); */ + FLOATOBJ_SetFloat(&tmp, y); + FLOATOBJ_Add(&tmp, (FLOATOBJ*)&gef1); + FLOATOBJ_Div(&tmp, (FLOATOBJ*)&gef2); + FLOATOBJ_MulLong(&tmp, corners[1].y - corners[0].y); + FLOATOBJ_AddLong(&tmp, corners[0].y); + if (!FLOATOBJ_bConvertToLong(&tmp, &pPoint->y)) + return FALSE; + return TRUE; } /* PATH_NormalizePoint @@ -382,18 +399,29 @@ PATH_ScaleNormalizedPoint( VOID FASTCALL PATH_NormalizePoint( - FLOAT_POINT corners[], - const FLOAT_POINT *pPoint, - double *pX, - double *pY) + POINTL corners[], + const POINTL *pPoint, + FLOATL *pX, + FLOATL *pY) { + FLOATOBJ tmp; + ASSERT(corners); ASSERT(pPoint); ASSERT(pX); ASSERT(pY); - *pX = (double)(pPoint->x - corners[0].x) / (double)(corners[1].x - corners[0].x) * 2.0 - 1.0; - *pY = (double)(pPoint->y - corners[0].y) / (double)(corners[1].y - corners[0].y) * 2.0 - 1.0; + /* *pX = (float)(pPoint->x - corners[0].x) / (float)(corners[1].x - corners[0].x) * 2.0 - 1.0; */ + FLOATOBJ_SetLong(&tmp, (pPoint->x - corners[0].x) * 2); + FLOATOBJ_DivLong(&tmp, corners[1].x - corners[0].x); + FLOATOBJ_Sub(&tmp, (PFLOATOBJ)&gef1); + *pX = FLOATOBJ_GetFloat(&tmp); + + /* *pY = (float)(pPoint->y - corners[0].y) / (float)(corners[1].y - corners[0].y) * 2.0 - 1.0; */ + FLOATOBJ_SetLong(&tmp, (pPoint->y - corners[0].y) * 2); + FLOATOBJ_DivLong(&tmp, corners[1].y - corners[0].y); + FLOATOBJ_Sub(&tmp, (PFLOATOBJ)&gef1); + *pY = FLOATOBJ_GetFloat(&tmp); } /* PATH_CheckCorners @@ -505,14 +533,14 @@ static BOOL start_new_stroke( PPATH path ) /* set current position to the last point that was added to the path */ static void update_current_pos( PPATH path ) { - assert( path->numEntriesUsed ); + ASSERT(path->numEntriesUsed); path->pos = path->pPoints[path->numEntriesUsed - 1]; } /* close the current figure */ static void close_figure( PPATH path ) { - assert( path->numEntriesUsed ); + ASSERT(path->numEntriesUsed); path->pFlags[path->numEntriesUsed - 1] |= PT_CLOSEFIGURE; } @@ -524,7 +552,7 @@ static BOOL add_log_points_new_stroke( DC *dc, PPATH path, const POINT *points, if (!add_log_points( dc, path, points, count, type )) return FALSE; update_current_pos( path ); - DPRINT("ALPNS : Pos X %d Y %d\n",path->pos.x, path->pos.y); + TRACE("ALPNS : Pos X %d Y %d\n",path->pos.x, path->pos.y); IntGdiMoveToEx(dc, path->pos.x, path->pos.y, NULL); return TRUE; @@ -547,7 +575,7 @@ PATH_MoveTo( // GDI32 : Signal from user space of a change in position. if (dc->pdcattr->ulDirty_ & DIRTY_STYLESTATE) { - DPRINT("MoveTo has changed\n"); + TRACE("MoveTo has changed\n"); pPath->newStroke = TRUE; // Set position and clear the signal flag. IntGetCurrentPositionEx(dc, &pPath->pos); @@ -588,7 +616,7 @@ PATH_LineTo( /* Add a PT_MOVETO if necessary */ if (pPath->newStroke) { - DPRINT("Line To : New Stroke\n"); + TRACE("Line To : New Stroke\n"); pPath->newStroke = FALSE; IntGetCurrentPositionEx(dc, &pointCurPos); CoordLPtoDP(dc, &pointCurPos); @@ -816,7 +844,7 @@ PATH_Ellipse( if (dc->dclevel.flPath & DCPATH_CLOCKWISE) reverse_points( points, 13 ); if (!(type = add_points( pPath, points, 13, PT_BEZIERTO ))) { - DPRINT1("PATH_Ellipse No add\n"); + ERR("PATH_Ellipse No add\n"); PATH_UnlockPath(pPath); return FALSE; } @@ -836,17 +864,17 @@ PATH_Ellipse( * control point is added to the path; otherwise, it is assumed that the current * position is equal to the first control point. */ +static BOOL -FASTCALL PATH_DoArcPart( PPATH pPath, - FLOAT_POINT corners[], + POINT corners[], double angleStart, double angleEnd, BYTE startEntryType) { double halfAngle, a; - double xNorm[4], yNorm[4]; + float xNorm[4], yNorm[4]; POINT points[4]; BYTE *type; int i, start; @@ -880,7 +908,11 @@ PATH_DoArcPart( start = !startEntryType; /* Add remaining control points */ - for (i = start; i < 4; i++) PATH_ScaleNormalizedPoint(corners, xNorm[i], yNorm[i], &points[i]); + for (i = start; i < 4; i++) + { + if (!PATH_ScaleNormalizedPoint(corners, *(FLOATL*)&xNorm[i], *(FLOATL*)&yNorm[i], &points[i])) + return FALSE; + } if (!(type = add_points( pPath, points + start, 4 - start, PT_BEZIERTO ))) return FALSE; if (!start) type[0] = startEntryType; @@ -914,8 +946,8 @@ PATH_Arc( { double angleStart, angleEnd, angleStartQuadrant, angleEndQuadrant = 0.0; /* Initialize angleEndQuadrant to silence gcc's warning */ - double x, y; - FLOAT_POINT corners[2], pointStart, pointEnd; + FLOATL x, y; + POINT corners[2], pointStart, pointEnd; POINT centre, pointCurPos; BOOL start, end, Ret = TRUE; INT temp; @@ -943,18 +975,13 @@ PATH_Arc( goto ArcExit; } /* Convert points to device coordinates */ - corners[0].x = (FLOAT)x1; - corners[0].y = (FLOAT)y1; - corners[1].x = (FLOAT)x2; - corners[1].y = (FLOAT)y2; - pointStart.x = (FLOAT)xStart; - pointStart.y = (FLOAT)yStart; - pointEnd.x = (FLOAT)xEnd; - pointEnd.y = (FLOAT)yEnd; - INTERNAL_LPTODP_FLOAT(dc, corners); - INTERNAL_LPTODP_FLOAT(dc, corners + 1); - INTERNAL_LPTODP_FLOAT(dc, &pointStart); - INTERNAL_LPTODP_FLOAT(dc, &pointEnd); + corners[0].x = x1; corners[0].y = y1; + corners[1].x = x2; corners[1].y = y2; + pointStart.x = xStart; pointStart.y = yStart; + pointEnd.x = xEnd; pointEnd.y = yEnd; + INTERNAL_LPTODP(dc, corners, 2); + INTERNAL_LPTODP(dc, &pointStart, 1); + INTERNAL_LPTODP(dc, &pointEnd, 1); /* Make sure first corner is top left and second corner is bottom right */ if (corners[0].x > corners[1].x) @@ -972,9 +999,9 @@ PATH_Arc( /* Compute start and end angle */ PATH_NormalizePoint(corners, &pointStart, &x, &y); - angleStart = atan2(y, x); + angleStart = atan2(*(FLOAT*)&y, *(FLOAT*)&x); PATH_NormalizePoint(corners, &pointEnd, &x, &y); - angleEnd = atan2(y, x); + angleEnd = atan2(*(FLOAT*)&y, *(FLOAT*)&x); /* Make sure the end angle is "on the right side" of the start angle */ if (clockwise) @@ -1153,8 +1180,8 @@ PATH_PolyDraw( IntGetCurrentPositionEx(dc, &cur_pos); - DPRINT("PPD : Current pos X %d Y %d\n",pPath->pos.x, pPath->pos.y); - DPRINT("PPD : last %d pos X %d Y %d\n",lastmove, pPath->pPoints[lastmove].x, pPath->pPoints[lastmove].y); + TRACE("PPD : Current pos X %d Y %d\n",pPath->pos.x, pPath->pos.y); + TRACE("PPD : last %d pos X %d Y %d\n",lastmove, pPath->pPoints[lastmove].x, pPath->pPoints[lastmove].y); for(i = 0; i < cbPoints; i++) @@ -1192,7 +1219,7 @@ PATH_PolyDraw( /* restore original position */ pPath->pos = orig_pos; - DPRINT("PPD Bad : pos X %d Y %d\n",pPath->pos.x, pPath->pos.y); + TRACE("PPD Bad : pos X %d Y %d\n",pPath->pos.x, pPath->pos.y); IntGdiMoveToEx(dc, cur_pos.x, cur_pos.y, NULL); @@ -1204,7 +1231,7 @@ PATH_PolyDraw( { close_figure( pPath ); pPath->pos = pPath->pPoints[lastmove]; - DPRINT("PPD close : pos X %d Y %d\n",pPath->pos.x, pPath->pos.y); + TRACE("PPD close : pos X %d Y %d\n",pPath->pos.x, pPath->pos.y); } } PATH_UnlockPath(pPath); @@ -1317,7 +1344,7 @@ PATH_PolyPolyline( PATH_AddEntry(pPath, &pt, (point == 0) ? PT_MOVETO : PT_LINETO); } } - DPRINT("PATH_PolyPolyline end count %d\n",pPath->numEntriesUsed); + TRACE("PATH_PolyPolyline end count %d\n",pPath->numEntriesUsed); PATH_UnlockPath(pPath); return TRUE; } @@ -1360,7 +1387,7 @@ PATH_FlattenPath(PPATH pPath) { PPATH newPath; INT srcpt; - DPRINT("PATH_FlattenPath\n"); + TRACE("PATH_FlattenPath\n"); if (!(newPath = PATH_CreatePath(pPath->numEntriesUsed))) return NULL; for (srcpt = 0; srcpt < pPath->numEntriesUsed; srcpt++) @@ -1387,7 +1414,7 @@ PATH_FlattenPath(PPATH pPath) break; } } - DPRINT("PATH_FlattenPath good\n"); + TRACE("PATH_FlattenPath good\n"); newPath->state = pPath->state; return newPath; } @@ -1414,7 +1441,7 @@ PATH_PathToRegion( counts = ExAllocatePoolWithTag(PagedPool, (pPath->numEntriesUsed / 2) * sizeof(counts), TAG_PATH); if (!counts) { - DPRINT1("Failed to allocate %lu strokes\n", (pPath->numEntriesUsed / 2) * sizeof(*counts)); + ERR("Failed to allocate %lu strokes\n", (pPath->numEntriesUsed / 2) * sizeof(*counts)); EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -1439,7 +1466,7 @@ PATH_PathToRegion( Mode); if (!Ret) { - DPRINT1("REGION_SetPolyPolygonRgn failed\n"); + ERR("REGION_SetPolyPolygonRgn failed\n"); } ExFreePoolWithTag(counts, TAG_PATH); @@ -1486,7 +1513,7 @@ PATH_FillPathEx( if (!PATH_PathToRegion(pPath, pdcattr->jFillMode, Rgn)) { - DPRINT("PFP : Fail P2R\n"); + TRACE("PFP : Fail P2R\n"); /* EngSetLastError ? */ REGION_Delete(Rgn); return FALSE; @@ -1561,7 +1588,7 @@ PATH_StrokePath( XFORM xform; PDC_ATTR pdcattr = dc->pdcattr; - DPRINT("Enter %s\n", __FUNCTION__); + TRACE("Enter %s\n", __FUNCTION__); /* Save the mapping mode info */ mapMode = pdcattr->iMapMode; @@ -1591,7 +1618,7 @@ PATH_StrokePath( pLinePts = ExAllocatePoolWithTag(PagedPool, nAlloc * sizeof(POINT), TAG_PATH); if (!pLinePts) { - DPRINT1("Can't allocate pool!\n"); + ERR("Can't allocate pool!\n"); EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); goto end; } @@ -1602,7 +1629,7 @@ PATH_StrokePath( if ((i == 0 || (pPath->pFlags[i - 1] & PT_CLOSEFIGURE)) && (pPath->pFlags[i] != PT_MOVETO)) { - DPRINT1("Expected PT_MOVETO %s, got path flag %d\n", + ERR("Expected PT_MOVETO %s, got path flag %d\n", i == 0 ? "as first point" : "after PT_CLOSEFIGURE", (INT)pPath->pFlags[i]); goto end; @@ -1611,7 +1638,7 @@ PATH_StrokePath( switch(pPath->pFlags[i]) { case PT_MOVETO: - DPRINT("Got PT_MOVETO (%ld, %ld)\n", + TRACE("Got PT_MOVETO (%ld, %ld)\n", pPath->pPoints[i].x, pPath->pPoints[i].y); if (nLinePts >= 2) IntGdiPolyline(dc, pLinePts, nLinePts); nLinePts = 0; @@ -1619,16 +1646,16 @@ PATH_StrokePath( break; case PT_LINETO: case (PT_LINETO | PT_CLOSEFIGURE): - DPRINT("Got PT_LINETO (%ld, %ld)\n", + TRACE("Got PT_LINETO (%ld, %ld)\n", pPath->pPoints[i].x, pPath->pPoints[i].y); pLinePts[nLinePts++] = pPath->pPoints[i]; break; case PT_BEZIERTO: - DPRINT("Got PT_BEZIERTO\n"); + TRACE("Got PT_BEZIERTO\n"); if (pPath->pFlags[i + 1] != PT_BEZIERTO || (pPath->pFlags[i + 2] & ~PT_CLOSEFIGURE) != PT_BEZIERTO) { - DPRINT1("Path didn't contain 3 successive PT_BEZIERTOs\n"); + ERR("Path didn't contain 3 successive PT_BEZIERTOs\n"); ret = FALSE; goto end; } @@ -1653,7 +1680,7 @@ PATH_StrokePath( if (!Realloc) { - DPRINT1("Can't allocate pool!\n"); + ERR("Can't allocate pool!\n"); ExFreePoolWithTag(pBzrPts, TAG_BEZIER); goto end; } @@ -1669,7 +1696,7 @@ PATH_StrokePath( } break; default: - DPRINT1("Got path flag %d (not supported)\n", (INT)pPath->pFlags[i]); + ERR("Got path flag %d (not supported)\n", (INT)pPath->pFlags[i]); goto end; } @@ -1714,7 +1741,7 @@ end: IntDPtoLP(dc, &pt, 1); IntGdiMoveToEx(dc, pt.x, pt.y, NULL); } - DPRINT("Leave %s, ret=%d\n", __FUNCTION__, ret); + TRACE("Leave %s, ret=%d\n", __FUNCTION__, ret); return ret; } @@ -1733,7 +1760,7 @@ IntGdiWidenPath(PPATH pPath, UINT penWidth, UINT penStyle, FLOAT eMiterLimit) if (!(flat_path = PATH_FlattenPath(pPath))) { - DPRINT1("PATH_FlattenPath\n"); + ERR("PATH_FlattenPath\n"); return NULL; } @@ -1750,7 +1777,7 @@ IntGdiWidenPath(PPATH pPath, UINT penWidth, UINT penStyle, FLOAT eMiterLimit) if ((i == 0 || (flat_path->pFlags[i - 1] & PT_CLOSEFIGURE)) && (flat_path->pFlags[i] != PT_MOVETO)) { - DPRINT1("Expected PT_MOVETO %s, got path flag %c\n", + ERR("Expected PT_MOVETO %s, got path flag %c\n", i == 0 ? "as first point" : "after PT_CLOSEFIGURE", flat_path->pFlags[i]); if (pStrokes) @@ -1806,10 +1833,10 @@ IntGdiWidenPath(PPATH pPath, UINT penWidth, UINT penStyle, FLOAT eMiterLimit) break; case PT_BEZIERTO: /* Should never happen because of the FlattenPath call */ - DPRINT1("Should never happen\n"); + ERR("Should never happen\n"); break; default: - DPRINT1("Got path flag %c\n", flat_path->pFlags[i]); + ERR("Got path flag %c\n", flat_path->pFlags[i]); if (pStrokes) ExFreePoolWithTag(pStrokes, TAG_PATH); PATH_UnlockPath(flat_path); @@ -1835,9 +1862,10 @@ IntGdiWidenPath(PPATH pPath, UINT penWidth, UINT penStyle, FLOAT eMiterLimit) if ((!(pStrokes[i]->pFlags[pStrokes[i]->numEntriesUsed - 1] & PT_CLOSEFIGURE)) && (j == 0 || j == pStrokes[i]->numEntriesUsed - 1)) { /* Compute segment angle */ - double xo, yo, xa, ya, theta; + INT xo, yo, xa, ya; + double theta; POINT pt; - FLOAT_POINT corners[2]; + POINT corners[2]; if (j == 0) { xo = pStrokes[i]->pPoints[j].x; @@ -2067,7 +2095,7 @@ PATH_WidenPath(DC *dc) if (pPath->state != PATH_Closed) { - DPRINT("PWP 1\n"); + TRACE("PWP 1\n"); PATH_UnlockPath(pPath); EngSetLastError(ERROR_CAN_NOT_COMPLETE); return NULL; @@ -2076,7 +2104,7 @@ PATH_WidenPath(DC *dc) size = GreGetObject(pdcattr->hpen, 0, NULL); if (!size) { - DPRINT("PWP 2\n"); + TRACE("PWP 2\n"); PATH_UnlockPath(pPath); EngSetLastError(ERROR_CAN_NOT_COMPLETE); return NULL; @@ -2085,7 +2113,7 @@ PATH_WidenPath(DC *dc) elp = ExAllocatePoolWithTag(PagedPool, size, TAG_PATH); if (elp == NULL) { - DPRINT("PWP 3\n"); + TRACE("PWP 3\n"); PATH_UnlockPath(pPath); EngSetLastError(ERROR_OUTOFMEMORY); return NULL; @@ -2104,7 +2132,7 @@ PATH_WidenPath(DC *dc) } else { - DPRINT("PWP 4\n"); + TRACE("PWP 4\n"); EngSetLastError(ERROR_CAN_NOT_COMPLETE); ExFreePoolWithTag(elp, TAG_PATH); PATH_UnlockPath(pPath); @@ -2118,7 +2146,7 @@ PATH_WidenPath(DC *dc) if (obj_type == GDI_OBJECT_TYPE_EXTPEN && (PS_TYPE_MASK & penStyle) == PS_COSMETIC) { - DPRINT("PWP 5\n"); + TRACE("PWP 5\n"); PATH_UnlockPath(pPath); EngSetLastError(ERROR_CAN_NOT_COMPLETE); return FALSE; @@ -2206,7 +2234,7 @@ PATH_add_outline( if (header->dwType != TT_POLYGON_TYPE) { - DPRINT1("Unknown header type %lu\n", header->dwType); + ERR("Unknown header type %lu\n", header->dwType); goto cleanup; } @@ -2218,7 +2246,7 @@ PATH_add_outline( while ((char *)curve < (char *)header + header->cb) { - /*DPRINT1("curve->wType %d\n", curve->wType);*/ + TRACE("curve->wType %d\n", curve->wType); switch(curve->wType) { @@ -2262,7 +2290,7 @@ PATH_add_outline( } default: - DPRINT1("Unknown curve type %04x\n", curve->wType); + ERR("Unknown curve type %04x\n", curve->wType); goto cleanup; } @@ -2305,7 +2333,7 @@ PATH_ExtTextOut( if (pPath->state != PATH_Open) { - DPRINT1("PATH_ExtTextOut not open\n"); + ERR("PATH_ExtTextOut not open\n"); return FALSE; } @@ -2435,7 +2463,7 @@ NtGdiBeginPath(HDC hDC) if (dc->dclevel.hPath) { - DPRINT("BeginPath 1 0x%p\n", dc->dclevel.hPath); + TRACE("BeginPath 1 0x%p\n", dc->dclevel.hPath); if (!(dc->dclevel.flPath & DCPATH_SAVE)) { // Remove previous handle. @@ -2457,7 +2485,7 @@ NtGdiBeginPath(HDC hDC) dc->dclevel.hPath = pPath->BaseObject.hHmgr; IntGetCurrentPositionEx(dc, &pPath->pos); IntLPtoDP( dc, &pPath->pos, 1 ); - DPRINT("BP : Current pos X %d Y %d\n",pPath->pos.x, pPath->pos.y); + TRACE("BP : Current pos X %d Y %d\n",pPath->pos.x, pPath->pos.y); PATH_UnlockPath(pPath); DC_UnlockDc(dc); @@ -2476,7 +2504,7 @@ NtGdiCloseFigure(HDC hDC) PDC pDc; PPATH pPath; - DPRINT("Enter %s\n", __FUNCTION__); + TRACE("Enter %s\n", __FUNCTION__); pDc = DC_LockDc(hDC); if (!pDc) @@ -2532,14 +2560,14 @@ NtGdiEndPath(HDC hDC) /* Check that path is currently being constructed */ if ((pPath->state != PATH_Open) || !(dc->dclevel.flPath & DCPATH_ACTIVE)) { - DPRINT("EndPath ERROR! 0x%p\n", dc->dclevel.hPath); + TRACE("EndPath ERROR! 0x%p\n", dc->dclevel.hPath); EngSetLastError(ERROR_CAN_NOT_COMPLETE); ret = FALSE; } /* Set flag to indicate that path is finished */ else { - DPRINT("EndPath 0x%p\n", dc->dclevel.hPath); + TRACE("EndPath 0x%p\n", dc->dclevel.hPath); pPath->state = PATH_Closed; dc->dclevel.flPath &= ~DCPATH_ACTIVE; } @@ -2615,7 +2643,7 @@ NtGdiFlattenPath(HDC hDC) DC *pDc; PPATH pPath, pNewPath = NULL; - DPRINT("Enter %s\n", __FUNCTION__); + TRACE("Enter %s\n", __FUNCTION__); pDc = DC_LockDc(hDC); if (!pDc) @@ -2709,10 +2737,10 @@ NtGdiGetPath( _SEH2_END dc = DC_LockDc(hDC); - DPRINT("NtGdiGetPath start\n"); + TRACE("NtGdiGetPath start\n"); if (!dc) { - DPRINT1("Can't lock dc!\n"); + ERR("Can't lock dc!\n"); EngSetLastError(ERROR_INVALID_PARAMETER); return -1; } @@ -2763,7 +2791,7 @@ NtGdiGetPath( } done: - DPRINT("NtGdiGetPath exit %d\n",ret); + TRACE("NtGdiGetPath exit %d\n",ret); PATH_UnlockPath(pPath); DC_UnlockDc(dc); return ret; @@ -2780,12 +2808,12 @@ NtGdiPathToRegion(HDC hDC) DC *pDc; PDC_ATTR pdcattr; - DPRINT("Enter %s\n", __FUNCTION__); + TRACE("Enter %s\n", __FUNCTION__); pDc = DC_LockDc(hDC); if (!pDc) { - DPRINT("Failed to lock DC %p\n", hDC); + ERR("Failed to lock DC %p\n", hDC); EngSetLastError(ERROR_INVALID_PARAMETER); return NULL; } @@ -2795,7 +2823,7 @@ NtGdiPathToRegion(HDC hDC) pPath = PATH_LockPath(pDc->dclevel.hPath); if (!pPath) { - DPRINT("Failed to lock DC path %p\n", pDc->dclevel.hPath); + ERR("Failed to lock DC path %p\n", pDc->dclevel.hPath); DC_UnlockDc(pDc); return NULL; } @@ -2803,7 +2831,7 @@ NtGdiPathToRegion(HDC hDC) if (pPath->state != PATH_Closed) { // FIXME: Check that setlasterror is being called correctly - DPRINT("Path is not closed!\n"); + ERR("Path is not closed!\n"); EngSetLastError(ERROR_CAN_NOT_COMPLETE); } else @@ -2812,7 +2840,7 @@ NtGdiPathToRegion(HDC hDC) Rgn = REGION_AllocUserRgnWithHandle(1); if (!Rgn) { - DPRINT("Failed to allocate a region\n"); + ERR("Failed to allocate a region\n"); PATH_UnlockPath(pPath); DC_UnlockDc(pDc); return NULL; @@ -2828,7 +2856,7 @@ NtGdiPathToRegion(HDC hDC) if (!Ret) { - DPRINT("PATH_PathToRegion failed\n"); + ERR("PATH_PathToRegion failed\n"); REGION_Delete(Rgn); hrgnRval = NULL; } @@ -2894,7 +2922,7 @@ NtGdiStrokeAndFillPath(HDC hDC) PPATH pPath, pNewPath; BOOL bRet = FALSE; - DPRINT("Enter %s\n", __FUNCTION__); + TRACE("Enter %s\n", __FUNCTION__); if (!(pDc = DC_LockDc(hDC))) { @@ -2953,7 +2981,7 @@ NtGdiStrokePath(HDC hDC) PPATH pPath, pNewPath; BOOL bRet = FALSE; - DPRINT("Enter %s\n", __FUNCTION__); + TRACE("Enter %s\n", __FUNCTION__); if (!(pDc = DC_LockDc(hDC))) { @@ -3004,7 +3032,7 @@ NtGdiWidenPath(HDC hDC) PPATH pPath; BOOL Ret = FALSE; PDC pdc = DC_LockDc(hDC); - DPRINT("NtGdiWidenPat Enter\n"); + TRACE("NtGdiWidenPat Enter\n"); if (!pdc) { EngSetLastError(ERROR_INVALID_PARAMETER); @@ -3014,13 +3042,13 @@ NtGdiWidenPath(HDC hDC) pPath = PATH_WidenPath(pdc); if (pPath) { - DPRINT("WindenPath New Path\n"); + TRACE("WindenPath New Path\n"); PATH_Delete(pdc->dclevel.hPath); pdc->dclevel.hPath = pPath->BaseObject.hHmgr; Ret = TRUE; } DC_UnlockDc(pdc); - DPRINT("NtGdiWidenPat Ret %d\n",Ret); + TRACE("NtGdiWidenPat Ret %d\n",Ret); return Ret; } diff --git a/win32ss/gdi/ntgdi/path.h b/win32ss/gdi/ntgdi/path.h index 021045ee5f5..fc8144644a1 100644 --- a/win32ss/gdi/ntgdi/path.h +++ b/win32ss/gdi/ntgdi/path.h @@ -90,14 +90,11 @@ BOOL FASTCALL PATH_ExtTextOut(PDC dc,INT x,INT y,UINT flags,const RECTL *lprc,LP BOOL FASTCALL PATH_AddEntry (PPATH pPath, const POINT *pPoint, BYTE flags); BOOL FASTCALL PATH_AddFlatBezier (PPATH pPath, POINT *pt, BOOL closed); -BOOL FASTCALL PATH_DoArcPart (PPATH pPath, FLOAT_POINT corners[], double angleStart, double angleEnd, BYTE startEntryType); BOOL FASTCALL PATH_FillPath( PDC dc, PPATH pPath ); BOOL FASTCALL PATH_FillPathEx(PDC dc, PPATH pPath, PBRUSH pbrFill); PPATH FASTCALL PATH_FlattenPath (PPATH pPath); -VOID FASTCALL PATH_NormalizePoint (FLOAT_POINT corners[], const FLOAT_POINT *pPoint, double *pX, double *pY); BOOL FASTCALL PATH_ReserveEntries (PPATH pPath, INT numEntries); -VOID FASTCALL PATH_ScaleNormalizedPoint (FLOAT_POINT corners[], double x, double y, POINT *pPoint); BOOL FASTCALL PATH_StrokePath(DC *dc, PPATH pPath); BOOL PATH_CheckCorners(DC *dc, POINT corners[], INT x1, INT y1, INT x2, INT y2);
3 years, 8 months
1
0
0
0
[reactos] 01/01: [WIN32K] Fix brain-fail of mine
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=40f7e863472d2b0a662c0…
commit 40f7e863472d2b0a662c06a95316997ab7c62d2b Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Wed Mar 31 16:55:30 2021 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Mar 31 16:55:30 2021 +0200 [WIN32K] Fix brain-fail of mine Copying e.g. (2;2);(6;6) to (0;0);(4;4) also needs to have an intermediate buffer. --- win32ss/gdi/dib/dib1bpp.c | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/win32ss/gdi/dib/dib1bpp.c b/win32ss/gdi/dib/dib1bpp.c index 0bc25777f0c..6dcc444baec 100644 --- a/win32ss/gdi/dib/dib1bpp.c +++ b/win32ss/gdi/dib/dib1bpp.c @@ -69,6 +69,7 @@ DIB_1BPP_BitBltSrcCopy_From1BPP ( LONG Width = RECTL_lGetWidth(DestRect); BOOLEAN XorBit = !!XLATEOBJ_iXlate(pxlo, 0); BOOLEAN Overlap = FALSE; + BYTE *DstStart, *DstEnd, *SrcStart, *SrcEnd; /* Make sure this is as expected */ ASSERT(DestRect->left >= 0); @@ -78,34 +79,30 @@ DIB_1BPP_BitBltSrcCopy_From1BPP ( /* * Check if we need to allocate a buffer for our operation. - * NB: if we're not mirroring, we're doing a memmove-like operation, so this is always fine. */ - if (bTopToBottom || bLeftToRight) - { - BYTE* DstStart = (BYTE*)DestSurf->pvScan0 + DestRect->top * DestSurf->lDelta + DestRect->left / 8; - BYTE* DstEnd = (BYTE*)DestSurf->pvScan0 + (DestRect->bottom - 1) * DestSurf->lDelta + (DestRect->right) / 8; - BYTE* SrcStart = (BYTE*)SourceSurf->pvScan0 + SourcePoint->y * SourceSurf->lDelta + SourcePoint->x / 8; - BYTE* SrcEnd = (BYTE*)SourceSurf->pvScan0 + (SourcePoint->y + Height - 1) * SourceSurf->lDelta + (SourcePoint->x + Width) / 8; + DstStart = (BYTE*)DestSurf->pvScan0 + DestRect->top * DestSurf->lDelta + DestRect->left / 8; + DstEnd = (BYTE*)DestSurf->pvScan0 + (DestRect->bottom - 1) * DestSurf->lDelta + (DestRect->right) / 8; + SrcStart = (BYTE*)SourceSurf->pvScan0 + SourcePoint->y * SourceSurf->lDelta + SourcePoint->x / 8; + SrcEnd = (BYTE*)SourceSurf->pvScan0 + (SourcePoint->y + Height - 1) * SourceSurf->lDelta + (SourcePoint->x + Width) / 8; - /* Beware of bitmaps with negative pitch! */ - if (DstStart > DstEnd) - { - BYTE* tmp = DstStart; - DstStart = DstEnd; - DstEnd = tmp; - } - - if (SrcStart > SrcEnd) - { - BYTE* tmp = SrcStart; - SrcStart = SrcEnd; - SrcEnd = tmp; - } + /* Beware of bitmaps with negative pitch! */ + if (DstStart > DstEnd) + { + BYTE* tmp = DstStart; + DstStart = DstEnd; + DstEnd = tmp; + } - /* We allocate a new buffer when the two buffers overlap */ - Overlap = ((SrcStart >= DstStart) && (SrcStart < DstEnd)) || ((SrcEnd >= DstStart) && (SrcEnd < DstEnd)); + if (SrcStart > SrcEnd) + { + BYTE* tmp = SrcStart; + SrcStart = SrcEnd; + SrcEnd = tmp; } + /* We allocate a new buffer when the two buffers overlap */ + Overlap = ((SrcStart >= DstStart) && (SrcStart < DstEnd)) || ((SrcEnd >= DstStart) && (SrcEnd < DstEnd)); + if (!Overlap) { LONG y;
3 years, 8 months
1
0
0
0
[reactos] 02/02: [WIN32K] Fix case when buffers overlap in 1BPP -> 1BPP DIB copy
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=30886e74f232eb72952ba…
commit 30886e74f232eb72952ba47045acb49be5cf2ca3 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Wed Mar 31 15:02:20 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Mar 31 16:39:57 2021 +0200 [WIN32K] Fix case when buffers overlap in 1BPP -> 1BPP DIB copy Logic by Doug Lyons CORE-17520 --- win32ss/gdi/dib/dib1bpp.c | 99 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 80 insertions(+), 19 deletions(-) diff --git a/win32ss/gdi/dib/dib1bpp.c b/win32ss/gdi/dib/dib1bpp.c index c1b33ad4182..0bc25777f0c 100644 --- a/win32ss/gdi/dib/dib1bpp.c +++ b/win32ss/gdi/dib/dib1bpp.c @@ -55,7 +55,7 @@ DIB_1BPP_VLine(SURFOBJ *SurfObj, LONG x, LONG y1, LONG y2, ULONG c) } static -void +BOOLEAN DIB_1BPP_BitBltSrcCopy_From1BPP ( SURFOBJ* DestSurf, SURFOBJ* SourceSurf, @@ -66,34 +66,96 @@ DIB_1BPP_BitBltSrcCopy_From1BPP ( BOOLEAN bLeftToRight ) { LONG Height = RECTL_lGetHeight(DestRect); + LONG Width = RECTL_lGetWidth(DestRect); BOOLEAN XorBit = !!XLATEOBJ_iXlate(pxlo, 0); + BOOLEAN Overlap = FALSE; /* Make sure this is as expected */ ASSERT(DestRect->left >= 0); ASSERT(DestRect->top >= 0); ASSERT(Height > 0); - ASSERT(RECTL_lGetWidth(DestRect) > 0); + ASSERT(Width > 0); - while (Height--) + /* + * Check if we need to allocate a buffer for our operation. + * NB: if we're not mirroring, we're doing a memmove-like operation, so this is always fine. + */ + if (bTopToBottom || bLeftToRight) { - LONG yDst = DestRect->top + Height; - LONG ySrc = bTopToBottom ? - SourcePoint->y + RECTL_lGetHeight(DestRect) - Height - 1 - : SourcePoint->y + Height; - LONG Width = RECTL_lGetWidth(DestRect); + BYTE* DstStart = (BYTE*)DestSurf->pvScan0 + DestRect->top * DestSurf->lDelta + DestRect->left / 8; + BYTE* DstEnd = (BYTE*)DestSurf->pvScan0 + (DestRect->bottom - 1) * DestSurf->lDelta + (DestRect->right) / 8; + BYTE* SrcStart = (BYTE*)SourceSurf->pvScan0 + SourcePoint->y * SourceSurf->lDelta + SourcePoint->x / 8; + BYTE* SrcEnd = (BYTE*)SourceSurf->pvScan0 + (SourcePoint->y + Height - 1) * SourceSurf->lDelta + (SourcePoint->x + Width) / 8; + + /* Beware of bitmaps with negative pitch! */ + if (DstStart > DstEnd) + { + BYTE* tmp = DstStart; + DstStart = DstEnd; + DstEnd = tmp; + } - while (Width--) + if (SrcStart > SrcEnd) { - LONG xDst = DestRect->left + Width; - LONG xSrc = bLeftToRight ? - SourcePoint->x + RECTL_lGetWidth(DestRect) - Width - 1 - : SourcePoint->x + Width; - ULONG PixelPut = DIB_1BPP_GetPixel(SourceSurf, xSrc, ySrc); - if (XorBit) - PixelPut = !PixelPut; - DIB_1BPP_PutPixel(DestSurf, xDst, yDst, PixelPut); + BYTE* tmp = SrcStart; + SrcStart = SrcEnd; + SrcEnd = tmp; } + + /* We allocate a new buffer when the two buffers overlap */ + Overlap = ((SrcStart >= DstStart) && (SrcStart < DstEnd)) || ((SrcEnd >= DstStart) && (SrcEnd < DstEnd)); } + + if (!Overlap) + { + LONG y; + for (y = 0; y < Height; y++) + { + LONG ySrc = bTopToBottom ? SourcePoint->y + Height - y - 1 : SourcePoint->y + y; + LONG x; + + for(x = 0; x < Width; x++) + { + LONG xSrc = bLeftToRight ? SourcePoint->x + Width - x - 1 : SourcePoint->x + x; + ULONG Pixel = DIB_1BPP_GetPixel(SourceSurf, xSrc, ySrc); + if (XorBit) + Pixel = !Pixel; + DIB_1BPP_PutPixel(DestSurf, DestRect->left + x, DestRect->top + y, Pixel); + } + } + } + else + { + LONG y; + BYTE* PixBuf = ExAllocatePoolZero(PagedPool, Height * (ALIGN_UP_BY(Width, 8) / 8), TAG_DIB); + if (!PixBuf) + return FALSE; + for (y = 0; y < Height; y++) + { + BYTE* Row = PixBuf + y * ALIGN_UP_BY(Width, 8) / 8; + LONG ySrc = bTopToBottom ? SourcePoint->y + Height - y - 1 : SourcePoint->y + y; + LONG x; + + for (x = 0; x < Width; x++) + { + LONG xSrc = bLeftToRight ? SourcePoint->x + Width - x - 1 : SourcePoint->x + x; + if ((!DIB_1BPP_GetPixel(SourceSurf, xSrc, ySrc)) == XorBit) + Row[x / 8] |= 1 << (x & 7); + } + } + + for (y = 0; y < Height; y++) + { + BYTE* Row = PixBuf + y * ALIGN_UP_BY(Width, 8) / 8; + LONG x; + for (x = 0; x < Width; x++) + DIB_1BPP_PutPixel(DestSurf, DestRect->left + x, DestRect->top + y, !!(Row[x/8] & (1 << (x&7)))); + } + + ExFreePoolWithTag(PixBuf, TAG_DIB); + } + + return TRUE; } BOOLEAN @@ -129,10 +191,9 @@ DIB_1BPP_BitBltSrcCopy(PBLTINFO BltInfo) DPRINT("1BPP Case Selected with DestRect Width of '%d'.\n", BltInfo->DestRect.right - BltInfo->DestRect.left); - DIB_1BPP_BitBltSrcCopy_From1BPP ( BltInfo->DestSurface, BltInfo->SourceSurface, + return DIB_1BPP_BitBltSrcCopy_From1BPP ( BltInfo->DestSurface, BltInfo->SourceSurface, BltInfo->XlateSourceToDest, &BltInfo->DestRect, &BltInfo->SourcePoint, bTopToBottom, bLeftToRight ); - break; case BMF_4BPP: DPRINT("4BPP Case Selected with DestRect Width of '%d'.\n",
3 years, 8 months
1
0
0
0
[reactos] 01/02: [WIN32K] Fix off-by-one errors
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=068687e0fde0f417ed8a8…
commit 068687e0fde0f417ed8a81c44a0009de721da68a Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Wed Mar 31 09:59:44 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Mar 31 16:39:57 2021 +0200 [WIN32K] Fix off-by-one errors Spotted by Doug Lyons CORE-17520 --- win32ss/gdi/dib/dib1bpp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/win32ss/gdi/dib/dib1bpp.c b/win32ss/gdi/dib/dib1bpp.c index 6a90282808d..c1b33ad4182 100644 --- a/win32ss/gdi/dib/dib1bpp.c +++ b/win32ss/gdi/dib/dib1bpp.c @@ -78,7 +78,7 @@ DIB_1BPP_BitBltSrcCopy_From1BPP ( { LONG yDst = DestRect->top + Height; LONG ySrc = bTopToBottom ? - SourcePoint->y + RECTL_lGetHeight(DestRect) - Height + SourcePoint->y + RECTL_lGetHeight(DestRect) - Height - 1 : SourcePoint->y + Height; LONG Width = RECTL_lGetWidth(DestRect); @@ -86,7 +86,7 @@ DIB_1BPP_BitBltSrcCopy_From1BPP ( { LONG xDst = DestRect->left + Width; LONG xSrc = bLeftToRight ? - SourcePoint->x + RECTL_lGetWidth(DestRect) - Width + SourcePoint->x + RECTL_lGetWidth(DestRect) - Width - 1 : SourcePoint->x + Width; ULONG PixelPut = DIB_1BPP_GetPixel(SourceSurf, xSrc, ySrc); if (XorBit)
3 years, 8 months
1
0
0
0
[reactos] 01/01: [NTOS:MM] Properly fail for invalid sizes of data section mappings
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=998870c5ea85eabdd2b4d…
commit 998870c5ea85eabdd2b4df798f86e8de08d8a71b Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Mon Feb 8 14:33:08 2021 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Tue Mar 30 22:20:15 2021 +0200 [NTOS:MM] Properly fail for invalid sizes of data section mappings --- ntoskrnl/mm/ARM3/section.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c index 3e6a25b44db..1301267e6b3 100644 --- a/ntoskrnl/mm/ARM3/section.c +++ b/ntoskrnl/mm/ARM3/section.c @@ -1326,25 +1326,26 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea, /* Check if the caller specified the view size */ if (!(*ViewSize)) { + LONGLONG ViewSizeLL; + /* The caller did not, so pick a 64K aligned view size based on the offset */ SectionOffset->LowPart &= ~(_64K - 1); - /* Make sure that we will not overflow */ - if ((Section->SizeOfSection.QuadPart - SectionOffset->QuadPart) > MAXLONG_PTR) + /* Calculate size and make sure this fits */ + if (!NT_SUCCESS(RtlLongLongSub(Section->SizeOfSection.QuadPart, SectionOffset->QuadPart, &ViewSizeLL)) + || !NT_SUCCESS(RtlLongLongToSIZET(ViewSizeLL, ViewSize)) + || (*ViewSize > MAXLONG_PTR)) { MiDereferenceControlArea(ControlArea); return STATUS_INVALID_VIEW_SIZE; } - - *ViewSize = (SIZE_T)(Section->SizeOfSection.QuadPart - SectionOffset->QuadPart); } else { - /* A size was specified, align it to a 64K boundary */ - *ViewSize += SectionOffset->LowPart & (_64K - 1); - - /* Check for overflow or huge value */ - if ((*ViewSize < (SectionOffset->LowPart & (_64K - 1))) || ((*ViewSize) > MAXLONG_PTR)) + /* A size was specified, align it to a 64K boundary + * and check for overflow or huge value. */ + if (!NT_SUCCESS(RtlSIZETAdd(*ViewSize, SectionOffset->LowPart & (_64K - 1), ViewSize)) + || (*ViewSize > MAXLONG_PTR)) { MiDereferenceControlArea(ControlArea); return STATUS_INVALID_VIEW_SIZE;
3 years, 8 months
1
0
0
0
← Newer
1
2
3
4
...
17
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Results per page:
10
25
50
100
200