[haiku-commits] haiku: hrev54880 - src/apps/processcontroller

  • From: Alex von Gluck IV <kallisti5@xxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 10 Jan 2021 20:08:22 -0500 (EST)

hrev54880 adds 1 changeset to branch 'master'
old head: b1b6769b6f040f077544d7884ca5a7c4fbb7af27
new head: b18298348af33f990b51d66cf21652b0a4520317
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=b18298348af3+%5Eb1b6769b6f04

----------------------------------------------------------------------------

b18298348af3: ProcessController: Just toss static scaling mode all together
  
  * It was making things confusing and honestly the dynamic
    calculation code does a pretty good job.
  * Just make sure we scale the scale the CPU bars with a
    multipler that makes sense for a minimum width.
  * This should give us a good baseline. Tested 1 to 32 cpus
  
  Change-Id: If41c73e68b2de2b39196013af13e6c0ffdbe6489

                          [ Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev54880
Commit:      b18298348af33f990b51d66cf21652b0a4520317
URL:         https://git.haiku-os.org/haiku/commit/?id=b18298348af3
Author:      Alexander von Gluck IV <kallisti5@xxxxxxxxxxx>
Date:        Mon Jan 11 01:06:31 2021 UTC

----------------------------------------------------------------------------

2 files changed, 22 insertions(+), 46 deletions(-)
src/apps/processcontroller/PCWindow.cpp          | 17 +++----
src/apps/processcontroller/ProcessController.cpp | 51 ++++++--------------

----------------------------------------------------------------------------

diff --git a/src/apps/processcontroller/PCWindow.cpp 
b/src/apps/processcontroller/PCWindow.cpp
index 6bcde64612..942354bfe1 100644
--- a/src/apps/processcontroller/PCWindow.cpp
+++ b/src/apps/processcontroller/PCWindow.cpp
@@ -32,15 +32,14 @@ PCWindow::PCWindow()
         system_info info;
         get_system_info(&info);
 
-       int width = 15;
-       // Over 4 cpus, flip to "dynamic size mode"
-       if (info.cpu_count > 4) {
-               width = info.cpu_count;
-               // For the memory bar
-               width += 4;
-               if (info.cpu_count <= 16)
-                       width *= 2;
-       }
+       int width = info.cpu_count;
+       if (info.cpu_count <= 4)
+               width *= 4;
+       else if (info.cpu_count <= 16)
+               width *= 2;
+
+       // For the memory bar
+       width += 8;
 
        BRect rect = Bounds();
 
diff --git a/src/apps/processcontroller/ProcessController.cpp 
b/src/apps/processcontroller/ProcessController.cpp
index 11b9ef88bb..9ab5963cb0 100644
--- a/src/apps/processcontroller/ProcessController.cpp
+++ b/src/apps/processcontroller/ProcessController.cpp
@@ -102,23 +102,6 @@ typedef struct {
        time_t          totalTime;
 } Tdebug_thead_param;
 
-// Bar layout depending on number of CPUs
-// This is used only in case the replicant width is 16
-
-typedef struct {
-       float   cpu_width;
-       float   cpu_inter;
-       float   mem_width;
-} layoutT;
-
-layoutT layout[] = {
-       { 1, 1, 1 },
-       { 5, 1, 5 },    // 1
-       { 3, 1, 4 },    // 2
-       { 2, 1, 3 },
-       { 2, 0, 3 },    // 4
-};
-
 
 extern "C" _EXPORT BView* instantiate_deskbar_item(float maxWidth,
        float maxHeight);
@@ -131,15 +114,14 @@ instantiate_deskbar_item(float maxWidth, float maxHeight)
        system_info info;
        get_system_info(&info);
 
-       int width = 15;
-       // Over 4 cpus, flip to "dynamic size mode"
-       if (info.cpu_count > 4) {
-               width = info.cpu_count;
-               // For the memory bar
-               width += 4;
-               if (info.cpu_count <= 16)
-                       width *= 2;
-       }
+       int width = info.cpu_count;
+       if (info.cpu_count <= 4)
+               width *= 4;
+       else if (info.cpu_count <= 16)
+               width *= 2;
+
+       // For the memory bar
+       width += 8;
 
        // Damn, you got a lot of CPU
        if (width > maxWidth)
@@ -610,17 +592,12 @@ ProcessController::DoDraw(bool force)
        float barWidth;
        float barGap;
        float memWidth;
-       if (gCPUcount <= 4 && bounds.Width() == 15) {
-               // Use fixed sizes for small CPU counts
-               barWidth = layout[gCPUcount].cpu_width;
-               barGap = layout[gCPUcount].cpu_inter;
-               memWidth = layout[gCPUcount].mem_width;
-       } else {
-               memWidth = floorf((bounds.Height() + 1) / 8);
-               barGap = ((bounds.Width() + 1) / gCPUcount) > 3 ? 1 : 0;
-               barWidth = floorf((bounds.Width() - 1 - memWidth - barGap * 
gCPUcount)
-                       / gCPUcount);
-       }
+
+       memWidth = floorf((bounds.Height() + 1) / 8);
+       barGap = ((bounds.Width() + 1) / gCPUcount) > 3 ? 1 : 0;
+       barWidth = floorf((bounds.Width() - 1 - memWidth - barGap * gCPUcount)
+               / gCPUcount);
+
        // interspace
        float right = left + gCPUcount * (barWidth + barGap) - barGap;
        float leftMem = bounds.Width() - memWidth;


Other related posts:

  • » [haiku-commits] haiku: hrev54880 - src/apps/processcontroller - Alex von Gluck IV