From 88e417d7614aa1dbb46187fb0609a3a2c2291905 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 8 Oct 2012 11:40:58 +0100 Subject: st/wgl: Don't cache HDC anywhere. Applications may destroy HDC at any time. So always get a HDC as needed. Fixes lack of presents with Solidworks eDrawings when screen resolution is changed. Reviewed-by: Brian Paul --- src/gallium/state_trackers/wgl/stw_ext_pbuffer.c | 2 -- src/gallium/state_trackers/wgl/stw_framebuffer.c | 7 ------- src/gallium/state_trackers/wgl/stw_framebuffer.h | 1 - src/gallium/state_trackers/wgl/stw_st.c | 13 ++++++++++++- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/gallium/state_trackers/wgl/stw_ext_pbuffer.c b/src/gallium/state_trackers/wgl/stw_ext_pbuffer.c index 7596cb6bd95..0bd60c064d7 100644 --- a/src/gallium/state_trackers/wgl/stw_ext_pbuffer.c +++ b/src/gallium/state_trackers/wgl/stw_ext_pbuffer.c @@ -248,8 +248,6 @@ wglGetPbufferDCARB(HPBUFFERARB hPbuffer) hDC = GetDC(fb->hWnd); - assert(hDC == fb->hDC); - return hDC; } diff --git a/src/gallium/state_trackers/wgl/stw_framebuffer.c b/src/gallium/state_trackers/wgl/stw_framebuffer.c index d0d5e9e0fe6..449c5373b06 100644 --- a/src/gallium/state_trackers/wgl/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/stw_framebuffer.c @@ -92,8 +92,6 @@ stw_framebuffer_destroy_locked( stw_st_destroy_framebuffer_locked(fb->stfb); - ReleaseDC(fb->hWnd, fb->hDC); - pipe_mutex_unlock( fb->mutex ); pipe_mutex_destroy( fb->mutex ); @@ -254,11 +252,6 @@ stw_framebuffer_create( if (fb == NULL) return NULL; - /* Applications use, create, destroy device contexts, so the hdc passed is. We create our own DC - * because we need one for single buffered visuals. - */ - fb->hDC = GetDC(hWnd); - fb->hWnd = hWnd; fb->iPixelFormat = iPixelFormat; diff --git a/src/gallium/state_trackers/wgl/stw_framebuffer.h b/src/gallium/state_trackers/wgl/stw_framebuffer.h index bf20d6a3d29..3ba51ba6898 100644 --- a/src/gallium/state_trackers/wgl/stw_framebuffer.h +++ b/src/gallium/state_trackers/wgl/stw_framebuffer.h @@ -58,7 +58,6 @@ struct stw_framebuffer * above, to prevent the framebuffer from being destroyed. */ - HDC hDC; HWND hWnd; int iPixelFormat; diff --git a/src/gallium/state_trackers/wgl/stw_st.c b/src/gallium/state_trackers/wgl/stw_st.c index 28c93f4fb57..7151508b73e 100644 --- a/src/gallium/state_trackers/wgl/stw_st.c +++ b/src/gallium/state_trackers/wgl/stw_st.c @@ -175,10 +175,21 @@ stw_st_framebuffer_flush_front(struct st_framebuffer_iface *stfb, enum st_attachment_type statt) { struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb); + boolean ret; + HDC hDC; pipe_mutex_lock(stwfb->fb->mutex); - return stw_st_framebuffer_present_locked(stwfb->fb->hDC, &stwfb->base, statt); + /* We must not cache HDCs anywhere, as they can be invalidated by the + * application, or screen resolution changes. */ + + hDC = GetDC(stwfb->fb->hWnd); + + ret = stw_st_framebuffer_present_locked(hDC, &stwfb->base, statt); + + ReleaseDC(stwfb->fb->hWnd, hDC); + + return ret; } /** -- cgit v1.2.3