summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2016-05-19 16:30:49 +0100
committerJose Fonseca <jfonseca@vmware.com>2016-05-20 11:42:39 +0100
commit0d41e4b4a114c0af3d0ae7964c251aee00f63fc3 (patch)
tree104f43fc2bd0ea383545c5f719d2e46ea2e95156
parent9dea5043431ca8b9680c74198bd5a05aa5b17c2b (diff)
downloadmesa-demos-0d41e4b4a114c0af3d0ae7964c251aee00f63fc3.zip
mesa-demos-0d41e4b4a114c0af3d0ae7964c251aee00f63fc3.tar.xz
wgl: Keep winthread pointer in GWLP_USERDATA.
Instead of walking the WinThreads array all the time. Trivial.
-rw-r--r--src/wgl/wglthreads.c29
1 files 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");