From 1abb2f64c555485dfc3b03d7f333ec1308eabd55 Mon Sep 17 00:00:00 2001 From: signin404 <145902543+signin404@users.noreply.github.com> Date: Mon, 1 Sep 2025 02:41:09 +0800 Subject: [PATCH 1/3] Add files via upload --- CPUCoreBars/CPUCoreBars.cpp | 38 +++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/CPUCoreBars/CPUCoreBars.cpp b/CPUCoreBars/CPUCoreBars.cpp index 21fd7af..f0888ed 100644 --- a/CPUCoreBars/CPUCoreBars.cpp +++ b/CPUCoreBars/CPUCoreBars.cpp @@ -1,4 +1,4 @@ -// CPUCoreBars/CPUCoreBars.cpp - 性能优化版本 +// CPUCoreBars/CPUCoreBars.cpp - 性能优化版本 #include "CPUCoreBars.h" #include #include @@ -16,6 +16,7 @@ using namespace Gdiplus; // 静态成员变量定义 HFONT CCpuUsageItem::s_symbolFont = nullptr; +HFONT CCpuUsageItem::s_coreNumberFont = nullptr; // Font for core numbers int CCpuUsageItem::s_fontRefCount = 0; CCpuUsageItem::CCpuUsageItem(int core_index, bool is_e_core) @@ -23,11 +24,14 @@ CCpuUsageItem::CCpuUsageItem(int core_index, bool is_e_core) m_cachedBgBrush(nullptr), m_cachedBarBrush(nullptr), m_lastBgColor(0), m_lastBarColor(0), m_lastDarkMode(false) { - // 初始化静态字体(只创建一次) - if (s_symbolFont == nullptr) { + // Initialize static fonts (only create once) + if (s_fontRefCount == 0) { s_symbolFont = CreateFontW(12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Segoe UI Symbol"); + s_coreNumberFont = CreateFontW(10, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, + DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, + DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Segoe UI"); } s_fontRefCount++; @@ -43,9 +47,15 @@ CCpuUsageItem::~CCpuUsageItem() // 减少字体引用计数 s_fontRefCount--; - if (s_fontRefCount == 0 && s_symbolFont) { - DeleteObject(s_symbolFont); - s_symbolFont = nullptr; + if (s_fontRefCount == 0) { + if (s_symbolFont) { + DeleteObject(s_symbolFont); + s_symbolFont = nullptr; + } + if (s_coreNumberFont) { + DeleteObject(s_coreNumberFont); + s_coreNumberFont = nullptr; + } } } @@ -154,6 +164,22 @@ void CCpuUsageItem::DrawItem(void* hDC, int x, int y, int w, int h, bool dark_mo if (m_is_e_core) { DrawECoreSymbol(dc, rect, dark_mode); } + else { + // For non-E-cores, draw the core number at the top + wchar_t core_num_str[4]; // Buffer for core number string + swprintf_s(core_num_str, L"%d", m_core_index); + + COLORREF text_color = dark_mode ? RGB(255, 255, 255) : RGB(0, 0, 0); + SetTextColor(dc, text_color); + SetBkMode(dc, TRANSPARENT); + + // Use the cached core number font + if (s_coreNumberFont) { + HGDIOBJ hOldFont = SelectObject(dc, s_coreNumberFont); + DrawTextW(dc, core_num_str, -1, &rect, DT_CENTER | DT_TOP | DT_SINGLELINE); + SelectObject(dc, hOldFont); + } + } } From ea348fb774b1e1d831293350de94c740b4d331b4 Mon Sep 17 00:00:00 2001 From: signin404 <145902543+signin404@users.noreply.github.com> Date: Mon, 1 Sep 2025 02:42:42 +0800 Subject: [PATCH 2/3] Add files via upload --- CPUCoreBars/CPUCoreBars.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CPUCoreBars/CPUCoreBars.cpp b/CPUCoreBars/CPUCoreBars.cpp index f0888ed..a6086c6 100644 --- a/CPUCoreBars/CPUCoreBars.cpp +++ b/CPUCoreBars/CPUCoreBars.cpp @@ -1,4 +1,4 @@ -// CPUCoreBars/CPUCoreBars.cpp - 性能优化版本 +// CPUCoreBars/CPUCoreBars.cpp - 性能优化版本 #include "CPUCoreBars.h" #include #include From f755bc36c5240c16d25625917cbbc415c08063b4 Mon Sep 17 00:00:00 2001 From: signin404 <145902543+signin404@users.noreply.github.com> Date: Mon, 1 Sep 2025 02:46:05 +0800 Subject: [PATCH 3/3] Add files via upload --- CPUCoreBars/CPUCoreBars.h | 1 + 1 file changed, 1 insertion(+) diff --git a/CPUCoreBars/CPUCoreBars.h b/CPUCoreBars/CPUCoreBars.h index cd58157..7f70824 100644 --- a/CPUCoreBars/CPUCoreBars.h +++ b/CPUCoreBars/CPUCoreBars.h @@ -45,6 +45,7 @@ class CCpuUsageItem : public IPluginItem // 新增:静态字体缓存 static HFONT s_symbolFont; + static HFONT s_coreNumberFont; // Added missing declaration static int s_fontRefCount; // 新增:GDI对象缓存