pipe_mutex_lock( stw_dev->mutex );
- src = stw_lookup_context( hglrcSrc );
- dst = stw_lookup_context( hglrcDst );
+ src = stw_lookup_context_locked( hglrcSrc );
+ dst = stw_lookup_context_locked( hglrcDst );
if (src && dst) {
/* FIXME */
ctx->st->ctx->DriverCtx = ctx;
pipe_mutex_lock( stw_dev->mutex );
- {
- hglrc = handle_table_add(stw_dev->ctx_table, ctx);
- }
+ hglrc = handle_table_add(stw_dev->ctx_table, ctx);
pipe_mutex_unlock( stw_dev->mutex );
/* Success?
return FALSE;
pipe_mutex_lock( stw_dev->mutex );
+ ctx = stw_lookup_context_locked(hglrc);
+ handle_table_remove(stw_dev->ctx_table, hglrc);
+ pipe_mutex_unlock( stw_dev->mutex );
- ctx = stw_lookup_context(hglrc);
if (ctx) {
GLcontext *glctx = ctx->st->ctx;
GET_CURRENT_CONTEXT( glcurctx );
if (WindowFromDC( ctx->hdc ) != NULL)
ReleaseDC( WindowFromDC( ctx->hdc ), ctx->hdc );
- pipe_mutex_lock(stw_dev->mutex);
- {
- st_destroy_context(ctx->st);
- FREE(ctx);
- handle_table_remove(stw_dev->ctx_table, hglrc);
- }
- pipe_mutex_unlock(stw_dev->mutex);
+ st_destroy_context(ctx->st);
+ FREE(ctx);
ret = TRUE;
}
- pipe_mutex_unlock( stw_dev->mutex );
-
return ret;
}
stw_release_context(
UINT_PTR hglrc )
{
- BOOL ret = FALSE;
+ struct stw_context *ctx;
if (!stw_dev)
- return ret;
+ return FALSE;
pipe_mutex_lock( stw_dev->mutex );
- {
- struct stw_context *ctx;
-
- /* XXX: The expectation is that ctx is the same context which is
- * current for this thread. We should check that and return False
- * if not the case.
- */
- ctx = stw_lookup_context( hglrc );
- if (ctx == NULL)
- goto done;
+ ctx = stw_lookup_context_locked( hglrc );
+ pipe_mutex_unlock( stw_dev->mutex );
- if (stw_make_current( NULL, 0 ) == FALSE)
- goto done;
+ if (!ctx)
+ return FALSE;
+
+ /* XXX: The expectation is that ctx is the same context which is
+ * current for this thread. We should check that and return False
+ * if not the case.
+ */
- ret = TRUE;
- }
-done:
- pipe_mutex_unlock( stw_dev->mutex );
+ if (stw_make_current( NULL, 0 ) == FALSE)
+ return FALSE;
- return ret;
+ return TRUE;
}
/* Find the width and height of the window named by hdc.
return FALSE;
pipe_mutex_lock( stw_dev->mutex );
- ctx = stw_lookup_context( hglrc );
+ ctx = stw_lookup_context_locked( hglrc );
pipe_mutex_unlock( stw_dev->mutex );
stw_tls_get_data()->currentDC = hdc;
st_resize_framebuffer( fb->stfb, width, height );
}
-static struct stw_framebuffer *fb_head = NULL;
-
static LRESULT CALLBACK
stw_window_proc(
HWND hWnd,
{
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)
(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;
}
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(
{
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;
}