ExtendedTools: GPU column now respects "Include CPU usage of children" option

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@5163 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
wj32
2012-12-09 06:38:18 +00:00
parent cb5472f485
commit d2b849aad9
8 changed files with 131 additions and 6 deletions
+1
View File
@@ -13,6 +13,7 @@ Process Hacker
* Fixed bug when restarting services
* Updated ExtendedTools plugin:
* Improved support for multiple GPUs (again)
* GPU column now respects "Include CPU usage of children" option
* Updated ToolStatus plugin:
* Fixed controls not being properly hidden/removed from the window when disabled
* FIXED:
+43
View File
@@ -46,6 +46,7 @@ VOID PhCmInitializeManager(
Manager->NextId = MinId;
Manager->PostSortFunction = PostSortFunction;
InitializeListHead(&Manager->ColumnListHead);
Manager->NotifyList = NULL;
}
VOID PhCmDeleteManager(
@@ -64,6 +65,9 @@ VOID PhCmDeleteManager(
PhFree(column);
}
if (Manager->NotifyList)
PhDereferenceObject(Manager->NotifyList);
}
PPH_CM_COLUMN PhCmCreateColumn(
@@ -127,6 +131,24 @@ PPH_CM_COLUMN PhCmFindColumn(
return NULL;
}
VOID PhCmSetNotifyPlugin(
__in PPH_CM_MANAGER Manager,
__in struct _PH_PLUGIN *Plugin
)
{
if (!Manager->NotifyList)
{
Manager->NotifyList = PhCreateList(8);
}
else
{
if (PhFindItemList(Manager->NotifyList, Plugin) != -1)
return;
}
PhAddItemList(Manager->NotifyList, Plugin);
}
BOOLEAN PhCmForwardMessage(
__in HWND hwnd,
__in PH_TREENEW_MESSAGE Message,
@@ -187,6 +209,27 @@ BOOLEAN PhCmForwardMessage(
}
break;
default:
{
// Some plugins want to be notified about all messages.
if (Manager->NotifyList)
{
ULONG i;
for (i = 0; i < Manager->NotifyList->Count; i++)
{
plugin = Manager->NotifyList->Items[i];
pluginMessage.TreeNewHandle = hwnd;
pluginMessage.Message = Message;
pluginMessage.Parameter1 = Parameter1;
pluginMessage.Parameter2 = Parameter2;
pluginMessage.SubId = 0;
pluginMessage.Context = NULL;
PhInvokeCallback(PhGetPluginCallback(plugin, PluginCallbackTreeNewMessage), &pluginMessage);
}
}
}
return FALSE;
}
+6
View File
@@ -17,6 +17,7 @@ typedef struct _PH_CM_MANAGER
ULONG NextId;
PPH_CM_POST_SORT_FUNCTION PostSortFunction;
LIST_ENTRY ColumnListHead;
PPH_LIST NotifyList;
} PH_CM_MANAGER, *PPH_CM_MANAGER;
typedef struct _PH_CM_COLUMN
@@ -55,6 +56,11 @@ PPH_CM_COLUMN PhCmFindColumn(
__in ULONG SubId
);
VOID PhCmSetNotifyPlugin(
__in PPH_CM_MANAGER Manager,
__in struct _PH_PLUGIN *Plugin
);
BOOLEAN PhCmForwardMessage(
__in HWND hwnd,
__in PH_TREENEW_MESSAGE Message,
+8
View File
@@ -472,6 +472,14 @@ PhPluginRegisterIcon(
__in struct _PH_NF_ICON_REGISTRATION_DATA *RegistrationData
);
PHAPPAPI
VOID
NTAPI
PhPluginEnableTreeNewNotify(
__in PPH_PLUGIN Plugin,
__in PVOID CmData
);
#ifdef __cplusplus
}
#endif
+15
View File
@@ -1051,3 +1051,18 @@ struct _PH_NF_ICON *PhPluginRegisterIcon(
RegistrationData->MessageCallback
);
}
/**
* Allows a plugin to receive all treenew messages, not just column-related ones.
*
* \param Plugin A plugin instance structure.
* \param CmData The CmData value from the \ref PH_PLUGIN_TREENEW_INFORMATION
* structure.
*/
VOID PhPluginEnableTreeNewNotify(
__in PPH_PLUGIN Plugin,
__in PVOID CmData
)
{
PhCmSetNotifyPlugin(CmData, Plugin);
}
+3
View File
@@ -63,6 +63,9 @@ typedef struct _PH_PROCESS_NODE
HANDLE ProcessId;
PPH_PROCESS_ITEM ProcessItem;
struct _PH_PROCESS_NODE *Parent;
PPH_LIST Children;
// ...
} PH_PROCESS_NODE, *PPH_PROCESS_NODE;
@@ -1,5 +1,6 @@
1.12
* Improved support for multiple GPUs (again)
* GPU column now respects "Include CPU usage of children" option
1.11
* Fixed network graph scaling
+54 -6
View File
@@ -49,6 +49,9 @@ typedef struct _COLUMN_INFO
BOOLEAN SortDescending;
} COLUMN_INFO, *PCOLUMN_INFO;
static ULONG ProcessTreeListSortColumn;
static PH_SORT_ORDER ProcessTreeListSortOrder;
static GUID IID_INetFwMgr_I = { 0xf7898af5, 0xcac4, 0x4632, { 0xa2, 0xec, 0xda, 0x06, 0xe5, 0x11, 0x1a, 0xf2 } };
static GUID CLSID_NetFwMgr_I = { 0x304ce942, 0x6e39, 0x40d8, { 0x94, 0x3a, 0xb9, 0x13, 0xc4, 0x0c, 0x9c, 0xd4 } };
@@ -130,6 +133,25 @@ VOID EtProcessTreeNewInitializing(
EtpAddTreeNewColumn(treeNewInfo, columns[i].SubId, columns[i].Text, columns[i].Width, columns[i].Alignment,
columns[i].TextFlags, columns[i].SortDescending, EtpProcessTreeNewSortFunction);
}
PhPluginEnableTreeNewNotify(PluginInstance, treeNewInfo->CmData);
}
static FLOAT EtpCalculateInclusiveGpuUsage(
__in PPH_PROCESS_NODE ProcessNode
)
{
FLOAT gpuUsage;
ULONG i;
gpuUsage = EtGetProcessBlock(ProcessNode->ProcessItem)->GpuNodeUsage;
for (i = 0; i < ProcessNode->Children->Count; i++)
{
gpuUsage += EtpCalculateInclusiveGpuUsage(ProcessNode->Children->Items[i]);
}
return gpuUsage;
}
VOID EtProcessTreeNewMessage(
@@ -137,14 +159,15 @@ VOID EtProcessTreeNewMessage(
)
{
PPH_PLUGIN_TREENEW_MESSAGE message = Parameter;
PPH_PROCESS_NODE processNode;
PET_PROCESS_BLOCK block;
if (message->Message == TreeNewGetCellText)
{
PPH_TREENEW_GET_CELL_TEXT getCellText = message->Parameter1;
PPH_PROCESS_NODE processNode = (PPH_PROCESS_NODE)getCellText->Node;
PET_PROCESS_BLOCK block;
PPH_STRING text;
processNode = (PPH_PROCESS_NODE)getCellText->Node;
block = EtGetProcessBlock(processNode->ProcessItem);
PhAcquireQueuedLockExclusive(&block->TextCacheLock);
@@ -251,12 +274,25 @@ VOID EtProcessTreeNewMessage(
text = PhFormatUInt64(block->ProcessItem->PeakNumberOfThreads, TRUE);
break;
case ETPRTNC_GPU:
if (block->GpuNodeUsage >= 0.0001)
{
PH_FORMAT format;
FLOAT gpuUsage;
PhInitFormatF(&format, block->GpuNodeUsage * 100, 2);
text = PhFormat(&format, 1, 0);
if (!PhGetIntegerSetting(L"PropagateCpuUsage") || processNode->Node.Expanded || ProcessTreeListSortOrder != NoSortOrder)
{
gpuUsage = block->GpuNodeUsage * 100;
}
else
{
gpuUsage = EtpCalculateInclusiveGpuUsage(processNode) * 100;
}
if (gpuUsage >= 0.01)
{
PH_FORMAT format;
PhInitFormatF(&format, gpuUsage, 2);
text = PhFormat(&format, 1, 0);
}
}
break;
case ETPRTNC_GPUDEDICATEDBYTES:
@@ -304,6 +340,18 @@ VOID EtProcessTreeNewMessage(
PhReleaseQueuedLockExclusive(&block->TextCacheLock);
}
else if (message->Message == TreeNewSortChanged)
{
TreeNew_GetSort(message->TreeNewHandle, &ProcessTreeListSortColumn, &ProcessTreeListSortOrder);
}
else if (message->Message == TreeNewNodeExpanding)
{
processNode = message->Parameter1;
block = EtGetProcessBlock(processNode->ProcessItem);
if (PhGetIntegerSetting(L"PropagateCpuUsage"))
block->TextCacheValid[ETPRTNC_GPU] = FALSE;
}
}
LONG EtpProcessTreeNewSortFunction(