https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5c9fdcb1de7faa49c2af341631217baa7b9fe552

commit 5c9fdcb1de7faa49c2af341631217baa7b9fe552
Author:     Doug Lyons <[email protected]>
AuthorDate: Thu Dec 2 12:55:39 2021 -0600
Commit:     GitHub <[email protected]>
CommitDate: Thu Dec 2 19:55:39 2021 +0100

    [3DTEXT] Fix 3dtext.scr using near 100% CPU (#4125)
    
    CORE-17866, CORE-8217
---
 base/applications/screensavers/3dtext/3dtext.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/base/applications/screensavers/3dtext/3dtext.c 
b/base/applications/screensavers/3dtext/3dtext.c
index c1f908ca37a..b46fcce6905 100644
--- a/base/applications/screensavers/3dtext/3dtext.c
+++ b/base/applications/screensavers/3dtext/3dtext.c
@@ -41,6 +41,9 @@ GLfloat extentY = 0.0f;
 
 HINSTANCE hInstance;
 BOOL fullscreen = FALSE;
+UINT uTimerID;                                          // SetTimer Actual ID
+#define APP_TIMER             1                         // Graphics Update 
Timer ID
+#define APP_TIMER_INTERVAL    (USER_TIMER_MINIMUM * 5)  // Graphics Update 
Interval
 
 // Build Our Bitmap Font
 GLvoid BuildFont(GLvoid)
@@ -338,12 +341,18 @@ ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, 
LPARAM lParam)
 
             // Initialize The GL Screen Using Screen Info
             InitGL(Screen.right, Screen.bottom);
+
+            // Create Graphics update timer
+            uTimerID = SetTimer(hWnd, APP_TIMER, APP_TIMER_INTERVAL, NULL);
             break;
 
         case WM_DESTROY:
             // Disable Fullscreen Mode
             ChangeDisplaySettings(NULL, 0);
 
+            // Delete the Update Timer
+            KillTimer(hWnd, uTimerID);
+
             // Deletes The Font Display List
             KillFont();
 
@@ -360,6 +369,8 @@ ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, 
LPARAM lParam)
         case WM_PAINT:
             DrawGLScene();
             SwapBuffers(hDC);
+            // Mark this window as updated, so the OS won't ask us to update 
it again.
+            ValidateRect(hWnd, NULL);
             break;
 
         case WM_SIZE: // Resizing The Screen
@@ -367,6 +378,11 @@ ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, 
LPARAM lParam)
             ReSizeGLScene(LOWORD(lParam), HIWORD(lParam));
             break;
 
+        case WM_TIMER:
+            // Used to update graphic based on timer udpate interval
+            InvalidateRect(hWnd, NULL, TRUE);
+            break;
+
         default:
             // Pass Windows Messages to the default screensaver window 
procedure
             return DefScreenSaverProc(hWnd, message, wParam, lParam);

Reply via email to