st/wgl: Don't cache HDC anywhere.
authorJosé Fonseca <jfonseca@vmware.com>
Mon, 8 Oct 2012 10:40:58 +0000 (11:40 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 8 Oct 2012 14:42:50 +0000 (15:42 +0100)
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 <brianp@vmware.com>
src/gallium/state_trackers/wgl/stw_ext_pbuffer.c
src/gallium/state_trackers/wgl/stw_framebuffer.c
src/gallium/state_trackers/wgl/stw_framebuffer.h
src/gallium/state_trackers/wgl/stw_st.c

index 7596cb6bd9502a6527bde6b589016d536b8d7d0e..0bd60c064d796b662043cb14d9d5a0b7a13d5dff 100644 (file)
@@ -248,8 +248,6 @@ wglGetPbufferDCARB(HPBUFFERARB hPbuffer)
 
    hDC = GetDC(fb->hWnd);
 
-   assert(hDC == fb->hDC);
-
    return hDC;
 }
 
index d0d5e9e0fe60b238dc2059cdf4d87b8c87ddeedd..449c5373b067acd75ccaf3c2812211b7d3b121c8 100644 (file)
@@ -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;
 
index bf20d6a3d2990677f4ac448d401d70f1e360e746..3ba51ba6898b18e02983e05d1cfff38aab970873 100644 (file)
@@ -58,7 +58,6 @@ struct stw_framebuffer
     * above, to prevent the framebuffer from being destroyed.
     */
    
-   HDC hDC;
    HWND hWnd;
 
    int iPixelFormat;
index 28c93f4fb57f90952e8fbcb2952ec06817f44c43..7151508b73eb210656097b856e1e0be83b17c319 100644 (file)
@@ -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;
 }
 
 /**