[TASKMGR] Clamp the values returned from PerfDataGetProcessorUsage() and PerfDataGetProcessorSystemUsage() inside these functions.

It's necessary to make this clamping there so that returned values are
always used consistently in taskmgr, including in places where the
values are directly fetched into other functions.

This is a free adaptation from
Wine commit
a9742b3210c4cec67aca3c0012f3b9504a4368cf
From: Gerald Pfeifer <gerald@pfeifer.com>

taskmgr: Move out-of-domain checking into
PerfDataGetProcessorUsage() and PerfDataGetProcessorSystemUsage().
This commit is contained in:
Hermès Bélusca-Maïto 2021-12-18 03:10:26 +01:00
parent 7b53126375
commit 0b4c8bdd1c
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
3 changed files with 3 additions and 14 deletions

View file

@ -148,8 +148,6 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
* Get the CPU usage
*/
CpuUsage = PerfDataGetProcessorUsage();
if (CpuUsage <= 0) CpuUsage = 0;
if (CpuUsage > 100) CpuUsage = 100;
wsprintfW(Text, L"%d%%", (int)CpuUsage);
@ -179,8 +177,6 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
if (TaskManagerSettings.ShowKernelTimes)
{
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
if (CpuKernelUsage <= 0) CpuKernelUsage = 0;
if (CpuKernelUsage >= 100) CpuKernelUsage = 100;
nBarsUsedKernel = (nBars * CpuKernelUsage) / 100;
}
else