summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-04-09 14:58:17 +0100
committerJosé Fonseca <jfonseca@vmware.com>2009-04-09 15:22:15 +0100
commit858d3da441d3548eae23c91b3bc888c3b0233797 (patch)
tree761174e5f26d5e4063afc913c448d79efa393864 /src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
parent8ef412900363aa6338351001574867866ebcae89 (diff)
wgl: Move the framebuffer list to the device. Avoid recursive locking.
Diffstat (limited to 'src/gallium/state_trackers/wgl/shared/stw_framebuffer.c')
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_framebuffer.c63
1 files changed, 34 insertions, 29 deletions
diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
index a1202ab14d..d6cf6fb534 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
@@ -53,8 +53,6 @@ stw_framebuffer_resize(
st_resize_framebuffer( fb->stfb, width, height );
}
-static struct stw_framebuffer *fb_head = NULL;
-
static LRESULT CALLBACK
stw_window_proc(
HWND hWnd,
@@ -64,9 +62,11 @@ stw_window_proc(
{
struct stw_framebuffer *fb;
- for (fb = fb_head; fb != NULL; fb = fb->next)
+ pipe_mutex_lock( stw_dev->mutex );
+ for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
if (fb->hWnd == hWnd)
break;
+ pipe_mutex_unlock( stw_dev->mutex );
assert( fb != NULL );
if (uMsg == WM_SIZE && wParam != SIZE_MINIMIZED)
@@ -201,8 +201,11 @@ stw_framebuffer_create(
(LONG_PTR) stw_window_proc );
}
- fb->next = fb_head;
- fb_head = fb;
+ pipe_mutex_lock( stw_dev->mutex );
+ fb->next = stw_dev->fb_head;
+ stw_dev->fb_head = fb;
+ pipe_mutex_unlock( stw_dev->mutex );
+
return fb;
}
@@ -210,29 +213,28 @@ void
stw_framebuffer_destroy(
struct stw_framebuffer *fb )
{
- struct stw_framebuffer **link = &fb_head;
- struct stw_framebuffer *pfb = fb_head;
-
- while (pfb != NULL) {
- if (pfb == fb) {
- if (fb->hWnd != NULL) {
- SetWindowLongPtr(
- fb->hWnd,
- GWLP_WNDPROC,
- (LONG_PTR) fb->WndProc );
- }
-
- *link = fb->next;
- FREE( fb );
- return;
- }
-
- link = &pfb->next;
- pfb = pfb->next;
- }
+ struct stw_framebuffer **link;
+
+ pipe_mutex_lock( stw_dev->mutex );
+
+ link = &stw_dev->fb_head;
+ while (link && *link != fb)
+ link = &(*link)->next;
+ assert(*link);
+ if (link)
+ *link = fb->next;
+ fb->next = NULL;
+
+ pipe_mutex_unlock( stw_dev->mutex );
+
+ if (fb->hWnd)
+ SetWindowLongPtr( fb->hWnd, GWLP_WNDPROC, (LONG_PTR)fb->WndProc );
+
+ FREE( fb );
}
-/* Given an hdc, return the corresponding stw_framebuffer.
+/**
+ * Given an hdc, return the corresponding stw_framebuffer.
*/
struct stw_framebuffer *
stw_framebuffer_from_hdc(
@@ -240,10 +242,13 @@ stw_framebuffer_from_hdc(
{
struct stw_framebuffer *fb;
- for (fb = fb_head; fb != NULL; fb = fb->next)
+ pipe_mutex_lock( stw_dev->mutex );
+ for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
if (fb->hDC == hdc)
- return fb;
- return NULL;
+ break;
+ pipe_mutex_unlock( stw_dev->mutex );
+
+ return fb;
}