Module: Demos
Branch: master
Commit: 0d41e4b4a114c0af3d0ae7964c251aee00f63fc3
URL:    
http://cgit.freedesktop.org/mesa/demos/commit/?id=0d41e4b4a114c0af3d0ae7964c251aee00f63fc3

Author: Jose Fonseca <jfons...@vmware.com>
Date:   Thu May 19 16:30:49 2016 +0100

wgl: Keep winthread pointer in GWLP_USERDATA.

Instead of walking the WinThreads array all the time.

Trivial.

---

 src/wgl/wglthreads.c | 29 +++++++++--------------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/src/wgl/wglthreads.c b/src/wgl/wglthreads.c
index beaf369..95a648d 100644
--- a/src/wgl/wglthreads.c
+++ b/src/wgl/wglthreads.c
@@ -76,7 +76,7 @@ struct winthread {
 };
 
 
-#define MAX_WINTHREADS 100
+#define MAX_WINTHREADS 128
 static struct winthread WinThreads[MAX_WINTHREADS];
 static int NumWinThreads = 2;
 static HANDLE ExitEvent = NULL;
@@ -380,30 +380,17 @@ WndProc(HWND hWnd,
         WPARAM wParam,
         LPARAM lParam )
 {
-   int i;
+   struct winthread *wt = (struct winthread *)(INT_PTR)GetWindowLongPtr(hWnd, 
GWLP_USERDATA);
 
    switch (uMsg) {
    case WM_KEYDOWN:
-      for (i = 0; i < NumWinThreads; i++) {
-         struct winthread *wt = &WinThreads[i];
-
-         if (hWnd == wt->Win) {
-            keypress(wParam, wt);
-            break;
-         }
-      }
+      keypress(wParam, wt);
       break;
    case WM_SIZE:
-      for (i = 0; i < NumWinThreads; i++) {
-         struct winthread *wt = &WinThreads[i];
-
-         if (hWnd == wt->Win) {
-            RECT r;
-
-            GetClientRect(hWnd, &r);
-            resize(wt, r.right, r.bottom);
-            break;
-         }
+      {
+         RECT r;
+         GetClientRect(hWnd, &r);
+         resize(wt, r.right, r.bottom);
       }
       break;
    case WM_DESTROY:
@@ -456,6 +443,8 @@ create_window(struct winthread *wt, HGLRC shareCtx)
       Error("Couldn't create window");
    }
 
+   SetWindowLongPtr(win, GWLP_USERDATA, (LONG_PTR)wt);
+
    hdc = GetDC(win);
    if (!hdc) {
       Error("Couldn't obtain HDC");

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to